| author | |
| committer | |
| log | 156ab8750056c3ff440af0937806d8cdb2623816 |
| tree | 26956c58e4d169279885ab94d479f8b9f4285872 |
| parent | 7ab01c9a42fa0262d67d9ff1a0ecde24fb7031e7 |
| signature |
See:
* https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc/77319
* https://discourse.llvm.org/t/rfc-project-hand-in-hand-llvm-libc-libc-code-sharing/77701
We're dropping support for C++03 for Zig due to the first change; it would be
insane to ship 1018 duplicate header files just for this outdated use case.
As a result of the second change, I had to bring in a subset of the headers from
llvm-libc since libc++ now depends on these. Hopefully we can continue to get
away with not copying the entirety of llvm-libc.1001 files changed, 36835 insertions(+), 19964 deletions(-)
lib/libcxx/include/__algorithm/adjacent_find.h+11-9| ... | ... | @@ -11,9 +11,9 @@ |
| 11 | 11 | #define _LIBCPP___ALGORITHM_ADJACENT_FIND_H |
| 12 | 12 | |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 15 | 14 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__type_traits/invoke.h> | |
| 17 | 17 | #include <__utility/move.h> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -25,14 +25,15 @@ _LIBCPP_PUSH_MACROS |
| 25 | 25 | |
| 26 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | |
| 28 | template <class _Iter, class _Sent, class _BinaryPredicate> | |
| 29 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter | |
| 30 | __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { | |
| 28 | template <class _Iter, class _Sent, class _Pred, class _Proj> | |
| 29 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter | |
| 30 | __adjacent_find(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 31 | 31 | if (__first == __last) |
| 32 | 32 | return __first; |
| 33 | ||
| 33 | 34 | _Iter __i = __first; |
| 34 | 35 | while (++__i != __last) { |
| 35 | if (__pred(*__first, *__i)) | |
| 36 | if (std::__invoke(__pred, std::__invoke(__proj, *__first), std::__invoke(__proj, *__i))) | |
| 36 | 37 | return __first; |
| 37 | 38 | __first = __i; |
| 38 | 39 | } |
| ... | ... | @@ -40,13 +41,14 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { |
| 40 | 41 | } |
| 41 | 42 | |
| 42 | 43 | template <class _ForwardIterator, class _BinaryPredicate> |
| 43 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 44 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 44 | 45 | adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { |
| 45 | return std::__adjacent_find(std::move(__first), std::move(__last), __pred); | |
| 46 | __identity __proj; | |
| 47 | return std::__adjacent_find(std::move(__first), std::move(__last), __pred, __proj); | |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | template <class _ForwardIterator> |
| 49 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 51 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 50 | 52 | adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { |
| 51 | 53 | return std::adjacent_find(std::move(__first), std::move(__last), __equal_to()); |
| 52 | 54 | } |
lib/libcxx/include/__algorithm/all_of.h+15-5| ... | ... | @@ -11,6 +11,8 @@ |
| 11 | 11 | #define _LIBCPP___ALGORITHM_ALL_OF_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__type_traits/invoke.h> | |
| 14 | 16 | |
| 15 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 18 | # pragma GCC system_header |
| ... | ... | @@ -18,15 +20,23 @@ |
| 18 | 20 | |
| 19 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 22 | |
| 21 | template <class _InputIterator, class _Predicate> | |
| 22 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 23 | all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | |
| 24 | for (; __first != __last; ++__first) | |
| 25 | if (!__pred(*__first)) | |
| 23 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 24 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | |
| 25 | __all_of(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 26 | for (; __first != __last; ++__first) { | |
| 27 | if (!std::__invoke(__pred, std::__invoke(__proj, *__first))) | |
| 26 | 28 | return false; |
| 29 | } | |
| 27 | 30 | return true; |
| 28 | 31 | } |
| 29 | 32 | |
| 33 | template <class _InputIterator, class _Predicate> | |
| 34 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 35 | all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | |
| 36 | __identity __proj; | |
| 37 | return std::__all_of(__first, __last, __pred, __proj); | |
| 38 | } | |
| 39 | ||
| 30 | 40 | _LIBCPP_END_NAMESPACE_STD |
| 31 | 41 | |
| 32 | 42 | #endif // _LIBCPP___ALGORITHM_ALL_OF_H |
lib/libcxx/include/__algorithm/any_of.h+15-5| ... | ... | @@ -11,6 +11,8 @@ |
| 11 | 11 | #define _LIBCPP___ALGORITHM_ANY_OF_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__type_traits/invoke.h> | |
| 14 | 16 | |
| 15 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 18 | # pragma GCC system_header |
| ... | ... | @@ -18,15 +20,23 @@ |
| 18 | 20 | |
| 19 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 22 | |
| 21 | template <class _InputIterator, class _Predicate> | |
| 22 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 23 | any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | |
| 24 | for (; __first != __last; ++__first) | |
| 25 | if (__pred(*__first)) | |
| 23 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 24 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | |
| 25 | __any_of(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 26 | for (; __first != __last; ++__first) { | |
| 27 | if (std::__invoke(__pred, std::__invoke(__proj, *__first))) | |
| 26 | 28 | return true; |
| 29 | } | |
| 27 | 30 | return false; |
| 28 | 31 | } |
| 29 | 32 | |
| 33 | template <class _InputIterator, class _Predicate> | |
| 34 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 35 | any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | |
| 36 | __identity __proj; | |
| 37 | return std::__any_of(__first, __last, __pred, __proj); | |
| 38 | } | |
| 39 | ||
| 30 | 40 | _LIBCPP_END_NAMESPACE_STD |
| 31 | 41 | |
| 32 | 42 | #endif // _LIBCPP___ALGORITHM_ANY_OF_H |
lib/libcxx/include/__algorithm/binary_search.h+2-3| ... | ... | @@ -13,7 +13,6 @@ |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/lower_bound.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | |
| 17 | 16 | |
| 18 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 18 | # pragma GCC system_header |
| ... | ... | @@ -22,14 +21,14 @@ |
| 22 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 22 | |
| 24 | 23 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 25 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 24 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 26 | 25 | binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { |
| 27 | 26 | __first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp); |
| 28 | 27 | return __first != __last && !__comp(__value, *__first); |
| 29 | 28 | } |
| 30 | 29 | |
| 31 | 30 | template <class _ForwardIterator, class _Tp> |
| 32 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 31 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 33 | 32 | binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 34 | 33 | return std::binary_search(__first, __last, __value, __less<>()); |
| 35 | 34 | } |
lib/libcxx/include/__algorithm/comp.h+4| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__type_traits/desugars_to.h> |
| 14 | #include <__type_traits/is_integral.h> | |
| 14 | 15 | |
| 15 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 17 | # pragma GCC system_header |
| ... | ... | @@ -44,6 +45,9 @@ struct __less<void, void> { |
| 44 | 45 | template <class _Tp> |
| 45 | 46 | inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true; |
| 46 | 47 | |
| 48 | template <class _Tp> | |
| 49 | inline const bool __desugars_to_v<__totally_ordered_less_tag, __less<>, _Tp, _Tp> = is_integral<_Tp>::value; | |
| 50 | ||
| 47 | 51 | _LIBCPP_END_NAMESPACE_STD |
| 48 | 52 | |
| 49 | 53 | #endif // _LIBCPP___ALGORITHM_COMP_H |
lib/libcxx/include/__algorithm/comp_ref_type.h+2-2| ... | ... | @@ -56,10 +56,10 @@ struct __debug_less { |
| 56 | 56 | // Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference. |
| 57 | 57 | #if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG |
| 58 | 58 | template <class _Comp> |
| 59 | using __comp_ref_type = __debug_less<_Comp>; | |
| 59 | using __comp_ref_type _LIBCPP_NODEBUG = __debug_less<_Comp>; | |
| 60 | 60 | #else |
| 61 | 61 | template <class _Comp> |
| 62 | using __comp_ref_type = _Comp&; | |
| 62 | using __comp_ref_type _LIBCPP_NODEBUG = _Comp&; | |
| 63 | 63 | #endif |
| 64 | 64 | |
| 65 | 65 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/copy.h+9-10| ... | ... | @@ -11,11 +11,12 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/copy_move_common.h> |
| 13 | 13 | #include <__algorithm/for_each_segment.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 15 | 14 | #include <__algorithm/min.h> |
| 16 | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | |
| 17 | 17 | #include <__iterator/segmented_iterator.h> |
| 18 | 18 | #include <__type_traits/common_type.h> |
| 19 | #include <__type_traits/enable_if.h> | |
| 19 | 20 | #include <__utility/move.h> |
| 20 | 21 | #include <__utility/pair.h> |
| 21 | 22 | |
| ... | ... | @@ -28,10 +29,9 @@ _LIBCPP_PUSH_MACROS |
| 28 | 29 | |
| 29 | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 31 | |
| 31 | template <class, class _InIter, class _Sent, class _OutIter> | |
| 32 | template <class _InIter, class _Sent, class _OutIter> | |
| 32 | 33 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter); |
| 33 | 34 | |
| 34 | template <class _AlgPolicy> | |
| 35 | 35 | struct __copy_impl { |
| 36 | 36 | template <class _InIter, class _Sent, class _OutIter> |
| 37 | 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> |
| ... | ... | @@ -47,7 +47,7 @@ struct __copy_impl { |
| 47 | 47 | |
| 48 | 48 | template <class _InIter, class _OutIter> |
| 49 | 49 | struct _CopySegment { |
| 50 | using _Traits = __segmented_iterator_traits<_InIter>; | |
| 50 | using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>; | |
| 51 | 51 | |
| 52 | 52 | _OutIter& __result_; |
| 53 | 53 | |
| ... | ... | @@ -56,7 +56,7 @@ struct __copy_impl { |
| 56 | 56 | |
| 57 | 57 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void |
| 58 | 58 | operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) { |
| 59 | __result_ = std::__copy<_AlgPolicy>(__lfirst, __llast, std::move(__result_)).second; | |
| 59 | __result_ = std::__copy(__lfirst, __llast, std::move(__result_)).second; | |
| 60 | 60 | } |
| 61 | 61 | }; |
| 62 | 62 | |
| ... | ... | @@ -85,7 +85,7 @@ struct __copy_impl { |
| 85 | 85 | while (true) { |
| 86 | 86 | auto __local_last = _Traits::__end(__segment_iterator); |
| 87 | 87 | auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first); |
| 88 | auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first); | |
| 88 | auto __iters = std::__copy(__first, __first + __size, __local_first); | |
| 89 | 89 | __first = std::move(__iters.first); |
| 90 | 90 | |
| 91 | 91 | if (__first == __last) |
| ... | ... | @@ -103,17 +103,16 @@ struct __copy_impl { |
| 103 | 103 | } |
| 104 | 104 | }; |
| 105 | 105 | |
| 106 | template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> | |
| 106 | template <class _InIter, class _Sent, class _OutIter> | |
| 107 | 107 | pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 |
| 108 | 108 | __copy(_InIter __first, _Sent __last, _OutIter __result) { |
| 109 | return std::__copy_move_unwrap_iters<__copy_impl<_AlgPolicy> >( | |
| 110 | std::move(__first), std::move(__last), std::move(__result)); | |
| 109 | return std::__copy_move_unwrap_iters<__copy_impl>(std::move(__first), std::move(__last), std::move(__result)); | |
| 111 | 110 | } |
| 112 | 111 | |
| 113 | 112 | template <class _InputIterator, class _OutputIterator> |
| 114 | 113 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator |
| 115 | 114 | copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { |
| 116 | return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second; | |
| 115 | return std::__copy(__first, __last, __result).second; | |
| 117 | 116 | } |
| 118 | 117 | |
| 119 | 118 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/copy_backward.h+2| ... | ... | @@ -13,8 +13,10 @@ |
| 13 | 13 | #include <__algorithm/iterator_operations.h> |
| 14 | 14 | #include <__algorithm/min.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | |
| 16 | 17 | #include <__iterator/segmented_iterator.h> |
| 17 | 18 | #include <__type_traits/common_type.h> |
| 19 | #include <__type_traits/enable_if.h> | |
| 18 | 20 | #include <__type_traits/is_constructible.h> |
| 19 | 21 | #include <__utility/move.h> |
| 20 | 22 | #include <__utility/pair.h> |
lib/libcxx/include/__algorithm/copy_if.h+21-5| ... | ... | @@ -10,25 +10,41 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_COPY_IF_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__type_traits/invoke.h> | |
| 15 | #include <__utility/move.h> | |
| 16 | #include <__utility/pair.h> | |
| 13 | 17 | |
| 14 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | 19 | # pragma GCC system_header |
| 16 | 20 | #endif |
| 17 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 18 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 26 | |
| 20 | template <class _InputIterator, class _OutputIterator, class _Predicate> | |
| 21 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | |
| 22 | copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) { | |
| 27 | template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred> | |
| 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | |
| 29 | __copy_if(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) { | |
| 23 | 30 | for (; __first != __last; ++__first) { |
| 24 | if (__pred(*__first)) { | |
| 31 | if (std::__invoke(__pred, std::__invoke(__proj, *__first))) { | |
| 25 | 32 | *__result = *__first; |
| 26 | 33 | ++__result; |
| 27 | 34 | } |
| 28 | 35 | } |
| 29 | return __result; | |
| 36 | return std::make_pair(std::move(__first), std::move(__result)); | |
| 37 | } | |
| 38 | ||
| 39 | template <class _InputIterator, class _OutputIterator, class _Predicate> | |
| 40 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | |
| 41 | copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) { | |
| 42 | __identity __proj; | |
| 43 | return std::__copy_if(__first, __last, __result, __pred, __proj).second; | |
| 30 | 44 | } |
| 31 | 45 | |
| 32 | 46 | _LIBCPP_END_NAMESPACE_STD |
| 33 | 47 | |
| 48 | _LIBCPP_POP_MACROS | |
| 49 | ||
| 34 | 50 | #endif // _LIBCPP___ALGORITHM_COPY_IF_H |
lib/libcxx/include/__algorithm/copy_move_common.h+1-2| ... | ... | @@ -9,10 +9,10 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H |
| 11 | 11 | |
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | 12 | #include <__algorithm/unwrap_iter.h> |
| 14 | 13 | #include <__algorithm/unwrap_range.h> |
| 15 | 14 | #include <__config> |
| 15 | #include <__cstddef/size_t.h> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | #include <__memory/pointer_traits.h> |
| 18 | 18 | #include <__string/constexpr_c_functions.h> |
| ... | ... | @@ -24,7 +24,6 @@ |
| 24 | 24 | #include <__type_traits/is_volatile.h> |
| 25 | 25 | #include <__utility/move.h> |
| 26 | 26 | #include <__utility/pair.h> |
| 27 | #include <cstddef> | |
| 28 | 27 | |
| 29 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 30 | 29 | # pragma GCC system_header |
lib/libcxx/include/__algorithm/count.h+8-5| ... | ... | @@ -16,9 +16,10 @@ |
| 16 | 16 | #include <__bit/popcount.h> |
| 17 | 17 | #include <__config> |
| 18 | 18 | #include <__functional/identity.h> |
| 19 | #include <__functional/invoke.h> | |
| 20 | 19 | #include <__fwd/bit_reference.h> |
| 21 | 20 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__type_traits/enable_if.h> | |
| 22 | #include <__type_traits/invoke.h> | |
| 22 | 23 | |
| 23 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | 25 | # pragma GCC system_header |
| ... | ... | @@ -43,7 +44,7 @@ __count(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { |
| 43 | 44 | // __bit_iterator implementation |
| 44 | 45 | template <bool _ToCount, class _Cp, bool _IsConst> |
| 45 | 46 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bit_iterator<_Cp, _IsConst>::difference_type |
| 46 | __count_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) { | |
| 47 | __count_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_type_traits<_Cp>::size_type __n) { | |
| 47 | 48 | using _It = __bit_iterator<_Cp, _IsConst>; |
| 48 | 49 | using __storage_type = typename _It::__storage_type; |
| 49 | 50 | using difference_type = typename _It::difference_type; |
| ... | ... | @@ -74,12 +75,14 @@ template <class, class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t |
| 74 | 75 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<__bit_iterator<_Cp, _IsConst> > |
| 75 | 76 | __count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) { |
| 76 | 77 | if (__value) |
| 77 | return std::__count_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first)); | |
| 78 | return std::__count_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first)); | |
| 78 | return std::__count_bool<true>( | |
| 79 | __first, static_cast<typename __size_difference_type_traits<_Cp>::size_type>(__last - __first)); | |
| 80 | return std::__count_bool<false>( | |
| 81 | __first, static_cast<typename __size_difference_type_traits<_Cp>::size_type>(__last - __first)); | |
| 79 | 82 | } |
| 80 | 83 | |
| 81 | 84 | template <class _InputIterator, class _Tp> |
| 82 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator> | |
| 85 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator> | |
| 83 | 86 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { |
| 84 | 87 | __identity __proj; |
| 85 | 88 | return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj); |
lib/libcxx/include/__algorithm/count_if.h+17-6| ... | ... | @@ -10,8 +10,11 @@ |
| 10 | 10 | #ifndef _LIBCPP___ALGORITHM_COUNT_IF_H |
| 11 | 11 | #define _LIBCPP___ALGORITHM_COUNT_IF_H |
| 12 | 12 | |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 13 | 14 | #include <__config> |
| 15 | #include <__functional/identity.h> | |
| 14 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__type_traits/invoke.h> | |
| 15 | 18 | |
| 16 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 20 | # pragma GCC system_header |
| ... | ... | @@ -19,15 +22,23 @@ |
| 19 | 22 | |
| 20 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 24 | |
| 25 | template <class _AlgPolicy, class _Iter, class _Sent, class _Proj, class _Pred> | |
| 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __policy_iter_diff_t<_AlgPolicy, _Iter> | |
| 27 | __count_if(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 28 | __policy_iter_diff_t<_AlgPolicy, _Iter> __counter(0); | |
| 29 | for (; __first != __last; ++__first) { | |
| 30 | if (std::__invoke(__pred, std::__invoke(__proj, *__first))) | |
| 31 | ++__counter; | |
| 32 | } | |
| 33 | return __counter; | |
| 34 | } | |
| 35 | ||
| 22 | 36 | template <class _InputIterator, class _Predicate> |
| 23 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 37 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 24 | 38 | typename iterator_traits<_InputIterator>::difference_type |
| 25 | 39 | count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 26 | typename iterator_traits<_InputIterator>::difference_type __r(0); | |
| 27 | for (; __first != __last; ++__first) | |
| 28 | if (__pred(*__first)) | |
| 29 | ++__r; | |
| 30 | return __r; | |
| 40 | __identity __proj; | |
| 41 | return std::__count_if<_ClassicAlgPolicy>(__first, __last, __pred, __proj); | |
| 31 | 42 | } |
| 32 | 43 | |
| 33 | 44 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/equal.h+9-10| ... | ... | @@ -14,13 +14,12 @@ |
| 14 | 14 | #include <__algorithm/unwrap_iter.h> |
| 15 | 15 | #include <__config> |
| 16 | 16 | #include <__functional/identity.h> |
| 17 | #include <__functional/invoke.h> | |
| 18 | 17 | #include <__iterator/distance.h> |
| 19 | 18 | #include <__iterator/iterator_traits.h> |
| 20 | 19 | #include <__string/constexpr_c_functions.h> |
| 21 | 20 | #include <__type_traits/desugars_to.h> |
| 22 | 21 | #include <__type_traits/enable_if.h> |
| 23 | #include <__type_traits/is_constant_evaluated.h> | |
| 22 | #include <__type_traits/invoke.h> | |
| 24 | 23 | #include <__type_traits/is_equality_comparable.h> |
| 25 | 24 | #include <__type_traits/is_volatile.h> |
| 26 | 25 | #include <__utility/move.h> |
| ... | ... | @@ -35,7 +34,7 @@ _LIBCPP_PUSH_MACROS |
| 35 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 35 | |
| 37 | 36 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 38 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( | |
| 37 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl( | |
| 39 | 38 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate& __pred) { |
| 40 | 39 | for (; __first1 != __last1; ++__first1, (void)++__first2) |
| 41 | 40 | if (!__pred(*__first1, *__first2)) |
| ... | ... | @@ -49,20 +48,20 @@ template <class _Tp, |
| 49 | 48 | __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, _Tp, _Up> && !is_volatile<_Tp>::value && |
| 50 | 49 | !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, |
| 51 | 50 | int> = 0> |
| 52 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 51 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 53 | 52 | __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&) { |
| 54 | 53 | return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); |
| 55 | 54 | } |
| 56 | 55 | |
| 57 | 56 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 58 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 57 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 59 | 58 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { |
| 60 | 59 | return std::__equal_iter_impl( |
| 61 | 60 | std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred); |
| 62 | 61 | } |
| 63 | 62 | |
| 64 | 63 | template <class _InputIterator1, class _InputIterator2> |
| 65 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 64 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 66 | 65 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { |
| 67 | 66 | return std::equal(__first1, __last1, __first2, __equal_to()); |
| 68 | 67 | } |
| ... | ... | @@ -70,7 +69,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first |
| 70 | 69 | #if _LIBCPP_STD_VER >= 14 |
| 71 | 70 | |
| 72 | 71 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> |
| 73 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl( | |
| 72 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl( | |
| 74 | 73 | _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __comp, _Proj1& __proj1, _Proj2& __proj2) { |
| 75 | 74 | while (__first1 != __last1 && __first2 != __last2) { |
| 76 | 75 | if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) |
| ... | ... | @@ -90,13 +89,13 @@ template <class _Tp, |
| 90 | 89 | __is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value && |
| 91 | 90 | __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value, |
| 92 | 91 | int> = 0> |
| 93 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 92 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 94 | 93 | __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) { |
| 95 | 94 | return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1)); |
| 96 | 95 | } |
| 97 | 96 | |
| 98 | 97 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 99 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 98 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 100 | 99 | equal(_InputIterator1 __first1, |
| 101 | 100 | _InputIterator1 __last1, |
| 102 | 101 | _InputIterator2 __first2, |
| ... | ... | @@ -119,7 +118,7 @@ equal(_InputIterator1 __first1, |
| 119 | 118 | } |
| 120 | 119 | |
| 121 | 120 | template <class _InputIterator1, class _InputIterator2> |
| 122 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 121 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 123 | 122 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { |
| 124 | 123 | return std::equal(__first1, __last1, __first2, __last2, __equal_to()); |
| 125 | 124 | } |
lib/libcxx/include/__algorithm/equal_range.h+4-8| ... | ... | @@ -17,11 +17,7 @@ |
| 17 | 17 | #include <__algorithm/upper_bound.h> |
| 18 | 18 | #include <__config> |
| 19 | 19 | #include <__functional/identity.h> |
| 20 | #include <__functional/invoke.h> | |
| 21 | #include <__iterator/advance.h> | |
| 22 | #include <__iterator/distance.h> | |
| 23 | #include <__iterator/iterator_traits.h> | |
| 24 | #include <__iterator/next.h> | |
| 20 | #include <__type_traits/invoke.h> | |
| 25 | 21 | #include <__type_traits/is_callable.h> |
| 26 | 22 | #include <__type_traits/is_constructible.h> |
| 27 | 23 | #include <__utility/move.h> |
| ... | ... | @@ -60,9 +56,9 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp |
| 60 | 56 | } |
| 61 | 57 | |
| 62 | 58 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 63 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> | |
| 59 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> | |
| 64 | 60 | 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"); | |
| 61 | static_assert(__is_callable<_Compare&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); | |
| 66 | 62 | static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible"); |
| 67 | 63 | return std::__equal_range<_ClassicAlgPolicy>( |
| 68 | 64 | std::move(__first), |
| ... | ... | @@ -73,7 +69,7 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu |
| 73 | 69 | } |
| 74 | 70 | |
| 75 | 71 | template <class _ForwardIterator, class _Tp> |
| 76 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> | |
| 72 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> | |
| 77 | 73 | equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 78 | 74 | return std::equal_range(std::move(__first), std::move(__last), __value, __less<>()); |
| 79 | 75 | } |
lib/libcxx/include/__algorithm/fill_n.h+1-2| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | #include <__algorithm/min.h> |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__fwd/bit_reference.h> |
| 15 | #include <__iterator/iterator_traits.h> | |
| 16 | 15 | #include <__memory/pointer_traits.h> |
| 17 | 16 | #include <__utility/convert_to_integral.h> |
| 18 | 17 | |
| ... | ... | @@ -33,7 +32,7 @@ __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value); |
| 33 | 32 | |
| 34 | 33 | template <bool _FillVal, class _Cp> |
| 35 | 34 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 36 | __fill_n_bool(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) { | |
| 35 | __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_type_traits<_Cp>::size_type __n) { | |
| 37 | 36 | using _It = __bit_iterator<_Cp, false>; |
| 38 | 37 | using __storage_type = typename _It::__storage_type; |
| 39 | 38 |
lib/libcxx/include/__algorithm/find.h+12-9| ... | ... | @@ -17,17 +17,18 @@ |
| 17 | 17 | #include <__bit/invert_if.h> |
| 18 | 18 | #include <__config> |
| 19 | 19 | #include <__functional/identity.h> |
| 20 | #include <__functional/invoke.h> | |
| 21 | 20 | #include <__fwd/bit_reference.h> |
| 22 | 21 | #include <__iterator/segmented_iterator.h> |
| 23 | 22 | #include <__string/constexpr_c_functions.h> |
| 23 | #include <__type_traits/enable_if.h> | |
| 24 | #include <__type_traits/invoke.h> | |
| 25 | #include <__type_traits/is_equality_comparable.h> | |
| 24 | 26 | #include <__type_traits/is_integral.h> |
| 25 | #include <__type_traits/is_same.h> | |
| 26 | 27 | #include <__type_traits/is_signed.h> |
| 27 | 28 | #include <__utility/move.h> |
| 28 | 29 | #include <limits> |
| 29 | 30 | |
| 30 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 31 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 31 | 32 | # include <cwchar> |
| 32 | 33 | #endif |
| 33 | 34 | |
| ... | ... | @@ -63,7 +64,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T |
| 63 | 64 | return __last; |
| 64 | 65 | } |
| 65 | 66 | |
| 66 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 67 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 67 | 68 | template <class _Tp, |
| 68 | 69 | class _Up, |
| 69 | 70 | class _Proj, |
| ... | ... | @@ -75,7 +76,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T |
| 75 | 76 | return __ret; |
| 76 | 77 | return __last; |
| 77 | 78 | } |
| 78 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 79 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 79 | 80 | |
| 80 | 81 | // TODO: This should also be possible to get right with different signedness |
| 81 | 82 | // cast integral types to allow vectorization |
| ... | ... | @@ -96,7 +97,7 @@ __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj& __proj) { |
| 96 | 97 | // __bit_iterator implementation |
| 97 | 98 | template <bool _ToFind, class _Cp, bool _IsConst> |
| 98 | 99 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst> |
| 99 | __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) { | |
| 100 | __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_type_traits<_Cp>::size_type __n) { | |
| 100 | 101 | using _It = __bit_iterator<_Cp, _IsConst>; |
| 101 | 102 | using __storage_type = typename _It::__storage_type; |
| 102 | 103 | |
| ... | ... | @@ -134,8 +135,10 @@ template <class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_i |
| 134 | 135 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, _IsConst> |
| 135 | 136 | __find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) { |
| 136 | 137 | if (static_cast<bool>(__value)) |
| 137 | return std::__find_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first)); | |
| 138 | return std::__find_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first)); | |
| 138 | return std::__find_bool<true>( | |
| 139 | __first, static_cast<typename __size_difference_type_traits<_Cp>::size_type>(__last - __first)); | |
| 140 | return std::__find_bool<false>( | |
| 141 | __first, static_cast<typename __size_difference_type_traits<_Cp>::size_type>(__last - __first)); | |
| 139 | 142 | } |
| 140 | 143 | |
| 141 | 144 | // segmented iterator implementation |
| ... | ... | @@ -167,7 +170,7 @@ struct __find_segment { |
| 167 | 170 | |
| 168 | 171 | // public API |
| 169 | 172 | template <class _InputIterator, class _Tp> |
| 170 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | |
| 173 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | |
| 171 | 174 | find(_InputIterator __first, _InputIterator __last, const _Tp& __value) { |
| 172 | 175 | __identity __proj; |
| 173 | 176 | return std::__rewrap_iter( |
lib/libcxx/include/__algorithm/find_end.h+4-111| ... | ... | @@ -12,14 +12,10 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | #include <__algorithm/search.h> | |
| 16 | 15 | #include <__config> |
| 17 | 16 | #include <__functional/identity.h> |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__iterator/advance.h> | |
| 20 | 17 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__iterator/next.h> | |
| 22 | #include <__iterator/reverse_iterator.h> | |
| 18 | #include <__type_traits/invoke.h> | |
| 23 | 19 | #include <__utility/pair.h> |
| 24 | 20 | |
| 25 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -80,111 +76,8 @@ _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> |
| 80 | 76 | } |
| 81 | 77 | } |
| 82 | 78 | |
| 83 | template < class _IterOps, | |
| 84 | class _Pred, | |
| 85 | class _Iter1, | |
| 86 | class _Sent1, | |
| 87 | class _Iter2, | |
| 88 | class _Sent2, | |
| 89 | class _Proj1, | |
| 90 | class _Proj2> | |
| 91 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter1 __find_end( | |
| 92 | _Iter1 __first1, | |
| 93 | _Sent1 __sent1, | |
| 94 | _Iter2 __first2, | |
| 95 | _Sent2 __sent2, | |
| 96 | _Pred& __pred, | |
| 97 | _Proj1& __proj1, | |
| 98 | _Proj2& __proj2, | |
| 99 | bidirectional_iterator_tag, | |
| 100 | bidirectional_iterator_tag) { | |
| 101 | auto __last1 = _IterOps::next(__first1, __sent1); | |
| 102 | auto __last2 = _IterOps::next(__first2, __sent2); | |
| 103 | // modeled after search algorithm (in reverse) | |
| 104 | if (__first2 == __last2) | |
| 105 | return __last1; // Everything matches an empty sequence | |
| 106 | _Iter1 __l1 = __last1; | |
| 107 | _Iter2 __l2 = __last2; | |
| 108 | --__l2; | |
| 109 | while (true) { | |
| 110 | // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks | |
| 111 | while (true) { | |
| 112 | if (__first1 == __l1) // return __last1 if no element matches *__first2 | |
| 113 | return __last1; | |
| 114 | if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2))) | |
| 115 | break; | |
| 116 | } | |
| 117 | // *__l1 matches *__l2, now match elements before here | |
| 118 | _Iter1 __m1 = __l1; | |
| 119 | _Iter2 __m2 = __l2; | |
| 120 | while (true) { | |
| 121 | if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern) | |
| 122 | return __m1; | |
| 123 | if (__m1 == __first1) // Otherwise if source exhaused, pattern not found | |
| 124 | return __last1; | |
| 125 | ||
| 126 | // if there is a mismatch, restart with a new __l1 | |
| 127 | if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(__proj2, *--__m2))) { | |
| 128 | break; | |
| 129 | } // else there is a match, check next elements | |
| 130 | } | |
| 131 | } | |
| 132 | } | |
| 133 | ||
| 134 | template < class _AlgPolicy, | |
| 135 | class _Pred, | |
| 136 | class _Iter1, | |
| 137 | class _Sent1, | |
| 138 | class _Iter2, | |
| 139 | class _Sent2, | |
| 140 | class _Proj1, | |
| 141 | class _Proj2> | |
| 142 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter1 __find_end( | |
| 143 | _Iter1 __first1, | |
| 144 | _Sent1 __sent1, | |
| 145 | _Iter2 __first2, | |
| 146 | _Sent2 __sent2, | |
| 147 | _Pred& __pred, | |
| 148 | _Proj1& __proj1, | |
| 149 | _Proj2& __proj2, | |
| 150 | random_access_iterator_tag, | |
| 151 | random_access_iterator_tag) { | |
| 152 | typedef typename iterator_traits<_Iter1>::difference_type _D1; | |
| 153 | auto __last1 = _IterOps<_AlgPolicy>::next(__first1, __sent1); | |
| 154 | auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __sent2); | |
| 155 | // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern | |
| 156 | auto __len2 = __last2 - __first2; | |
| 157 | if (__len2 == 0) | |
| 158 | return __last1; | |
| 159 | auto __len1 = __last1 - __first1; | |
| 160 | if (__len1 < __len2) | |
| 161 | return __last1; | |
| 162 | const _Iter1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here | |
| 163 | _Iter1 __l1 = __last1; | |
| 164 | _Iter2 __l2 = __last2; | |
| 165 | --__l2; | |
| 166 | while (true) { | |
| 167 | while (true) { | |
| 168 | if (__s == __l1) | |
| 169 | return __last1; | |
| 170 | if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2))) | |
| 171 | break; | |
| 172 | } | |
| 173 | _Iter1 __m1 = __l1; | |
| 174 | _Iter2 __m2 = __l2; | |
| 175 | while (true) { | |
| 176 | if (__m2 == __first2) | |
| 177 | return __m1; | |
| 178 | // no need to check range on __m1 because __s guarantees we have enough source | |
| 179 | if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(*--__m2))) { | |
| 180 | break; | |
| 181 | } | |
| 182 | } | |
| 183 | } | |
| 184 | } | |
| 185 | ||
| 186 | 79 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 187 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_end_classic( | |
| 80 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_end_classic( | |
| 188 | 81 | _ForwardIterator1 __first1, |
| 189 | 82 | _ForwardIterator1 __last1, |
| 190 | 83 | _ForwardIterator2 __first2, |
| ... | ... | @@ -205,7 +98,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Fo |
| 205 | 98 | } |
| 206 | 99 | |
| 207 | 100 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 208 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end( | |
| 101 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end( | |
| 209 | 102 | _ForwardIterator1 __first1, |
| 210 | 103 | _ForwardIterator1 __last1, |
| 211 | 104 | _ForwardIterator2 __first2, |
| ... | ... | @@ -215,7 +108,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Fo |
| 215 | 108 | } |
| 216 | 109 | |
| 217 | 110 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 218 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 | |
| 111 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 | |
| 219 | 112 | find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { |
| 220 | 113 | return std::find_end(__first1, __last1, __first2, __last2, __equal_to()); |
| 221 | 114 | } |
lib/libcxx/include/__algorithm/find_first_of.h+2-3| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__iterator/iterator_traits.h> | |
| 16 | 15 | |
| 17 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 17 | # pragma GCC system_header |
| ... | ... | @@ -35,7 +34,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_fir |
| 35 | 34 | } |
| 36 | 35 | |
| 37 | 36 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 38 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( | |
| 37 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( | |
| 39 | 38 | _ForwardIterator1 __first1, |
| 40 | 39 | _ForwardIterator1 __last1, |
| 41 | 40 | _ForwardIterator2 __first2, |
| ... | ... | @@ -45,7 +44,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Fo |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | 46 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 48 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( | |
| 47 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( | |
| 49 | 48 | _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { |
| 50 | 49 | return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to()); |
| 51 | 50 | } |
lib/libcxx/include/__algorithm/find_if.h+1-1| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _InputIterator, class _Predicate> |
| 22 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | |
| 22 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | |
| 23 | 23 | find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 24 | 24 | for (; __first != __last; ++__first) |
| 25 | 25 | if (__pred(*__first)) |
lib/libcxx/include/__algorithm/find_if_not.h+1-1| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _InputIterator, class _Predicate> |
| 22 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | |
| 22 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | |
| 23 | 23 | find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 24 | 24 | for (; __first != __last; ++__first) |
| 25 | 25 | if (!__pred(*__first)) |
lib/libcxx/include/__algorithm/fold.h deleted-128| ... | ... | @@ -1,128 +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_FOLD_H | |
| 11 | #define _LIBCPP___ALGORITHM_FOLD_H | |
| 12 | ||
| 13 | #include <__concepts/assignable.h> | |
| 14 | #include <__concepts/convertible_to.h> | |
| 15 | #include <__concepts/invocable.h> | |
| 16 | #include <__concepts/movable.h> | |
| 17 | #include <__config> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/reference_wrapper.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/iterator_traits.h> | |
| 22 | #include <__iterator/next.h> | |
| 23 | #include <__ranges/access.h> | |
| 24 | #include <__ranges/concepts.h> | |
| 25 | #include <__ranges/dangling.h> | |
| 26 | #include <__type_traits/decay.h> | |
| 27 | #include <__type_traits/invoke.h> | |
| 28 | #include <__utility/forward.h> | |
| 29 | #include <__utility/move.h> | |
| 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 >= 23 | |
| 41 | ||
| 42 | namespace ranges { | |
| 43 | template <class _Ip, class _Tp> | |
| 44 | struct in_value_result { | |
| 45 | _LIBCPP_NO_UNIQUE_ADDRESS _Ip in; | |
| 46 | _LIBCPP_NO_UNIQUE_ADDRESS _Tp value; | |
| 47 | ||
| 48 | template <class _I2, class _T2> | |
| 49 | requires convertible_to<const _Ip&, _I2> && convertible_to<const _Tp&, _T2> | |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr operator in_value_result<_I2, _T2>() const& { | |
| 51 | return {in, value}; | |
| 52 | } | |
| 53 | ||
| 54 | template <class _I2, class _T2> | |
| 55 | requires convertible_to<_Ip, _I2> && convertible_to<_Tp, _T2> | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr operator in_value_result<_I2, _T2>() && { | |
| 57 | return {std::move(in), std::move(value)}; | |
| 58 | } | |
| 59 | }; | |
| 60 | ||
| 61 | template <class _Ip, class _Tp> | |
| 62 | using fold_left_with_iter_result = in_value_result<_Ip, _Tp>; | |
| 63 | ||
| 64 | template <class _Fp, class _Tp, class _Ip, class _Rp, class _Up = decay_t<_Rp>> | |
| 65 | concept __indirectly_binary_left_foldable_impl = | |
| 66 | convertible_to<_Rp, _Up> && // | |
| 67 | movable<_Tp> && // | |
| 68 | movable<_Up> && // | |
| 69 | convertible_to<_Tp, _Up> && // | |
| 70 | invocable<_Fp&, _Up, iter_reference_t<_Ip>> && // | |
| 71 | assignable_from<_Up&, invoke_result_t<_Fp&, _Up, iter_reference_t<_Ip>>>; | |
| 72 | ||
| 73 | template <class _Fp, class _Tp, class _Ip> | |
| 74 | concept __indirectly_binary_left_foldable = | |
| 75 | copy_constructible<_Fp> && // | |
| 76 | invocable<_Fp&, _Tp, iter_reference_t<_Ip>> && // | |
| 77 | __indirectly_binary_left_foldable_impl<_Fp, _Tp, _Ip, invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>; | |
| 78 | ||
| 79 | struct __fold_left_with_iter { | |
| 80 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp> | |
| 81 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) { | |
| 82 | using _Up = decay_t<invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>; | |
| 83 | ||
| 84 | if (__first == __last) { | |
| 85 | return fold_left_with_iter_result<_Ip, _Up>{std::move(__first), _Up(std::move(__init))}; | |
| 86 | } | |
| 87 | ||
| 88 | _Up __result = std::invoke(__f, std::move(__init), *__first); | |
| 89 | for (++__first; __first != __last; ++__first) { | |
| 90 | __result = std::invoke(__f, std::move(__result), *__first); | |
| 91 | } | |
| 92 | ||
| 93 | return fold_left_with_iter_result<_Ip, _Up>{std::move(__first), std::move(__result)}; | |
| 94 | } | |
| 95 | ||
| 96 | template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp> | |
| 97 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) { | |
| 98 | auto __result = operator()(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)); | |
| 99 | ||
| 100 | using _Up = decay_t<invoke_result_t<_Fp&, _Tp, range_reference_t<_Rp>>>; | |
| 101 | return fold_left_with_iter_result<borrowed_iterator_t<_Rp>, _Up>{std::move(__result.in), std::move(__result.value)}; | |
| 102 | } | |
| 103 | }; | |
| 104 | ||
| 105 | inline constexpr auto fold_left_with_iter = __fold_left_with_iter(); | |
| 106 | ||
| 107 | struct __fold_left { | |
| 108 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp> | |
| 109 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) { | |
| 110 | return fold_left_with_iter(std::move(__first), std::move(__last), std::move(__init), std::ref(__f)).value; | |
| 111 | } | |
| 112 | ||
| 113 | template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp> | |
| 114 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) { | |
| 115 | return fold_left_with_iter(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)).value; | |
| 116 | } | |
| 117 | }; | |
| 118 | ||
| 119 | inline constexpr auto fold_left = __fold_left(); | |
| 120 | } // namespace ranges | |
| 121 | ||
| 122 | #endif // _LIBCPP_STD_VER >= 23 | |
| 123 | ||
| 124 | _LIBCPP_END_NAMESPACE_STD | |
| 125 | ||
| 126 | _LIBCPP_POP_MACROS | |
| 127 | ||
| 128 | #endif // _LIBCPP___ALGORITHM_FOLD_H |
lib/libcxx/include/__algorithm/for_each.h-1| ... | ... | @@ -14,7 +14,6 @@ |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__iterator/segmented_iterator.h> |
| 16 | 16 | #include <__ranges/movable_box.h> |
| 17 | #include <__type_traits/enable_if.h> | |
| 18 | 17 | #include <__utility/in_place.h> |
| 19 | 18 | #include <__utility/move.h> |
| 20 | 19 |
lib/libcxx/include/__algorithm/includes.h+4-5| ... | ... | @@ -13,8 +13,7 @@ |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__functional/identity.h> |
| 16 | #include <__functional/invoke.h> | |
| 17 | #include <__iterator/iterator_traits.h> | |
| 16 | #include <__type_traits/invoke.h> | |
| 18 | 17 | #include <__type_traits/is_callable.h> |
| 19 | 18 | #include <__utility/move.h> |
| 20 | 19 | |
| ... | ... | @@ -47,14 +46,14 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __includes( |
| 47 | 46 | } |
| 48 | 47 | |
| 49 | 48 | template <class _InputIterator1, class _InputIterator2, class _Compare> |
| 50 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 49 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 51 | 50 | includes(_InputIterator1 __first1, |
| 52 | 51 | _InputIterator1 __last1, |
| 53 | 52 | _InputIterator2 __first2, |
| 54 | 53 | _InputIterator2 __last2, |
| 55 | 54 | _Compare __comp) { |
| 56 | 55 | static_assert( |
| 57 | __is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value, "Comparator has to be callable"); | |
| 56 | __is_callable<_Compare&, decltype(*__first1), decltype(*__first2)>::value, "The comparator has to be callable"); | |
| 58 | 57 | |
| 59 | 58 | return std::__includes( |
| 60 | 59 | std::move(__first1), |
| ... | ... | @@ -67,7 +66,7 @@ includes(_InputIterator1 __first1, |
| 67 | 66 | } |
| 68 | 67 | |
| 69 | 68 | template <class _InputIterator1, class _InputIterator2> |
| 70 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 69 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 71 | 70 | includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { |
| 72 | 71 | return std::includes(std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __less<>()); |
| 73 | 72 | } |
lib/libcxx/include/__algorithm/inplace_merge.h+22-20| ... | ... | @@ -18,16 +18,15 @@ |
| 18 | 18 | #include <__algorithm/rotate.h> |
| 19 | 19 | #include <__algorithm/upper_bound.h> |
| 20 | 20 | #include <__config> |
| 21 | #include <__cstddef/ptrdiff_t.h> | |
| 21 | 22 | #include <__functional/identity.h> |
| 22 | #include <__iterator/advance.h> | |
| 23 | #include <__iterator/distance.h> | |
| 24 | 23 | #include <__iterator/iterator_traits.h> |
| 25 | 24 | #include <__iterator/reverse_iterator.h> |
| 26 | 25 | #include <__memory/destruct_n.h> |
| 27 | #include <__memory/temporary_buffer.h> | |
| 28 | 26 | #include <__memory/unique_ptr.h> |
| 27 | #include <__memory/unique_temporary_buffer.h> | |
| 28 | #include <__utility/move.h> | |
| 29 | 29 | #include <__utility/pair.h> |
| 30 | #include <new> | |
| 31 | 30 | |
| 32 | 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 33 | 32 | # pragma GCC system_header |
| ... | ... | @@ -45,17 +44,17 @@ private: |
| 45 | 44 | _Predicate __p_; |
| 46 | 45 | |
| 47 | 46 | public: |
| 48 | _LIBCPP_HIDE_FROM_ABI __invert() {} | |
| 47 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __invert() {} | |
| 49 | 48 | |
| 50 | _LIBCPP_HIDE_FROM_ABI explicit __invert(_Predicate __p) : __p_(__p) {} | |
| 49 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __invert(_Predicate __p) : __p_(__p) {} | |
| 51 | 50 | |
| 52 | 51 | template <class _T1> |
| 53 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _T1& __x) { | |
| 52 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _T1& __x) { | |
| 54 | 53 | return !__p_(__x); |
| 55 | 54 | } |
| 56 | 55 | |
| 57 | 56 | template <class _T1, class _T2> |
| 58 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _T1& __x, const _T2& __y) { | |
| 57 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _T1& __x, const _T2& __y) { | |
| 59 | 58 | return __p_(__y, __x); |
| 60 | 59 | } |
| 61 | 60 | }; |
| ... | ... | @@ -67,7 +66,7 @@ template <class _AlgPolicy, |
| 67 | 66 | class _InputIterator2, |
| 68 | 67 | class _Sent2, |
| 69 | 68 | class _OutputIterator> |
| 70 | _LIBCPP_HIDE_FROM_ABI void __half_inplace_merge( | |
| 69 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __half_inplace_merge( | |
| 71 | 70 | _InputIterator1 __first1, |
| 72 | 71 | _Sent1 __last1, |
| 73 | 72 | _InputIterator2 __first2, |
| ... | ... | @@ -92,7 +91,7 @@ _LIBCPP_HIDE_FROM_ABI void __half_inplace_merge( |
| 92 | 91 | } |
| 93 | 92 | |
| 94 | 93 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> |
| 95 | _LIBCPP_HIDE_FROM_ABI void __buffered_inplace_merge( | |
| 94 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __buffered_inplace_merge( | |
| 96 | 95 | _BidirectionalIterator __first, |
| 97 | 96 | _BidirectionalIterator __middle, |
| 98 | 97 | _BidirectionalIterator __last, |
| ... | ... | @@ -123,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI void __buffered_inplace_merge( |
| 123 | 122 | } |
| 124 | 123 | |
| 125 | 124 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> |
| 126 | void __inplace_merge( | |
| 125 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void __inplace_merge( | |
| 127 | 126 | _BidirectionalIterator __first, |
| 128 | 127 | _BidirectionalIterator __middle, |
| 129 | 128 | _BidirectionalIterator __last, |
| ... | ... | @@ -208,16 +207,19 @@ _LIBCPP_HIDE_FROM_ABI void __inplace_merge( |
| 208 | 207 | _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare&& __comp) { |
| 209 | 208 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; |
| 210 | 209 | typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; |
| 211 | difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle); | |
| 212 | difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last); | |
| 213 | difference_type __buf_size = std::min(__len1, __len2); | |
| 214 | // TODO: Remove the use of std::get_temporary_buffer | |
| 215 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 216 | pair<value_type*, ptrdiff_t> __buf = std::get_temporary_buffer<value_type>(__buf_size); | |
| 217 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 218 | unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first); | |
| 210 | difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle); | |
| 211 | difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last); | |
| 212 | difference_type __buf_size = std::min(__len1, __len2); | |
| 213 | __unique_temporary_buffer<value_type> __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__buf_size); | |
| 219 | 214 | return std::__inplace_merge<_AlgPolicy>( |
| 220 | std::move(__first), std::move(__middle), std::move(__last), __comp, __len1, __len2, __buf.first, __buf.second); | |
| 215 | std::move(__first), | |
| 216 | std::move(__middle), | |
| 217 | std::move(__last), | |
| 218 | __comp, | |
| 219 | __len1, | |
| 220 | __len2, | |
| 221 | __unique_buf.get(), | |
| 222 | __unique_buf.get_deleter().__count_); | |
| 221 | 223 | } |
| 222 | 224 | |
| 223 | 225 | template <class _BidirectionalIterator, class _Compare> |
lib/libcxx/include/__algorithm/is_heap.h+2-3| ... | ... | @@ -13,7 +13,6 @@ |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/is_heap_until.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | |
| 17 | 16 | |
| 18 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 18 | # pragma GCC system_header |
| ... | ... | @@ -22,13 +21,13 @@ |
| 22 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 22 | |
| 24 | 23 | template <class _RandomAccessIterator, class _Compare> |
| 25 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 24 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 26 | 25 | is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { |
| 27 | 26 | return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last; |
| 28 | 27 | } |
| 29 | 28 | |
| 30 | 29 | template <class _RandomAccessIterator> |
| 31 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 30 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 32 | 31 | is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { |
| 33 | 32 | return std::is_heap(__first, __last, __less<>()); |
| 34 | 33 | } |
lib/libcxx/include/__algorithm/is_heap_until.h+2-2| ... | ... | @@ -46,13 +46,13 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | template <class _RandomAccessIterator, class _Compare> |
| 49 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator | |
| 49 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator | |
| 50 | 50 | is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { |
| 51 | 51 | return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | template <class _RandomAccessIterator> |
| 55 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator | |
| 55 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator | |
| 56 | 56 | is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) { |
| 57 | 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 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | 20 | template <class _InputIterator, class _Predicate> |
| 21 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 21 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 22 | 22 | is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 23 | 23 | for (; __first != __last; ++__first) |
| 24 | 24 | if (!__pred(*__first)) |
lib/libcxx/include/__algorithm/is_permutation.h+12-11| ... | ... | @@ -14,12 +14,13 @@ |
| 14 | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | 15 | #include <__config> |
| 16 | 16 | #include <__functional/identity.h> |
| 17 | #include <__functional/invoke.h> | |
| 18 | 17 | #include <__iterator/concepts.h> |
| 19 | 18 | #include <__iterator/distance.h> |
| 20 | 19 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__iterator/next.h> | |
| 20 | #include <__type_traits/enable_if.h> | |
| 21 | #include <__type_traits/invoke.h> | |
| 22 | 22 | #include <__type_traits/is_callable.h> |
| 23 | #include <__type_traits/is_same.h> | |
| 23 | 24 | #include <__utility/move.h> |
| 24 | 25 | |
| 25 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -113,7 +114,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation_impl( |
| 113 | 114 | |
| 114 | 115 | // 2+1 iterators, predicate. Not used by range algorithms. |
| 115 | 116 | template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate> |
| 116 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( | |
| 117 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( | |
| 117 | 118 | _ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _BinaryPredicate&& __pred) { |
| 118 | 119 | // Shorten sequences as much as possible by lopping of any equal prefix. |
| 119 | 120 | for (; __first1 != __last1; ++__first1, (void)++__first2) { |
| ... | ... | @@ -247,17 +248,17 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation( |
| 247 | 248 | |
| 248 | 249 | // 2+1 iterators, predicate |
| 249 | 250 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 250 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( | |
| 251 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( | |
| 251 | 252 | _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) { |
| 252 | static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, | |
| 253 | "The predicate has to be callable"); | |
| 253 | static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value, | |
| 254 | "The comparator has to be callable"); | |
| 254 | 255 | |
| 255 | 256 | return std::__is_permutation<_ClassicAlgPolicy>(std::move(__first1), std::move(__last1), std::move(__first2), __pred); |
| 256 | 257 | } |
| 257 | 258 | |
| 258 | 259 | // 2+1 iterators |
| 259 | 260 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 260 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 261 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 261 | 262 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { |
| 262 | 263 | return std::is_permutation(__first1, __last1, __first2, __equal_to()); |
| 263 | 264 | } |
| ... | ... | @@ -266,7 +267,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt |
| 266 | 267 | |
| 267 | 268 | // 2+2 iterators |
| 268 | 269 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 269 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( | |
| 270 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( | |
| 270 | 271 | _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { |
| 271 | 272 | return std::__is_permutation<_ClassicAlgPolicy>( |
| 272 | 273 | std::move(__first1), |
| ... | ... | @@ -280,14 +281,14 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 boo |
| 280 | 281 | |
| 281 | 282 | // 2+2 iterators, predicate |
| 282 | 283 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 283 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( | |
| 284 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation( | |
| 284 | 285 | _ForwardIterator1 __first1, |
| 285 | 286 | _ForwardIterator1 __last1, |
| 286 | 287 | _ForwardIterator2 __first2, |
| 287 | 288 | _ForwardIterator2 __last2, |
| 288 | 289 | _BinaryPredicate __pred) { |
| 289 | static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, | |
| 290 | "The predicate has to be callable"); | |
| 290 | static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value, | |
| 291 | "The comparator has to be callable"); | |
| 291 | 292 | |
| 292 | 293 | return std::__is_permutation<_ClassicAlgPolicy>( |
| 293 | 294 | std::move(__first1), |
lib/libcxx/include/__algorithm/is_sorted.h+2-3| ... | ... | @@ -13,7 +13,6 @@ |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/is_sorted_until.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | |
| 17 | 16 | |
| 18 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 18 | # pragma GCC system_header |
| ... | ... | @@ -22,13 +21,13 @@ |
| 22 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 22 | |
| 24 | 23 | template <class _ForwardIterator, class _Compare> |
| 25 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 24 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 26 | 25 | is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { |
| 27 | 26 | return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last; |
| 28 | 27 | } |
| 29 | 28 | |
| 30 | 29 | template <class _ForwardIterator> |
| 31 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 30 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 32 | 31 | is_sorted(_ForwardIterator __first, _ForwardIterator __last) { |
| 33 | 32 | return std::is_sorted(__first, __last, __less<>()); |
| 34 | 33 | } |
lib/libcxx/include/__algorithm/is_sorted_until.h+2-3| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__iterator/iterator_traits.h> | |
| 16 | 15 | |
| 17 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 17 | # pragma GCC system_header |
| ... | ... | @@ -35,13 +34,13 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __ |
| 35 | 34 | } |
| 36 | 35 | |
| 37 | 36 | template <class _ForwardIterator, class _Compare> |
| 38 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 37 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 39 | 38 | is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { |
| 40 | 39 | return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp); |
| 41 | 40 | } |
| 42 | 41 | |
| 43 | 42 | template <class _ForwardIterator> |
| 44 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 43 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 45 | 44 | is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) { |
| 46 | 45 | return std::is_sorted_until(__first, __last, __less<>()); |
| 47 | 46 | } |
lib/libcxx/include/__algorithm/iterator_operations.h+11-8| ... | ... | @@ -48,13 +48,13 @@ struct _RangeAlgPolicy {}; |
| 48 | 48 | template <> |
| 49 | 49 | struct _IterOps<_RangeAlgPolicy> { |
| 50 | 50 | template <class _Iter> |
| 51 | using __value_type = iter_value_t<_Iter>; | |
| 51 | using __value_type _LIBCPP_NODEBUG = iter_value_t<_Iter>; | |
| 52 | 52 | |
| 53 | 53 | template <class _Iter> |
| 54 | using __iterator_category = ranges::__iterator_concept<_Iter>; | |
| 54 | using __iterator_category _LIBCPP_NODEBUG = ranges::__iterator_concept<_Iter>; | |
| 55 | 55 | |
| 56 | 56 | template <class _Iter> |
| 57 | using __difference_type = iter_difference_t<_Iter>; | |
| 57 | using __difference_type _LIBCPP_NODEBUG = iter_difference_t<_Iter>; | |
| 58 | 58 | |
| 59 | 59 | static constexpr auto advance = ranges::advance; |
| 60 | 60 | static constexpr auto distance = ranges::distance; |
| ... | ... | @@ -72,13 +72,13 @@ struct _ClassicAlgPolicy {}; |
| 72 | 72 | template <> |
| 73 | 73 | struct _IterOps<_ClassicAlgPolicy> { |
| 74 | 74 | template <class _Iter> |
| 75 | using __value_type = typename iterator_traits<_Iter>::value_type; | |
| 75 | using __value_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::value_type; | |
| 76 | 76 | |
| 77 | 77 | template <class _Iter> |
| 78 | using __iterator_category = typename iterator_traits<_Iter>::iterator_category; | |
| 78 | using __iterator_category _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category; | |
| 79 | 79 | |
| 80 | 80 | template <class _Iter> |
| 81 | using __difference_type = typename iterator_traits<_Iter>::difference_type; | |
| 81 | using __difference_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::difference_type; | |
| 82 | 82 | |
| 83 | 83 | // advance |
| 84 | 84 | template <class _Iter, class _Distance> |
| ... | ... | @@ -94,10 +94,10 @@ struct _IterOps<_ClassicAlgPolicy> { |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | template <class _Iter> |
| 97 | using __deref_t = decltype(*std::declval<_Iter&>()); | |
| 97 | using __deref_t _LIBCPP_NODEBUG = decltype(*std::declval<_Iter&>()); | |
| 98 | 98 | |
| 99 | 99 | template <class _Iter> |
| 100 | using __move_t = decltype(std::move(*std::declval<_Iter&>())); | |
| 100 | using __move_t _LIBCPP_NODEBUG = decltype(std::move(*std::declval<_Iter&>())); | |
| 101 | 101 | |
| 102 | 102 | template <class _Iter> |
| 103 | 103 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static void __validate_iter_reference() { |
| ... | ... | @@ -216,6 +216,9 @@ private: |
| 216 | 216 | } |
| 217 | 217 | }; |
| 218 | 218 | |
| 219 | template <class _AlgPolicy, class _Iter> | |
| 220 | using __policy_iter_diff_t _LIBCPP_NODEBUG = typename _IterOps<_AlgPolicy>::template __difference_type<_Iter>; | |
| 221 | ||
| 219 | 222 | _LIBCPP_END_NAMESPACE_STD |
| 220 | 223 | |
| 221 | 224 | _LIBCPP_POP_MACROS |
lib/libcxx/include/__algorithm/lexicographical_compare.h+85-13| ... | ... | @@ -10,48 +10,120 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 13 | #include <__algorithm/min.h> | |
| 14 | #include <__algorithm/mismatch.h> | |
| 15 | #include <__algorithm/simd_utils.h> | |
| 16 | #include <__algorithm/unwrap_iter.h> | |
| 14 | 17 | #include <__config> |
| 18 | #include <__functional/identity.h> | |
| 15 | 19 | #include <__iterator/iterator_traits.h> |
| 20 | #include <__string/constexpr_c_functions.h> | |
| 21 | #include <__type_traits/desugars_to.h> | |
| 22 | #include <__type_traits/enable_if.h> | |
| 23 | #include <__type_traits/invoke.h> | |
| 24 | #include <__type_traits/is_equality_comparable.h> | |
| 25 | #include <__type_traits/is_integral.h> | |
| 26 | #include <__type_traits/is_trivially_lexicographically_comparable.h> | |
| 27 | #include <__type_traits/is_volatile.h> | |
| 28 | ||
| 29 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 30 | # include <cwchar> | |
| 31 | #endif | |
| 16 | 32 | |
| 17 | 33 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 34 | # pragma GCC system_header |
| 19 | 35 | #endif |
| 20 | 36 | |
| 37 | _LIBCPP_PUSH_MACROS | |
| 38 | #include <__undef_macros> | |
| 39 | ||
| 21 | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 41 | |
| 23 | template <class _Compare, class _InputIterator1, class _InputIterator2> | |
| 42 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp> | |
| 24 | 43 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __lexicographical_compare( |
| 25 | _InputIterator1 __first1, | |
| 26 | _InputIterator1 __last1, | |
| 27 | _InputIterator2 __first2, | |
| 28 | _InputIterator2 __last2, | |
| 29 | _Compare __comp) { | |
| 30 | for (; __first2 != __last2; ++__first1, (void)++__first2) { | |
| 31 | if (__first1 == __last1 || __comp(*__first1, *__first2)) | |
| 44 | _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) { | |
| 45 | while (__first2 != __last2) { | |
| 46 | if (__first1 == __last1 || | |
| 47 | std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | |
| 32 | 48 | return true; |
| 33 | if (__comp(*__first2, *__first1)) | |
| 49 | if (std::__invoke(__comp, std::__invoke(__proj2, *__first2), std::__invoke(__proj1, *__first1))) | |
| 34 | 50 | return false; |
| 51 | ++__first1; | |
| 52 | ++__first2; | |
| 35 | 53 | } |
| 36 | 54 | return false; |
| 37 | 55 | } |
| 38 | 56 | |
| 57 | #if _LIBCPP_STD_VER >= 14 | |
| 58 | ||
| 59 | // If the comparison operation is equivalent to < and that is a total order, we know that we can use equality comparison | |
| 60 | // on that type instead to extract some information. Furthermore, if equality comparison on that type is trivial, the | |
| 61 | // user can't observe that we're calling it. So instead of using the user-provided total order, we use std::mismatch, | |
| 62 | // which uses equality comparison (and is vertorized). Additionally, if the type is trivially lexicographically | |
| 63 | // comparable, we can go one step further and use std::memcmp directly instead of calling std::mismatch. | |
| 64 | template <class _Tp, | |
| 65 | class _Proj1, | |
| 66 | class _Proj2, | |
| 67 | class _Comp, | |
| 68 | __enable_if_t<__desugars_to_v<__totally_ordered_less_tag, _Comp, _Tp, _Tp> && !is_volatile<_Tp>::value && | |
| 69 | __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value && | |
| 70 | __is_identity<_Proj1>::value && __is_identity<_Proj2>::value, | |
| 71 | int> = 0> | |
| 72 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 73 | __lexicographical_compare(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Comp&, _Proj1&, _Proj2&) { | |
| 74 | if constexpr (__is_trivially_lexicographically_comparable_v<_Tp, _Tp>) { | |
| 75 | auto __res = | |
| 76 | std::__constexpr_memcmp(__first1, __first2, __element_count(std::min(__last1 - __first1, __last2 - __first2))); | |
| 77 | if (__res == 0) | |
| 78 | return __last1 - __first1 < __last2 - __first2; | |
| 79 | return __res < 0; | |
| 80 | } | |
| 81 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 82 | else if constexpr (is_same<__remove_cv_t<_Tp>, wchar_t>::value) { | |
| 83 | auto __res = std::__constexpr_wmemcmp(__first1, __first2, std::min(__last1 - __first1, __last2 - __first2)); | |
| 84 | if (__res == 0) | |
| 85 | return __last1 - __first1 < __last2 - __first2; | |
| 86 | return __res < 0; | |
| 87 | } | |
| 88 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 89 | else { | |
| 90 | auto __res = std::mismatch(__first1, __last1, __first2, __last2); | |
| 91 | if (__res.second == __last2) | |
| 92 | return false; | |
| 93 | if (__res.first == __last1) | |
| 94 | return true; | |
| 95 | return *__res.first < *__res.second; | |
| 96 | } | |
| 97 | } | |
| 98 | ||
| 99 | #endif // _LIBCPP_STD_VER >= 14 | |
| 100 | ||
| 39 | 101 | template <class _InputIterator1, class _InputIterator2, class _Compare> |
| 40 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( | |
| 102 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( | |
| 41 | 103 | _InputIterator1 __first1, |
| 42 | 104 | _InputIterator1 __last1, |
| 43 | 105 | _InputIterator2 __first2, |
| 44 | 106 | _InputIterator2 __last2, |
| 45 | 107 | _Compare __comp) { |
| 46 | return std::__lexicographical_compare<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __comp); | |
| 108 | __identity __proj; | |
| 109 | return std::__lexicographical_compare( | |
| 110 | std::__unwrap_iter(__first1), | |
| 111 | std::__unwrap_iter(__last1), | |
| 112 | std::__unwrap_iter(__first2), | |
| 113 | std::__unwrap_iter(__last2), | |
| 114 | __comp, | |
| 115 | __proj, | |
| 116 | __proj); | |
| 47 | 117 | } |
| 48 | 118 | |
| 49 | 119 | template <class _InputIterator1, class _InputIterator2> |
| 50 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( | |
| 120 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare( | |
| 51 | 121 | _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { |
| 52 | 122 | return std::lexicographical_compare(__first1, __last1, __first2, __last2, __less<>()); |
| 53 | 123 | } |
| 54 | 124 | |
| 55 | 125 | _LIBCPP_END_NAMESPACE_STD |
| 56 | 126 | |
| 127 | _LIBCPP_POP_MACROS | |
| 128 | ||
| 57 | 129 | #endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H |
lib/libcxx/include/__algorithm/lower_bound.h+7-8| ... | ... | @@ -14,12 +14,11 @@ |
| 14 | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | 15 | #include <__config> |
| 16 | 16 | #include <__functional/identity.h> |
| 17 | #include <__functional/invoke.h> | |
| 18 | 17 | #include <__iterator/advance.h> |
| 19 | 18 | #include <__iterator/distance.h> |
| 20 | 19 | #include <__iterator/iterator_traits.h> |
| 20 | #include <__type_traits/invoke.h> | |
| 21 | 21 | #include <__type_traits/is_callable.h> |
| 22 | #include <__type_traits/remove_reference.h> | |
| 23 | 22 | |
| 24 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | 24 | # pragma GCC system_header |
| ... | ... | @@ -28,7 +27,7 @@ |
| 28 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 28 | |
| 30 | 29 | template <class _AlgPolicy, class _Iter, class _Type, class _Proj, class _Comp> |
| 31 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lower_bound_bisecting( | |
| 30 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lower_bound_bisecting( | |
| 32 | 31 | _Iter __first, |
| 33 | 32 | const _Type& __value, |
| 34 | 33 | typename iterator_traits<_Iter>::difference_type __len, |
| ... | ... | @@ -58,7 +57,7 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lo |
| 58 | 57 | // whereas the one-sided version will yield O(n) operations on both counts, with a \Omega(log(n)) bound on the number of |
| 59 | 58 | // comparisons. |
| 60 | 59 | 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 | |
| 60 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 62 | 61 | __lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) { |
| 63 | 62 | // step = 0, ensuring we can always short-circuit when distance is 1 later on |
| 64 | 63 | if (__first == __last || !std::__invoke(__comp, std::__invoke(__proj, *__first), __value)) |
| ... | ... | @@ -84,22 +83,22 @@ __lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __va |
| 84 | 83 | } |
| 85 | 84 | |
| 86 | 85 | 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 | |
| 86 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 88 | 87 | __lower_bound(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) { |
| 89 | 88 | const auto __dist = _IterOps<_AlgPolicy>::distance(__first, __last); |
| 90 | 89 | return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj); |
| 91 | 90 | } |
| 92 | 91 | |
| 93 | 92 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 94 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 93 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 95 | 94 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { |
| 96 | static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); | |
| 95 | static_assert(__is_callable<_Compare&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); | |
| 97 | 96 | auto __proj = std::__identity(); |
| 98 | 97 | return std::__lower_bound<_ClassicAlgPolicy>(__first, __last, __value, __comp, __proj); |
| 99 | 98 | } |
| 100 | 99 | |
| 101 | 100 | template <class _ForwardIterator, class _Tp> |
| 102 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 101 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 103 | 102 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 104 | 103 | return std::lower_bound(__first, __last, __value, __less<>()); |
| 105 | 104 | } |
lib/libcxx/include/__algorithm/make_projected.h+7-9| ... | ... | @@ -9,15 +9,13 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MAKE_PROJECTED_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MAKE_PROJECTED_H |
| 11 | 11 | |
| 12 | #include <__concepts/same_as.h> | |
| 13 | 12 | #include <__config> |
| 14 | 13 | #include <__functional/identity.h> |
| 15 | 14 | #include <__functional/invoke.h> |
| 16 | 15 | #include <__type_traits/decay.h> |
| 17 | 16 | #include <__type_traits/enable_if.h> |
| 18 | #include <__type_traits/integral_constant.h> | |
| 17 | #include <__type_traits/invoke.h> | |
| 19 | 18 | #include <__type_traits/is_member_pointer.h> |
| 20 | #include <__type_traits/is_same.h> | |
| 21 | 19 | #include <__utility/declval.h> |
| 22 | 20 | #include <__utility/forward.h> |
| 23 | 21 | |
| ... | ... | @@ -36,16 +34,16 @@ struct _ProjectedPred { |
| 36 | 34 | : __pred(__pred_arg), __proj(__proj_arg) {} |
| 37 | 35 | |
| 38 | 36 | template <class _Tp> |
| 39 | typename __invoke_of<_Pred&, decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))>::type | |
| 40 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI | |
| 41 | operator()(_Tp&& __v) const { | |
| 37 | __invoke_result_t<_Pred&, decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))> _LIBCPP_CONSTEXPR | |
| 38 | _LIBCPP_HIDE_FROM_ABI | |
| 39 | operator()(_Tp&& __v) const { | |
| 42 | 40 | return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v))); |
| 43 | 41 | } |
| 44 | 42 | |
| 45 | 43 | template <class _T1, class _T2> |
| 46 | typename __invoke_of<_Pred&, | |
| 47 | decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())), | |
| 48 | decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))>::type _LIBCPP_CONSTEXPR | |
| 44 | __invoke_result_t<_Pred&, | |
| 45 | decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())), | |
| 46 | decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))> _LIBCPP_CONSTEXPR | |
| 49 | 47 | _LIBCPP_HIDE_FROM_ABI |
| 50 | 48 | operator()(_T1&& __lhs, _T2&& __rhs) const { |
| 51 | 49 | return std::__invoke( |
lib/libcxx/include/__algorithm/max.h+4-4| ... | ... | @@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | 27 | template <class _Tp, class _Compare> |
| 28 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | |
| 28 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | |
| 29 | 29 | max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { |
| 30 | 30 | return __comp(__a, __b) ? __b : __a; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | template <class _Tp> |
| 34 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | |
| 34 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | |
| 35 | 35 | max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { |
| 36 | 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 | 39 | #ifndef _LIBCPP_CXX03_LANG |
| 40 | 40 | |
| 41 | 41 | template <class _Tp, class _Compare> |
| 42 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp | |
| 42 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp | |
| 43 | 43 | max(initializer_list<_Tp> __t, _Compare __comp) { |
| 44 | 44 | return *std::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | template <class _Tp> |
| 48 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) { | |
| 48 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) { | |
| 49 | 49 | return *std::max_element(__t.begin(), __t.end(), __less<>()); |
| 50 | 50 | } |
| 51 | 51 |
lib/libcxx/include/__algorithm/max_element.h+5-2| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <__type_traits/is_callable.h> | |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 19 | # pragma GCC system_header |
| ... | ... | @@ -35,13 +36,15 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp |
| 35 | 36 | } |
| 36 | 37 | |
| 37 | 38 | template <class _ForwardIterator, class _Compare> |
| 38 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | |
| 39 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | |
| 39 | 40 | max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { |
| 41 | static_assert( | |
| 42 | __is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable"); | |
| 40 | 43 | return std::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp); |
| 41 | 44 | } |
| 42 | 45 | |
| 43 | 46 | template <class _ForwardIterator> |
| 44 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | |
| 47 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | |
| 45 | 48 | max_element(_ForwardIterator __first, _ForwardIterator __last) { |
| 46 | 49 | return std::max_element(__first, __last, __less<>()); |
| 47 | 50 | } |
lib/libcxx/include/__algorithm/merge.h-1| ... | ... | @@ -13,7 +13,6 @@ |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/copy.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | |
| 17 | 16 | |
| 18 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 18 | # pragma GCC system_header |
lib/libcxx/include/__algorithm/min.h+4-4| ... | ... | @@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | 27 | template <class _Tp, class _Compare> |
| 28 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | |
| 28 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | |
| 29 | 29 | min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { |
| 30 | 30 | return __comp(__b, __a) ? __b : __a; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | template <class _Tp> |
| 34 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | |
| 34 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& | |
| 35 | 35 | min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { |
| 36 | 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 | 39 | #ifndef _LIBCPP_CXX03_LANG |
| 40 | 40 | |
| 41 | 41 | template <class _Tp, class _Compare> |
| 42 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp | |
| 42 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp | |
| 43 | 43 | min(initializer_list<_Tp> __t, _Compare __comp) { |
| 44 | 44 | return *std::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | template <class _Tp> |
| 48 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) { | |
| 48 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) { | |
| 49 | 49 | return *std::min_element(__t.begin(), __t.end(), __less<>()); |
| 50 | 50 | } |
| 51 | 51 |
lib/libcxx/include/__algorithm/min_element.h+4-4| ... | ... | @@ -13,8 +13,8 @@ |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__functional/identity.h> |
| 16 | #include <__functional/invoke.h> | |
| 17 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__type_traits/invoke.h> | |
| 18 | 18 | #include <__type_traits/is_callable.h> |
| 19 | 19 | #include <__utility/move.h> |
| 20 | 20 | |
| ... | ... | @@ -48,18 +48,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter __min_element(_Iter __ |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | template <class _ForwardIterator, class _Compare> |
| 51 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | |
| 51 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | |
| 52 | 52 | min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { |
| 53 | 53 | static_assert( |
| 54 | 54 | __has_forward_iterator_category<_ForwardIterator>::value, "std::min_element requires a ForwardIterator"); |
| 55 | 55 | static_assert( |
| 56 | __is_callable<_Compare, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable"); | |
| 56 | __is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable"); | |
| 57 | 57 | |
| 58 | 58 | return std::__min_element<__comp_ref_type<_Compare> >(std::move(__first), std::move(__last), __comp); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | template <class _ForwardIterator> |
| 62 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | |
| 62 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator | |
| 63 | 63 | min_element(_ForwardIterator __first, _ForwardIterator __last) { |
| 64 | 64 | return std::min_element(__first, __last, __less<>()); |
| 65 | 65 | } |
lib/libcxx/include/__algorithm/minmax.h+5-5| ... | ... | @@ -24,13 +24,13 @@ |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | |
| 26 | 26 | template <class _Tp, class _Compare> |
| 27 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> | |
| 27 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> | |
| 28 | 28 | minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) { |
| 29 | 29 | return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) : pair<const _Tp&, const _Tp&>(__a, __b); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | template <class _Tp> |
| 33 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> | |
| 33 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&> | |
| 34 | 34 | minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) { |
| 35 | 35 | return std::minmax(__a, __b, __less<>()); |
| 36 | 36 | } |
| ... | ... | @@ -38,16 +38,16 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __ |
| 38 | 38 | #ifndef _LIBCPP_CXX03_LANG |
| 39 | 39 | |
| 40 | 40 | template <class _Tp, class _Compare> |
| 41 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> | |
| 41 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> | |
| 42 | 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 | 44 | __identity __proj; |
| 45 | 45 | auto __ret = std::__minmax_element_impl(__t.begin(), __t.end(), __comp, __proj); |
| 46 | 46 | return pair<_Tp, _Tp>(*__ret.first, *__ret.second); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | template <class _Tp> |
| 50 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> | |
| 50 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp> | |
| 51 | 51 | minmax(initializer_list<_Tp> __t) { |
| 52 | 52 | return std::minmax(__t, __less<>()); |
| 53 | 53 | } |
lib/libcxx/include/__algorithm/minmax_element.h+4-4| ... | ... | @@ -12,8 +12,8 @@ |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__functional/identity.h> |
| 15 | #include <__functional/invoke.h> | |
| 16 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <__type_traits/invoke.h> | |
| 17 | 17 | #include <__type_traits/is_callable.h> |
| 18 | 18 | #include <__utility/pair.h> |
| 19 | 19 | |
| ... | ... | @@ -79,18 +79,18 @@ __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | template <class _ForwardIterator, class _Compare> |
| 82 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> | |
| 82 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> | |
| 83 | 83 | minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { |
| 84 | 84 | static_assert( |
| 85 | 85 | __has_forward_iterator_category<_ForwardIterator>::value, "std::minmax_element requires a ForwardIterator"); |
| 86 | 86 | static_assert( |
| 87 | __is_callable<_Compare, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable"); | |
| 87 | __is_callable<_Compare&, decltype(*__first), decltype(*__first)>::value, "The comparator has to be callable"); | |
| 88 | 88 | auto __proj = __identity(); |
| 89 | 89 | return std::__minmax_element_impl(__first, __last, __comp, __proj); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | template <class _ForwardIterator> |
| 93 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> | |
| 93 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator> | |
| 94 | 94 | minmax_element(_ForwardIterator __first, _ForwardIterator __last) { |
| 95 | 95 | return std::minmax_element(__first, __last, __less<>()); |
| 96 | 96 | } |
lib/libcxx/include/__algorithm/mismatch.h+14-13| ... | ... | @@ -15,17 +15,18 @@ |
| 15 | 15 | #include <__algorithm/simd_utils.h> |
| 16 | 16 | #include <__algorithm/unwrap_iter.h> |
| 17 | 17 | #include <__config> |
| 18 | #include <__cstddef/size_t.h> | |
| 18 | 19 | #include <__functional/identity.h> |
| 19 | 20 | #include <__iterator/aliasing_iterator.h> |
| 21 | #include <__iterator/iterator_traits.h> | |
| 20 | 22 | #include <__type_traits/desugars_to.h> |
| 23 | #include <__type_traits/enable_if.h> | |
| 21 | 24 | #include <__type_traits/invoke.h> |
| 22 | 25 | #include <__type_traits/is_constant_evaluated.h> |
| 23 | 26 | #include <__type_traits/is_equality_comparable.h> |
| 24 | 27 | #include <__type_traits/is_integral.h> |
| 25 | 28 | #include <__utility/move.h> |
| 26 | 29 | #include <__utility/pair.h> |
| 27 | #include <__utility/unreachable.h> | |
| 28 | #include <cstddef> | |
| 29 | 30 | |
| 30 | 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 31 | 32 | # pragma GCC system_header |
| ... | ... | @@ -37,7 +38,7 @@ _LIBCPP_PUSH_MACROS |
| 37 | 38 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 38 | 39 | |
| 39 | 40 | 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 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> | |
| 41 | 42 | __mismatch_loop(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { |
| 42 | 43 | while (__first1 != __last1) { |
| 43 | 44 | if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) |
| ... | ... | @@ -49,7 +50,7 @@ __mismatch_loop(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, |
| 49 | 50 | } |
| 50 | 51 | |
| 51 | 52 | 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 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> | |
| 53 | 54 | __mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { |
| 54 | 55 | return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2); |
| 55 | 56 | } |
| ... | ... | @@ -57,7 +58,7 @@ __mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Pro |
| 57 | 58 | #if _LIBCPP_VECTORIZE_ALGORITHMS |
| 58 | 59 | |
| 59 | 60 | template <class _Iter> |
| 60 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter> | |
| 61 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter> | |
| 61 | 62 | __mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) { |
| 62 | 63 | using __value_type = __iter_value_type<_Iter>; |
| 63 | 64 | constexpr size_t __unroll_count = 4; |
| ... | ... | @@ -124,7 +125,7 @@ template <class _Tp, |
| 124 | 125 | __enable_if_t<is_integral<_Tp>::value && __desugars_to_v<__equal_tag, _Pred, _Tp, _Tp> && |
| 125 | 126 | __is_identity<_Proj1>::value && __is_identity<_Proj2>::value, |
| 126 | 127 | int> = 0> |
| 127 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> | |
| 128 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> | |
| 128 | 129 | __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred&, _Proj1&, _Proj2&) { |
| 129 | 130 | return std::__mismatch_vectorized(__first1, __last1, __first2); |
| 130 | 131 | } |
| ... | ... | @@ -137,7 +138,7 @@ template <class _Tp, |
| 137 | 138 | __is_identity<_Proj1>::value && __is_identity<_Proj2>::value && |
| 138 | 139 | __can_map_to_integer_v<_Tp> && __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value, |
| 139 | 140 | int> = 0> |
| 140 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> | |
| 141 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> | |
| 141 | 142 | __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { |
| 142 | 143 | if (__libcpp_is_constant_evaluated()) { |
| 143 | 144 | return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2); |
| ... | ... | @@ -150,7 +151,7 @@ __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __ |
| 150 | 151 | #endif // _LIBCPP_VECTORIZE_ALGORITHMS |
| 151 | 152 | |
| 152 | 153 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 153 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | |
| 154 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | |
| 154 | 155 | mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { |
| 155 | 156 | __identity __proj; |
| 156 | 157 | auto __res = std::__mismatch( |
| ... | ... | @@ -159,14 +160,14 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi |
| 159 | 160 | } |
| 160 | 161 | |
| 161 | 162 | template <class _InputIterator1, class _InputIterator2> |
| 162 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | |
| 163 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | |
| 163 | 164 | mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { |
| 164 | 165 | return std::mismatch(__first1, __last1, __first2, __equal_to()); |
| 165 | 166 | } |
| 166 | 167 | |
| 167 | 168 | #if _LIBCPP_STD_VER >= 14 |
| 168 | 169 | 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 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch( | |
| 170 | 171 | _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { |
| 171 | 172 | while (__first1 != __last1 && __first2 != __last2) { |
| 172 | 173 | if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) |
| ... | ... | @@ -178,14 +179,14 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter |
| 178 | 179 | } |
| 179 | 180 | |
| 180 | 181 | template <class _Tp, class _Pred, class _Proj1, class _Proj2> |
| 181 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> | |
| 182 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*> | |
| 182 | 183 | __mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { |
| 183 | 184 | auto __len = std::min(__last1 - __first1, __last2 - __first2); |
| 184 | 185 | return std::__mismatch(__first1, __first1 + __len, __first2, __pred, __proj1, __proj2); |
| 185 | 186 | } |
| 186 | 187 | |
| 187 | 188 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 188 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | |
| 189 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | |
| 189 | 190 | mismatch(_InputIterator1 __first1, |
| 190 | 191 | _InputIterator1 __last1, |
| 191 | 192 | _InputIterator2 __first2, |
| ... | ... | @@ -204,7 +205,7 @@ mismatch(_InputIterator1 __first1, |
| 204 | 205 | } |
| 205 | 206 | |
| 206 | 207 | template <class _InputIterator1, class _InputIterator2> |
| 207 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | |
| 208 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2> | |
| 208 | 209 | mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { |
| 209 | 210 | return std::mismatch(__first1, __last1, __first2, __last2, __equal_to()); |
| 210 | 211 | } |
lib/libcxx/include/__algorithm/move.h+3-1| ... | ... | @@ -14,8 +14,10 @@ |
| 14 | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | 15 | #include <__algorithm/min.h> |
| 16 | 16 | #include <__config> |
| 17 | #include <__iterator/iterator_traits.h> | |
| 17 | 18 | #include <__iterator/segmented_iterator.h> |
| 18 | 19 | #include <__type_traits/common_type.h> |
| 20 | #include <__type_traits/enable_if.h> | |
| 19 | 21 | #include <__type_traits/is_constructible.h> |
| 20 | 22 | #include <__utility/move.h> |
| 21 | 23 | #include <__utility/pair.h> |
| ... | ... | @@ -48,7 +50,7 @@ struct __move_impl { |
| 48 | 50 | |
| 49 | 51 | template <class _InIter, class _OutIter> |
| 50 | 52 | struct _MoveSegment { |
| 51 | using _Traits = __segmented_iterator_traits<_InIter>; | |
| 53 | using _Traits _LIBCPP_NODEBUG = __segmented_iterator_traits<_InIter>; | |
| 52 | 54 | |
| 53 | 55 | _OutIter& __result_; |
| 54 | 56 |
lib/libcxx/include/__algorithm/move_backward.h+2| ... | ... | @@ -13,8 +13,10 @@ |
| 13 | 13 | #include <__algorithm/iterator_operations.h> |
| 14 | 14 | #include <__algorithm/min.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | |
| 16 | 17 | #include <__iterator/segmented_iterator.h> |
| 17 | 18 | #include <__type_traits/common_type.h> |
| 19 | #include <__type_traits/enable_if.h> | |
| 18 | 20 | #include <__type_traits/is_constructible.h> |
| 19 | 21 | #include <__utility/move.h> |
| 20 | 22 | #include <__utility/pair.h> |
lib/libcxx/include/__algorithm/none_of.h+1-1| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _InputIterator, class _Predicate> |
| 22 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 22 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | |
| 23 | 23 | none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 24 | 24 | for (; __first != __last; ++__first) |
| 25 | 25 | if (__pred(*__first)) |
lib/libcxx/include/__algorithm/partial_sort_copy.h+3-3| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | #include <__algorithm/sort_heap.h> |
| 19 | 19 | #include <__config> |
| 20 | 20 | #include <__functional/identity.h> |
| 21 | #include <__functional/invoke.h> | |
| 22 | 21 | #include <__iterator/iterator_traits.h> |
| 22 | #include <__type_traits/invoke.h> | |
| 23 | 23 | #include <__type_traits/is_callable.h> |
| 24 | 24 | #include <__utility/move.h> |
| 25 | 25 | #include <__utility/pair.h> |
| ... | ... | @@ -76,8 +76,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator |
| 76 | 76 | _RandomAccessIterator __result_first, |
| 77 | 77 | _RandomAccessIterator __result_last, |
| 78 | 78 | _Compare __comp) { |
| 79 | static_assert( | |
| 80 | __is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value, "Comparator has to be callable"); | |
| 79 | static_assert(__is_callable<_Compare&, decltype(*__first), decltype(*__result_first)>::value, | |
| 80 | "The comparator has to be callable"); | |
| 81 | 81 | |
| 82 | 82 | auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>( |
| 83 | 83 | __first, |
lib/libcxx/include/__algorithm/partition.h+2-1| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | #include <__algorithm/iterator_operations.h> |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | #include <__type_traits/remove_cvref.h> | |
| 15 | 16 | #include <__utility/move.h> |
| 16 | 17 | #include <__utility/pair.h> |
| 17 | 18 | |
| ... | ... | @@ -29,7 +30,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _Forw |
| 29 | 30 | __partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag) { |
| 30 | 31 | while (true) { |
| 31 | 32 | if (__first == __last) |
| 32 | return std::make_pair(std::move(__first), std::move(__first)); | |
| 33 | return std::make_pair(__first, __first); | |
| 33 | 34 | if (!__pred(*__first)) |
| 34 | 35 | break; |
| 35 | 36 | ++__first; |
lib/libcxx/include/__algorithm/pstl.h+3-3| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | _LIBCPP_PUSH_MACROS |
| 19 | 19 | #include <__undef_macros> |
| 20 | 20 | |
| 21 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | |
| 21 | #if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17 | |
| 22 | 22 | |
| 23 | 23 | # include <__functional/operations.h> |
| 24 | 24 | # include <__iterator/cpp17_iterator_concepts.h> |
| ... | ... | @@ -352,7 +352,7 @@ template <class _ExecutionPolicy, |
| 352 | 352 | class _Predicate, |
| 353 | 353 | class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, |
| 354 | 354 | enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> |
| 355 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool | |
| 355 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool | |
| 356 | 356 | is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { |
| 357 | 357 | _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "is_partitioned requires ForwardIterators"); |
| 358 | 358 | using _Implementation = __pstl::__dispatch<__pstl::__is_partitioned, __pstl::__current_configuration, _RawPolicy>; |
| ... | ... | @@ -656,7 +656,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform( |
| 656 | 656 | |
| 657 | 657 | _LIBCPP_END_NAMESPACE_STD |
| 658 | 658 | |
| 659 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | |
| 659 | #endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17 | |
| 660 | 660 | |
| 661 | 661 | _LIBCPP_POP_MACROS |
| 662 | 662 |
lib/libcxx/include/__algorithm/radix_sort.h created+332| ... | ... | @@ -0,0 +1,332 @@ |
| 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_RADIX_SORT_H | |
| 11 | #define _LIBCPP___ALGORITHM_RADIX_SORT_H | |
| 12 | ||
| 13 | // This is an implementation of classic LSD radix sort algorithm, running in linear time and using `O(max(N, M))` | |
| 14 | // additional memory, where `N` is size of an input range, `M` - maximum value of | |
| 15 | // a radix of the sorted integer type. Type of the radix and its maximum value are determined at compile time | |
| 16 | // based on type returned by function `__radix`. The default radix is uint8. | |
| 17 | ||
| 18 | // The algorithm is equivalent to several consecutive calls of counting sort for each | |
| 19 | // radix of the sorted numbers from low to high byte. | |
| 20 | // The algorithm uses a temporary buffer of size equal to size of the input range. Each `i`-th pass | |
| 21 | // of the algorithm sorts values by `i`-th radix and moves values to the temporary buffer (for each even `i`, counted | |
| 22 | // from zero), or moves them back to the initial range (for each odd `i`). If there is only one radix in sorted integers | |
| 23 | // (e.g. int8), the sorted values are placed to the buffer, and then moved back to the initial range. | |
| 24 | ||
| 25 | // The implementation also has several optimizations: | |
| 26 | // - the counters for the counting sort are calculated in one pass for all radices; | |
| 27 | // - if all values of a radix are the same, we do not sort that radix, and just move items to the buffer; | |
| 28 | // - if two consecutive radices satisfies condition above, we do nothing for these two radices. | |
| 29 | ||
| 30 | #include <__algorithm/for_each.h> | |
| 31 | #include <__algorithm/move.h> | |
| 32 | #include <__bit/bit_log2.h> | |
| 33 | #include <__bit/countl.h> | |
| 34 | #include <__config> | |
| 35 | #include <__functional/identity.h> | |
| 36 | #include <__iterator/distance.h> | |
| 37 | #include <__iterator/iterator_traits.h> | |
| 38 | #include <__iterator/move_iterator.h> | |
| 39 | #include <__iterator/next.h> | |
| 40 | #include <__iterator/reverse_iterator.h> | |
| 41 | #include <__numeric/partial_sum.h> | |
| 42 | #include <__type_traits/decay.h> | |
| 43 | #include <__type_traits/enable_if.h> | |
| 44 | #include <__type_traits/invoke.h> | |
| 45 | #include <__type_traits/is_assignable.h> | |
| 46 | #include <__type_traits/is_integral.h> | |
| 47 | #include <__type_traits/is_unsigned.h> | |
| 48 | #include <__type_traits/make_unsigned.h> | |
| 49 | #include <__utility/forward.h> | |
| 50 | #include <__utility/integer_sequence.h> | |
| 51 | #include <__utility/move.h> | |
| 52 | #include <__utility/pair.h> | |
| 53 | #include <climits> | |
| 54 | #include <cstdint> | |
| 55 | #include <initializer_list> | |
| 56 | #include <limits> | |
| 57 | ||
| 58 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 59 | # pragma GCC system_header | |
| 60 | #endif | |
| 61 | ||
| 62 | _LIBCPP_PUSH_MACROS | |
| 63 | #include <__undef_macros> | |
| 64 | ||
| 65 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 66 | ||
| 67 | #if _LIBCPP_STD_VER >= 14 | |
| 68 | ||
| 69 | template <class _InputIterator, class _OutputIterator> | |
| 70 | _LIBCPP_HIDE_FROM_ABI pair<_OutputIterator, __iter_value_type<_InputIterator>> | |
| 71 | __partial_sum_max(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | |
| 72 | if (__first == __last) | |
| 73 | return {__result, 0}; | |
| 74 | ||
| 75 | auto __max = *__first; | |
| 76 | __iter_value_type<_InputIterator> __sum = *__first; | |
| 77 | *__result = __sum; | |
| 78 | ||
| 79 | while (++__first != __last) { | |
| 80 | if (__max < *__first) { | |
| 81 | __max = *__first; | |
| 82 | } | |
| 83 | __sum = std::move(__sum) + *__first; | |
| 84 | *++__result = __sum; | |
| 85 | } | |
| 86 | return {++__result, __max}; | |
| 87 | } | |
| 88 | ||
| 89 | template <class _Value, class _Map, class _Radix> | |
| 90 | struct __radix_sort_traits { | |
| 91 | using __image_type _LIBCPP_NODEBUG = decay_t<__invoke_result_t<_Map, _Value>>; | |
| 92 | static_assert(is_unsigned<__image_type>::value); | |
| 93 | ||
| 94 | using __radix_type _LIBCPP_NODEBUG = decay_t<__invoke_result_t<_Radix, __image_type>>; | |
| 95 | static_assert(is_integral<__radix_type>::value); | |
| 96 | ||
| 97 | static constexpr auto __radix_value_range = numeric_limits<__radix_type>::max() + 1; | |
| 98 | static constexpr auto __radix_size = std::__bit_log2<uint64_t>(__radix_value_range); | |
| 99 | static constexpr auto __radix_count = sizeof(__image_type) * CHAR_BIT / __radix_size; | |
| 100 | }; | |
| 101 | ||
| 102 | template <class _Value, class _Map> | |
| 103 | struct __counting_sort_traits { | |
| 104 | using __image_type _LIBCPP_NODEBUG = decay_t<__invoke_result_t<_Map, _Value>>; | |
| 105 | static_assert(is_unsigned<__image_type>::value); | |
| 106 | ||
| 107 | static constexpr const auto __value_range = numeric_limits<__image_type>::max() + 1; | |
| 108 | static constexpr auto __radix_size = std::__bit_log2<uint64_t>(__value_range); | |
| 109 | }; | |
| 110 | ||
| 111 | template <class _Radix, class _Integer> | |
| 112 | _LIBCPP_HIDE_FROM_ABI auto __nth_radix(size_t __radix_number, _Radix __radix, _Integer __n) { | |
| 113 | static_assert(is_unsigned<_Integer>::value); | |
| 114 | using __traits = __counting_sort_traits<_Integer, _Radix>; | |
| 115 | ||
| 116 | return __radix(static_cast<_Integer>(__n >> __traits::__radix_size * __radix_number)); | |
| 117 | } | |
| 118 | ||
| 119 | template <class _ForwardIterator, class _Map, class _RandomAccessIterator> | |
| 120 | _LIBCPP_HIDE_FROM_ABI void | |
| 121 | __collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _RandomAccessIterator __counters) { | |
| 122 | using __value_type = __iter_value_type<_ForwardIterator>; | |
| 123 | using __traits = __counting_sort_traits<__value_type, _Map>; | |
| 124 | ||
| 125 | std::for_each(__first, __last, [&__counters, &__map](const auto& __preimage) { ++__counters[__map(__preimage)]; }); | |
| 126 | ||
| 127 | const auto __counters_end = __counters + __traits::__value_range; | |
| 128 | std::partial_sum(__counters, __counters_end, __counters); | |
| 129 | } | |
| 130 | ||
| 131 | template <class _ForwardIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2> | |
| 132 | _LIBCPP_HIDE_FROM_ABI void | |
| 133 | __dispose(_ForwardIterator __first, | |
| 134 | _ForwardIterator __last, | |
| 135 | _RandomAccessIterator1 __result, | |
| 136 | _Map __map, | |
| 137 | _RandomAccessIterator2 __counters) { | |
| 138 | std::for_each(__first, __last, [&__result, &__counters, &__map](auto&& __preimage) { | |
| 139 | auto __index = __counters[__map(__preimage)]++; | |
| 140 | __result[__index] = std::move(__preimage); | |
| 141 | }); | |
| 142 | } | |
| 143 | ||
| 144 | template <class _ForwardIterator, | |
| 145 | class _Map, | |
| 146 | class _Radix, | |
| 147 | class _RandomAccessIterator1, | |
| 148 | class _RandomAccessIterator2, | |
| 149 | size_t... _Radices> | |
| 150 | _LIBCPP_HIDE_FROM_ABI bool __collect_impl( | |
| 151 | _ForwardIterator __first, | |
| 152 | _ForwardIterator __last, | |
| 153 | _Map __map, | |
| 154 | _Radix __radix, | |
| 155 | _RandomAccessIterator1 __counters, | |
| 156 | _RandomAccessIterator2 __maximums, | |
| 157 | index_sequence<_Radices...>) { | |
| 158 | using __value_type = __iter_value_type<_ForwardIterator>; | |
| 159 | constexpr auto __radix_value_range = __radix_sort_traits<__value_type, _Map, _Radix>::__radix_value_range; | |
| 160 | ||
| 161 | auto __previous = numeric_limits<__invoke_result_t<_Map, __value_type>>::min(); | |
| 162 | auto __is_sorted = true; | |
| 163 | std::for_each(__first, __last, [&__counters, &__map, &__radix, &__previous, &__is_sorted](const auto& __value) { | |
| 164 | auto __current = __map(__value); | |
| 165 | __is_sorted &= (__current >= __previous); | |
| 166 | __previous = __current; | |
| 167 | ||
| 168 | (++__counters[_Radices][std::__nth_radix(_Radices, __radix, __current)], ...); | |
| 169 | }); | |
| 170 | ||
| 171 | ((__maximums[_Radices] = | |
| 172 | std::__partial_sum_max(__counters[_Radices], __counters[_Radices] + __radix_value_range, __counters[_Radices]) | |
| 173 | .second), | |
| 174 | ...); | |
| 175 | ||
| 176 | return __is_sorted; | |
| 177 | } | |
| 178 | ||
| 179 | template <class _ForwardIterator, class _Map, class _Radix, class _RandomAccessIterator1, class _RandomAccessIterator2> | |
| 180 | _LIBCPP_HIDE_FROM_ABI bool | |
| 181 | __collect(_ForwardIterator __first, | |
| 182 | _ForwardIterator __last, | |
| 183 | _Map __map, | |
| 184 | _Radix __radix, | |
| 185 | _RandomAccessIterator1 __counters, | |
| 186 | _RandomAccessIterator2 __maximums) { | |
| 187 | using __value_type = __iter_value_type<_ForwardIterator>; | |
| 188 | constexpr auto __radix_count = __radix_sort_traits<__value_type, _Map, _Radix>::__radix_count; | |
| 189 | return std::__collect_impl( | |
| 190 | __first, __last, __map, __radix, __counters, __maximums, make_index_sequence<__radix_count>()); | |
| 191 | } | |
| 192 | ||
| 193 | template <class _BidirectionalIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2> | |
| 194 | _LIBCPP_HIDE_FROM_ABI void __dispose_backward( | |
| 195 | _BidirectionalIterator __first, | |
| 196 | _BidirectionalIterator __last, | |
| 197 | _RandomAccessIterator1 __result, | |
| 198 | _Map __map, | |
| 199 | _RandomAccessIterator2 __counters) { | |
| 200 | std::for_each(std::make_reverse_iterator(__last), | |
| 201 | std::make_reverse_iterator(__first), | |
| 202 | [&__result, &__counters, &__map](auto&& __preimage) { | |
| 203 | auto __index = --__counters[__map(__preimage)]; | |
| 204 | __result[__index] = std::move(__preimage); | |
| 205 | }); | |
| 206 | } | |
| 207 | ||
| 208 | template <class _ForwardIterator, class _RandomAccessIterator, class _Map> | |
| 209 | _LIBCPP_HIDE_FROM_ABI _RandomAccessIterator | |
| 210 | __counting_sort_impl(_ForwardIterator __first, _ForwardIterator __last, _RandomAccessIterator __result, _Map __map) { | |
| 211 | using __value_type = __iter_value_type<_ForwardIterator>; | |
| 212 | using __traits = __counting_sort_traits<__value_type, _Map>; | |
| 213 | ||
| 214 | __iter_diff_t<_RandomAccessIterator> __counters[__traits::__value_range + 1] = {0}; | |
| 215 | ||
| 216 | std::__collect(__first, __last, __map, std::next(std::begin(__counters))); | |
| 217 | std::__dispose(__first, __last, __result, __map, std::begin(__counters)); | |
| 218 | ||
| 219 | return __result + __counters[__traits::__value_range]; | |
| 220 | } | |
| 221 | ||
| 222 | template <class _RandomAccessIterator1, | |
| 223 | class _RandomAccessIterator2, | |
| 224 | class _Map, | |
| 225 | class _Radix, | |
| 226 | enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count == 1, | |
| 227 | int> = 0> | |
| 228 | _LIBCPP_HIDE_FROM_ABI void __radix_sort_impl( | |
| 229 | _RandomAccessIterator1 __first, | |
| 230 | _RandomAccessIterator1 __last, | |
| 231 | _RandomAccessIterator2 __buffer, | |
| 232 | _Map __map, | |
| 233 | _Radix __radix) { | |
| 234 | auto __buffer_end = std::__counting_sort_impl(__first, __last, __buffer, [&__map, &__radix](const auto& __value) { | |
| 235 | return __radix(__map(__value)); | |
| 236 | }); | |
| 237 | ||
| 238 | std::move(__buffer, __buffer_end, __first); | |
| 239 | } | |
| 240 | ||
| 241 | template < | |
| 242 | class _RandomAccessIterator1, | |
| 243 | class _RandomAccessIterator2, | |
| 244 | class _Map, | |
| 245 | class _Radix, | |
| 246 | enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count % 2 == 0, | |
| 247 | int> = 0 > | |
| 248 | _LIBCPP_HIDE_FROM_ABI void __radix_sort_impl( | |
| 249 | _RandomAccessIterator1 __first, | |
| 250 | _RandomAccessIterator1 __last, | |
| 251 | _RandomAccessIterator2 __buffer_begin, | |
| 252 | _Map __map, | |
| 253 | _Radix __radix) { | |
| 254 | using __value_type = __iter_value_type<_RandomAccessIterator1>; | |
| 255 | using __traits = __radix_sort_traits<__value_type, _Map, _Radix>; | |
| 256 | ||
| 257 | __iter_diff_t<_RandomAccessIterator1> __counters[__traits::__radix_count][__traits::__radix_value_range] = {{0}}; | |
| 258 | __iter_diff_t<_RandomAccessIterator1> __maximums[__traits::__radix_count] = {0}; | |
| 259 | const auto __is_sorted = std::__collect(__first, __last, __map, __radix, __counters, __maximums); | |
| 260 | if (!__is_sorted) { | |
| 261 | const auto __range_size = std::distance(__first, __last); | |
| 262 | auto __buffer_end = __buffer_begin + __range_size; | |
| 263 | for (size_t __radix_number = 0; __radix_number < __traits::__radix_count; __radix_number += 2) { | |
| 264 | const auto __n0th_is_single = __maximums[__radix_number] == __range_size; | |
| 265 | const auto __n1th_is_single = __maximums[__radix_number + 1] == __range_size; | |
| 266 | ||
| 267 | if (__n0th_is_single && __n1th_is_single) { | |
| 268 | continue; | |
| 269 | } | |
| 270 | ||
| 271 | if (__n0th_is_single) { | |
| 272 | std::move(__first, __last, __buffer_begin); | |
| 273 | } else { | |
| 274 | auto __n0th = [__radix_number, &__map, &__radix](const auto& __v) { | |
| 275 | return std::__nth_radix(__radix_number, __radix, __map(__v)); | |
| 276 | }; | |
| 277 | std::__dispose_backward(__first, __last, __buffer_begin, __n0th, __counters[__radix_number]); | |
| 278 | } | |
| 279 | ||
| 280 | if (__n1th_is_single) { | |
| 281 | std::move(__buffer_begin, __buffer_end, __first); | |
| 282 | } else { | |
| 283 | auto __n1th = [__radix_number, &__map, &__radix](const auto& __v) { | |
| 284 | return std::__nth_radix(__radix_number + 1, __radix, __map(__v)); | |
| 285 | }; | |
| 286 | std::__dispose_backward(__buffer_begin, __buffer_end, __first, __n1th, __counters[__radix_number + 1]); | |
| 287 | } | |
| 288 | } | |
| 289 | } | |
| 290 | } | |
| 291 | ||
| 292 | _LIBCPP_HIDE_FROM_ABI constexpr auto __shift_to_unsigned(bool __b) { return __b; } | |
| 293 | ||
| 294 | template <class _Ip> | |
| 295 | _LIBCPP_HIDE_FROM_ABI constexpr auto __shift_to_unsigned(_Ip __n) { | |
| 296 | constexpr const auto __min_value = numeric_limits<_Ip>::min(); | |
| 297 | return static_cast<make_unsigned_t<_Ip> >(__n ^ __min_value); | |
| 298 | } | |
| 299 | ||
| 300 | struct __low_byte_fn { | |
| 301 | template <class _Ip> | |
| 302 | _LIBCPP_HIDE_FROM_ABI constexpr uint8_t operator()(_Ip __integer) const { | |
| 303 | static_assert(is_unsigned<_Ip>::value); | |
| 304 | ||
| 305 | return static_cast<uint8_t>(__integer & 0xff); | |
| 306 | } | |
| 307 | }; | |
| 308 | ||
| 309 | template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _Map, class _Radix> | |
| 310 | _LIBCPP_HIDE_FROM_ABI void | |
| 311 | __radix_sort(_RandomAccessIterator1 __first, | |
| 312 | _RandomAccessIterator1 __last, | |
| 313 | _RandomAccessIterator2 __buffer, | |
| 314 | _Map __map, | |
| 315 | _Radix __radix) { | |
| 316 | auto __map_to_unsigned = [__map = std::move(__map)](const auto& __x) { return std::__shift_to_unsigned(__map(__x)); }; | |
| 317 | std::__radix_sort_impl(__first, __last, __buffer, __map_to_unsigned, __radix); | |
| 318 | } | |
| 319 | ||
| 320 | template <class _RandomAccessIterator1, class _RandomAccessIterator2> | |
| 321 | _LIBCPP_HIDE_FROM_ABI void | |
| 322 | __radix_sort(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _RandomAccessIterator2 __buffer) { | |
| 323 | std::__radix_sort(__first, __last, __buffer, __identity{}, __low_byte_fn{}); | |
| 324 | } | |
| 325 | ||
| 326 | #endif // _LIBCPP_STD_VER >= 14 | |
| 327 | ||
| 328 | _LIBCPP_END_NAMESPACE_STD | |
| 329 | ||
| 330 | _LIBCPP_POP_MACROS | |
| 331 | ||
| 332 | #endif // _LIBCPP___ALGORITHM_RADIX_SORT_H |
lib/libcxx/include/__algorithm/ranges_adjacent_find.h+5-22| ... | ... | @@ -9,9 +9,9 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H |
| 11 | 11 | |
| 12 | #include <__algorithm/adjacent_find.h> | |
| 12 | 13 | #include <__config> |
| 13 | 14 | #include <__functional/identity.h> |
| 14 | #include <__functional/invoke.h> | |
| 15 | 15 | #include <__functional/ranges_operations.h> |
| 16 | 16 | #include <__iterator/concepts.h> |
| 17 | 17 | #include <__iterator/projected.h> |
| ... | ... | @@ -32,30 +32,14 @@ _LIBCPP_PUSH_MACROS |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | 34 | namespace ranges { |
| 35 | namespace __adjacent_find { | |
| 36 | struct __fn { | |
| 37 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter | |
| 39 | __adjacent_find_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 40 | if (__first == __last) | |
| 41 | return __first; | |
| 42 | ||
| 43 | auto __i = __first; | |
| 44 | while (++__i != __last) { | |
| 45 | if (std::invoke(__pred, std::invoke(__proj, *__first), std::invoke(__proj, *__i))) | |
| 46 | return __first; | |
| 47 | __first = __i; | |
| 48 | } | |
| 49 | return __i; | |
| 50 | } | |
| 51 | ||
| 35 | struct __adjacent_find { | |
| 52 | 36 | template <forward_iterator _Iter, |
| 53 | 37 | sentinel_for<_Iter> _Sent, |
| 54 | 38 | class _Proj = identity, |
| 55 | 39 | indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to> |
| 56 | 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter |
| 57 | 41 | operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { |
| 58 | return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 42 | return std::__adjacent_find(std::move(__first), std::move(__last), __pred, __proj); | |
| 59 | 43 | } |
| 60 | 44 | |
| 61 | 45 | template <forward_range _Range, |
| ... | ... | @@ -64,13 +48,12 @@ struct __fn { |
| 64 | 48 | _Pred = ranges::equal_to> |
| 65 | 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> |
| 66 | 50 | operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const { |
| 67 | return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 51 | return std::__adjacent_find(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 68 | 52 | } |
| 69 | 53 | }; |
| 70 | } // namespace __adjacent_find | |
| 71 | 54 | |
| 72 | 55 | inline namespace __cpo { |
| 73 | inline constexpr auto adjacent_find = __adjacent_find::__fn{}; | |
| 56 | inline constexpr auto adjacent_find = __adjacent_find{}; | |
| 74 | 57 | } // namespace __cpo |
| 75 | 58 | } // namespace ranges |
| 76 | 59 |
lib/libcxx/include/__algorithm/ranges_all_of.h+5-15| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_ALL_OF_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_ALL_OF_H |
| 11 | 11 | |
| 12 | #include <__algorithm/all_of.h> | |
| 12 | 13 | #include <__config> |
| 13 | 14 | #include <__functional/identity.h> |
| 14 | 15 | #include <__functional/invoke.h> |
| ... | ... | @@ -30,24 +31,14 @@ _LIBCPP_PUSH_MACROS |
| 30 | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 32 | |
| 32 | 33 | namespace ranges { |
| 33 | namespace __all_of { | |
| 34 | struct __fn { | |
| 35 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr static bool __all_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 37 | for (; __first != __last; ++__first) { | |
| 38 | if (!std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 39 | return false; | |
| 40 | } | |
| 41 | return true; | |
| 42 | } | |
| 43 | ||
| 34 | struct __all_of { | |
| 44 | 35 | template <input_iterator _Iter, |
| 45 | 36 | sentinel_for<_Iter> _Sent, |
| 46 | 37 | class _Proj = identity, |
| 47 | 38 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> |
| 48 | 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 49 | 40 | operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { |
| 50 | return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 41 | return std::__all_of(std::move(__first), std::move(__last), __pred, __proj); | |
| 51 | 42 | } |
| 52 | 43 | |
| 53 | 44 | template <input_range _Range, |
| ... | ... | @@ -55,13 +46,12 @@ struct __fn { |
| 55 | 46 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> |
| 56 | 47 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 57 | 48 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { |
| 58 | return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 49 | return std::__all_of(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 59 | 50 | } |
| 60 | 51 | }; |
| 61 | } // namespace __all_of | |
| 62 | 52 | |
| 63 | 53 | inline namespace __cpo { |
| 64 | inline constexpr auto all_of = __all_of::__fn{}; | |
| 54 | inline constexpr auto all_of = __all_of{}; | |
| 65 | 55 | } // namespace __cpo |
| 66 | 56 | } // namespace ranges |
| 67 | 57 |
lib/libcxx/include/__algorithm/ranges_any_of.h+5-16| ... | ... | @@ -9,9 +9,9 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_ANY_OF_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_ANY_OF_H |
| 11 | 11 | |
| 12 | #include <__algorithm/any_of.h> | |
| 12 | 13 | #include <__config> |
| 13 | 14 | #include <__functional/identity.h> |
| 14 | #include <__functional/invoke.h> | |
| 15 | 15 | #include <__iterator/concepts.h> |
| 16 | 16 | #include <__iterator/projected.h> |
| 17 | 17 | #include <__ranges/access.h> |
| ... | ... | @@ -30,24 +30,14 @@ _LIBCPP_PUSH_MACROS |
| 30 | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 31 | |
| 32 | 32 | namespace ranges { |
| 33 | namespace __any_of { | |
| 34 | struct __fn { | |
| 35 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr static bool __any_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 37 | for (; __first != __last; ++__first) { | |
| 38 | if (std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 39 | return true; | |
| 40 | } | |
| 41 | return false; | |
| 42 | } | |
| 43 | ||
| 33 | struct __any_of { | |
| 44 | 34 | template <input_iterator _Iter, |
| 45 | 35 | sentinel_for<_Iter> _Sent, |
| 46 | 36 | class _Proj = identity, |
| 47 | 37 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> |
| 48 | 38 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 49 | 39 | operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { |
| 50 | return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 40 | return std::__any_of(std::move(__first), std::move(__last), __pred, __proj); | |
| 51 | 41 | } |
| 52 | 42 | |
| 53 | 43 | template <input_range _Range, |
| ... | ... | @@ -55,13 +45,12 @@ struct __fn { |
| 55 | 45 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> |
| 56 | 46 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool |
| 57 | 47 | operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { |
| 58 | return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 48 | return std::__any_of(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 59 | 49 | } |
| 60 | 50 | }; |
| 61 | } // namespace __any_of | |
| 62 | 51 | |
| 63 | 52 | inline namespace __cpo { |
| 64 | inline constexpr auto any_of = __any_of::__fn{}; | |
| 53 | inline constexpr auto any_of = __any_of{}; | |
| 65 | 54 | } // namespace __cpo |
| 66 | 55 | } // namespace ranges |
| 67 | 56 |
lib/libcxx/include/__algorithm/ranges_binary_search.h+2-4| ... | ... | @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | 34 | namespace ranges { |
| 35 | namespace __binary_search { | |
| 36 | struct __fn { | |
| 35 | struct __binary_search { | |
| 37 | 36 | template <forward_iterator _Iter, |
| 38 | 37 | sentinel_for<_Iter> _Sent, |
| 39 | 38 | class _Type, |
| ... | ... | @@ -57,10 +56,9 @@ struct __fn { |
| 57 | 56 | return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__ret)); |
| 58 | 57 | } |
| 59 | 58 | }; |
| 60 | } // namespace __binary_search | |
| 61 | 59 | |
| 62 | 60 | inline namespace __cpo { |
| 63 | inline constexpr auto binary_search = __binary_search::__fn{}; | |
| 61 | inline constexpr auto binary_search = __binary_search{}; | |
| 64 | 62 | } // namespace __cpo |
| 65 | 63 | } // namespace ranges |
| 66 | 64 |
lib/libcxx/include/__algorithm/ranges_clamp.h+2-4| ... | ... | @@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS |
| 30 | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 31 | |
| 32 | 32 | namespace ranges { |
| 33 | namespace __clamp { | |
| 34 | struct __fn { | |
| 33 | struct __clamp { | |
| 35 | 34 | template <class _Type, |
| 36 | 35 | class _Proj = identity, |
| 37 | 36 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> |
| ... | ... | @@ -50,10 +49,9 @@ struct __fn { |
| 50 | 49 | return __value; |
| 51 | 50 | } |
| 52 | 51 | }; |
| 53 | } // namespace __clamp | |
| 54 | 52 | |
| 55 | 53 | inline namespace __cpo { |
| 56 | inline constexpr auto clamp = __clamp::__fn{}; | |
| 54 | inline constexpr auto clamp = __clamp{}; | |
| 57 | 55 | } // namespace __cpo |
| 58 | 56 | } // namespace ranges |
| 59 | 57 |
lib/libcxx/include/__algorithm/ranges_contains.h+2-4| ... | ... | @@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS |
| 33 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | |
| 35 | 35 | namespace ranges { |
| 36 | namespace __contains { | |
| 37 | struct __fn { | |
| 36 | struct __contains { | |
| 38 | 37 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> |
| 39 | 38 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> |
| 40 | 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static |
| ... | ... | @@ -50,10 +49,9 @@ struct __fn { |
| 50 | 49 | ranges::end(__range); |
| 51 | 50 | } |
| 52 | 51 | }; |
| 53 | } // namespace __contains | |
| 54 | 52 | |
| 55 | 53 | inline namespace __cpo { |
| 56 | inline constexpr auto contains = __contains::__fn{}; | |
| 54 | inline constexpr auto contains = __contains{}; | |
| 57 | 55 | } // namespace __cpo |
| 58 | 56 | } // namespace ranges |
| 59 | 57 |
lib/libcxx/include/__algorithm/ranges_contains_subrange.h+2-4| ... | ... | @@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS |
| 35 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 36 | |
| 37 | 37 | namespace ranges { |
| 38 | namespace __contains_subrange { | |
| 39 | struct __fn { | |
| 38 | struct __contains_subrange { | |
| 40 | 39 | template <forward_iterator _Iter1, |
| 41 | 40 | sentinel_for<_Iter1> _Sent1, |
| 42 | 41 | forward_iterator _Iter2, |
| ... | ... | @@ -81,10 +80,9 @@ struct __fn { |
| 81 | 80 | return __ret.empty() == false; |
| 82 | 81 | } |
| 83 | 82 | }; |
| 84 | } // namespace __contains_subrange | |
| 85 | 83 | |
| 86 | 84 | inline namespace __cpo { |
| 87 | inline constexpr auto contains_subrange = __contains_subrange::__fn{}; | |
| 85 | inline constexpr auto contains_subrange = __contains_subrange{}; | |
| 88 | 86 | } // namespace __cpo |
| 89 | 87 | } // namespace ranges |
| 90 | 88 |
lib/libcxx/include/__algorithm/ranges_copy.h+4-7| ... | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/copy.h> |
| 13 | 13 | #include <__algorithm/in_out_result.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 15 | 14 | #include <__config> |
| 16 | 15 | #include <__functional/identity.h> |
| 17 | 16 | #include <__iterator/concepts.h> |
| ... | ... | @@ -37,13 +36,12 @@ namespace ranges { |
| 37 | 36 | template <class _InIter, class _OutIter> |
| 38 | 37 | using copy_result = in_out_result<_InIter, _OutIter>; |
| 39 | 38 | |
| 40 | namespace __copy { | |
| 41 | struct __fn { | |
| 39 | struct __copy { | |
| 42 | 40 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> |
| 43 | 41 | requires indirectly_copyable<_InIter, _OutIter> |
| 44 | 42 | _LIBCPP_HIDE_FROM_ABI constexpr copy_result<_InIter, _OutIter> |
| 45 | 43 | operator()(_InIter __first, _Sent __last, _OutIter __result) const { |
| 46 | auto __ret = std::__copy<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)); | |
| 44 | auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result)); | |
| 47 | 45 | return {std::move(__ret.first), std::move(__ret.second)}; |
| 48 | 46 | } |
| 49 | 47 | |
| ... | ... | @@ -51,14 +49,13 @@ struct __fn { |
| 51 | 49 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> |
| 52 | 50 | _LIBCPP_HIDE_FROM_ABI constexpr copy_result<borrowed_iterator_t<_Range>, _OutIter> |
| 53 | 51 | operator()(_Range&& __r, _OutIter __result) const { |
| 54 | auto __ret = std::__copy<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result)); | |
| 52 | auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result)); | |
| 55 | 53 | return {std::move(__ret.first), std::move(__ret.second)}; |
| 56 | 54 | } |
| 57 | 55 | }; |
| 58 | } // namespace __copy | |
| 59 | 56 | |
| 60 | 57 | inline namespace __cpo { |
| 61 | inline constexpr auto copy = __copy::__fn{}; | |
| 58 | inline constexpr auto copy = __copy{}; | |
| 62 | 59 | } // namespace __cpo |
| 63 | 60 | } // namespace ranges |
| 64 | 61 |
lib/libcxx/include/__algorithm/ranges_copy_backward.h+2-4| ... | ... | @@ -35,8 +35,7 @@ namespace ranges { |
| 35 | 35 | template <class _Ip, class _Op> |
| 36 | 36 | using copy_backward_result = in_out_result<_Ip, _Op>; |
| 37 | 37 | |
| 38 | namespace __copy_backward { | |
| 39 | struct __fn { | |
| 38 | struct __copy_backward { | |
| 40 | 39 | template <bidirectional_iterator _InIter1, sentinel_for<_InIter1> _Sent1, bidirectional_iterator _InIter2> |
| 41 | 40 | requires indirectly_copyable<_InIter1, _InIter2> |
| 42 | 41 | _LIBCPP_HIDE_FROM_ABI constexpr copy_backward_result<_InIter1, _InIter2> |
| ... | ... | @@ -53,10 +52,9 @@ struct __fn { |
| 53 | 52 | return {std::move(__ret.first), std::move(__ret.second)}; |
| 54 | 53 | } |
| 55 | 54 | }; |
| 56 | } // namespace __copy_backward | |
| 57 | 55 | |
| 58 | 56 | inline namespace __cpo { |
| 59 | inline constexpr auto copy_backward = __copy_backward::__fn{}; | |
| 57 | inline constexpr auto copy_backward = __copy_backward{}; | |
| 60 | 58 | } // namespace __cpo |
| 61 | 59 | } // namespace ranges |
| 62 | 60 |
lib/libcxx/include/__algorithm/ranges_copy_if.h+7-18| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_COPY_IF_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_COPY_IF_H |
| 11 | 11 | |
| 12 | #include <__algorithm/copy_if.h> | |
| 12 | 13 | #include <__algorithm/in_out_result.h> |
| 13 | 14 | #include <__config> |
| 14 | 15 | #include <__functional/identity.h> |
| ... | ... | @@ -36,20 +37,7 @@ namespace ranges { |
| 36 | 37 | template <class _Ip, class _Op> |
| 37 | 38 | using copy_if_result = in_out_result<_Ip, _Op>; |
| 38 | 39 | |
| 39 | namespace __copy_if { | |
| 40 | struct __fn { | |
| 41 | template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred> | |
| 42 | _LIBCPP_HIDE_FROM_ABI static constexpr copy_if_result<_InIter, _OutIter> | |
| 43 | __copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) { | |
| 44 | for (; __first != __last; ++__first) { | |
| 45 | if (std::invoke(__pred, std::invoke(__proj, *__first))) { | |
| 46 | *__result = *__first; | |
| 47 | ++__result; | |
| 48 | } | |
| 49 | } | |
| 50 | return {std::move(__first), std::move(__result)}; | |
| 51 | } | |
| 52 | ||
| 40 | struct __copy_if { | |
| 53 | 41 | template <input_iterator _Iter, |
| 54 | 42 | sentinel_for<_Iter> _Sent, |
| 55 | 43 | weakly_incrementable _OutIter, |
| ... | ... | @@ -58,7 +46,8 @@ struct __fn { |
| 58 | 46 | requires indirectly_copyable<_Iter, _OutIter> |
| 59 | 47 | _LIBCPP_HIDE_FROM_ABI constexpr copy_if_result<_Iter, _OutIter> |
| 60 | 48 | operator()(_Iter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { |
| 61 | return __copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj); | |
| 49 | auto __res = std::__copy_if(std::move(__first), std::move(__last), std::move(__result), __pred, __proj); | |
| 50 | return {std::move(__res.first), std::move(__res.second)}; | |
| 62 | 51 | } |
| 63 | 52 | |
| 64 | 53 | template <input_range _Range, |
| ... | ... | @@ -68,13 +57,13 @@ struct __fn { |
| 68 | 57 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> |
| 69 | 58 | _LIBCPP_HIDE_FROM_ABI constexpr copy_if_result<borrowed_iterator_t<_Range>, _OutIter> |
| 70 | 59 | operator()(_Range&& __r, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { |
| 71 | return __copy_if_impl(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj); | |
| 60 | auto __res = std::__copy_if(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj); | |
| 61 | return {std::move(__res.first), std::move(__res.second)}; | |
| 72 | 62 | } |
| 73 | 63 | }; |
| 74 | } // namespace __copy_if | |
| 75 | 64 | |
| 76 | 65 | inline namespace __cpo { |
| 77 | inline constexpr auto copy_if = __copy_if::__fn{}; | |
| 66 | inline constexpr auto copy_if = __copy_if{}; | |
| 78 | 67 | } // namespace __cpo |
| 79 | 68 | } // namespace ranges |
| 80 | 69 |
lib/libcxx/include/__algorithm/ranges_copy_n.h+4-5| ... | ... | @@ -37,8 +37,8 @@ namespace ranges { |
| 37 | 37 | template <class _Ip, class _Op> |
| 38 | 38 | using copy_n_result = in_out_result<_Ip, _Op>; |
| 39 | 39 | |
| 40 | namespace __copy_n { | |
| 41 | struct __fn { | |
| 40 | // TODO: Merge this with copy_n | |
| 41 | struct __copy_n { | |
| 42 | 42 | template <class _InIter, class _DiffType, class _OutIter> |
| 43 | 43 | _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter> |
| 44 | 44 | __go(_InIter __first, _DiffType __n, _OutIter __result) { |
| ... | ... | @@ -54,7 +54,7 @@ struct __fn { |
| 54 | 54 | template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter> |
| 55 | 55 | _LIBCPP_HIDE_FROM_ABI constexpr static copy_n_result<_InIter, _OutIter> |
| 56 | 56 | __go(_InIter __first, _DiffType __n, _OutIter __result) { |
| 57 | auto __ret = std::__copy<_RangeAlgPolicy>(__first, __first + __n, __result); | |
| 57 | auto __ret = std::__copy(__first, __first + __n, __result); | |
| 58 | 58 | return {__ret.first, __ret.second}; |
| 59 | 59 | } |
| 60 | 60 | |
| ... | ... | @@ -65,10 +65,9 @@ struct __fn { |
| 65 | 65 | return __go(std::move(__first), __n, std::move(__result)); |
| 66 | 66 | } |
| 67 | 67 | }; |
| 68 | } // namespace __copy_n | |
| 69 | 68 | |
| 70 | 69 | inline namespace __cpo { |
| 71 | inline constexpr auto copy_n = __copy_n::__fn{}; | |
| 70 | inline constexpr auto copy_n = __copy_n{}; | |
| 72 | 71 | } // namespace __cpo |
| 73 | 72 | } // namespace ranges |
| 74 | 73 |
lib/libcxx/include/__algorithm/ranges_count.h+2-4| ... | ... | @@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS |
| 34 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 35 | |
| 36 | 36 | namespace ranges { |
| 37 | namespace __count { | |
| 38 | struct __fn { | |
| 37 | struct __count { | |
| 39 | 38 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> |
| 40 | 39 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> |
| 41 | 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> |
| ... | ... | @@ -50,10 +49,9 @@ struct __fn { |
| 50 | 49 | return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj); |
| 51 | 50 | } |
| 52 | 51 | }; |
| 53 | } // namespace __count | |
| 54 | 52 | |
| 55 | 53 | inline namespace __cpo { |
| 56 | inline constexpr auto count = __count::__fn{}; | |
| 54 | inline constexpr auto count = __count{}; | |
| 57 | 55 | } // namespace __cpo |
| 58 | 56 | } // namespace ranges |
| 59 | 57 |
lib/libcxx/include/__algorithm/ranges_count_if.h+6-18| ... | ... | @@ -9,9 +9,10 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H |
| 11 | 11 | |
| 12 | #include <__algorithm/count_if.h> | |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 12 | 14 | #include <__config> |
| 13 | 15 | #include <__functional/identity.h> |
| 14 | #include <__functional/invoke.h> | |
| 15 | 16 | #include <__functional/ranges_operations.h> |
| 16 | 17 | #include <__iterator/concepts.h> |
| 17 | 18 | #include <__iterator/incrementable_traits.h> |
| ... | ... | @@ -33,26 +34,14 @@ _LIBCPP_PUSH_MACROS |
| 33 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 35 | |
| 35 | 36 | namespace ranges { |
| 36 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> | |
| 38 | __count_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 39 | iter_difference_t<_Iter> __counter(0); | |
| 40 | for (; __first != __last; ++__first) { | |
| 41 | if (std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 42 | ++__counter; | |
| 43 | } | |
| 44 | return __counter; | |
| 45 | } | |
| 46 | ||
| 47 | namespace __count_if { | |
| 48 | struct __fn { | |
| 37 | struct __count_if { | |
| 49 | 38 | template <input_iterator _Iter, |
| 50 | 39 | sentinel_for<_Iter> _Sent, |
| 51 | 40 | class _Proj = identity, |
| 52 | 41 | indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate> |
| 53 | 42 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> |
| 54 | 43 | operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const { |
| 55 | return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 44 | return std::__count_if<_RangeAlgPolicy>(std::move(__first), std::move(__last), __pred, __proj); | |
| 56 | 45 | } |
| 57 | 46 | |
| 58 | 47 | template <input_range _Range, |
| ... | ... | @@ -60,13 +49,12 @@ struct __fn { |
| 60 | 49 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate> |
| 61 | 50 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range> |
| 62 | 51 | operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const { |
| 63 | return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); | |
| 52 | return std::__count_if<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __pred, __proj); | |
| 64 | 53 | } |
| 65 | 54 | }; |
| 66 | } // namespace __count_if | |
| 67 | 55 | |
| 68 | 56 | inline namespace __cpo { |
| 69 | inline constexpr auto count_if = __count_if::__fn{}; | |
| 57 | inline constexpr auto count_if = __count_if{}; | |
| 70 | 58 | } // namespace __cpo |
| 71 | 59 | } // namespace ranges |
| 72 | 60 |
lib/libcxx/include/__algorithm/ranges_ends_with.h+3-4| ... | ... | @@ -22,6 +22,7 @@ |
| 22 | 22 | #include <__iterator/reverse_iterator.h> |
| 23 | 23 | #include <__ranges/access.h> |
| 24 | 24 | #include <__ranges/concepts.h> |
| 25 | #include <__ranges/size.h> | |
| 25 | 26 | #include <__utility/move.h> |
| 26 | 27 | |
| 27 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -36,8 +37,7 @@ _LIBCPP_PUSH_MACROS |
| 36 | 37 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 37 | 38 | |
| 38 | 39 | namespace ranges { |
| 39 | namespace __ends_with { | |
| 40 | struct __fn { | |
| 40 | struct __ends_with { | |
| 41 | 41 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> |
| 42 | 42 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl_bidirectional( |
| 43 | 43 | _Iter1 __first1, |
| ... | ... | @@ -185,10 +185,9 @@ struct __fn { |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | }; |
| 188 | } // namespace __ends_with | |
| 189 | 188 | |
| 190 | 189 | inline namespace __cpo { |
| 191 | inline constexpr auto ends_with = __ends_with::__fn{}; | |
| 190 | inline constexpr auto ends_with = __ends_with{}; | |
| 192 | 191 | } // namespace __cpo |
| 193 | 192 | } // namespace ranges |
| 194 | 193 |
lib/libcxx/include/__algorithm/ranges_equal.h+2-4| ... | ... | @@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS |
| 34 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 35 | |
| 36 | 36 | namespace ranges { |
| 37 | namespace __equal { | |
| 38 | struct __fn { | |
| 37 | struct __equal { | |
| 39 | 38 | template <input_iterator _Iter1, |
| 40 | 39 | sentinel_for<_Iter1> _Sent1, |
| 41 | 40 | input_iterator _Iter2, |
| ... | ... | @@ -93,10 +92,9 @@ struct __fn { |
| 93 | 92 | return false; |
| 94 | 93 | } |
| 95 | 94 | }; |
| 96 | } // namespace __equal | |
| 97 | 95 | |
| 98 | 96 | inline namespace __cpo { |
| 99 | inline constexpr auto equal = __equal::__fn{}; | |
| 97 | inline constexpr auto equal = __equal{}; | |
| 100 | 98 | } // namespace __cpo |
| 101 | 99 | } // namespace ranges |
| 102 | 100 |
lib/libcxx/include/__algorithm/ranges_equal_range.h+2-6| ... | ... | @@ -38,9 +38,7 @@ _LIBCPP_PUSH_MACROS |
| 38 | 38 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 39 | 39 | |
| 40 | 40 | namespace ranges { |
| 41 | namespace __equal_range { | |
| 42 | ||
| 43 | struct __fn { | |
| 41 | struct __equal_range { | |
| 44 | 42 | template <forward_iterator _Iter, |
| 45 | 43 | sentinel_for<_Iter> _Sent, |
| 46 | 44 | class _Tp, |
| ... | ... | @@ -64,10 +62,8 @@ struct __fn { |
| 64 | 62 | } |
| 65 | 63 | }; |
| 66 | 64 | |
| 67 | } // namespace __equal_range | |
| 68 | ||
| 69 | 65 | inline namespace __cpo { |
| 70 | inline constexpr auto equal_range = __equal_range::__fn{}; | |
| 66 | inline constexpr auto equal_range = __equal_range{}; | |
| 71 | 67 | } // namespace __cpo |
| 72 | 68 | } // namespace ranges |
| 73 | 69 |
lib/libcxx/include/__algorithm/ranges_fill.h+2-4| ... | ... | @@ -28,8 +28,7 @@ _LIBCPP_PUSH_MACROS |
| 28 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | |
| 30 | 30 | namespace ranges { |
| 31 | namespace __fill { | |
| 32 | struct __fn { | |
| 31 | struct __fill { | |
| 33 | 32 | template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent> |
| 34 | 33 | _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const { |
| 35 | 34 | if constexpr (random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) { |
| ... | ... | @@ -46,10 +45,9 @@ struct __fn { |
| 46 | 45 | return (*this)(ranges::begin(__range), ranges::end(__range), __value); |
| 47 | 46 | } |
| 48 | 47 | }; |
| 49 | } // namespace __fill | |
| 50 | 48 | |
| 51 | 49 | inline namespace __cpo { |
| 52 | inline constexpr auto fill = __fill::__fn{}; | |
| 50 | inline constexpr auto fill = __fill{}; | |
| 53 | 51 | } // namespace __cpo |
| 54 | 52 | } // namespace ranges |
| 55 | 53 |
lib/libcxx/include/__algorithm/ranges_fill_n.h+5-9| ... | ... | @@ -9,9 +9,11 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FILL_N_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_FILL_N_H |
| 11 | 11 | |
| 12 | #include <__algorithm/fill_n.h> | |
| 12 | 13 | #include <__config> |
| 13 | 14 | #include <__iterator/concepts.h> |
| 14 | 15 | #include <__iterator/incrementable_traits.h> |
| 16 | #include <__utility/move.h> | |
| 15 | 17 | |
| 16 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 19 | # pragma GCC system_header |
| ... | ... | @@ -25,22 +27,16 @@ _LIBCPP_PUSH_MACROS |
| 25 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 28 | |
| 27 | 29 | namespace ranges { |
| 28 | namespace __fill_n { | |
| 29 | struct __fn { | |
| 30 | struct __fill_n { | |
| 30 | 31 | template <class _Type, output_iterator<const _Type&> _Iter> |
| 31 | 32 | _LIBCPP_HIDE_FROM_ABI constexpr _Iter |
| 32 | 33 | operator()(_Iter __first, iter_difference_t<_Iter> __n, const _Type& __value) const { |
| 33 | for (; __n != 0; --__n) { | |
| 34 | *__first = __value; | |
| 35 | ++__first; | |
| 36 | } | |
| 37 | return __first; | |
| 34 | return std::__fill_n(std::move(__first), __n, __value); | |
| 38 | 35 | } |
| 39 | 36 | }; |
| 40 | } // namespace __fill_n | |
| 41 | 37 | |
| 42 | 38 | inline namespace __cpo { |
| 43 | inline constexpr auto fill_n = __fill_n::__fn{}; | |
| 39 | inline constexpr auto fill_n = __fill_n{}; | |
| 44 | 40 | } // namespace __cpo |
| 45 | 41 | } // namespace ranges |
| 46 | 42 |
lib/libcxx/include/__algorithm/ranges_find.h+2-4| ... | ... | @@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS |
| 36 | 36 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 37 | 37 | |
| 38 | 38 | namespace ranges { |
| 39 | namespace __find { | |
| 40 | struct __fn { | |
| 39 | struct __find { | |
| 41 | 40 | template <class _Iter, class _Sent, class _Tp, class _Proj> |
| 42 | 41 | _LIBCPP_HIDE_FROM_ABI static constexpr _Iter |
| 43 | 42 | __find_unwrap(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { |
| ... | ... | @@ -64,10 +63,9 @@ struct __fn { |
| 64 | 63 | return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj); |
| 65 | 64 | } |
| 66 | 65 | }; |
| 67 | } // namespace __find | |
| 68 | 66 | |
| 69 | 67 | inline namespace __cpo { |
| 70 | inline constexpr auto find = __find::__fn{}; | |
| 68 | inline constexpr auto find = __find{}; | |
| 71 | 69 | } // namespace __cpo |
| 72 | 70 | } // namespace ranges |
| 73 | 71 |
lib/libcxx/include/__algorithm/ranges_find_end.h+2-4| ... | ... | @@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS |
| 35 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 36 | |
| 37 | 37 | namespace ranges { |
| 38 | namespace __find_end { | |
| 39 | struct __fn { | |
| 38 | struct __find_end { | |
| 40 | 39 | template <forward_iterator _Iter1, |
| 41 | 40 | sentinel_for<_Iter1> _Sent1, |
| 42 | 41 | forward_iterator _Iter2, |
| ... | ... | @@ -87,10 +86,9 @@ struct __fn { |
| 87 | 86 | return {__ret.first, __ret.second}; |
| 88 | 87 | } |
| 89 | 88 | }; |
| 90 | } // namespace __find_end | |
| 91 | 89 | |
| 92 | 90 | inline namespace __cpo { |
| 93 | inline constexpr auto find_end = __find_end::__fn{}; | |
| 91 | inline constexpr auto find_end = __find_end{}; | |
| 94 | 92 | } // namespace __cpo |
| 95 | 93 | } // namespace ranges |
| 96 | 94 |
lib/libcxx/include/__algorithm/ranges_find_first_of.h+2-4| ... | ... | @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | 34 | namespace ranges { |
| 35 | namespace __find_first_of { | |
| 36 | struct __fn { | |
| 35 | struct __find_first_of { | |
| 37 | 36 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> |
| 38 | 37 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter1 __find_first_of_impl( |
| 39 | 38 | _Iter1 __first1, |
| ... | ... | @@ -90,10 +89,9 @@ struct __fn { |
| 90 | 89 | __proj2); |
| 91 | 90 | } |
| 92 | 91 | }; |
| 93 | } // namespace __find_first_of | |
| 94 | 92 | |
| 95 | 93 | inline namespace __cpo { |
| 96 | inline constexpr auto find_first_of = __find_first_of::__fn{}; | |
| 94 | inline constexpr auto find_first_of = __find_first_of{}; | |
| 97 | 95 | } // namespace __cpo |
| 98 | 96 | } // namespace ranges |
| 99 | 97 |
lib/libcxx/include/__algorithm/ranges_find_if.h+2-4| ... | ... | @@ -42,8 +42,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ip __find_if_impl(_Ip __first, _Sp __last, _Pre |
| 42 | 42 | return __first; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | namespace __find_if { | |
| 46 | struct __fn { | |
| 45 | struct __find_if { | |
| 47 | 46 | template <input_iterator _Ip, |
| 48 | 47 | sentinel_for<_Ip> _Sp, |
| 49 | 48 | class _Proj = identity, |
| ... | ... | @@ -59,10 +58,9 @@ struct __fn { |
| 59 | 58 | return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); |
| 60 | 59 | } |
| 61 | 60 | }; |
| 62 | } // namespace __find_if | |
| 63 | 61 | |
| 64 | 62 | inline namespace __cpo { |
| 65 | inline constexpr auto find_if = __find_if::__fn{}; | |
| 63 | inline constexpr auto find_if = __find_if{}; | |
| 66 | 64 | } // namespace __cpo |
| 67 | 65 | } // namespace ranges |
| 68 | 66 |
lib/libcxx/include/__algorithm/ranges_find_if_not.h+2-4| ... | ... | @@ -34,8 +34,7 @@ _LIBCPP_PUSH_MACROS |
| 34 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 35 | |
| 36 | 36 | namespace ranges { |
| 37 | namespace __find_if_not { | |
| 38 | struct __fn { | |
| 37 | struct __find_if_not { | |
| 39 | 38 | template <input_iterator _Ip, |
| 40 | 39 | sentinel_for<_Ip> _Sp, |
| 41 | 40 | class _Proj = identity, |
| ... | ... | @@ -53,10 +52,9 @@ struct __fn { |
| 53 | 52 | return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj); |
| 54 | 53 | } |
| 55 | 54 | }; |
| 56 | } // namespace __find_if_not | |
| 57 | 55 | |
| 58 | 56 | inline namespace __cpo { |
| 59 | inline constexpr auto find_if_not = __find_if_not::__fn{}; | |
| 57 | inline constexpr auto find_if_not = __find_if_not{}; | |
| 60 | 58 | } // namespace __cpo |
| 61 | 59 | } // namespace ranges |
| 62 | 60 |
lib/libcxx/include/__algorithm/ranges_find_last.h+7-12| ... | ... | @@ -21,6 +21,7 @@ |
| 21 | 21 | #include <__ranges/access.h> |
| 22 | 22 | #include <__ranges/concepts.h> |
| 23 | 23 | #include <__ranges/subrange.h> |
| 24 | #include <__utility/forward.h> | |
| 24 | 25 | #include <__utility/move.h> |
| 25 | 26 | |
| 26 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -72,8 +73,7 @@ __find_last_impl(_Iter __first, _Sent __last, _Pred __pred, _Proj& __proj) { |
| 72 | 73 | } |
| 73 | 74 | } |
| 74 | 75 | |
| 75 | namespace __find_last { | |
| 76 | struct __fn { | |
| 76 | struct __find_last { | |
| 77 | 77 | template <class _Type> |
| 78 | 78 | struct __op { |
| 79 | 79 | const _Type& __value; |
| ... | ... | @@ -97,10 +97,8 @@ struct __fn { |
| 97 | 97 | return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Type>{__value}, __proj); |
| 98 | 98 | } |
| 99 | 99 | }; |
| 100 | } // namespace __find_last | |
| 101 | 100 | |
| 102 | namespace __find_last_if { | |
| 103 | struct __fn { | |
| 101 | struct __find_last_if { | |
| 104 | 102 | template <class _Pred> |
| 105 | 103 | struct __op { |
| 106 | 104 | _Pred& __pred; |
| ... | ... | @@ -127,10 +125,8 @@ struct __fn { |
| 127 | 125 | return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj); |
| 128 | 126 | } |
| 129 | 127 | }; |
| 130 | } // namespace __find_last_if | |
| 131 | 128 | |
| 132 | namespace __find_last_if_not { | |
| 133 | struct __fn { | |
| 129 | struct __find_last_if_not { | |
| 134 | 130 | template <class _Pred> |
| 135 | 131 | struct __op { |
| 136 | 132 | _Pred& __pred; |
| ... | ... | @@ -157,12 +153,11 @@ struct __fn { |
| 157 | 153 | return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj); |
| 158 | 154 | } |
| 159 | 155 | }; |
| 160 | } // namespace __find_last_if_not | |
| 161 | 156 | |
| 162 | 157 | 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{}; | |
| 158 | inline constexpr auto find_last = __find_last{}; | |
| 159 | inline constexpr auto find_last_if = __find_last_if{}; | |
| 160 | inline constexpr auto find_last_if_not = __find_last_if_not{}; | |
| 166 | 161 | } // namespace __cpo |
| 167 | 162 | } // namespace ranges |
| 168 | 163 |
lib/libcxx/include/__algorithm/ranges_fold.h created+129| ... | ... | @@ -0,0 +1,129 @@ |
| 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_RANGES_FOLD_H | |
| 11 | #define _LIBCPP___ALGORITHM_RANGES_FOLD_H | |
| 12 | ||
| 13 | #include <__concepts/assignable.h> | |
| 14 | #include <__concepts/constructible.h> | |
| 15 | #include <__concepts/convertible_to.h> | |
| 16 | #include <__concepts/invocable.h> | |
| 17 | #include <__concepts/movable.h> | |
| 18 | #include <__config> | |
| 19 | #include <__functional/invoke.h> | |
| 20 | #include <__functional/reference_wrapper.h> | |
| 21 | #include <__iterator/concepts.h> | |
| 22 | #include <__iterator/iterator_traits.h> | |
| 23 | #include <__iterator/next.h> | |
| 24 | #include <__ranges/access.h> | |
| 25 | #include <__ranges/concepts.h> | |
| 26 | #include <__ranges/dangling.h> | |
| 27 | #include <__type_traits/decay.h> | |
| 28 | #include <__type_traits/invoke.h> | |
| 29 | #include <__utility/forward.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 >= 23 | |
| 42 | ||
| 43 | namespace ranges { | |
| 44 | template <class _Ip, class _Tp> | |
| 45 | struct in_value_result { | |
| 46 | _LIBCPP_NO_UNIQUE_ADDRESS _Ip in; | |
| 47 | _LIBCPP_NO_UNIQUE_ADDRESS _Tp value; | |
| 48 | ||
| 49 | template <class _I2, class _T2> | |
| 50 | requires convertible_to<const _Ip&, _I2> && convertible_to<const _Tp&, _T2> | |
| 51 | _LIBCPP_HIDE_FROM_ABI constexpr operator in_value_result<_I2, _T2>() const& { | |
| 52 | return {in, value}; | |
| 53 | } | |
| 54 | ||
| 55 | template <class _I2, class _T2> | |
| 56 | requires convertible_to<_Ip, _I2> && convertible_to<_Tp, _T2> | |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr operator in_value_result<_I2, _T2>() && { | |
| 58 | return {std::move(in), std::move(value)}; | |
| 59 | } | |
| 60 | }; | |
| 61 | ||
| 62 | template <class _Ip, class _Tp> | |
| 63 | using fold_left_with_iter_result = in_value_result<_Ip, _Tp>; | |
| 64 | ||
| 65 | template <class _Fp, class _Tp, class _Ip, class _Rp, class _Up = decay_t<_Rp>> | |
| 66 | concept __indirectly_binary_left_foldable_impl = | |
| 67 | convertible_to<_Rp, _Up> && // | |
| 68 | movable<_Tp> && // | |
| 69 | movable<_Up> && // | |
| 70 | convertible_to<_Tp, _Up> && // | |
| 71 | invocable<_Fp&, _Up, iter_reference_t<_Ip>> && // | |
| 72 | assignable_from<_Up&, invoke_result_t<_Fp&, _Up, iter_reference_t<_Ip>>>; | |
| 73 | ||
| 74 | template <class _Fp, class _Tp, class _Ip> | |
| 75 | concept __indirectly_binary_left_foldable = | |
| 76 | copy_constructible<_Fp> && // | |
| 77 | invocable<_Fp&, _Tp, iter_reference_t<_Ip>> && // | |
| 78 | __indirectly_binary_left_foldable_impl<_Fp, _Tp, _Ip, invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>; | |
| 79 | ||
| 80 | struct __fold_left_with_iter { | |
| 81 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp> | |
| 82 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) { | |
| 83 | using _Up = decay_t<invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>; | |
| 84 | ||
| 85 | if (__first == __last) { | |
| 86 | return fold_left_with_iter_result<_Ip, _Up>{std::move(__first), _Up(std::move(__init))}; | |
| 87 | } | |
| 88 | ||
| 89 | _Up __result = std::invoke(__f, std::move(__init), *__first); | |
| 90 | for (++__first; __first != __last; ++__first) { | |
| 91 | __result = std::invoke(__f, std::move(__result), *__first); | |
| 92 | } | |
| 93 | ||
| 94 | return fold_left_with_iter_result<_Ip, _Up>{std::move(__first), std::move(__result)}; | |
| 95 | } | |
| 96 | ||
| 97 | template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp> | |
| 98 | [[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)); | |
| 100 | ||
| 101 | using _Up = decay_t<invoke_result_t<_Fp&, _Tp, range_reference_t<_Rp>>>; | |
| 102 | return fold_left_with_iter_result<borrowed_iterator_t<_Rp>, _Up>{std::move(__result.in), std::move(__result.value)}; | |
| 103 | } | |
| 104 | }; | |
| 105 | ||
| 106 | inline constexpr auto fold_left_with_iter = __fold_left_with_iter(); | |
| 107 | ||
| 108 | struct __fold_left { | |
| 109 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp> | |
| 110 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) { | |
| 111 | return fold_left_with_iter(std::move(__first), std::move(__last), std::move(__init), std::ref(__f)).value; | |
| 112 | } | |
| 113 | ||
| 114 | template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp> | |
| 115 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) { | |
| 116 | return fold_left_with_iter(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)).value; | |
| 117 | } | |
| 118 | }; | |
| 119 | ||
| 120 | inline constexpr auto fold_left = __fold_left(); | |
| 121 | } // namespace ranges | |
| 122 | ||
| 123 | #endif // _LIBCPP_STD_VER >= 23 | |
| 124 | ||
| 125 | _LIBCPP_END_NAMESPACE_STD | |
| 126 | ||
| 127 | _LIBCPP_POP_MACROS | |
| 128 | ||
| 129 | #endif // _LIBCPP___ALGORITHM_RANGES_FOLD_H |
lib/libcxx/include/__algorithm/ranges_for_each.h+2-4| ... | ... | @@ -36,8 +36,7 @@ namespace ranges { |
| 36 | 36 | template <class _Iter, class _Func> |
| 37 | 37 | using for_each_result = in_fun_result<_Iter, _Func>; |
| 38 | 38 | |
| 39 | namespace __for_each { | |
| 40 | struct __fn { | |
| 39 | struct __for_each { | |
| 41 | 40 | private: |
| 42 | 41 | template <class _Iter, class _Sent, class _Proj, class _Func> |
| 43 | 42 | _LIBCPP_HIDE_FROM_ABI constexpr static for_each_result<_Iter, _Func> |
| ... | ... | @@ -65,10 +64,9 @@ public: |
| 65 | 64 | return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj); |
| 66 | 65 | } |
| 67 | 66 | }; |
| 68 | } // namespace __for_each | |
| 69 | 67 | |
| 70 | 68 | inline namespace __cpo { |
| 71 | inline constexpr auto for_each = __for_each::__fn{}; | |
| 69 | inline constexpr auto for_each = __for_each{}; | |
| 72 | 70 | } // namespace __cpo |
| 73 | 71 | } // namespace ranges |
| 74 | 72 |
lib/libcxx/include/__algorithm/ranges_for_each_n.h+2-4| ... | ... | @@ -36,8 +36,7 @@ namespace ranges { |
| 36 | 36 | template <class _Iter, class _Func> |
| 37 | 37 | using for_each_n_result = in_fun_result<_Iter, _Func>; |
| 38 | 38 | |
| 39 | namespace __for_each_n { | |
| 40 | struct __fn { | |
| 39 | struct __for_each_n { | |
| 41 | 40 | template <input_iterator _Iter, class _Proj = identity, indirectly_unary_invocable<projected<_Iter, _Proj>> _Func> |
| 42 | 41 | _LIBCPP_HIDE_FROM_ABI constexpr for_each_n_result<_Iter, _Func> |
| 43 | 42 | operator()(_Iter __first, iter_difference_t<_Iter> __count, _Func __func, _Proj __proj = {}) const { |
| ... | ... | @@ -48,10 +47,9 @@ struct __fn { |
| 48 | 47 | return {std::move(__first), std::move(__func)}; |
| 49 | 48 | } |
| 50 | 49 | }; |
| 51 | } // namespace __for_each_n | |
| 52 | 50 | |
| 53 | 51 | inline namespace __cpo { |
| 54 | inline constexpr auto for_each_n = __for_each_n::__fn{}; | |
| 52 | inline constexpr auto for_each_n = __for_each_n{}; | |
| 55 | 53 | } // namespace __cpo |
| 56 | 54 | } // namespace ranges |
| 57 | 55 |
lib/libcxx/include/__algorithm/ranges_generate.h+3-7| ... | ... | @@ -12,12 +12,12 @@ |
| 12 | 12 | #include <__concepts/constructible.h> |
| 13 | 13 | #include <__concepts/invocable.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__functional/invoke.h> | |
| 16 | 15 | #include <__iterator/concepts.h> |
| 17 | 16 | #include <__iterator/iterator_traits.h> |
| 18 | 17 | #include <__ranges/access.h> |
| 19 | 18 | #include <__ranges/concepts.h> |
| 20 | 19 | #include <__ranges/dangling.h> |
| 20 | #include <__type_traits/invoke.h> | |
| 21 | 21 | #include <__utility/move.h> |
| 22 | 22 | |
| 23 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -32,9 +32,7 @@ _LIBCPP_PUSH_MACROS |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | 34 | namespace ranges { |
| 35 | namespace __generate { | |
| 36 | ||
| 37 | struct __fn { | |
| 35 | struct __generate { | |
| 38 | 36 | template <class _OutIter, class _Sent, class _Func> |
| 39 | 37 | _LIBCPP_HIDE_FROM_ABI constexpr static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) { |
| 40 | 38 | for (; __first != __last; ++__first) { |
| ... | ... | @@ -57,10 +55,8 @@ struct __fn { |
| 57 | 55 | } |
| 58 | 56 | }; |
| 59 | 57 | |
| 60 | } // namespace __generate | |
| 61 | ||
| 62 | 58 | inline namespace __cpo { |
| 63 | inline constexpr auto generate = __generate::__fn{}; | |
| 59 | inline constexpr auto generate = __generate{}; | |
| 64 | 60 | } // namespace __cpo |
| 65 | 61 | } // namespace ranges |
| 66 | 62 |
lib/libcxx/include/__algorithm/ranges_generate_n.h+3-7| ... | ... | @@ -13,12 +13,12 @@ |
| 13 | 13 | #include <__concepts/invocable.h> |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__functional/identity.h> |
| 16 | #include <__functional/invoke.h> | |
| 17 | 16 | #include <__iterator/concepts.h> |
| 18 | 17 | #include <__iterator/incrementable_traits.h> |
| 19 | 18 | #include <__iterator/iterator_traits.h> |
| 20 | 19 | #include <__ranges/access.h> |
| 21 | 20 | #include <__ranges/concepts.h> |
| 21 | #include <__type_traits/invoke.h> | |
| 22 | 22 | #include <__utility/move.h> |
| 23 | 23 | |
| 24 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -33,9 +33,7 @@ _LIBCPP_PUSH_MACROS |
| 33 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | |
| 35 | 35 | namespace ranges { |
| 36 | namespace __generate_n { | |
| 37 | ||
| 38 | struct __fn { | |
| 36 | struct __generate_n { | |
| 39 | 37 | template <input_or_output_iterator _OutIter, copy_constructible _Func> |
| 40 | 38 | requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>> |
| 41 | 39 | _LIBCPP_HIDE_FROM_ABI constexpr _OutIter |
| ... | ... | @@ -49,10 +47,8 @@ struct __fn { |
| 49 | 47 | } |
| 50 | 48 | }; |
| 51 | 49 | |
| 52 | } // namespace __generate_n | |
| 53 | ||
| 54 | 50 | inline namespace __cpo { |
| 55 | inline constexpr auto generate_n = __generate_n::__fn{}; | |
| 51 | inline constexpr auto generate_n = __generate_n{}; | |
| 56 | 52 | } // namespace __cpo |
| 57 | 53 | } // namespace ranges |
| 58 | 54 |
lib/libcxx/include/__algorithm/ranges_includes.h+2-6| ... | ... | @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS |
| 35 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 36 | |
| 37 | 37 | namespace ranges { |
| 38 | namespace __includes { | |
| 39 | ||
| 40 | struct __fn { | |
| 38 | struct __includes { | |
| 41 | 39 | template <input_iterator _Iter1, |
| 42 | 40 | sentinel_for<_Iter1> _Sent1, |
| 43 | 41 | input_iterator _Iter2, |
| ... | ... | @@ -82,10 +80,8 @@ struct __fn { |
| 82 | 80 | } |
| 83 | 81 | }; |
| 84 | 82 | |
| 85 | } // namespace __includes | |
| 86 | ||
| 87 | 83 | inline namespace __cpo { |
| 88 | inline constexpr auto includes = __includes::__fn{}; | |
| 84 | inline constexpr auto includes = __includes{}; | |
| 89 | 85 | } // namespace __cpo |
| 90 | 86 | } // namespace ranges |
| 91 | 87 |
lib/libcxx/include/__algorithm/ranges_inplace_merge.h+2-6| ... | ... | @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS |
| 39 | 39 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | 40 | |
| 41 | 41 | namespace ranges { |
| 42 | namespace __inplace_merge { | |
| 43 | ||
| 44 | struct __fn { | |
| 42 | struct __inplace_merge { | |
| 45 | 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 46 | 44 | _LIBCPP_HIDE_FROM_ABI static constexpr auto |
| 47 | 45 | __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) { |
| ... | ... | @@ -68,10 +66,8 @@ struct __fn { |
| 68 | 66 | } |
| 69 | 67 | }; |
| 70 | 68 | |
| 71 | } // namespace __inplace_merge | |
| 72 | ||
| 73 | 69 | inline namespace __cpo { |
| 74 | inline constexpr auto inplace_merge = __inplace_merge::__fn{}; | |
| 70 | inline constexpr auto inplace_merge = __inplace_merge{}; | |
| 75 | 71 | } // namespace __cpo |
| 76 | 72 | } // namespace ranges |
| 77 | 73 |
lib/libcxx/include/__algorithm/ranges_is_heap.h+2-6| ... | ... | @@ -34,9 +34,7 @@ _LIBCPP_PUSH_MACROS |
| 34 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 35 | |
| 36 | 36 | namespace ranges { |
| 37 | namespace __is_heap { | |
| 38 | ||
| 39 | struct __fn { | |
| 37 | struct __is_heap { | |
| 40 | 38 | template <class _Iter, class _Sent, class _Proj, class _Comp> |
| 41 | 39 | _LIBCPP_HIDE_FROM_ABI constexpr static bool |
| 42 | 40 | __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| ... | ... | @@ -65,10 +63,8 @@ struct __fn { |
| 65 | 63 | } |
| 66 | 64 | }; |
| 67 | 65 | |
| 68 | } // namespace __is_heap | |
| 69 | ||
| 70 | 66 | inline namespace __cpo { |
| 71 | inline constexpr auto is_heap = __is_heap::__fn{}; | |
| 67 | inline constexpr auto is_heap = __is_heap{}; | |
| 72 | 68 | } // namespace __cpo |
| 73 | 69 | } // namespace ranges |
| 74 | 70 |
lib/libcxx/include/__algorithm/ranges_is_heap_until.h+2-6| ... | ... | @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS |
| 35 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 36 | |
| 37 | 37 | namespace ranges { |
| 38 | namespace __is_heap_until { | |
| 39 | ||
| 40 | struct __fn { | |
| 38 | struct __is_heap_until { | |
| 41 | 39 | template <class _Iter, class _Sent, class _Proj, class _Comp> |
| 42 | 40 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter |
| 43 | 41 | __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| ... | ... | @@ -65,10 +63,8 @@ struct __fn { |
| 65 | 63 | } |
| 66 | 64 | }; |
| 67 | 65 | |
| 68 | } // namespace __is_heap_until | |
| 69 | ||
| 70 | 66 | inline namespace __cpo { |
| 71 | inline constexpr auto is_heap_until = __is_heap_until::__fn{}; | |
| 67 | inline constexpr auto is_heap_until = __is_heap_until{}; | |
| 72 | 68 | } // namespace __cpo |
| 73 | 69 | } // namespace ranges |
| 74 | 70 |
lib/libcxx/include/__algorithm/ranges_is_partitioned.h+2-4| ... | ... | @@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS |
| 31 | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 32 | |
| 33 | 33 | namespace ranges { |
| 34 | namespace __is_partitioned { | |
| 35 | struct __fn { | |
| 34 | struct __is_partitioned { | |
| 36 | 35 | template <class _Iter, class _Sent, class _Proj, class _Pred> |
| 37 | 36 | _LIBCPP_HIDE_FROM_ABI constexpr static bool |
| 38 | 37 | __is_partitioned_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { |
| ... | ... | @@ -70,10 +69,9 @@ struct __fn { |
| 70 | 69 | return __is_partitioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 71 | 70 | } |
| 72 | 71 | }; |
| 73 | } // namespace __is_partitioned | |
| 74 | 72 | |
| 75 | 73 | inline namespace __cpo { |
| 76 | inline constexpr auto is_partitioned = __is_partitioned::__fn{}; | |
| 74 | inline constexpr auto is_partitioned = __is_partitioned{}; | |
| 77 | 75 | } // namespace __cpo |
| 78 | 76 | } // namespace ranges |
| 79 | 77 |
lib/libcxx/include/__algorithm/ranges_is_permutation.h+2-4| ... | ... | @@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS |
| 33 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | |
| 35 | 35 | namespace ranges { |
| 36 | namespace __is_permutation { | |
| 37 | struct __fn { | |
| 36 | struct __is_permutation { | |
| 38 | 37 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Pred> |
| 39 | 38 | _LIBCPP_HIDE_FROM_ABI constexpr static bool __is_permutation_func_impl( |
| 40 | 39 | _Iter1 __first1, |
| ... | ... | @@ -91,10 +90,9 @@ struct __fn { |
| 91 | 90 | __proj2); |
| 92 | 91 | } |
| 93 | 92 | }; |
| 94 | } // namespace __is_permutation | |
| 95 | 93 | |
| 96 | 94 | inline namespace __cpo { |
| 97 | inline constexpr auto is_permutation = __is_permutation::__fn{}; | |
| 95 | inline constexpr auto is_permutation = __is_permutation{}; | |
| 98 | 96 | } // namespace __cpo |
| 99 | 97 | } // namespace ranges |
| 100 | 98 |
lib/libcxx/include/__algorithm/ranges_is_sorted.h+2-4| ... | ... | @@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS |
| 31 | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 32 | |
| 33 | 33 | namespace ranges { |
| 34 | namespace __is_sorted { | |
| 35 | struct __fn { | |
| 34 | struct __is_sorted { | |
| 36 | 35 | template <forward_iterator _Iter, |
| 37 | 36 | sentinel_for<_Iter> _Sent, |
| 38 | 37 | class _Proj = identity, |
| ... | ... | @@ -51,10 +50,9 @@ struct __fn { |
| 51 | 50 | return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last; |
| 52 | 51 | } |
| 53 | 52 | }; |
| 54 | } // namespace __is_sorted | |
| 55 | 53 | |
| 56 | 54 | inline namespace __cpo { |
| 57 | inline constexpr auto is_sorted = __is_sorted::__fn{}; | |
| 55 | inline constexpr auto is_sorted = __is_sorted{}; | |
| 58 | 56 | } // namespace __cpo |
| 59 | 57 | } // namespace ranges |
| 60 | 58 |
lib/libcxx/include/__algorithm/ranges_is_sorted_until.h+2-4| ... | ... | @@ -47,8 +47,7 @@ __is_sorted_until_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj |
| 47 | 47 | return __i; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | namespace __is_sorted_until { | |
| 51 | struct __fn { | |
| 50 | struct __is_sorted_until { | |
| 52 | 51 | template <forward_iterator _Iter, |
| 53 | 52 | sentinel_for<_Iter> _Sent, |
| 54 | 53 | class _Proj = identity, |
| ... | ... | @@ -66,10 +65,9 @@ struct __fn { |
| 66 | 65 | return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); |
| 67 | 66 | } |
| 68 | 67 | }; |
| 69 | } // namespace __is_sorted_until | |
| 70 | 68 | |
| 71 | 69 | inline namespace __cpo { |
| 72 | inline constexpr auto is_sorted_until = __is_sorted_until::__fn{}; | |
| 70 | inline constexpr auto is_sorted_until = __is_sorted_until{}; | |
| 73 | 71 | } // namespace __cpo |
| 74 | 72 | } // namespace ranges |
| 75 | 73 |
lib/libcxx/include/__algorithm/ranges_iterator_concept.h+1-1| ... | ... | @@ -44,7 +44,7 @@ consteval auto __get_iterator_concept() { |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | template <class _Iter> |
| 47 | using __iterator_concept = decltype(__get_iterator_concept<_Iter>()); | |
| 47 | using __iterator_concept _LIBCPP_NODEBUG = decltype(__get_iterator_concept<_Iter>()); | |
| 48 | 48 | |
| 49 | 49 | } // namespace ranges |
| 50 | 50 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/ranges_lexicographical_compare.h+17-16| ... | ... | @@ -9,6 +9,8 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H |
| 11 | 11 | |
| 12 | #include <__algorithm/lexicographical_compare.h> | |
| 13 | #include <__algorithm/unwrap_range.h> | |
| 12 | 14 | #include <__config> |
| 13 | 15 | #include <__functional/identity.h> |
| 14 | 16 | #include <__functional/invoke.h> |
| ... | ... | @@ -31,10 +33,9 @@ _LIBCPP_PUSH_MACROS |
| 31 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 34 | |
| 33 | 35 | namespace ranges { |
| 34 | namespace __lexicographical_compare { | |
| 35 | struct __fn { | |
| 36 | struct __lexicographical_compare { | |
| 36 | 37 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp> |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr static bool __lexicographical_compare_impl( | |
| 38 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __lexicographical_compare_unwrap( | |
| 38 | 39 | _Iter1 __first1, |
| 39 | 40 | _Sent1 __last1, |
| 40 | 41 | _Iter2 __first2, |
| ... | ... | @@ -42,15 +43,16 @@ struct __fn { |
| 42 | 43 | _Comp& __comp, |
| 43 | 44 | _Proj1& __proj1, |
| 44 | 45 | _Proj2& __proj2) { |
| 45 | while (__first2 != __last2) { | |
| 46 | if (__first1 == __last1 || std::invoke(__comp, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2))) | |
| 47 | return true; | |
| 48 | if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) | |
| 49 | return false; | |
| 50 | ++__first1; | |
| 51 | ++__first2; | |
| 52 | } | |
| 53 | return false; | |
| 46 | auto [__first1_un, __last1_un] = std::__unwrap_range(std::move(__first1), std::move(__last1)); | |
| 47 | auto [__first2_un, __last2_un] = std::__unwrap_range(std::move(__first2), std::move(__last2)); | |
| 48 | return std::__lexicographical_compare( | |
| 49 | std::move(__first1_un), | |
| 50 | std::move(__last1_un), | |
| 51 | std::move(__first2_un), | |
| 52 | std::move(__last2_un), | |
| 53 | __comp, | |
| 54 | __proj1, | |
| 55 | __proj2); | |
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | template <input_iterator _Iter1, |
| ... | ... | @@ -68,7 +70,7 @@ struct __fn { |
| 68 | 70 | _Comp __comp = {}, |
| 69 | 71 | _Proj1 __proj1 = {}, |
| 70 | 72 | _Proj2 __proj2 = {}) const { |
| 71 | return __lexicographical_compare_impl( | |
| 73 | return __lexicographical_compare_unwrap( | |
| 72 | 74 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __comp, __proj1, __proj2); |
| 73 | 75 | } |
| 74 | 76 | |
| ... | ... | @@ -80,7 +82,7 @@ struct __fn { |
| 80 | 82 | _Comp = ranges::less> |
| 81 | 83 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( |
| 82 | 84 | _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { |
| 83 | return __lexicographical_compare_impl( | |
| 85 | return __lexicographical_compare_unwrap( | |
| 84 | 86 | ranges::begin(__range1), |
| 85 | 87 | ranges::end(__range1), |
| 86 | 88 | ranges::begin(__range2), |
| ... | ... | @@ -90,10 +92,9 @@ struct __fn { |
| 90 | 92 | __proj2); |
| 91 | 93 | } |
| 92 | 94 | }; |
| 93 | } // namespace __lexicographical_compare | |
| 94 | 95 | |
| 95 | 96 | inline namespace __cpo { |
| 96 | inline constexpr auto lexicographical_compare = __lexicographical_compare::__fn{}; | |
| 97 | inline constexpr auto lexicographical_compare = __lexicographical_compare{}; | |
| 97 | 98 | } // namespace __cpo |
| 98 | 99 | } // namespace ranges |
| 99 | 100 |
lib/libcxx/include/__algorithm/ranges_lower_bound.h+2-4| ... | ... | @@ -36,8 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 36 | |
| 37 | 37 | namespace ranges { |
| 38 | 38 | |
| 39 | namespace __lower_bound { | |
| 40 | struct __fn { | |
| 39 | struct __lower_bound { | |
| 41 | 40 | template <forward_iterator _Iter, |
| 42 | 41 | sentinel_for<_Iter> _Sent, |
| 43 | 42 | class _Type, |
| ... | ... | @@ -57,10 +56,9 @@ struct __fn { |
| 57 | 56 | return std::__lower_bound<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj); |
| 58 | 57 | } |
| 59 | 58 | }; |
| 60 | } // namespace __lower_bound | |
| 61 | 59 | |
| 62 | 60 | inline namespace __cpo { |
| 63 | inline constexpr auto lower_bound = __lower_bound::__fn{}; | |
| 61 | inline constexpr auto lower_bound = __lower_bound{}; | |
| 64 | 62 | } // namespace __cpo |
| 65 | 63 | } // namespace ranges |
| 66 | 64 |
lib/libcxx/include/__algorithm/ranges_make_heap.h+2-6| ... | ... | @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS |
| 40 | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 41 | |
| 42 | 42 | namespace ranges { |
| 43 | namespace __make_heap { | |
| 44 | ||
| 45 | struct __fn { | |
| 43 | struct __make_heap { | |
| 46 | 44 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 47 | 45 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter |
| 48 | 46 | __make_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| ... | ... | @@ -69,10 +67,8 @@ struct __fn { |
| 69 | 67 | } |
| 70 | 68 | }; |
| 71 | 69 | |
| 72 | } // namespace __make_heap | |
| 73 | ||
| 74 | 70 | inline namespace __cpo { |
| 75 | inline constexpr auto make_heap = __make_heap::__fn{}; | |
| 71 | inline constexpr auto make_heap = __make_heap{}; | |
| 76 | 72 | } // namespace __cpo |
| 77 | 73 | } // namespace ranges |
| 78 | 74 |
lib/libcxx/include/__algorithm/ranges_max.h+2-4| ... | ... | @@ -36,8 +36,7 @@ _LIBCPP_PUSH_MACROS |
| 36 | 36 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 37 | 37 | |
| 38 | 38 | namespace ranges { |
| 39 | namespace __max { | |
| 40 | struct __fn { | |
| 39 | struct __max { | |
| 41 | 40 | template <class _Tp, |
| 42 | 41 | class _Proj = identity, |
| 43 | 42 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> |
| ... | ... | @@ -87,10 +86,9 @@ struct __fn { |
| 87 | 86 | } |
| 88 | 87 | } |
| 89 | 88 | }; |
| 90 | } // namespace __max | |
| 91 | 89 | |
| 92 | 90 | inline namespace __cpo { |
| 93 | inline constexpr auto max = __max::__fn{}; | |
| 91 | inline constexpr auto max = __max{}; | |
| 94 | 92 | } // namespace __cpo |
| 95 | 93 | } // namespace ranges |
| 96 | 94 |
lib/libcxx/include/__algorithm/ranges_max_element.h+2-4| ... | ... | @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | 34 | namespace ranges { |
| 35 | namespace __max_element { | |
| 36 | struct __fn { | |
| 35 | struct __max_element { | |
| 37 | 36 | template <forward_iterator _Ip, |
| 38 | 37 | sentinel_for<_Ip> _Sp, |
| 39 | 38 | class _Proj = identity, |
| ... | ... | @@ -53,10 +52,9 @@ struct __fn { |
| 53 | 52 | return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj); |
| 54 | 53 | } |
| 55 | 54 | }; |
| 56 | } // namespace __max_element | |
| 57 | 55 | |
| 58 | 56 | inline namespace __cpo { |
| 59 | inline constexpr auto max_element = __max_element::__fn{}; | |
| 57 | inline constexpr auto max_element = __max_element{}; | |
| 60 | 58 | } // namespace __cpo |
| 61 | 59 | } // namespace ranges |
| 62 | 60 |
lib/libcxx/include/__algorithm/ranges_merge.h+35-39| ... | ... | @@ -39,42 +39,7 @@ namespace ranges { |
| 39 | 39 | template <class _InIter1, class _InIter2, class _OutIter> |
| 40 | 40 | using merge_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; |
| 41 | 41 | |
| 42 | namespace __merge { | |
| 43 | ||
| 44 | template < class _InIter1, | |
| 45 | class _Sent1, | |
| 46 | class _InIter2, | |
| 47 | class _Sent2, | |
| 48 | class _OutIter, | |
| 49 | class _Comp, | |
| 50 | class _Proj1, | |
| 51 | class _Proj2> | |
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr merge_result<__remove_cvref_t<_InIter1>, | |
| 53 | __remove_cvref_t<_InIter2>, | |
| 54 | __remove_cvref_t<_OutIter>> | |
| 55 | __merge_impl(_InIter1&& __first1, | |
| 56 | _Sent1&& __last1, | |
| 57 | _InIter2&& __first2, | |
| 58 | _Sent2&& __last2, | |
| 59 | _OutIter&& __result, | |
| 60 | _Comp&& __comp, | |
| 61 | _Proj1&& __proj1, | |
| 62 | _Proj2&& __proj2) { | |
| 63 | for (; __first1 != __last1 && __first2 != __last2; ++__result) { | |
| 64 | if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) { | |
| 65 | *__result = *__first2; | |
| 66 | ++__first2; | |
| 67 | } else { | |
| 68 | *__result = *__first1; | |
| 69 | ++__first1; | |
| 70 | } | |
| 71 | } | |
| 72 | auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 73 | auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out)); | |
| 74 | return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)}; | |
| 75 | } | |
| 76 | ||
| 77 | struct __fn { | |
| 42 | struct __merge { | |
| 78 | 43 | template <input_iterator _InIter1, |
| 79 | 44 | sentinel_for<_InIter1> _Sent1, |
| 80 | 45 | input_iterator _InIter2, |
| ... | ... | @@ -120,12 +85,43 @@ struct __fn { |
| 120 | 85 | __proj1, |
| 121 | 86 | __proj2); |
| 122 | 87 | } |
| 123 | }; | |
| 124 | 88 | |
| 125 | } // namespace __merge | |
| 89 | template < class _InIter1, | |
| 90 | class _Sent1, | |
| 91 | class _InIter2, | |
| 92 | class _Sent2, | |
| 93 | class _OutIter, | |
| 94 | class _Comp, | |
| 95 | class _Proj1, | |
| 96 | class _Proj2> | |
| 97 | _LIBCPP_HIDE_FROM_ABI static constexpr merge_result<__remove_cvref_t<_InIter1>, | |
| 98 | __remove_cvref_t<_InIter2>, | |
| 99 | __remove_cvref_t<_OutIter>> | |
| 100 | __merge_impl(_InIter1&& __first1, | |
| 101 | _Sent1&& __last1, | |
| 102 | _InIter2&& __first2, | |
| 103 | _Sent2&& __last2, | |
| 104 | _OutIter&& __result, | |
| 105 | _Comp&& __comp, | |
| 106 | _Proj1&& __proj1, | |
| 107 | _Proj2&& __proj2) { | |
| 108 | for (; __first1 != __last1 && __first2 != __last2; ++__result) { | |
| 109 | if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) { | |
| 110 | *__result = *__first2; | |
| 111 | ++__first2; | |
| 112 | } else { | |
| 113 | *__result = *__first1; | |
| 114 | ++__first1; | |
| 115 | } | |
| 116 | } | |
| 117 | auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 118 | auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out)); | |
| 119 | return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)}; | |
| 120 | } | |
| 121 | }; | |
| 126 | 122 | |
| 127 | 123 | inline namespace __cpo { |
| 128 | inline constexpr auto merge = __merge::__fn{}; | |
| 124 | inline constexpr auto merge = __merge{}; | |
| 129 | 125 | } // namespace __cpo |
| 130 | 126 | } // namespace ranges |
| 131 | 127 |
lib/libcxx/include/__algorithm/ranges_min.h+2-4| ... | ... | @@ -35,8 +35,7 @@ _LIBCPP_PUSH_MACROS |
| 35 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 36 | |
| 37 | 37 | namespace ranges { |
| 38 | namespace __min { | |
| 39 | struct __fn { | |
| 38 | struct __min { | |
| 40 | 39 | template <class _Tp, |
| 41 | 40 | class _Proj = identity, |
| 42 | 41 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> |
| ... | ... | @@ -79,10 +78,9 @@ struct __fn { |
| 79 | 78 | } |
| 80 | 79 | } |
| 81 | 80 | }; |
| 82 | } // namespace __min | |
| 83 | 81 | |
| 84 | 82 | inline namespace __cpo { |
| 85 | inline constexpr auto min = __min::__fn{}; | |
| 83 | inline constexpr auto min = __min{}; | |
| 86 | 84 | } // namespace __cpo |
| 87 | 85 | } // namespace ranges |
| 88 | 86 |
lib/libcxx/include/__algorithm/ranges_min_element.h+2-4| ... | ... | @@ -46,8 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ip __min_element_impl(_Ip __first, _Sp __last, |
| 46 | 46 | return __first; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | namespace __min_element { | |
| 50 | struct __fn { | |
| 49 | struct __min_element { | |
| 51 | 50 | template <forward_iterator _Ip, |
| 52 | 51 | sentinel_for<_Ip> _Sp, |
| 53 | 52 | class _Proj = identity, |
| ... | ... | @@ -65,10 +64,9 @@ struct __fn { |
| 65 | 64 | return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); |
| 66 | 65 | } |
| 67 | 66 | }; |
| 68 | } // namespace __min_element | |
| 69 | 67 | |
| 70 | 68 | inline namespace __cpo { |
| 71 | inline constexpr auto min_element = __min_element::__fn{}; | |
| 69 | inline constexpr auto min_element = __min_element{}; | |
| 72 | 70 | } // namespace __cpo |
| 73 | 71 | } // namespace ranges |
| 74 | 72 |
lib/libcxx/include/__algorithm/ranges_minmax.h+3-4| ... | ... | @@ -24,6 +24,7 @@ |
| 24 | 24 | #include <__ranges/access.h> |
| 25 | 25 | #include <__ranges/concepts.h> |
| 26 | 26 | #include <__type_traits/desugars_to.h> |
| 27 | #include <__type_traits/is_integral.h> | |
| 27 | 28 | #include <__type_traits/is_reference.h> |
| 28 | 29 | #include <__type_traits/is_trivially_copyable.h> |
| 29 | 30 | #include <__type_traits/remove_cvref.h> |
| ... | ... | @@ -47,8 +48,7 @@ namespace ranges { |
| 47 | 48 | template <class _T1> |
| 48 | 49 | using minmax_result = min_max_result<_T1>; |
| 49 | 50 | |
| 50 | namespace __minmax { | |
| 51 | struct __fn { | |
| 51 | struct __minmax { | |
| 52 | 52 | template <class _Type, |
| 53 | 53 | class _Proj = identity, |
| 54 | 54 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> |
| ... | ... | @@ -159,10 +159,9 @@ struct __fn { |
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | }; |
| 162 | } // namespace __minmax | |
| 163 | 162 | |
| 164 | 163 | inline namespace __cpo { |
| 165 | inline constexpr auto minmax = __minmax::__fn{}; | |
| 164 | inline constexpr auto minmax = __minmax{}; | |
| 166 | 165 | } // namespace __cpo |
| 167 | 166 | } // namespace ranges |
| 168 | 167 |
lib/libcxx/include/__algorithm/ranges_minmax_element.h+2-4| ... | ... | @@ -40,8 +40,7 @@ namespace ranges { |
| 40 | 40 | template <class _T1> |
| 41 | 41 | using minmax_element_result = min_max_result<_T1>; |
| 42 | 42 | |
| 43 | namespace __minmax_element { | |
| 44 | struct __fn { | |
| 43 | struct __minmax_element { | |
| 45 | 44 | template <forward_iterator _Ip, |
| 46 | 45 | sentinel_for<_Ip> _Sp, |
| 47 | 46 | class _Proj = identity, |
| ... | ... | @@ -61,10 +60,9 @@ struct __fn { |
| 61 | 60 | return {__ret.first, __ret.second}; |
| 62 | 61 | } |
| 63 | 62 | }; |
| 64 | } // namespace __minmax_element | |
| 65 | 63 | |
| 66 | 64 | inline namespace __cpo { |
| 67 | inline constexpr auto minmax_element = __minmax_element::__fn{}; | |
| 65 | inline constexpr auto minmax_element = __minmax_element{}; | |
| 68 | 66 | } // namespace __cpo |
| 69 | 67 | |
| 70 | 68 | } // namespace ranges |
lib/libcxx/include/__algorithm/ranges_mismatch.h+2-4| ... | ... | @@ -39,8 +39,7 @@ namespace ranges { |
| 39 | 39 | template <class _I1, class _I2> |
| 40 | 40 | using mismatch_result = in_in_result<_I1, _I2>; |
| 41 | 41 | |
| 42 | namespace __mismatch { | |
| 43 | struct __fn { | |
| 42 | struct __mismatch { | |
| 44 | 43 | template <class _I1, class _S1, class _I2, class _S2, class _Pred, class _Proj1, class _Proj2> |
| 45 | 44 | static _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> |
| 46 | 45 | __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { |
| ... | ... | @@ -84,10 +83,9 @@ struct __fn { |
| 84 | 83 | ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), __pred, __proj1, __proj2); |
| 85 | 84 | } |
| 86 | 85 | }; |
| 87 | } // namespace __mismatch | |
| 88 | 86 | |
| 89 | 87 | inline namespace __cpo { |
| 90 | constexpr inline auto mismatch = __mismatch::__fn{}; | |
| 88 | constexpr inline auto mismatch = __mismatch{}; | |
| 91 | 89 | } // namespace __cpo |
| 92 | 90 | } // namespace ranges |
| 93 | 91 |
lib/libcxx/include/__algorithm/ranges_move.h+2-4| ... | ... | @@ -35,8 +35,7 @@ namespace ranges { |
| 35 | 35 | template <class _InIter, class _OutIter> |
| 36 | 36 | using move_result = in_out_result<_InIter, _OutIter>; |
| 37 | 37 | |
| 38 | namespace __move { | |
| 39 | struct __fn { | |
| 38 | struct __move { | |
| 40 | 39 | template <class _InIter, class _Sent, class _OutIter> |
| 41 | 40 | _LIBCPP_HIDE_FROM_ABI constexpr static move_result<_InIter, _OutIter> |
| 42 | 41 | __move_impl(_InIter __first, _Sent __last, _OutIter __result) { |
| ... | ... | @@ -58,10 +57,9 @@ struct __fn { |
| 58 | 57 | return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result)); |
| 59 | 58 | } |
| 60 | 59 | }; |
| 61 | } // namespace __move | |
| 62 | 60 | |
| 63 | 61 | inline namespace __cpo { |
| 64 | inline constexpr auto move = __move::__fn{}; | |
| 62 | inline constexpr auto move = __move{}; | |
| 65 | 63 | } // namespace __cpo |
| 66 | 64 | } // namespace ranges |
| 67 | 65 |
lib/libcxx/include/__algorithm/ranges_move_backward.h+2-4| ... | ... | @@ -37,8 +37,7 @@ namespace ranges { |
| 37 | 37 | template <class _InIter, class _OutIter> |
| 38 | 38 | using move_backward_result = in_out_result<_InIter, _OutIter>; |
| 39 | 39 | |
| 40 | namespace __move_backward { | |
| 41 | struct __fn { | |
| 40 | struct __move_backward { | |
| 42 | 41 | template <class _InIter, class _Sent, class _OutIter> |
| 43 | 42 | _LIBCPP_HIDE_FROM_ABI constexpr static move_backward_result<_InIter, _OutIter> |
| 44 | 43 | __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) { |
| ... | ... | @@ -60,10 +59,9 @@ struct __fn { |
| 60 | 59 | return __move_backward_impl(ranges::begin(__range), ranges::end(__range), std::move(__result)); |
| 61 | 60 | } |
| 62 | 61 | }; |
| 63 | } // namespace __move_backward | |
| 64 | 62 | |
| 65 | 63 | inline namespace __cpo { |
| 66 | inline constexpr auto move_backward = __move_backward::__fn{}; | |
| 64 | inline constexpr auto move_backward = __move_backward{}; | |
| 67 | 65 | } // namespace __cpo |
| 68 | 66 | } // namespace ranges |
| 69 | 67 |
lib/libcxx/include/__algorithm/ranges_next_permutation.h+2-6| ... | ... | @@ -40,9 +40,7 @@ namespace ranges { |
| 40 | 40 | template <class _InIter> |
| 41 | 41 | using next_permutation_result = in_found_result<_InIter>; |
| 42 | 42 | |
| 43 | namespace __next_permutation { | |
| 44 | ||
| 45 | struct __fn { | |
| 43 | struct __next_permutation { | |
| 46 | 44 | template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> |
| 47 | 45 | requires sortable<_Iter, _Comp, _Proj> |
| 48 | 46 | _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<_Iter> |
| ... | ... | @@ -62,10 +60,8 @@ struct __fn { |
| 62 | 60 | } |
| 63 | 61 | }; |
| 64 | 62 | |
| 65 | } // namespace __next_permutation | |
| 66 | ||
| 67 | 63 | inline namespace __cpo { |
| 68 | constexpr inline auto next_permutation = __next_permutation::__fn{}; | |
| 64 | constexpr inline auto next_permutation = __next_permutation{}; | |
| 69 | 65 | } // namespace __cpo |
| 70 | 66 | } // namespace ranges |
| 71 | 67 |
lib/libcxx/include/__algorithm/ranges_none_of.h+2-4| ... | ... | @@ -30,8 +30,7 @@ _LIBCPP_PUSH_MACROS |
| 30 | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 31 | |
| 32 | 32 | namespace ranges { |
| 33 | namespace __none_of { | |
| 34 | struct __fn { | |
| 33 | struct __none_of { | |
| 35 | 34 | template <class _Iter, class _Sent, class _Proj, class _Pred> |
| 36 | 35 | _LIBCPP_HIDE_FROM_ABI constexpr static bool |
| 37 | 36 | __none_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { |
| ... | ... | @@ -59,10 +58,9 @@ struct __fn { |
| 59 | 58 | return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 60 | 59 | } |
| 61 | 60 | }; |
| 62 | } // namespace __none_of | |
| 63 | 61 | |
| 64 | 62 | inline namespace __cpo { |
| 65 | inline constexpr auto none_of = __none_of::__fn{}; | |
| 63 | inline constexpr auto none_of = __none_of{}; | |
| 66 | 64 | } // namespace __cpo |
| 67 | 65 | } // namespace ranges |
| 68 | 66 |
lib/libcxx/include/__algorithm/ranges_nth_element.h+2-6| ... | ... | @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS |
| 39 | 39 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | 40 | |
| 41 | 41 | namespace ranges { |
| 42 | namespace __nth_element { | |
| 43 | ||
| 44 | struct __fn { | |
| 42 | struct __nth_element { | |
| 45 | 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 46 | 44 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter |
| 47 | 45 | __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| ... | ... | @@ -68,10 +66,8 @@ struct __fn { |
| 68 | 66 | } |
| 69 | 67 | }; |
| 70 | 68 | |
| 71 | } // namespace __nth_element | |
| 72 | ||
| 73 | 69 | inline namespace __cpo { |
| 74 | inline constexpr auto nth_element = __nth_element::__fn{}; | |
| 70 | inline constexpr auto nth_element = __nth_element{}; | |
| 75 | 71 | } // namespace __cpo |
| 76 | 72 | } // namespace ranges |
| 77 | 73 |
lib/libcxx/include/__algorithm/ranges_partial_sort.h+2-6| ... | ... | @@ -41,9 +41,7 @@ _LIBCPP_PUSH_MACROS |
| 41 | 41 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 42 | 42 | |
| 43 | 43 | namespace ranges { |
| 44 | namespace __partial_sort { | |
| 45 | ||
| 46 | struct __fn { | |
| 44 | struct __partial_sort { | |
| 47 | 45 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 48 | 46 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter |
| 49 | 47 | __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| ... | ... | @@ -66,10 +64,8 @@ struct __fn { |
| 66 | 64 | } |
| 67 | 65 | }; |
| 68 | 66 | |
| 69 | } // namespace __partial_sort | |
| 70 | ||
| 71 | 67 | inline namespace __cpo { |
| 72 | inline constexpr auto partial_sort = __partial_sort::__fn{}; | |
| 68 | inline constexpr auto partial_sort = __partial_sort{}; | |
| 73 | 69 | } // namespace __cpo |
| 74 | 70 | } // namespace ranges |
| 75 | 71 |
lib/libcxx/include/__algorithm/ranges_partial_sort_copy.h+2-6| ... | ... | @@ -42,9 +42,7 @@ namespace ranges { |
| 42 | 42 | template <class _InIter, class _OutIter> |
| 43 | 43 | using partial_sort_copy_result = in_out_result<_InIter, _OutIter>; |
| 44 | 44 | |
| 45 | namespace __partial_sort_copy { | |
| 46 | ||
| 47 | struct __fn { | |
| 45 | struct __partial_sort_copy { | |
| 48 | 46 | template <input_iterator _Iter1, |
| 49 | 47 | sentinel_for<_Iter1> _Sent1, |
| 50 | 48 | random_access_iterator _Iter2, |
| ... | ... | @@ -98,10 +96,8 @@ struct __fn { |
| 98 | 96 | } |
| 99 | 97 | }; |
| 100 | 98 | |
| 101 | } // namespace __partial_sort_copy | |
| 102 | ||
| 103 | 99 | inline namespace __cpo { |
| 104 | inline constexpr auto partial_sort_copy = __partial_sort_copy::__fn{}; | |
| 100 | inline constexpr auto partial_sort_copy = __partial_sort_copy{}; | |
| 105 | 101 | } // namespace __cpo |
| 106 | 102 | } // namespace ranges |
| 107 | 103 |
lib/libcxx/include/__algorithm/ranges_partition.h+3-6| ... | ... | @@ -24,6 +24,7 @@ |
| 24 | 24 | #include <__ranges/access.h> |
| 25 | 25 | #include <__ranges/concepts.h> |
| 26 | 26 | #include <__ranges/subrange.h> |
| 27 | #include <__type_traits/remove_cvref.h> | |
| 27 | 28 | #include <__utility/forward.h> |
| 28 | 29 | #include <__utility/move.h> |
| 29 | 30 | #include <__utility/pair.h> |
| ... | ... | @@ -40,9 +41,7 @@ _LIBCPP_PUSH_MACROS |
| 40 | 41 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 42 | |
| 42 | 43 | namespace ranges { |
| 43 | namespace __partition { | |
| 44 | ||
| 45 | struct __fn { | |
| 44 | struct __partition { | |
| 46 | 45 | template <class _Iter, class _Sent, class _Proj, class _Pred> |
| 47 | 46 | _LIBCPP_HIDE_FROM_ABI static constexpr subrange<__remove_cvref_t<_Iter>> |
| 48 | 47 | __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) { |
| ... | ... | @@ -72,10 +71,8 @@ struct __fn { |
| 72 | 71 | } |
| 73 | 72 | }; |
| 74 | 73 | |
| 75 | } // namespace __partition | |
| 76 | ||
| 77 | 74 | inline namespace __cpo { |
| 78 | inline constexpr auto partition = __partition::__fn{}; | |
| 75 | inline constexpr auto partition = __partition{}; | |
| 79 | 76 | } // namespace __cpo |
| 80 | 77 | } // namespace ranges |
| 81 | 78 |
lib/libcxx/include/__algorithm/ranges_partition_copy.h+2-6| ... | ... | @@ -38,9 +38,7 @@ namespace ranges { |
| 38 | 38 | template <class _InIter, class _OutIter1, class _OutIter2> |
| 39 | 39 | using partition_copy_result = in_out_out_result<_InIter, _OutIter1, _OutIter2>; |
| 40 | 40 | |
| 41 | namespace __partition_copy { | |
| 42 | ||
| 43 | struct __fn { | |
| 41 | struct __partition_copy { | |
| 44 | 42 | // TODO(ranges): delegate to the classic algorithm. |
| 45 | 43 | template <class _InIter, class _Sent, class _OutIter1, class _OutIter2, class _Proj, class _Pred> |
| 46 | 44 | _LIBCPP_HIDE_FROM_ABI constexpr static partition_copy_result<__remove_cvref_t<_InIter>, |
| ... | ... | @@ -94,10 +92,8 @@ struct __fn { |
| 94 | 92 | } |
| 95 | 93 | }; |
| 96 | 94 | |
| 97 | } // namespace __partition_copy | |
| 98 | ||
| 99 | 95 | inline namespace __cpo { |
| 100 | inline constexpr auto partition_copy = __partition_copy::__fn{}; | |
| 96 | inline constexpr auto partition_copy = __partition_copy{}; | |
| 101 | 97 | } // namespace __cpo |
| 102 | 98 | } // namespace ranges |
| 103 | 99 |
lib/libcxx/include/__algorithm/ranges_partition_point.h+2-6| ... | ... | @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS |
| 35 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 36 | |
| 37 | 37 | namespace ranges { |
| 38 | namespace __partition_point { | |
| 39 | ||
| 40 | struct __fn { | |
| 38 | struct __partition_point { | |
| 41 | 39 | // TODO(ranges): delegate to the classic algorithm. |
| 42 | 40 | template <class _Iter, class _Sent, class _Proj, class _Pred> |
| 43 | 41 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter |
| ... | ... | @@ -77,10 +75,8 @@ struct __fn { |
| 77 | 75 | } |
| 78 | 76 | }; |
| 79 | 77 | |
| 80 | } // namespace __partition_point | |
| 81 | ||
| 82 | 78 | inline namespace __cpo { |
| 83 | inline constexpr auto partition_point = __partition_point::__fn{}; | |
| 79 | inline constexpr auto partition_point = __partition_point{}; | |
| 84 | 80 | } // namespace __cpo |
| 85 | 81 | } // namespace ranges |
| 86 | 82 |
lib/libcxx/include/__algorithm/ranges_pop_heap.h+2-6| ... | ... | @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS |
| 40 | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 41 | |
| 42 | 42 | namespace ranges { |
| 43 | namespace __pop_heap { | |
| 44 | ||
| 45 | struct __fn { | |
| 43 | struct __pop_heap { | |
| 46 | 44 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 47 | 45 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter |
| 48 | 46 | __pop_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| ... | ... | @@ -70,10 +68,8 @@ struct __fn { |
| 70 | 68 | } |
| 71 | 69 | }; |
| 72 | 70 | |
| 73 | } // namespace __pop_heap | |
| 74 | ||
| 75 | 71 | inline namespace __cpo { |
| 76 | inline constexpr auto pop_heap = __pop_heap::__fn{}; | |
| 72 | inline constexpr auto pop_heap = __pop_heap{}; | |
| 77 | 73 | } // namespace __cpo |
| 78 | 74 | } // namespace ranges |
| 79 | 75 |
lib/libcxx/include/__algorithm/ranges_prev_permutation.h+2-6| ... | ... | @@ -40,9 +40,7 @@ namespace ranges { |
| 40 | 40 | template <class _InIter> |
| 41 | 41 | using prev_permutation_result = in_found_result<_InIter>; |
| 42 | 42 | |
| 43 | namespace __prev_permutation { | |
| 44 | ||
| 45 | struct __fn { | |
| 43 | struct __prev_permutation { | |
| 46 | 44 | template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> |
| 47 | 45 | requires sortable<_Iter, _Comp, _Proj> |
| 48 | 46 | _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<_Iter> |
| ... | ... | @@ -62,10 +60,8 @@ struct __fn { |
| 62 | 60 | } |
| 63 | 61 | }; |
| 64 | 62 | |
| 65 | } // namespace __prev_permutation | |
| 66 | ||
| 67 | 63 | inline namespace __cpo { |
| 68 | constexpr inline auto prev_permutation = __prev_permutation::__fn{}; | |
| 64 | constexpr inline auto prev_permutation = __prev_permutation{}; | |
| 69 | 65 | } // namespace __cpo |
| 70 | 66 | } // namespace ranges |
| 71 | 67 |
lib/libcxx/include/__algorithm/ranges_push_heap.h+2-6| ... | ... | @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS |
| 40 | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 41 | |
| 42 | 42 | namespace ranges { |
| 43 | namespace __push_heap { | |
| 44 | ||
| 45 | struct __fn { | |
| 43 | struct __push_heap { | |
| 46 | 44 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 47 | 45 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter |
| 48 | 46 | __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| ... | ... | @@ -69,10 +67,8 @@ struct __fn { |
| 69 | 67 | } |
| 70 | 68 | }; |
| 71 | 69 | |
| 72 | } // namespace __push_heap | |
| 73 | ||
| 74 | 70 | inline namespace __cpo { |
| 75 | inline constexpr auto push_heap = __push_heap::__fn{}; | |
| 71 | inline constexpr auto push_heap = __push_heap{}; | |
| 76 | 72 | } // namespace __cpo |
| 77 | 73 | } // namespace ranges |
| 78 | 74 |
lib/libcxx/include/__algorithm/ranges_remove.h+2-4| ... | ... | @@ -33,8 +33,7 @@ _LIBCPP_PUSH_MACROS |
| 33 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | |
| 35 | 35 | namespace ranges { |
| 36 | namespace __remove { | |
| 37 | struct __fn { | |
| 36 | struct __remove { | |
| 38 | 37 | template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> |
| 39 | 38 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> |
| 40 | 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> |
| ... | ... | @@ -52,10 +51,9 @@ struct __fn { |
| 52 | 51 | return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 53 | 52 | } |
| 54 | 53 | }; |
| 55 | } // namespace __remove | |
| 56 | 54 | |
| 57 | 55 | inline namespace __cpo { |
| 58 | inline constexpr auto remove = __remove::__fn{}; | |
| 56 | inline constexpr auto remove = __remove{}; | |
| 59 | 57 | } // namespace __cpo |
| 60 | 58 | } // namespace ranges |
| 61 | 59 |
lib/libcxx/include/__algorithm/ranges_remove_copy.h+2-6| ... | ... | @@ -38,9 +38,7 @@ namespace ranges { |
| 38 | 38 | template <class _InIter, class _OutIter> |
| 39 | 39 | using remove_copy_result = in_out_result<_InIter, _OutIter>; |
| 40 | 40 | |
| 41 | namespace __remove_copy { | |
| 42 | ||
| 43 | struct __fn { | |
| 41 | struct __remove_copy { | |
| 44 | 42 | template <input_iterator _InIter, |
| 45 | 43 | sentinel_for<_InIter> _Sent, |
| 46 | 44 | weakly_incrementable _OutIter, |
| ... | ... | @@ -65,10 +63,8 @@ struct __fn { |
| 65 | 63 | } |
| 66 | 64 | }; |
| 67 | 65 | |
| 68 | } // namespace __remove_copy | |
| 69 | ||
| 70 | 66 | inline namespace __cpo { |
| 71 | inline constexpr auto remove_copy = __remove_copy::__fn{}; | |
| 67 | inline constexpr auto remove_copy = __remove_copy{}; | |
| 72 | 68 | } // namespace __cpo |
| 73 | 69 | } // namespace ranges |
| 74 | 70 |
lib/libcxx/include/__algorithm/ranges_remove_copy_if.h+2-6| ... | ... | @@ -53,9 +53,7 @@ __remove_copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& _ |
| 53 | 53 | return {std::move(__first), std::move(__result)}; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | namespace __remove_copy_if { | |
| 57 | ||
| 58 | struct __fn { | |
| 56 | struct __remove_copy_if { | |
| 59 | 57 | template <input_iterator _InIter, |
| 60 | 58 | sentinel_for<_InIter> _Sent, |
| 61 | 59 | weakly_incrementable _OutIter, |
| ... | ... | @@ -79,10 +77,8 @@ struct __fn { |
| 79 | 77 | } |
| 80 | 78 | }; |
| 81 | 79 | |
| 82 | } // namespace __remove_copy_if | |
| 83 | ||
| 84 | 80 | inline namespace __cpo { |
| 85 | inline constexpr auto remove_copy_if = __remove_copy_if::__fn{}; | |
| 81 | inline constexpr auto remove_copy_if = __remove_copy_if{}; | |
| 86 | 82 | } // namespace __cpo |
| 87 | 83 | } // namespace ranges |
| 88 | 84 |
lib/libcxx/include/__algorithm/ranges_remove_if.h+2-4| ... | ... | @@ -53,8 +53,7 @@ __remove_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { |
| 53 | 53 | return {__new_end, __i}; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | namespace __remove_if { | |
| 57 | struct __fn { | |
| 56 | struct __remove_if { | |
| 58 | 57 | template <permutable _Iter, |
| 59 | 58 | sentinel_for<_Iter> _Sent, |
| 60 | 59 | class _Proj = identity, |
| ... | ... | @@ -73,10 +72,9 @@ struct __fn { |
| 73 | 72 | return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); |
| 74 | 73 | } |
| 75 | 74 | }; |
| 76 | } // namespace __remove_if | |
| 77 | 75 | |
| 78 | 76 | inline namespace __cpo { |
| 79 | inline constexpr auto remove_if = __remove_if::__fn{}; | |
| 77 | inline constexpr auto remove_if = __remove_if{}; | |
| 80 | 78 | } // namespace __cpo |
| 81 | 79 | } // namespace ranges |
| 82 | 80 |
lib/libcxx/include/__algorithm/ranges_replace.h+2-4| ... | ... | @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | 34 | namespace ranges { |
| 35 | namespace __replace { | |
| 36 | struct __fn { | |
| 35 | struct __replace { | |
| 37 | 36 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type1, class _Type2, class _Proj = identity> |
| 38 | 37 | requires indirectly_writable<_Iter, const _Type2&> && |
| 39 | 38 | indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type1*> |
| ... | ... | @@ -52,10 +51,9 @@ struct __fn { |
| 52 | 51 | return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj); |
| 53 | 52 | } |
| 54 | 53 | }; |
| 55 | } // namespace __replace | |
| 56 | 54 | |
| 57 | 55 | inline namespace __cpo { |
| 58 | inline constexpr auto replace = __replace::__fn{}; | |
| 56 | inline constexpr auto replace = __replace{}; | |
| 59 | 57 | } // namespace __cpo |
| 60 | 58 | } // namespace ranges |
| 61 | 59 |
lib/libcxx/include/__algorithm/ranges_replace_copy.h+2-6| ... | ... | @@ -38,9 +38,7 @@ namespace ranges { |
| 38 | 38 | template <class _InIter, class _OutIter> |
| 39 | 39 | using replace_copy_result = in_out_result<_InIter, _OutIter>; |
| 40 | 40 | |
| 41 | namespace __replace_copy { | |
| 42 | ||
| 43 | struct __fn { | |
| 41 | struct __replace_copy { | |
| 44 | 42 | template <input_iterator _InIter, |
| 45 | 43 | sentinel_for<_InIter> _Sent, |
| 46 | 44 | class _OldType, |
| ... | ... | @@ -77,10 +75,8 @@ struct __fn { |
| 77 | 75 | } |
| 78 | 76 | }; |
| 79 | 77 | |
| 80 | } // namespace __replace_copy | |
| 81 | ||
| 82 | 78 | inline namespace __cpo { |
| 83 | inline constexpr auto replace_copy = __replace_copy::__fn{}; | |
| 79 | inline constexpr auto replace_copy = __replace_copy{}; | |
| 84 | 80 | } // namespace __cpo |
| 85 | 81 | } // namespace ranges |
| 86 | 82 |
lib/libcxx/include/__algorithm/ranges_replace_copy_if.h+2-6| ... | ... | @@ -52,9 +52,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> __repl |
| 52 | 52 | return {std::move(__first), std::move(__result)}; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | namespace __replace_copy_if { | |
| 56 | ||
| 57 | struct __fn { | |
| 55 | struct __replace_copy_if { | |
| 58 | 56 | template <input_iterator _InIter, |
| 59 | 57 | sentinel_for<_InIter> _Sent, |
| 60 | 58 | class _Type, |
| ... | ... | @@ -82,10 +80,8 @@ struct __fn { |
| 82 | 80 | } |
| 83 | 81 | }; |
| 84 | 82 | |
| 85 | } // namespace __replace_copy_if | |
| 86 | ||
| 87 | 83 | inline namespace __cpo { |
| 88 | inline constexpr auto replace_copy_if = __replace_copy_if::__fn{}; | |
| 84 | inline constexpr auto replace_copy_if = __replace_copy_if{}; | |
| 89 | 85 | } // namespace __cpo |
| 90 | 86 | } // namespace ranges |
| 91 | 87 |
lib/libcxx/include/__algorithm/ranges_replace_if.h+2-4| ... | ... | @@ -42,8 +42,7 @@ __replace_if_impl(_Iter __first, _Sent __last, _Pred& __pred, const _Type& __new |
| 42 | 42 | return __first; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | namespace __replace_if { | |
| 46 | struct __fn { | |
| 45 | struct __replace_if { | |
| 47 | 46 | template <input_iterator _Iter, |
| 48 | 47 | sentinel_for<_Iter> _Sent, |
| 49 | 48 | class _Type, |
| ... | ... | @@ -65,10 +64,9 @@ struct __fn { |
| 65 | 64 | return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj); |
| 66 | 65 | } |
| 67 | 66 | }; |
| 68 | } // namespace __replace_if | |
| 69 | 67 | |
| 70 | 68 | inline namespace __cpo { |
| 71 | inline constexpr auto replace_if = __replace_if::__fn{}; | |
| 69 | inline constexpr auto replace_if = __replace_if{}; | |
| 72 | 70 | } // namespace __cpo |
| 73 | 71 | } // namespace ranges |
| 74 | 72 |
lib/libcxx/include/__algorithm/ranges_reverse.h+2-4| ... | ... | @@ -27,8 +27,7 @@ |
| 27 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | |
| 29 | 29 | namespace ranges { |
| 30 | namespace __reverse { | |
| 31 | struct __fn { | |
| 30 | struct __reverse { | |
| 32 | 31 | template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent> |
| 33 | 32 | requires permutable<_Iter> |
| 34 | 33 | _LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(_Iter __first, _Sent __last) const { |
| ... | ... | @@ -65,10 +64,9 @@ struct __fn { |
| 65 | 64 | return (*this)(ranges::begin(__range), ranges::end(__range)); |
| 66 | 65 | } |
| 67 | 66 | }; |
| 68 | } // namespace __reverse | |
| 69 | 67 | |
| 70 | 68 | inline namespace __cpo { |
| 71 | inline constexpr auto reverse = __reverse::__fn{}; | |
| 69 | inline constexpr auto reverse = __reverse{}; | |
| 72 | 70 | } // namespace __cpo |
| 73 | 71 | } // namespace ranges |
| 74 | 72 |
lib/libcxx/include/__algorithm/ranges_reverse_copy.h+2-4| ... | ... | @@ -37,8 +37,7 @@ namespace ranges { |
| 37 | 37 | template <class _InIter, class _OutIter> |
| 38 | 38 | using reverse_copy_result = in_out_result<_InIter, _OutIter>; |
| 39 | 39 | |
| 40 | namespace __reverse_copy { | |
| 41 | struct __fn { | |
| 40 | struct __reverse_copy { | |
| 42 | 41 | template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> |
| 43 | 42 | requires indirectly_copyable<_InIter, _OutIter> |
| 44 | 43 | _LIBCPP_HIDE_FROM_ABI constexpr reverse_copy_result<_InIter, _OutIter> |
| ... | ... | @@ -54,10 +53,9 @@ struct __fn { |
| 54 | 53 | return {ranges::next(ranges::begin(__range), ranges::end(__range)), std::move(__ret.out)}; |
| 55 | 54 | } |
| 56 | 55 | }; |
| 57 | } // namespace __reverse_copy | |
| 58 | 56 | |
| 59 | 57 | inline namespace __cpo { |
| 60 | inline constexpr auto reverse_copy = __reverse_copy::__fn{}; | |
| 58 | inline constexpr auto reverse_copy = __reverse_copy{}; | |
| 61 | 59 | } // namespace __cpo |
| 62 | 60 | } // namespace ranges |
| 63 | 61 |
lib/libcxx/include/__algorithm/ranges_rotate.h+2-6| ... | ... | @@ -33,9 +33,7 @@ _LIBCPP_PUSH_MACROS |
| 33 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | |
| 35 | 35 | namespace ranges { |
| 36 | namespace __rotate { | |
| 37 | ||
| 38 | struct __fn { | |
| 36 | struct __rotate { | |
| 39 | 37 | template <class _Iter, class _Sent> |
| 40 | 38 | _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter> __rotate_fn_impl(_Iter __first, _Iter __middle, _Sent __last) { |
| 41 | 39 | auto __ret = std::__rotate<_RangeAlgPolicy>(std::move(__first), std::move(__middle), std::move(__last)); |
| ... | ... | @@ -55,10 +53,8 @@ struct __fn { |
| 55 | 53 | } |
| 56 | 54 | }; |
| 57 | 55 | |
| 58 | } // namespace __rotate | |
| 59 | ||
| 60 | 56 | inline namespace __cpo { |
| 61 | inline constexpr auto rotate = __rotate::__fn{}; | |
| 57 | inline constexpr auto rotate = __rotate{}; | |
| 62 | 58 | } // namespace __cpo |
| 63 | 59 | } // namespace ranges |
| 64 | 60 |
lib/libcxx/include/__algorithm/ranges_rotate_copy.h+2-4| ... | ... | @@ -34,8 +34,7 @@ namespace ranges { |
| 34 | 34 | template <class _InIter, class _OutIter> |
| 35 | 35 | using rotate_copy_result = in_out_result<_InIter, _OutIter>; |
| 36 | 36 | |
| 37 | namespace __rotate_copy { | |
| 38 | struct __fn { | |
| 37 | struct __rotate_copy { | |
| 39 | 38 | template <forward_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> |
| 40 | 39 | requires indirectly_copyable<_InIter, _OutIter> |
| 41 | 40 | _LIBCPP_HIDE_FROM_ABI constexpr rotate_copy_result<_InIter, _OutIter> |
| ... | ... | @@ -52,10 +51,9 @@ struct __fn { |
| 52 | 51 | return (*this)(ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__result)); |
| 53 | 52 | } |
| 54 | 53 | }; |
| 55 | } // namespace __rotate_copy | |
| 56 | 54 | |
| 57 | 55 | inline namespace __cpo { |
| 58 | inline constexpr auto rotate_copy = __rotate_copy::__fn{}; | |
| 56 | inline constexpr auto rotate_copy = __rotate_copy{}; | |
| 59 | 57 | } // namespace __cpo |
| 60 | 58 | } // namespace ranges |
| 61 | 59 |
lib/libcxx/include/__algorithm/ranges_sample.h+2-6| ... | ... | @@ -35,9 +35,7 @@ _LIBCPP_PUSH_MACROS |
| 35 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 36 | |
| 37 | 37 | namespace ranges { |
| 38 | namespace __sample { | |
| 39 | ||
| 40 | struct __fn { | |
| 38 | struct __sample { | |
| 41 | 39 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Gen> |
| 42 | 40 | requires(forward_iterator<_Iter> || random_access_iterator<_OutIter>) && indirectly_copyable<_Iter, _OutIter> && |
| 43 | 41 | uniform_random_bit_generator<remove_reference_t<_Gen>> |
| ... | ... | @@ -58,10 +56,8 @@ struct __fn { |
| 58 | 56 | } |
| 59 | 57 | }; |
| 60 | 58 | |
| 61 | } // namespace __sample | |
| 62 | ||
| 63 | 59 | inline namespace __cpo { |
| 64 | inline constexpr auto sample = __sample::__fn{}; | |
| 60 | inline constexpr auto sample = __sample{}; | |
| 65 | 61 | } // namespace __cpo |
| 66 | 62 | } // namespace ranges |
| 67 | 63 |
lib/libcxx/include/__algorithm/ranges_search.h+2-4| ... | ... | @@ -33,8 +33,7 @@ |
| 33 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | |
| 35 | 35 | namespace ranges { |
| 36 | namespace __search { | |
| 37 | struct __fn { | |
| 36 | struct __search { | |
| 38 | 37 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> |
| 39 | 38 | _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_impl( |
| 40 | 39 | _Iter1 __first1, |
| ... | ... | @@ -120,10 +119,9 @@ struct __fn { |
| 120 | 119 | __proj2); |
| 121 | 120 | } |
| 122 | 121 | }; |
| 123 | } // namespace __search | |
| 124 | 122 | |
| 125 | 123 | inline namespace __cpo { |
| 126 | inline constexpr auto search = __search::__fn{}; | |
| 124 | inline constexpr auto search = __search{}; | |
| 127 | 125 | } // namespace __cpo |
| 128 | 126 | } // namespace ranges |
| 129 | 127 |
lib/libcxx/include/__algorithm/ranges_search_n.h+2-4| ... | ... | @@ -39,8 +39,7 @@ _LIBCPP_PUSH_MACROS |
| 39 | 39 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | 40 | |
| 41 | 41 | namespace ranges { |
| 42 | namespace __search_n { | |
| 43 | struct __fn { | |
| 42 | struct __search_n { | |
| 44 | 43 | template <class _Iter1, class _Sent1, class _SizeT, class _Type, class _Pred, class _Proj> |
| 45 | 44 | _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_n_impl( |
| 46 | 45 | _Iter1 __first, _Sent1 __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) { |
| ... | ... | @@ -100,10 +99,9 @@ struct __fn { |
| 100 | 99 | return __ranges_search_n_impl(ranges::begin(__range), ranges::end(__range), __count, __value, __pred, __proj); |
| 101 | 100 | } |
| 102 | 101 | }; |
| 103 | } // namespace __search_n | |
| 104 | 102 | |
| 105 | 103 | inline namespace __cpo { |
| 106 | inline constexpr auto search_n = __search_n::__fn{}; | |
| 104 | inline constexpr auto search_n = __search_n{}; | |
| 107 | 105 | } // namespace __cpo |
| 108 | 106 | } // namespace ranges |
| 109 | 107 |
lib/libcxx/include/__algorithm/ranges_set_difference.h+4-9| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/in_out_result.h> |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 14 | 13 | #include <__algorithm/make_projected.h> |
| 15 | 14 | #include <__algorithm/set_difference.h> |
| 16 | 15 | #include <__config> |
| ... | ... | @@ -42,9 +41,7 @@ namespace ranges { |
| 42 | 41 | template <class _InIter, class _OutIter> |
| 43 | 42 | using set_difference_result = in_out_result<_InIter, _OutIter>; |
| 44 | 43 | |
| 45 | namespace __set_difference { | |
| 46 | ||
| 47 | struct __fn { | |
| 44 | struct __set_difference { | |
| 48 | 45 | template <input_iterator _InIter1, |
| 49 | 46 | sentinel_for<_InIter1> _Sent1, |
| 50 | 47 | input_iterator _InIter2, |
| ... | ... | @@ -63,7 +60,7 @@ struct __fn { |
| 63 | 60 | _Comp __comp = {}, |
| 64 | 61 | _Proj1 __proj1 = {}, |
| 65 | 62 | _Proj2 __proj2 = {}) const { |
| 66 | auto __ret = std::__set_difference<_RangeAlgPolicy>( | |
| 63 | auto __ret = std::__set_difference( | |
| 67 | 64 | __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2)); |
| 68 | 65 | return {std::move(__ret.first), std::move(__ret.second)}; |
| 69 | 66 | } |
| ... | ... | @@ -82,7 +79,7 @@ struct __fn { |
| 82 | 79 | _Comp __comp = {}, |
| 83 | 80 | _Proj1 __proj1 = {}, |
| 84 | 81 | _Proj2 __proj2 = {}) const { |
| 85 | auto __ret = std::__set_difference<_RangeAlgPolicy>( | |
| 82 | auto __ret = std::__set_difference( | |
| 86 | 83 | ranges::begin(__range1), |
| 87 | 84 | ranges::end(__range1), |
| 88 | 85 | ranges::begin(__range2), |
| ... | ... | @@ -93,10 +90,8 @@ struct __fn { |
| 93 | 90 | } |
| 94 | 91 | }; |
| 95 | 92 | |
| 96 | } // namespace __set_difference | |
| 97 | ||
| 98 | 93 | inline namespace __cpo { |
| 99 | inline constexpr auto set_difference = __set_difference::__fn{}; | |
| 94 | inline constexpr auto set_difference = __set_difference{}; | |
| 100 | 95 | } // namespace __cpo |
| 101 | 96 | } // namespace ranges |
| 102 | 97 |
lib/libcxx/include/__algorithm/ranges_set_intersection.h+2-6| ... | ... | @@ -40,9 +40,7 @@ namespace ranges { |
| 40 | 40 | template <class _InIter1, class _InIter2, class _OutIter> |
| 41 | 41 | using set_intersection_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; |
| 42 | 42 | |
| 43 | namespace __set_intersection { | |
| 44 | ||
| 45 | struct __fn { | |
| 43 | struct __set_intersection { | |
| 46 | 44 | template <input_iterator _InIter1, |
| 47 | 45 | sentinel_for<_InIter1> _Sent1, |
| 48 | 46 | input_iterator _InIter2, |
| ... | ... | @@ -98,10 +96,8 @@ struct __fn { |
| 98 | 96 | } |
| 99 | 97 | }; |
| 100 | 98 | |
| 101 | } // namespace __set_intersection | |
| 102 | ||
| 103 | 99 | inline namespace __cpo { |
| 104 | inline constexpr auto set_intersection = __set_intersection::__fn{}; | |
| 100 | inline constexpr auto set_intersection = __set_intersection{}; | |
| 105 | 101 | } // namespace __cpo |
| 106 | 102 | } // namespace ranges |
| 107 | 103 |
lib/libcxx/include/__algorithm/ranges_set_symmetric_difference.h+4-9| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/in_in_out_result.h> |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 14 | 13 | #include <__algorithm/make_projected.h> |
| 15 | 14 | #include <__algorithm/set_symmetric_difference.h> |
| 16 | 15 | #include <__config> |
| ... | ... | @@ -40,9 +39,7 @@ namespace ranges { |
| 40 | 39 | template <class _InIter1, class _InIter2, class _OutIter> |
| 41 | 40 | using set_symmetric_difference_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; |
| 42 | 41 | |
| 43 | namespace __set_symmetric_difference { | |
| 44 | ||
| 45 | struct __fn { | |
| 42 | struct __set_symmetric_difference { | |
| 46 | 43 | template <input_iterator _InIter1, |
| 47 | 44 | sentinel_for<_InIter1> _Sent1, |
| 48 | 45 | input_iterator _InIter2, |
| ... | ... | @@ -61,7 +58,7 @@ struct __fn { |
| 61 | 58 | _Comp __comp = {}, |
| 62 | 59 | _Proj1 __proj1 = {}, |
| 63 | 60 | _Proj2 __proj2 = {}) const { |
| 64 | auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>( | |
| 61 | auto __ret = std::__set_symmetric_difference( | |
| 65 | 62 | std::move(__first1), |
| 66 | 63 | std::move(__last1), |
| 67 | 64 | std::move(__first2), |
| ... | ... | @@ -87,7 +84,7 @@ struct __fn { |
| 87 | 84 | _Comp __comp = {}, |
| 88 | 85 | _Proj1 __proj1 = {}, |
| 89 | 86 | _Proj2 __proj2 = {}) const { |
| 90 | auto __ret = std::__set_symmetric_difference<_RangeAlgPolicy>( | |
| 87 | auto __ret = std::__set_symmetric_difference( | |
| 91 | 88 | ranges::begin(__range1), |
| 92 | 89 | ranges::end(__range1), |
| 93 | 90 | ranges::begin(__range2), |
| ... | ... | @@ -98,10 +95,8 @@ struct __fn { |
| 98 | 95 | } |
| 99 | 96 | }; |
| 100 | 97 | |
| 101 | } // namespace __set_symmetric_difference | |
| 102 | ||
| 103 | 98 | inline namespace __cpo { |
| 104 | inline constexpr auto set_symmetric_difference = __set_symmetric_difference::__fn{}; | |
| 99 | inline constexpr auto set_symmetric_difference = __set_symmetric_difference{}; | |
| 105 | 100 | } // namespace __cpo |
| 106 | 101 | } // namespace ranges |
| 107 | 102 |
lib/libcxx/include/__algorithm/ranges_set_union.h+4-9| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/in_in_out_result.h> |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 14 | 13 | #include <__algorithm/make_projected.h> |
| 15 | 14 | #include <__algorithm/set_union.h> |
| 16 | 15 | #include <__config> |
| ... | ... | @@ -43,9 +42,7 @@ namespace ranges { |
| 43 | 42 | template <class _InIter1, class _InIter2, class _OutIter> |
| 44 | 43 | using set_union_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; |
| 45 | 44 | |
| 46 | namespace __set_union { | |
| 47 | ||
| 48 | struct __fn { | |
| 45 | struct __set_union { | |
| 49 | 46 | template <input_iterator _InIter1, |
| 50 | 47 | sentinel_for<_InIter1> _Sent1, |
| 51 | 48 | input_iterator _InIter2, |
| ... | ... | @@ -64,7 +61,7 @@ struct __fn { |
| 64 | 61 | _Comp __comp = {}, |
| 65 | 62 | _Proj1 __proj1 = {}, |
| 66 | 63 | _Proj2 __proj2 = {}) const { |
| 67 | auto __ret = std::__set_union<_RangeAlgPolicy>( | |
| 64 | auto __ret = std::__set_union( | |
| 68 | 65 | std::move(__first1), |
| 69 | 66 | std::move(__last1), |
| 70 | 67 | std::move(__first2), |
| ... | ... | @@ -88,7 +85,7 @@ struct __fn { |
| 88 | 85 | _Comp __comp = {}, |
| 89 | 86 | _Proj1 __proj1 = {}, |
| 90 | 87 | _Proj2 __proj2 = {}) const { |
| 91 | auto __ret = std::__set_union<_RangeAlgPolicy>( | |
| 88 | auto __ret = std::__set_union( | |
| 92 | 89 | ranges::begin(__range1), |
| 93 | 90 | ranges::end(__range1), |
| 94 | 91 | ranges::begin(__range2), |
| ... | ... | @@ -99,10 +96,8 @@ struct __fn { |
| 99 | 96 | } |
| 100 | 97 | }; |
| 101 | 98 | |
| 102 | } // namespace __set_union | |
| 103 | ||
| 104 | 99 | inline namespace __cpo { |
| 105 | inline constexpr auto set_union = __set_union::__fn{}; | |
| 100 | inline constexpr auto set_union = __set_union{}; | |
| 106 | 101 | } // namespace __cpo |
| 107 | 102 | } // namespace ranges |
| 108 | 103 |
lib/libcxx/include/__algorithm/ranges_shuffle.h+2-6| ... | ... | @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS |
| 39 | 39 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | 40 | |
| 41 | 41 | namespace ranges { |
| 42 | namespace __shuffle { | |
| 43 | ||
| 44 | struct __fn { | |
| 42 | struct __shuffle { | |
| 45 | 43 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen> |
| 46 | 44 | requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>> |
| 47 | 45 | _LIBCPP_HIDE_FROM_ABI _Iter operator()(_Iter __first, _Sent __last, _Gen&& __gen) const { |
| ... | ... | @@ -56,10 +54,8 @@ struct __fn { |
| 56 | 54 | } |
| 57 | 55 | }; |
| 58 | 56 | |
| 59 | } // namespace __shuffle | |
| 60 | ||
| 61 | 57 | inline namespace __cpo { |
| 62 | inline constexpr auto shuffle = __shuffle::__fn{}; | |
| 58 | inline constexpr auto shuffle = __shuffle{}; | |
| 63 | 59 | } // namespace __cpo |
| 64 | 60 | } // namespace ranges |
| 65 | 61 |
lib/libcxx/include/__algorithm/ranges_sort.h+2-6| ... | ... | @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS |
| 39 | 39 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | 40 | |
| 41 | 41 | namespace ranges { |
| 42 | namespace __sort { | |
| 43 | ||
| 44 | struct __fn { | |
| 42 | struct __sort { | |
| 45 | 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 46 | 44 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter |
| 47 | 45 | __sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| ... | ... | @@ -68,10 +66,8 @@ struct __fn { |
| 68 | 66 | } |
| 69 | 67 | }; |
| 70 | 68 | |
| 71 | } // namespace __sort | |
| 72 | ||
| 73 | 69 | inline namespace __cpo { |
| 74 | inline constexpr auto sort = __sort::__fn{}; | |
| 70 | inline constexpr auto sort = __sort{}; | |
| 75 | 71 | } // namespace __cpo |
| 76 | 72 | } // namespace ranges |
| 77 | 73 |
lib/libcxx/include/__algorithm/ranges_sort_heap.h+2-6| ... | ... | @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS |
| 40 | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 41 | |
| 42 | 42 | namespace ranges { |
| 43 | namespace __sort_heap { | |
| 44 | ||
| 45 | struct __fn { | |
| 43 | struct __sort_heap { | |
| 46 | 44 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 47 | 45 | _LIBCPP_HIDE_FROM_ABI constexpr static _Iter |
| 48 | 46 | __sort_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| ... | ... | @@ -69,10 +67,8 @@ struct __fn { |
| 69 | 67 | } |
| 70 | 68 | }; |
| 71 | 69 | |
| 72 | } // namespace __sort_heap | |
| 73 | ||
| 74 | 70 | inline namespace __cpo { |
| 75 | inline constexpr auto sort_heap = __sort_heap::__fn{}; | |
| 71 | inline constexpr auto sort_heap = __sort_heap{}; | |
| 76 | 72 | } // namespace __cpo |
| 77 | 73 | } // namespace ranges |
| 78 | 74 |
lib/libcxx/include/__algorithm/ranges_stable_partition.h+2-6| ... | ... | @@ -42,9 +42,7 @@ _LIBCPP_PUSH_MACROS |
| 42 | 42 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 43 | 43 | |
| 44 | 44 | namespace ranges { |
| 45 | namespace __stable_partition { | |
| 46 | ||
| 47 | struct __fn { | |
| 45 | struct __stable_partition { | |
| 48 | 46 | template <class _Iter, class _Sent, class _Proj, class _Pred> |
| 49 | 47 | _LIBCPP_HIDE_FROM_ABI static subrange<__remove_cvref_t<_Iter>> |
| 50 | 48 | __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) { |
| ... | ... | @@ -76,10 +74,8 @@ struct __fn { |
| 76 | 74 | } |
| 77 | 75 | }; |
| 78 | 76 | |
| 79 | } // namespace __stable_partition | |
| 80 | ||
| 81 | 77 | inline namespace __cpo { |
| 82 | inline constexpr auto stable_partition = __stable_partition::__fn{}; | |
| 78 | inline constexpr auto stable_partition = __stable_partition{}; | |
| 83 | 79 | } // namespace __cpo |
| 84 | 80 | } // namespace ranges |
| 85 | 81 |
lib/libcxx/include/__algorithm/ranges_stable_sort.h+2-6| ... | ... | @@ -39,9 +39,7 @@ _LIBCPP_PUSH_MACROS |
| 39 | 39 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | 40 | |
| 41 | 41 | namespace ranges { |
| 42 | namespace __stable_sort { | |
| 43 | ||
| 44 | struct __fn { | |
| 42 | struct __stable_sort { | |
| 45 | 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> |
| 46 | 44 | _LIBCPP_HIDE_FROM_ABI static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { |
| 47 | 45 | auto __last_iter = ranges::next(__first, __last); |
| ... | ... | @@ -66,10 +64,8 @@ struct __fn { |
| 66 | 64 | } |
| 67 | 65 | }; |
| 68 | 66 | |
| 69 | } // namespace __stable_sort | |
| 70 | ||
| 71 | 67 | inline namespace __cpo { |
| 72 | inline constexpr auto stable_sort = __stable_sort::__fn{}; | |
| 68 | inline constexpr auto stable_sort = __stable_sort{}; | |
| 73 | 69 | } // namespace __cpo |
| 74 | 70 | } // namespace ranges |
| 75 | 71 |
lib/libcxx/include/__algorithm/ranges_starts_with.h+4-6| ... | ... | @@ -32,8 +32,7 @@ _LIBCPP_PUSH_MACROS |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | 34 | namespace ranges { |
| 35 | namespace __starts_with { | |
| 36 | struct __fn { | |
| 35 | struct __starts_with { | |
| 37 | 36 | template <input_iterator _Iter1, |
| 38 | 37 | sentinel_for<_Iter1> _Sent1, |
| 39 | 38 | input_iterator _Iter2, |
| ... | ... | @@ -50,7 +49,7 @@ struct __fn { |
| 50 | 49 | _Pred __pred = {}, |
| 51 | 50 | _Proj1 __proj1 = {}, |
| 52 | 51 | _Proj2 __proj2 = {}) { |
| 53 | return __mismatch::__fn::__go( | |
| 52 | return __mismatch::__go( | |
| 54 | 53 | std::move(__first1), |
| 55 | 54 | std::move(__last1), |
| 56 | 55 | std::move(__first2), |
| ... | ... | @@ -69,7 +68,7 @@ struct __fn { |
| 69 | 68 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> |
| 70 | 69 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool |
| 71 | 70 | operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) { |
| 72 | return __mismatch::__fn::__go( | |
| 71 | return __mismatch::__go( | |
| 73 | 72 | ranges::begin(__range1), |
| 74 | 73 | ranges::end(__range1), |
| 75 | 74 | ranges::begin(__range2), |
| ... | ... | @@ -80,9 +79,8 @@ struct __fn { |
| 80 | 79 | .in2 == ranges::end(__range2); |
| 81 | 80 | } |
| 82 | 81 | }; |
| 83 | } // namespace __starts_with | |
| 84 | 82 | inline namespace __cpo { |
| 85 | inline constexpr auto starts_with = __starts_with::__fn{}; | |
| 83 | inline constexpr auto starts_with = __starts_with{}; | |
| 86 | 84 | } // namespace __cpo |
| 87 | 85 | } // namespace ranges |
| 88 | 86 |
lib/libcxx/include/__algorithm/ranges_swap_ranges.h+2-4| ... | ... | @@ -36,8 +36,7 @@ namespace ranges { |
| 36 | 36 | template <class _I1, class _I2> |
| 37 | 37 | using swap_ranges_result = in_in_result<_I1, _I2>; |
| 38 | 38 | |
| 39 | namespace __swap_ranges { | |
| 40 | struct __fn { | |
| 39 | struct __swap_ranges { | |
| 41 | 40 | template <input_iterator _I1, sentinel_for<_I1> _S1, input_iterator _I2, sentinel_for<_I2> _S2> |
| 42 | 41 | requires indirectly_swappable<_I1, _I2> |
| 43 | 42 | _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2> |
| ... | ... | @@ -54,10 +53,9 @@ struct __fn { |
| 54 | 53 | return operator()(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2)); |
| 55 | 54 | } |
| 56 | 55 | }; |
| 57 | } // namespace __swap_ranges | |
| 58 | 56 | |
| 59 | 57 | inline namespace __cpo { |
| 60 | inline constexpr auto swap_ranges = __swap_ranges::__fn{}; | |
| 58 | inline constexpr auto swap_ranges = __swap_ranges{}; | |
| 61 | 59 | } // namespace __cpo |
| 62 | 60 | } // namespace ranges |
| 63 | 61 |
lib/libcxx/include/__algorithm/ranges_transform.h+2-4| ... | ... | @@ -41,8 +41,7 @@ using unary_transform_result = in_out_result<_Ip, _Op>; |
| 41 | 41 | template <class _I1, class _I2, class _O1> |
| 42 | 42 | using binary_transform_result = in_in_out_result<_I1, _I2, _O1>; |
| 43 | 43 | |
| 44 | namespace __transform { | |
| 45 | struct __fn { | |
| 44 | struct __transform { | |
| 46 | 45 | private: |
| 47 | 46 | template <class _InIter, class _Sent, class _OutIter, class _Func, class _Proj> |
| 48 | 47 | _LIBCPP_HIDE_FROM_ABI static constexpr unary_transform_result<_InIter, _OutIter> |
| ... | ... | @@ -161,10 +160,9 @@ public: |
| 161 | 160 | __projection2); |
| 162 | 161 | } |
| 163 | 162 | }; |
| 164 | } // namespace __transform | |
| 165 | 163 | |
| 166 | 164 | inline namespace __cpo { |
| 167 | inline constexpr auto transform = __transform::__fn{}; | |
| 165 | inline constexpr auto transform = __transform{}; | |
| 168 | 166 | } // namespace __cpo |
| 169 | 167 | } // namespace ranges |
| 170 | 168 |
lib/libcxx/include/__algorithm/ranges_unique.h+2-6| ... | ... | @@ -40,9 +40,7 @@ _LIBCPP_PUSH_MACROS |
| 40 | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 41 | |
| 42 | 42 | namespace ranges { |
| 43 | namespace __unique { | |
| 44 | ||
| 45 | struct __fn { | |
| 43 | struct __unique { | |
| 46 | 44 | template <permutable _Iter, |
| 47 | 45 | sentinel_for<_Iter> _Sent, |
| 48 | 46 | class _Proj = identity, |
| ... | ... | @@ -66,10 +64,8 @@ struct __fn { |
| 66 | 64 | } |
| 67 | 65 | }; |
| 68 | 66 | |
| 69 | } // namespace __unique | |
| 70 | ||
| 71 | 67 | inline namespace __cpo { |
| 72 | inline constexpr auto unique = __unique::__fn{}; | |
| 68 | inline constexpr auto unique = __unique{}; | |
| 73 | 69 | } // namespace __cpo |
| 74 | 70 | } // namespace ranges |
| 75 | 71 |
lib/libcxx/include/__algorithm/ranges_unique_copy.h+3-7| ... | ... | @@ -44,12 +44,10 @@ namespace ranges { |
| 44 | 44 | template <class _InIter, class _OutIter> |
| 45 | 45 | using unique_copy_result = in_out_result<_InIter, _OutIter>; |
| 46 | 46 | |
| 47 | namespace __unique_copy { | |
| 48 | ||
| 49 | 47 | template <class _InIter, class _OutIter> |
| 50 | 48 | concept __can_reread_from_output = (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>); |
| 51 | 49 | |
| 52 | struct __fn { | |
| 50 | struct __unique_copy { | |
| 53 | 51 | template <class _InIter, class _OutIter> |
| 54 | 52 | static consteval auto __get_algo_tag() { |
| 55 | 53 | if constexpr (forward_iterator<_InIter>) { |
| ... | ... | @@ -62,7 +60,7 @@ struct __fn { |
| 62 | 60 | } |
| 63 | 61 | |
| 64 | 62 | template <class _InIter, class _OutIter> |
| 65 | using __algo_tag_t = decltype(__get_algo_tag<_InIter, _OutIter>()); | |
| 63 | using __algo_tag_t _LIBCPP_NODEBUG = decltype(__get_algo_tag<_InIter, _OutIter>()); | |
| 66 | 64 | |
| 67 | 65 | template <input_iterator _InIter, |
| 68 | 66 | sentinel_for<_InIter> _Sent, |
| ... | ... | @@ -104,10 +102,8 @@ struct __fn { |
| 104 | 102 | } |
| 105 | 103 | }; |
| 106 | 104 | |
| 107 | } // namespace __unique_copy | |
| 108 | ||
| 109 | 105 | inline namespace __cpo { |
| 110 | inline constexpr auto unique_copy = __unique_copy::__fn{}; | |
| 106 | inline constexpr auto unique_copy = __unique_copy{}; | |
| 111 | 107 | } // namespace __cpo |
| 112 | 108 | } // namespace ranges |
| 113 | 109 |
lib/libcxx/include/__algorithm/ranges_upper_bound.h+2-4| ... | ... | @@ -30,8 +30,7 @@ |
| 30 | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 31 | |
| 32 | 32 | namespace ranges { |
| 33 | namespace __upper_bound { | |
| 34 | struct __fn { | |
| 33 | struct __upper_bound { | |
| 35 | 34 | template <forward_iterator _Iter, |
| 36 | 35 | sentinel_for<_Iter> _Sent, |
| 37 | 36 | class _Type, |
| ... | ... | @@ -60,10 +59,9 @@ struct __fn { |
| 60 | 59 | ranges::begin(__r), ranges::end(__r), __value, __comp_lhs_rhs_swapped, __proj); |
| 61 | 60 | } |
| 62 | 61 | }; |
| 63 | } // namespace __upper_bound | |
| 64 | 62 | |
| 65 | 63 | inline namespace __cpo { |
| 66 | inline constexpr auto upper_bound = __upper_bound::__fn{}; | |
| 64 | inline constexpr auto upper_bound = __upper_bound{}; | |
| 67 | 65 | } // namespace __cpo |
| 68 | 66 | } // namespace ranges |
| 69 | 67 |
lib/libcxx/include/__algorithm/remove.h+1-1| ... | ... | @@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | |
| 26 | 26 | template <class _ForwardIterator, class _Tp> |
| 27 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 27 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 28 | 28 | remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 29 | 29 | __first = std::find(__first, __last, __value); |
| 30 | 30 | if (__first != __last) { |
lib/libcxx/include/__algorithm/remove_if.h+1-1| ... | ... | @@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | 25 | template <class _ForwardIterator, class _Predicate> |
| 26 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 26 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 27 | 27 | remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { |
| 28 | 28 | __first = std::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred); |
| 29 | 29 | if (__first != __last) { |
lib/libcxx/include/__algorithm/search.h+5-5| ... | ... | @@ -14,11 +14,11 @@ |
| 14 | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | 15 | #include <__config> |
| 16 | 16 | #include <__functional/identity.h> |
| 17 | #include <__functional/invoke.h> | |
| 18 | 17 | #include <__iterator/advance.h> |
| 19 | 18 | #include <__iterator/concepts.h> |
| 20 | 19 | #include <__iterator/iterator_traits.h> |
| 21 | 20 | #include <__type_traits/enable_if.h> |
| 21 | #include <__type_traits/invoke.h> | |
| 22 | 22 | #include <__type_traits/is_callable.h> |
| 23 | 23 | #include <__utility/pair.h> |
| 24 | 24 | |
| ... | ... | @@ -160,20 +160,20 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __searc |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 163 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 | |
| 163 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 | |
| 164 | 164 | search(_ForwardIterator1 __first1, |
| 165 | 165 | _ForwardIterator1 __last1, |
| 166 | 166 | _ForwardIterator2 __first2, |
| 167 | 167 | _ForwardIterator2 __last2, |
| 168 | 168 | _BinaryPredicate __pred) { |
| 169 | static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, | |
| 170 | "BinaryPredicate has to be callable"); | |
| 169 | static_assert(__is_callable<_BinaryPredicate&, decltype(*__first1), decltype(*__first2)>::value, | |
| 170 | "The comparator has to be callable"); | |
| 171 | 171 | auto __proj = __identity(); |
| 172 | 172 | return std::__search_impl(__first1, __last1, __first2, __last2, __pred, __proj, __proj).first; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 176 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 | |
| 176 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 | |
| 177 | 177 | search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { |
| 178 | 178 | return std::search(__first1, __last1, __first2, __last2, __equal_to()); |
| 179 | 179 | } |
lib/libcxx/include/__algorithm/search_n.h+5-4| ... | ... | @@ -14,12 +14,13 @@ |
| 14 | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | 15 | #include <__config> |
| 16 | 16 | #include <__functional/identity.h> |
| 17 | #include <__functional/invoke.h> | |
| 18 | 17 | #include <__iterator/advance.h> |
| 19 | 18 | #include <__iterator/concepts.h> |
| 20 | 19 | #include <__iterator/distance.h> |
| 21 | 20 | #include <__iterator/iterator_traits.h> |
| 22 | 21 | #include <__ranges/concepts.h> |
| 22 | #include <__type_traits/enable_if.h> | |
| 23 | #include <__type_traits/invoke.h> | |
| 23 | 24 | #include <__type_traits/is_callable.h> |
| 24 | 25 | #include <__utility/convert_to_integral.h> |
| 25 | 26 | #include <__utility/pair.h> |
| ... | ... | @@ -136,16 +137,16 @@ __search_n_impl(_Iter1 __first, _Sent1 __last, _DiffT __count, const _Type& __va |
| 136 | 137 | } |
| 137 | 138 | |
| 138 | 139 | template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate> |
| 139 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n( | |
| 140 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n( | |
| 140 | 141 | _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value, _BinaryPredicate __pred) { |
| 141 | 142 | static_assert( |
| 142 | __is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value, "BinaryPredicate has to be callable"); | |
| 143 | __is_callable<_BinaryPredicate&, decltype(*__first), const _Tp&>::value, "The comparator has to be callable"); | |
| 143 | 144 | auto __proj = __identity(); |
| 144 | 145 | return std::__search_n_impl(__first, __last, std::__convert_to_integral(__count), __value, __pred, __proj).first; |
| 145 | 146 | } |
| 146 | 147 | |
| 147 | 148 | template <class _ForwardIterator, class _Size, class _Tp> |
| 148 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 149 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 149 | 150 | search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) { |
| 150 | 151 | return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to()); |
| 151 | 152 | } |
lib/libcxx/include/__algorithm/set_difference.h+4-7| ... | ... | @@ -12,10 +12,8 @@ |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/copy.h> |
| 15 | #include <__algorithm/iterator_operations.h> | |
| 16 | 15 | #include <__config> |
| 17 | 16 | #include <__functional/identity.h> |
| 18 | #include <__functional/invoke.h> | |
| 19 | 17 | #include <__iterator/iterator_traits.h> |
| 20 | 18 | #include <__type_traits/remove_cvref.h> |
| 21 | 19 | #include <__utility/move.h> |
| ... | ... | @@ -30,7 +28,7 @@ _LIBCPP_PUSH_MACROS |
| 30 | 28 | |
| 31 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 30 | |
| 33 | template <class _AlgPolicy, class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | |
| 31 | template <class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | |
| 34 | 32 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> > |
| 35 | 33 | __set_difference( |
| 36 | 34 | _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) { |
| ... | ... | @@ -46,7 +44,7 @@ __set_difference( |
| 46 | 44 | ++__first2; |
| 47 | 45 | } |
| 48 | 46 | } |
| 49 | return std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 47 | return std::__copy(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 50 | 48 | } |
| 51 | 49 | |
| 52 | 50 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare> |
| ... | ... | @@ -57,8 +55,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d |
| 57 | 55 | _InputIterator2 __last2, |
| 58 | 56 | _OutputIterator __result, |
| 59 | 57 | _Compare __comp) { |
| 60 | return std::__set_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >( | |
| 61 | __first1, __last1, __first2, __last2, __result, __comp) | |
| 58 | return std::__set_difference<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp) | |
| 62 | 59 | .second; |
| 63 | 60 | } |
| 64 | 61 | |
| ... | ... | @@ -69,7 +66,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d |
| 69 | 66 | _InputIterator2 __first2, |
| 70 | 67 | _InputIterator2 __last2, |
| 71 | 68 | _OutputIterator __result) { |
| 72 | return std::__set_difference<_ClassicAlgPolicy>(__first1, __last1, __first2, __last2, __result, __less<>()).second; | |
| 69 | return std::__set_difference(__first1, __last1, __first2, __last2, __result, __less<>()).second; | |
| 73 | 70 | } |
| 74 | 71 | |
| 75 | 72 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/set_intersection.h+4-3| ... | ... | @@ -19,6 +19,7 @@ |
| 19 | 19 | #include <__iterator/next.h> |
| 20 | 20 | #include <__type_traits/is_same.h> |
| 21 | 21 | #include <__utility/exchange.h> |
| 22 | #include <__utility/forward.h> | |
| 22 | 23 | #include <__utility/move.h> |
| 23 | 24 | #include <__utility/swap.h> |
| 24 | 25 | |
| ... | ... | @@ -84,7 +85,7 @@ template <class _AlgPolicy, |
| 84 | 85 | class _InForwardIter2, |
| 85 | 86 | class _Sent2, |
| 86 | 87 | class _OutIter> |
| 87 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI | |
| 88 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI | |
| 88 | 89 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InForwardIter1, _InForwardIter2, _OutIter> |
| 89 | 90 | __set_intersection( |
| 90 | 91 | _InForwardIter1 __first1, |
| ... | ... | @@ -129,7 +130,7 @@ template <class _AlgPolicy, |
| 129 | 130 | class _InInputIter2, |
| 130 | 131 | class _Sent2, |
| 131 | 132 | class _OutIter> |
| 132 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI | |
| 133 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI | |
| 133 | 134 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InInputIter1, _InInputIter2, _OutIter> |
| 134 | 135 | __set_intersection( |
| 135 | 136 | _InInputIter1 __first1, |
| ... | ... | @@ -160,7 +161,7 @@ __set_intersection( |
| 160 | 161 | } |
| 161 | 162 | |
| 162 | 163 | template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> |
| 163 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI | |
| 164 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI | |
| 164 | 165 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter> |
| 165 | 166 | __set_intersection( |
| 166 | 167 | _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { |
lib/libcxx/include/__algorithm/set_symmetric_difference.h+4-5| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/copy.h> |
| 15 | #include <__algorithm/iterator_operations.h> | |
| 16 | 15 | #include <__config> |
| 17 | 16 | #include <__iterator/iterator_traits.h> |
| 18 | 17 | #include <__utility/move.h> |
| ... | ... | @@ -39,13 +38,13 @@ struct __set_symmetric_difference_result { |
| 39 | 38 | : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {} |
| 40 | 39 | }; |
| 41 | 40 | |
| 42 | template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | |
| 41 | template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | |
| 43 | 42 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter> |
| 44 | 43 | __set_symmetric_difference( |
| 45 | 44 | _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { |
| 46 | 45 | while (__first1 != __last1) { |
| 47 | 46 | if (__first2 == __last2) { |
| 48 | auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 47 | auto __ret1 = std::__copy(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 49 | 48 | return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>( |
| 50 | 49 | std::move(__ret1.first), std::move(__first2), std::move((__ret1.second))); |
| 51 | 50 | } |
| ... | ... | @@ -63,7 +62,7 @@ __set_symmetric_difference( |
| 63 | 62 | ++__first2; |
| 64 | 63 | } |
| 65 | 64 | } |
| 66 | auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result)); | |
| 65 | auto __ret2 = std::__copy(std::move(__first2), std::move(__last2), std::move(__result)); | |
| 67 | 66 | return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>( |
| 68 | 67 | std::move(__first1), std::move(__ret2.first), std::move((__ret2.second))); |
| 69 | 68 | } |
| ... | ... | @@ -76,7 +75,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_symmetri |
| 76 | 75 | _InputIterator2 __last2, |
| 77 | 76 | _OutputIterator __result, |
| 78 | 77 | _Compare __comp) { |
| 79 | return std::__set_symmetric_difference<_ClassicAlgPolicy, __comp_ref_type<_Compare> >( | |
| 78 | return std::__set_symmetric_difference<__comp_ref_type<_Compare> >( | |
| 80 | 79 | std::move(__first1), |
| 81 | 80 | std::move(__last1), |
| 82 | 81 | std::move(__first2), |
lib/libcxx/include/__algorithm/set_union.h+4-5| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/copy.h> |
| 15 | #include <__algorithm/iterator_operations.h> | |
| 16 | 15 | #include <__config> |
| 17 | 16 | #include <__iterator/iterator_traits.h> |
| 18 | 17 | #include <__utility/move.h> |
| ... | ... | @@ -39,12 +38,12 @@ struct __set_union_result { |
| 39 | 38 | : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {} |
| 40 | 39 | }; |
| 41 | 40 | |
| 42 | template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | |
| 41 | template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | |
| 43 | 42 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union( |
| 44 | 43 | _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { |
| 45 | 44 | for (; __first1 != __last1; ++__result) { |
| 46 | 45 | if (__first2 == __last2) { |
| 47 | auto __ret1 = std::__copy<_AlgPolicy>(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 46 | auto __ret1 = std::__copy(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 48 | 47 | return __set_union_result<_InIter1, _InIter2, _OutIter>( |
| 49 | 48 | std::move(__ret1.first), std::move(__first2), std::move((__ret1.second))); |
| 50 | 49 | } |
| ... | ... | @@ -59,7 +58,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1, |
| 59 | 58 | ++__first1; |
| 60 | 59 | } |
| 61 | 60 | } |
| 62 | auto __ret2 = std::__copy<_AlgPolicy>(std::move(__first2), std::move(__last2), std::move(__result)); | |
| 61 | auto __ret2 = std::__copy(std::move(__first2), std::move(__last2), std::move(__result)); | |
| 63 | 62 | return __set_union_result<_InIter1, _InIter2, _OutIter>( |
| 64 | 63 | std::move(__first1), std::move(__ret2.first), std::move((__ret2.second))); |
| 65 | 64 | } |
| ... | ... | @@ -72,7 +71,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_union( |
| 72 | 71 | _InputIterator2 __last2, |
| 73 | 72 | _OutputIterator __result, |
| 74 | 73 | _Compare __comp) { |
| 75 | return std::__set_union<_ClassicAlgPolicy, __comp_ref_type<_Compare> >( | |
| 74 | return std::__set_union<__comp_ref_type<_Compare> >( | |
| 76 | 75 | std::move(__first1), |
| 77 | 76 | std::move(__last1), |
| 78 | 77 | std::move(__first2), |
lib/libcxx/include/__algorithm/shuffle.h+1-1| ... | ... | @@ -11,12 +11,12 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/iterator_operations.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | 16 | #include <__random/uniform_int_distribution.h> |
| 16 | 17 | #include <__utility/forward.h> |
| 17 | 18 | #include <__utility/move.h> |
| 18 | 19 | #include <__utility/swap.h> |
| 19 | #include <cstddef> | |
| 20 | 20 | #include <cstdint> |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__algorithm/simd_utils.h+8-8| ... | ... | @@ -14,10 +14,10 @@ |
| 14 | 14 | #include <__bit/countl.h> |
| 15 | 15 | #include <__bit/countr.h> |
| 16 | 16 | #include <__config> |
| 17 | #include <__cstddef/size_t.h> | |
| 17 | 18 | #include <__type_traits/is_arithmetic.h> |
| 18 | 19 | #include <__type_traits/is_same.h> |
| 19 | 20 | #include <__utility/integer_sequence.h> |
| 20 | #include <cstddef> | |
| 21 | 21 | #include <cstdint> |
| 22 | 22 | |
| 23 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -70,7 +70,7 @@ struct __get_as_integer_type_impl<8> { |
| 70 | 70 | }; |
| 71 | 71 | |
| 72 | 72 | template <class _Tp> |
| 73 | using __get_as_integer_type_t = typename __get_as_integer_type_impl<sizeof(_Tp)>::type; | |
| 73 | using __get_as_integer_type_t _LIBCPP_NODEBUG = typename __get_as_integer_type_impl<sizeof(_Tp)>::type; | |
| 74 | 74 | |
| 75 | 75 | // This isn't specialized for 64 byte vectors on purpose. They have the potential to significantly reduce performance |
| 76 | 76 | // in mixed simd/non-simd workloads and don't provide any performance improvement for currently vectorized algorithms |
| ... | ... | @@ -90,7 +90,7 @@ inline constexpr size_t __native_vector_size = 1; |
| 90 | 90 | # endif |
| 91 | 91 | |
| 92 | 92 | template <class _ArithmeticT, size_t _Np> |
| 93 | using __simd_vector __attribute__((__ext_vector_type__(_Np))) = _ArithmeticT; | |
| 93 | using __simd_vector __attribute__((__ext_vector_type__(_Np))) _LIBCPP_NODEBUG = _ArithmeticT; | |
| 94 | 94 | |
| 95 | 95 | template <class _VecT> |
| 96 | 96 | inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t { |
| ... | ... | @@ -106,23 +106,23 @@ _LIBCPP_HIDE_FROM_ABI _Tp __simd_vector_underlying_type_impl(__simd_vector<_Tp, |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | template <class _VecT> |
| 109 | using __simd_vector_underlying_type_t = decltype(std::__simd_vector_underlying_type_impl(_VecT{})); | |
| 109 | using __simd_vector_underlying_type_t _LIBCPP_NODEBUG = decltype(std::__simd_vector_underlying_type_impl(_VecT{})); | |
| 110 | 110 | |
| 111 | 111 | // This isn't inlined without always_inline when loading chars. |
| 112 | 112 | template <class _VecT, class _Iter> |
| 113 | _LIBCPP_NODISCARD _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT __load_vector(_Iter __iter) noexcept { | |
| 113 | [[__nodiscard__]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT __load_vector(_Iter __iter) noexcept { | |
| 114 | 114 | return [=]<size_t... _Indices>(index_sequence<_Indices...>) _LIBCPP_ALWAYS_INLINE noexcept { |
| 115 | 115 | return _VecT{__iter[_Indices]...}; |
| 116 | 116 | }(make_index_sequence<__simd_vector_size_v<_VecT>>{}); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | template <class _Tp, size_t _Np> |
| 120 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<_Tp, _Np> __vec) noexcept { | |
| 120 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<_Tp, _Np> __vec) noexcept { | |
| 121 | 121 | return __builtin_reduce_and(__builtin_convertvector(__vec, __simd_vector<bool, _Np>)); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 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 { | |
| 125 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_Tp, _Np> __vec) noexcept { | |
| 126 | 126 | using __mask_vec = __simd_vector<bool, _Np>; |
| 127 | 127 | |
| 128 | 128 | // This has MSan disabled du to https://github.com/llvm/llvm-project/issues/85876 |
| ... | ... | @@ -151,7 +151,7 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_T |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 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 { | |
| 154 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_not_set(__simd_vector<_Tp, _Np> __vec) noexcept { | |
| 155 | 155 | return std::__find_first_set(~__vec); |
| 156 | 156 | } |
| 157 | 157 |
lib/libcxx/include/__algorithm/sort.h+128-170| ... | ... | @@ -27,9 +27,14 @@ |
| 27 | 27 | #include <__functional/ranges_operations.h> |
| 28 | 28 | #include <__iterator/iterator_traits.h> |
| 29 | 29 | #include <__type_traits/conditional.h> |
| 30 | #include <__type_traits/desugars_to.h> | |
| 30 | 31 | #include <__type_traits/disjunction.h> |
| 32 | #include <__type_traits/enable_if.h> | |
| 31 | 33 | #include <__type_traits/is_arithmetic.h> |
| 32 | 34 | #include <__type_traits/is_constant_evaluated.h> |
| 35 | #include <__type_traits/is_same.h> | |
| 36 | #include <__type_traits/is_trivially_copyable.h> | |
| 37 | #include <__type_traits/remove_cvref.h> | |
| 33 | 38 | #include <__utility/move.h> |
| 34 | 39 | #include <__utility/pair.h> |
| 35 | 40 | #include <climits> |
| ... | ... | @@ -44,110 +49,11 @@ _LIBCPP_PUSH_MACROS |
| 44 | 49 | |
| 45 | 50 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 46 | 51 | |
| 47 | // stable, 2-3 compares, 0-2 swaps | |
| 48 | ||
| 49 | template <class _AlgPolicy, class _Compare, class _ForwardIterator> | |
| 50 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 unsigned | |
| 51 | __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c) { | |
| 52 | using _Ops = _IterOps<_AlgPolicy>; | |
| 53 | ||
| 54 | unsigned __r = 0; | |
| 55 | if (!__c(*__y, *__x)) // if x <= y | |
| 56 | { | |
| 57 | if (!__c(*__z, *__y)) // if y <= z | |
| 58 | return __r; // x <= y && y <= z | |
| 59 | // x <= y && y > z | |
| 60 | _Ops::iter_swap(__y, __z); // x <= z && y < z | |
| 61 | __r = 1; | |
| 62 | if (__c(*__y, *__x)) // if x > y | |
| 63 | { | |
| 64 | _Ops::iter_swap(__x, __y); // x < y && y <= z | |
| 65 | __r = 2; | |
| 66 | } | |
| 67 | return __r; // x <= y && y < z | |
| 68 | } | |
| 69 | if (__c(*__z, *__y)) // x > y, if y > z | |
| 70 | { | |
| 71 | _Ops::iter_swap(__x, __z); // x < y && y < z | |
| 72 | __r = 1; | |
| 73 | return __r; | |
| 74 | } | |
| 75 | _Ops::iter_swap(__x, __y); // x > y && y <= z | |
| 76 | __r = 1; // x < y && x <= z | |
| 77 | if (__c(*__z, *__y)) // if y > z | |
| 78 | { | |
| 79 | _Ops::iter_swap(__y, __z); // x <= y && y < z | |
| 80 | __r = 2; | |
| 81 | } | |
| 82 | return __r; | |
| 83 | } // x <= y && y <= z | |
| 84 | ||
| 85 | // stable, 3-6 compares, 0-5 swaps | |
| 86 | ||
| 87 | template <class _AlgPolicy, class _Compare, class _ForwardIterator> | |
| 88 | _LIBCPP_HIDE_FROM_ABI void | |
| 89 | __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _Compare __c) { | |
| 90 | using _Ops = _IterOps<_AlgPolicy>; | |
| 91 | std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c); | |
| 92 | if (__c(*__x4, *__x3)) { | |
| 93 | _Ops::iter_swap(__x3, __x4); | |
| 94 | if (__c(*__x3, *__x2)) { | |
| 95 | _Ops::iter_swap(__x2, __x3); | |
| 96 | if (__c(*__x2, *__x1)) { | |
| 97 | _Ops::iter_swap(__x1, __x2); | |
| 98 | } | |
| 99 | } | |
| 100 | } | |
| 101 | } | |
| 102 | ||
| 103 | // stable, 4-10 compares, 0-9 swaps | |
| 104 | ||
| 105 | template <class _AlgPolicy, class _Comp, class _ForwardIterator> | |
| 106 | _LIBCPP_HIDE_FROM_ABI void | |
| 107 | __sort5(_ForwardIterator __x1, | |
| 108 | _ForwardIterator __x2, | |
| 109 | _ForwardIterator __x3, | |
| 110 | _ForwardIterator __x4, | |
| 111 | _ForwardIterator __x5, | |
| 112 | _Comp __comp) { | |
| 113 | using _Ops = _IterOps<_AlgPolicy>; | |
| 114 | ||
| 115 | std::__sort4<_AlgPolicy, _Comp>(__x1, __x2, __x3, __x4, __comp); | |
| 116 | if (__comp(*__x5, *__x4)) { | |
| 117 | _Ops::iter_swap(__x4, __x5); | |
| 118 | if (__comp(*__x4, *__x3)) { | |
| 119 | _Ops::iter_swap(__x3, __x4); | |
| 120 | if (__comp(*__x3, *__x2)) { | |
| 121 | _Ops::iter_swap(__x2, __x3); | |
| 122 | if (__comp(*__x2, *__x1)) { | |
| 123 | _Ops::iter_swap(__x1, __x2); | |
| 124 | } | |
| 125 | } | |
| 126 | } | |
| 127 | } | |
| 128 | } | |
| 129 | ||
| 130 | // The comparator being simple is a prerequisite for using the branchless optimization. | |
| 131 | template <class _Tp> | |
| 132 | struct __is_simple_comparator : false_type {}; | |
| 133 | template <> | |
| 134 | struct __is_simple_comparator<__less<>&> : true_type {}; | |
| 135 | template <class _Tp> | |
| 136 | struct __is_simple_comparator<less<_Tp>&> : true_type {}; | |
| 137 | template <class _Tp> | |
| 138 | struct __is_simple_comparator<greater<_Tp>&> : true_type {}; | |
| 139 | #if _LIBCPP_STD_VER >= 20 | |
| 140 | template <> | |
| 141 | struct __is_simple_comparator<ranges::less&> : true_type {}; | |
| 142 | template <> | |
| 143 | struct __is_simple_comparator<ranges::greater&> : true_type {}; | |
| 144 | #endif | |
| 145 | ||
| 146 | 52 | template <class _Compare, class _Iter, class _Tp = typename iterator_traits<_Iter>::value_type> |
| 147 | using __use_branchless_sort = | |
| 148 | integral_constant<bool, | |
| 149 | __libcpp_is_contiguous_iterator<_Iter>::value && sizeof(_Tp) <= sizeof(void*) && | |
| 150 | is_arithmetic<_Tp>::value && __is_simple_comparator<_Compare>::value>; | |
| 53 | inline const bool __use_branchless_sort = | |
| 54 | __libcpp_is_contiguous_iterator<_Iter>::value && __is_cheap_to_copy<_Tp> && is_arithmetic<_Tp>::value && | |
| 55 | (__desugars_to_v<__less_tag, __remove_cvref_t<_Compare>, _Tp, _Tp> || | |
| 56 | __desugars_to_v<__greater_tag, __remove_cvref_t<_Compare>, _Tp, _Tp>); | |
| 151 | 57 | |
| 152 | 58 | namespace __detail { |
| 153 | 59 | |
| ... | ... | @@ -158,59 +64,88 @@ enum { __block_size = sizeof(uint64_t) * 8 }; |
| 158 | 64 | |
| 159 | 65 | // Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary. |
| 160 | 66 | template <class _Compare, class _RandomAccessIterator> |
| 161 | inline _LIBCPP_HIDE_FROM_ABI void __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) { | |
| 67 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | |
| 68 | __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) { | |
| 162 | 69 | // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`). |
| 163 | 70 | using value_type = typename iterator_traits<_RandomAccessIterator>::value_type; |
| 164 | 71 | bool __r = __c(*__x, *__y); |
| 165 | 72 | value_type __tmp = __r ? *__x : *__y; |
| 166 | 73 | *__y = __r ? *__y : *__x; |
| 167 | 74 | *__x = __tmp; |
| 75 | return !__r; | |
| 168 | 76 | } |
| 169 | 77 | |
| 170 | 78 | // Ensures that *__x, *__y and *__z are ordered according to the comparator __c, |
| 171 | 79 | // under the assumption that *__y and *__z are already ordered. |
| 172 | 80 | template <class _Compare, class _RandomAccessIterator> |
| 173 | inline _LIBCPP_HIDE_FROM_ABI void | |
| 81 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | |
| 174 | 82 | __partially_sorted_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _RandomAccessIterator __z, _Compare __c) { |
| 175 | 83 | // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`). |
| 176 | 84 | using value_type = typename iterator_traits<_RandomAccessIterator>::value_type; |
| 177 | bool __r = __c(*__z, *__x); | |
| 178 | value_type __tmp = __r ? *__z : *__x; | |
| 179 | *__z = __r ? *__x : *__z; | |
| 180 | __r = __c(__tmp, *__y); | |
| 181 | *__x = __r ? *__x : *__y; | |
| 182 | *__y = __r ? *__y : __tmp; | |
| 85 | bool __r1 = __c(*__z, *__x); | |
| 86 | value_type __tmp = __r1 ? *__z : *__x; | |
| 87 | *__z = __r1 ? *__x : *__z; | |
| 88 | bool __r2 = __c(__tmp, *__y); | |
| 89 | *__x = __r2 ? *__x : *__y; | |
| 90 | *__y = __r2 ? *__y : __tmp; | |
| 91 | return !__r1 || !__r2; | |
| 183 | 92 | } |
| 184 | 93 | |
| 94 | // stable, 2-3 compares, 0-2 swaps | |
| 95 | ||
| 185 | 96 | template <class, |
| 186 | 97 | class _Compare, |
| 187 | 98 | class _RandomAccessIterator, |
| 188 | __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> | |
| 189 | inline _LIBCPP_HIDE_FROM_ABI void __sort3_maybe_branchless( | |
| 190 | _RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _Compare __c) { | |
| 191 | std::__cond_swap<_Compare>(__x2, __x3, __c); | |
| 192 | std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c); | |
| 99 | __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0> | |
| 100 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | |
| 101 | __sort3(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _Compare __c) { | |
| 102 | bool __swapped1 = std::__cond_swap<_Compare>(__x2, __x3, __c); | |
| 103 | bool __swapped2 = std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c); | |
| 104 | return __swapped1 || __swapped2; | |
| 193 | 105 | } |
| 194 | 106 | |
| 195 | 107 | template <class _AlgPolicy, |
| 196 | 108 | class _Compare, |
| 197 | 109 | class _RandomAccessIterator, |
| 198 | __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> | |
| 199 | inline _LIBCPP_HIDE_FROM_ABI void __sort3_maybe_branchless( | |
| 200 | _RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _Compare __c) { | |
| 201 | std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c); | |
| 202 | } | |
| 110 | __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0> | |
| 111 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | |
| 112 | __sort3(_RandomAccessIterator __x, _RandomAccessIterator __y, _RandomAccessIterator __z, _Compare __c) { | |
| 113 | using _Ops = _IterOps<_AlgPolicy>; | |
| 114 | ||
| 115 | if (!__c(*__y, *__x)) // if x <= y | |
| 116 | { | |
| 117 | if (!__c(*__z, *__y)) // if y <= z | |
| 118 | return false; // x <= y && y <= z | |
| 119 | // x <= y && y > z | |
| 120 | _Ops::iter_swap(__y, __z); // x <= z && y < z | |
| 121 | if (__c(*__y, *__x)) // if x > y | |
| 122 | _Ops::iter_swap(__x, __y); // x < y && y <= z | |
| 123 | return true; // x <= y && y < z | |
| 124 | } | |
| 125 | if (__c(*__z, *__y)) // x > y, if y > z | |
| 126 | { | |
| 127 | _Ops::iter_swap(__x, __z); // x < y && y < z | |
| 128 | return true; | |
| 129 | } | |
| 130 | _Ops::iter_swap(__x, __y); // x > y && y <= z | |
| 131 | // x < y && x <= z | |
| 132 | if (__c(*__z, *__y)) // if y > z | |
| 133 | _Ops::iter_swap(__y, __z); // x <= y && y < z | |
| 134 | return true; | |
| 135 | } // x <= y && y <= z | |
| 136 | ||
| 137 | // stable, 3-6 compares, 0-5 swaps | |
| 203 | 138 | |
| 204 | 139 | template <class, |
| 205 | 140 | class _Compare, |
| 206 | 141 | class _RandomAccessIterator, |
| 207 | __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> | |
| 208 | inline _LIBCPP_HIDE_FROM_ABI void __sort4_maybe_branchless( | |
| 209 | _RandomAccessIterator __x1, | |
| 210 | _RandomAccessIterator __x2, | |
| 211 | _RandomAccessIterator __x3, | |
| 212 | _RandomAccessIterator __x4, | |
| 213 | _Compare __c) { | |
| 142 | __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0> | |
| 143 | inline _LIBCPP_HIDE_FROM_ABI void | |
| 144 | __sort4(_RandomAccessIterator __x1, | |
| 145 | _RandomAccessIterator __x2, | |
| 146 | _RandomAccessIterator __x3, | |
| 147 | _RandomAccessIterator __x4, | |
| 148 | _Compare __c) { | |
| 214 | 149 | std::__cond_swap<_Compare>(__x1, __x3, __c); |
| 215 | 150 | std::__cond_swap<_Compare>(__x2, __x4, __c); |
| 216 | 151 | std::__cond_swap<_Compare>(__x1, __x2, __c); |
| ... | ... | @@ -221,27 +156,39 @@ inline _LIBCPP_HIDE_FROM_ABI void __sort4_maybe_branchless( |
| 221 | 156 | template <class _AlgPolicy, |
| 222 | 157 | class _Compare, |
| 223 | 158 | class _RandomAccessIterator, |
| 224 | __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> | |
| 225 | inline _LIBCPP_HIDE_FROM_ABI void __sort4_maybe_branchless( | |
| 226 | _RandomAccessIterator __x1, | |
| 227 | _RandomAccessIterator __x2, | |
| 228 | _RandomAccessIterator __x3, | |
| 229 | _RandomAccessIterator __x4, | |
| 230 | _Compare __c) { | |
| 231 | std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c); | |
| 159 | __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0> | |
| 160 | inline _LIBCPP_HIDE_FROM_ABI void | |
| 161 | __sort4(_RandomAccessIterator __x1, | |
| 162 | _RandomAccessIterator __x2, | |
| 163 | _RandomAccessIterator __x3, | |
| 164 | _RandomAccessIterator __x4, | |
| 165 | _Compare __c) { | |
| 166 | using _Ops = _IterOps<_AlgPolicy>; | |
| 167 | std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c); | |
| 168 | if (__c(*__x4, *__x3)) { | |
| 169 | _Ops::iter_swap(__x3, __x4); | |
| 170 | if (__c(*__x3, *__x2)) { | |
| 171 | _Ops::iter_swap(__x2, __x3); | |
| 172 | if (__c(*__x2, *__x1)) { | |
| 173 | _Ops::iter_swap(__x1, __x2); | |
| 174 | } | |
| 175 | } | |
| 176 | } | |
| 232 | 177 | } |
| 233 | 178 | |
| 179 | // stable, 4-10 compares, 0-9 swaps | |
| 180 | ||
| 234 | 181 | template <class _AlgPolicy, |
| 235 | 182 | class _Compare, |
| 236 | 183 | class _RandomAccessIterator, |
| 237 | __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> | |
| 238 | inline _LIBCPP_HIDE_FROM_ABI void __sort5_maybe_branchless( | |
| 239 | _RandomAccessIterator __x1, | |
| 240 | _RandomAccessIterator __x2, | |
| 241 | _RandomAccessIterator __x3, | |
| 242 | _RandomAccessIterator __x4, | |
| 243 | _RandomAccessIterator __x5, | |
| 244 | _Compare __c) { | |
| 184 | __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0> | |
| 185 | inline _LIBCPP_HIDE_FROM_ABI void | |
| 186 | __sort5(_RandomAccessIterator __x1, | |
| 187 | _RandomAccessIterator __x2, | |
| 188 | _RandomAccessIterator __x3, | |
| 189 | _RandomAccessIterator __x4, | |
| 190 | _RandomAccessIterator __x5, | |
| 191 | _Compare __c) { | |
| 245 | 192 | std::__cond_swap<_Compare>(__x1, __x2, __c); |
| 246 | 193 | std::__cond_swap<_Compare>(__x4, __x5, __c); |
| 247 | 194 | std::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c); |
| ... | ... | @@ -253,16 +200,29 @@ inline _LIBCPP_HIDE_FROM_ABI void __sort5_maybe_branchless( |
| 253 | 200 | template <class _AlgPolicy, |
| 254 | 201 | class _Compare, |
| 255 | 202 | class _RandomAccessIterator, |
| 256 | __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> | |
| 257 | inline _LIBCPP_HIDE_FROM_ABI void __sort5_maybe_branchless( | |
| 258 | _RandomAccessIterator __x1, | |
| 259 | _RandomAccessIterator __x2, | |
| 260 | _RandomAccessIterator __x3, | |
| 261 | _RandomAccessIterator __x4, | |
| 262 | _RandomAccessIterator __x5, | |
| 263 | _Compare __c) { | |
| 264 | std::__sort5<_AlgPolicy, _Compare, _RandomAccessIterator>( | |
| 265 | std::move(__x1), std::move(__x2), std::move(__x3), std::move(__x4), std::move(__x5), __c); | |
| 203 | __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>, int> = 0> | |
| 204 | inline _LIBCPP_HIDE_FROM_ABI void | |
| 205 | __sort5(_RandomAccessIterator __x1, | |
| 206 | _RandomAccessIterator __x2, | |
| 207 | _RandomAccessIterator __x3, | |
| 208 | _RandomAccessIterator __x4, | |
| 209 | _RandomAccessIterator __x5, | |
| 210 | _Compare __comp) { | |
| 211 | using _Ops = _IterOps<_AlgPolicy>; | |
| 212 | ||
| 213 | std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __comp); | |
| 214 | if (__comp(*__x5, *__x4)) { | |
| 215 | _Ops::iter_swap(__x4, __x5); | |
| 216 | if (__comp(*__x4, *__x3)) { | |
| 217 | _Ops::iter_swap(__x3, __x4); | |
| 218 | if (__comp(*__x3, *__x2)) { | |
| 219 | _Ops::iter_swap(__x2, __x3); | |
| 220 | if (__comp(*__x2, *__x1)) { | |
| 221 | _Ops::iter_swap(__x1, __x2); | |
| 222 | } | |
| 223 | } | |
| 224 | } | |
| 225 | } | |
| 266 | 226 | } |
| 267 | 227 | |
| 268 | 228 | // Assumes size > 0 |
| ... | ... | @@ -280,7 +240,7 @@ __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, |
| 280 | 240 | // Sort the iterator range [__first, __last) using the comparator __comp using |
| 281 | 241 | // the insertion sort algorithm. |
| 282 | 242 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> |
| 283 | _LIBCPP_HIDE_FROM_ABI void | |
| 243 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void | |
| 284 | 244 | __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { |
| 285 | 245 | using _Ops = _IterOps<_AlgPolicy>; |
| 286 | 246 | |
| ... | ... | @@ -352,14 +312,14 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator |
| 352 | 312 | _Ops::iter_swap(__first, __last); |
| 353 | 313 | return true; |
| 354 | 314 | case 3: |
| 355 | std::__sort3_maybe_branchless<_AlgPolicy, _Comp>(__first, __first + difference_type(1), --__last, __comp); | |
| 315 | std::__sort3<_AlgPolicy, _Comp>(__first, __first + difference_type(1), --__last, __comp); | |
| 356 | 316 | return true; |
| 357 | 317 | case 4: |
| 358 | std::__sort4_maybe_branchless<_AlgPolicy, _Comp>( | |
| 318 | std::__sort4<_AlgPolicy, _Comp>( | |
| 359 | 319 | __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp); |
| 360 | 320 | return true; |
| 361 | 321 | case 5: |
| 362 | std::__sort5_maybe_branchless<_AlgPolicy, _Comp>( | |
| 322 | std::__sort5<_AlgPolicy, _Comp>( | |
| 363 | 323 | __first, |
| 364 | 324 | __first + difference_type(1), |
| 365 | 325 | __first + difference_type(2), |
| ... | ... | @@ -370,7 +330,7 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator |
| 370 | 330 | } |
| 371 | 331 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| 372 | 332 | _RandomAccessIterator __j = __first + difference_type(2); |
| 373 | std::__sort3_maybe_branchless<_AlgPolicy, _Comp>(__first, __first + difference_type(1), __j, __comp); | |
| 333 | std::__sort3<_AlgPolicy, _Comp>(__first, __first + difference_type(1), __j, __comp); | |
| 374 | 334 | const unsigned __limit = 8; |
| 375 | 335 | unsigned __count = 0; |
| 376 | 336 | for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) { |
| ... | ... | @@ -777,14 +737,14 @@ void __introsort(_RandomAccessIterator __first, |
| 777 | 737 | _Ops::iter_swap(__first, __last); |
| 778 | 738 | return; |
| 779 | 739 | case 3: |
| 780 | std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp); | |
| 740 | std::__sort3<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp); | |
| 781 | 741 | return; |
| 782 | 742 | case 4: |
| 783 | std::__sort4_maybe_branchless<_AlgPolicy, _Compare>( | |
| 743 | std::__sort4<_AlgPolicy, _Compare>( | |
| 784 | 744 | __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp); |
| 785 | 745 | return; |
| 786 | 746 | case 5: |
| 787 | std::__sort5_maybe_branchless<_AlgPolicy, _Compare>( | |
| 747 | std::__sort5<_AlgPolicy, _Compare>( | |
| 788 | 748 | __first, |
| 789 | 749 | __first + difference_type(1), |
| 790 | 750 | __first + difference_type(2), |
| ... | ... | @@ -891,7 +851,7 @@ template <class _Comp, class _RandomAccessIterator> |
| 891 | 851 | void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp); |
| 892 | 852 | |
| 893 | 853 | extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<char>&, char*>(char*, char*, __less<char>&); |
| 894 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 854 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 895 | 855 | extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); |
| 896 | 856 | #endif |
| 897 | 857 | extern template _LIBCPP_EXPORTED_FROM_ABI void |
| ... | ... | @@ -925,20 +885,18 @@ __sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co |
| 925 | 885 | // Only use bitset partitioning for arithmetic types. We should also check |
| 926 | 886 | // that the default comparator is in use so that we are sure that there are no |
| 927 | 887 | // branches in the comparator. |
| 928 | std::__introsort<_AlgPolicy, | |
| 929 | _Comp&, | |
| 930 | _RandomAccessIterator, | |
| 931 | __use_branchless_sort<_Comp, _RandomAccessIterator>::value>(__first, __last, __comp, __depth_limit); | |
| 888 | std::__introsort<_AlgPolicy, _Comp&, _RandomAccessIterator, __use_branchless_sort<_Comp, _RandomAccessIterator> >( | |
| 889 | __first, __last, __comp, __depth_limit); | |
| 932 | 890 | } |
| 933 | 891 | |
| 934 | 892 | template <class _Type, class... _Options> |
| 935 | using __is_any_of = _Or<is_same<_Type, _Options>...>; | |
| 893 | using __is_any_of _LIBCPP_NODEBUG = _Or<is_same<_Type, _Options>...>; | |
| 936 | 894 | |
| 937 | 895 | template <class _Type> |
| 938 | using __sort_is_specialized_in_library = __is_any_of< | |
| 896 | using __sort_is_specialized_in_library _LIBCPP_NODEBUG = __is_any_of< | |
| 939 | 897 | _Type, |
| 940 | 898 | char, |
| 941 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 899 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 942 | 900 | wchar_t, |
| 943 | 901 | #endif |
| 944 | 902 | signed char, |
lib/libcxx/include/__algorithm/stable_partition.h+11-14| ... | ... | @@ -12,15 +12,16 @@ |
| 12 | 12 | #include <__algorithm/iterator_operations.h> |
| 13 | 13 | #include <__algorithm/rotate.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/ptrdiff_t.h> | |
| 15 | 16 | #include <__iterator/advance.h> |
| 16 | 17 | #include <__iterator/distance.h> |
| 17 | 18 | #include <__iterator/iterator_traits.h> |
| 18 | 19 | #include <__memory/destruct_n.h> |
| 19 | #include <__memory/temporary_buffer.h> | |
| 20 | 20 | #include <__memory/unique_ptr.h> |
| 21 | #include <__memory/unique_temporary_buffer.h> | |
| 22 | #include <__type_traits/remove_cvref.h> | |
| 21 | 23 | #include <__utility/move.h> |
| 22 | 24 | #include <__utility/pair.h> |
| 23 | #include <new> | |
| 24 | 25 | |
| 25 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | 27 | # pragma GCC system_header |
| ... | ... | @@ -132,14 +133,12 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred |
| 132 | 133 | // We now have a reduced range [__first, __last) |
| 133 | 134 | // *__first is known to be false |
| 134 | 135 | difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last); |
| 136 | __unique_temporary_buffer<value_type> __unique_buf; | |
| 135 | 137 | pair<value_type*, ptrdiff_t> __p(0, 0); |
| 136 | unique_ptr<value_type, __return_temporary_buffer> __h; | |
| 137 | 138 | if (__len >= __alloc_limit) { |
| 138 | // TODO: Remove the use of std::get_temporary_buffer | |
| 139 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 140 | __p = std::get_temporary_buffer<value_type>(__len); | |
| 141 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 142 | __h.reset(__p.first); | |
| 139 | __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len); | |
| 140 | __p.first = __unique_buf.get(); | |
| 141 | __p.second = __unique_buf.get_deleter().__count_; | |
| 143 | 142 | } |
| 144 | 143 | return std::__stable_partition_impl<_AlgPolicy, _Predicate&>( |
| 145 | 144 | std::move(__first), std::move(__last), __pred, __len, __p, forward_iterator_tag()); |
| ... | ... | @@ -272,14 +271,12 @@ _LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl( |
| 272 | 271 | // *__last is known to be true |
| 273 | 272 | // __len >= 2 |
| 274 | 273 | difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last) + 1; |
| 274 | __unique_temporary_buffer<value_type> __unique_buf; | |
| 275 | 275 | pair<value_type*, ptrdiff_t> __p(0, 0); |
| 276 | unique_ptr<value_type, __return_temporary_buffer> __h; | |
| 277 | 276 | if (__len >= __alloc_limit) { |
| 278 | // TODO: Remove the use of std::get_temporary_buffer | |
| 279 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 280 | __p = std::get_temporary_buffer<value_type>(__len); | |
| 281 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 282 | __h.reset(__p.first); | |
| 277 | __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len); | |
| 278 | __p.first = __unique_buf.get(); | |
| 279 | __p.second = __unique_buf.get_deleter().__count_; | |
| 283 | 280 | } |
| 284 | 281 | return std::__stable_partition_impl<_AlgPolicy, _Predicate&>( |
| 285 | 282 | std::move(__first), std::move(__last), __pred, __len, __p, bidirectional_iterator_tag()); |
lib/libcxx/include/__algorithm/stable_sort.h+90-44| ... | ... | @@ -13,17 +13,24 @@ |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/inplace_merge.h> |
| 15 | 15 | #include <__algorithm/iterator_operations.h> |
| 16 | #include <__algorithm/radix_sort.h> | |
| 16 | 17 | #include <__algorithm/sort.h> |
| 17 | 18 | #include <__config> |
| 19 | #include <__cstddef/ptrdiff_t.h> | |
| 18 | 20 | #include <__debug_utils/strict_weak_ordering_check.h> |
| 19 | 21 | #include <__iterator/iterator_traits.h> |
| 22 | #include <__memory/construct_at.h> | |
| 20 | 23 | #include <__memory/destruct_n.h> |
| 21 | #include <__memory/temporary_buffer.h> | |
| 22 | 24 | #include <__memory/unique_ptr.h> |
| 25 | #include <__memory/unique_temporary_buffer.h> | |
| 26 | #include <__type_traits/desugars_to.h> | |
| 27 | #include <__type_traits/enable_if.h> | |
| 28 | #include <__type_traits/is_integral.h> | |
| 29 | #include <__type_traits/is_same.h> | |
| 23 | 30 | #include <__type_traits/is_trivially_assignable.h> |
| 31 | #include <__type_traits/remove_cvref.h> | |
| 24 | 32 | #include <__utility/move.h> |
| 25 | 33 | #include <__utility/pair.h> |
| 26 | #include <new> | |
| 27 | 34 | |
| 28 | 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | 36 | # pragma GCC system_header |
| ... | ... | @@ -35,7 +42,7 @@ _LIBCPP_PUSH_MACROS |
| 35 | 42 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 43 | |
| 37 | 44 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> |
| 38 | _LIBCPP_HIDE_FROM_ABI void __insertion_sort_move( | |
| 45 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __insertion_sort_move( | |
| 39 | 46 | _BidirectionalIterator __first1, |
| 40 | 47 | _BidirectionalIterator __last1, |
| 41 | 48 | typename iterator_traits<_BidirectionalIterator>::value_type* __first2, |
| ... | ... | @@ -47,19 +54,19 @@ _LIBCPP_HIDE_FROM_ABI void __insertion_sort_move( |
| 47 | 54 | __destruct_n __d(0); |
| 48 | 55 | unique_ptr<value_type, __destruct_n&> __h(__first2, __d); |
| 49 | 56 | value_type* __last2 = __first2; |
| 50 | ::new ((void*)__last2) value_type(_Ops::__iter_move(__first1)); | |
| 57 | std::__construct_at(__last2, _Ops::__iter_move(__first1)); | |
| 51 | 58 | __d.template __incr<value_type>(); |
| 52 | 59 | for (++__last2; ++__first1 != __last1; ++__last2) { |
| 53 | 60 | value_type* __j2 = __last2; |
| 54 | 61 | value_type* __i2 = __j2; |
| 55 | 62 | if (__comp(*__first1, *--__i2)) { |
| 56 | ::new ((void*)__j2) value_type(std::move(*__i2)); | |
| 63 | std::__construct_at(__j2, std::move(*__i2)); | |
| 57 | 64 | __d.template __incr<value_type>(); |
| 58 | 65 | for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2) |
| 59 | 66 | *__j2 = std::move(*__i2); |
| 60 | 67 | *__j2 = _Ops::__iter_move(__first1); |
| 61 | 68 | } else { |
| 62 | ::new ((void*)__j2) value_type(_Ops::__iter_move(__first1)); | |
| 69 | std::__construct_at(__j2, _Ops::__iter_move(__first1)); | |
| 63 | 70 | __d.template __incr<value_type>(); |
| 64 | 71 | } |
| 65 | 72 | } |
| ... | ... | @@ -68,7 +75,7 @@ _LIBCPP_HIDE_FROM_ABI void __insertion_sort_move( |
| 68 | 75 | } |
| 69 | 76 | |
| 70 | 77 | template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2> |
| 71 | _LIBCPP_HIDE_FROM_ABI void __merge_move_construct( | |
| 78 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __merge_move_construct( | |
| 72 | 79 | _InputIterator1 __first1, |
| 73 | 80 | _InputIterator1 __last1, |
| 74 | 81 | _InputIterator2 __first2, |
| ... | ... | @@ -83,22 +90,22 @@ _LIBCPP_HIDE_FROM_ABI void __merge_move_construct( |
| 83 | 90 | for (; true; ++__result) { |
| 84 | 91 | if (__first1 == __last1) { |
| 85 | 92 | for (; __first2 != __last2; ++__first2, (void)++__result, __d.template __incr<value_type>()) |
| 86 | ::new ((void*)__result) value_type(_Ops::__iter_move(__first2)); | |
| 93 | std::__construct_at(__result, _Ops::__iter_move(__first2)); | |
| 87 | 94 | __h.release(); |
| 88 | 95 | return; |
| 89 | 96 | } |
| 90 | 97 | if (__first2 == __last2) { |
| 91 | 98 | for (; __first1 != __last1; ++__first1, (void)++__result, __d.template __incr<value_type>()) |
| 92 | ::new ((void*)__result) value_type(_Ops::__iter_move(__first1)); | |
| 99 | std::__construct_at(__result, _Ops::__iter_move(__first1)); | |
| 93 | 100 | __h.release(); |
| 94 | 101 | return; |
| 95 | 102 | } |
| 96 | 103 | if (__comp(*__first2, *__first1)) { |
| 97 | ::new ((void*)__result) value_type(_Ops::__iter_move(__first2)); | |
| 104 | std::__construct_at(__result, _Ops::__iter_move(__first2)); | |
| 98 | 105 | __d.template __incr<value_type>(); |
| 99 | 106 | ++__first2; |
| 100 | 107 | } else { |
| 101 | ::new ((void*)__result) value_type(_Ops::__iter_move(__first1)); | |
| 108 | std::__construct_at(__result, _Ops::__iter_move(__first1)); | |
| 102 | 109 | __d.template __incr<value_type>(); |
| 103 | 110 | ++__first1; |
| 104 | 111 | } |
| ... | ... | @@ -106,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI void __merge_move_construct( |
| 106 | 113 | } |
| 107 | 114 | |
| 108 | 115 | template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> |
| 109 | _LIBCPP_HIDE_FROM_ABI void __merge_move_assign( | |
| 116 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __merge_move_assign( | |
| 110 | 117 | _InputIterator1 __first1, |
| 111 | 118 | _InputIterator1 __last1, |
| 112 | 119 | _InputIterator2 __first2, |
| ... | ... | @@ -134,19 +141,21 @@ _LIBCPP_HIDE_FROM_ABI void __merge_move_assign( |
| 134 | 141 | } |
| 135 | 142 | |
| 136 | 143 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> |
| 137 | void __stable_sort(_RandomAccessIterator __first, | |
| 138 | _RandomAccessIterator __last, | |
| 139 | _Compare __comp, | |
| 140 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, | |
| 141 | typename iterator_traits<_RandomAccessIterator>::value_type* __buff, | |
| 142 | ptrdiff_t __buff_size); | |
| 144 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort( | |
| 145 | _RandomAccessIterator __first, | |
| 146 | _RandomAccessIterator __last, | |
| 147 | _Compare __comp, | |
| 148 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, | |
| 149 | typename iterator_traits<_RandomAccessIterator>::value_type* __buff, | |
| 150 | ptrdiff_t __buff_size); | |
| 143 | 151 | |
| 144 | 152 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> |
| 145 | void __stable_sort_move(_RandomAccessIterator __first1, | |
| 146 | _RandomAccessIterator __last1, | |
| 147 | _Compare __comp, | |
| 148 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, | |
| 149 | typename iterator_traits<_RandomAccessIterator>::value_type* __first2) { | |
| 153 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort_move( | |
| 154 | _RandomAccessIterator __first1, | |
| 155 | _RandomAccessIterator __last1, | |
| 156 | _Compare __comp, | |
| 157 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, | |
| 158 | typename iterator_traits<_RandomAccessIterator>::value_type* __first2) { | |
| 150 | 159 | using _Ops = _IterOps<_AlgPolicy>; |
| 151 | 160 | |
| 152 | 161 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| ... | ... | @@ -154,21 +163,21 @@ void __stable_sort_move(_RandomAccessIterator __first1, |
| 154 | 163 | case 0: |
| 155 | 164 | return; |
| 156 | 165 | case 1: |
| 157 | ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1)); | |
| 166 | std::__construct_at(__first2, _Ops::__iter_move(__first1)); | |
| 158 | 167 | return; |
| 159 | 168 | case 2: |
| 160 | 169 | __destruct_n __d(0); |
| 161 | 170 | unique_ptr<value_type, __destruct_n&> __h2(__first2, __d); |
| 162 | 171 | if (__comp(*--__last1, *__first1)) { |
| 163 | ::new ((void*)__first2) value_type(_Ops::__iter_move(__last1)); | |
| 172 | std::__construct_at(__first2, _Ops::__iter_move(__last1)); | |
| 164 | 173 | __d.template __incr<value_type>(); |
| 165 | 174 | ++__first2; |
| 166 | ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1)); | |
| 175 | std::__construct_at(__first2, _Ops::__iter_move(__first1)); | |
| 167 | 176 | } else { |
| 168 | ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1)); | |
| 177 | std::__construct_at(__first2, _Ops::__iter_move(__first1)); | |
| 169 | 178 | __d.template __incr<value_type>(); |
| 170 | 179 | ++__first2; |
| 171 | ::new ((void*)__first2) value_type(_Ops::__iter_move(__last1)); | |
| 180 | std::__construct_at(__first2, _Ops::__iter_move(__last1)); | |
| 172 | 181 | } |
| 173 | 182 | __h2.release(); |
| 174 | 183 | return; |
| ... | ... | @@ -189,13 +198,36 @@ struct __stable_sort_switch { |
| 189 | 198 | static const unsigned value = 128 * is_trivially_copy_assignable<_Tp>::value; |
| 190 | 199 | }; |
| 191 | 200 | |
| 201 | #if _LIBCPP_STD_VER >= 17 | |
| 202 | template <class _Tp> | |
| 203 | _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() { | |
| 204 | static_assert(is_integral<_Tp>::value); | |
| 205 | if constexpr (sizeof(_Tp) == 1) { | |
| 206 | return 1 << 8; | |
| 207 | } | |
| 208 | ||
| 209 | return 1 << 10; | |
| 210 | } | |
| 211 | ||
| 212 | template <class _Tp> | |
| 213 | _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_max_bound() { | |
| 214 | static_assert(is_integral<_Tp>::value); | |
| 215 | if constexpr (sizeof(_Tp) >= 8) { | |
| 216 | return 1 << 15; | |
| 217 | } | |
| 218 | ||
| 219 | return 1 << 16; | |
| 220 | } | |
| 221 | #endif // _LIBCPP_STD_VER >= 17 | |
| 222 | ||
| 192 | 223 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> |
| 193 | void __stable_sort(_RandomAccessIterator __first, | |
| 194 | _RandomAccessIterator __last, | |
| 195 | _Compare __comp, | |
| 196 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, | |
| 197 | typename iterator_traits<_RandomAccessIterator>::value_type* __buff, | |
| 198 | ptrdiff_t __buff_size) { | |
| 224 | _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort( | |
| 225 | _RandomAccessIterator __first, | |
| 226 | _RandomAccessIterator __last, | |
| 227 | _Compare __comp, | |
| 228 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, | |
| 229 | typename iterator_traits<_RandomAccessIterator>::value_type* __buff, | |
| 230 | ptrdiff_t __buff_size) { | |
| 199 | 231 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| 200 | 232 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 201 | 233 | switch (__len) { |
| ... | ... | @@ -211,6 +243,22 @@ void __stable_sort(_RandomAccessIterator __first, |
| 211 | 243 | std::__insertion_sort<_AlgPolicy, _Compare>(__first, __last, __comp); |
| 212 | 244 | return; |
| 213 | 245 | } |
| 246 | ||
| 247 | #if _LIBCPP_STD_VER >= 17 | |
| 248 | constexpr auto __default_comp = | |
| 249 | __desugars_to_v<__totally_ordered_less_tag, __remove_cvref_t<_Compare>, value_type, value_type >; | |
| 250 | constexpr auto __integral_value = | |
| 251 | is_integral_v<value_type > && is_same_v< value_type&, __iter_reference<_RandomAccessIterator>>; | |
| 252 | constexpr auto __allowed_radix_sort = __default_comp && __integral_value; | |
| 253 | if constexpr (__allowed_radix_sort) { | |
| 254 | if (__len <= __buff_size && __len >= static_cast<difference_type>(__radix_sort_min_bound<value_type>()) && | |
| 255 | __len <= static_cast<difference_type>(__radix_sort_max_bound<value_type>())) { | |
| 256 | std::__radix_sort(__first, __last, __buff); | |
| 257 | return; | |
| 258 | } | |
| 259 | } | |
| 260 | #endif // _LIBCPP_STD_VER >= 17 | |
| 261 | ||
| 214 | 262 | typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2; |
| 215 | 263 | _RandomAccessIterator __m = __first + __l2; |
| 216 | 264 | if (__len <= __buff_size) { |
| ... | ... | @@ -235,20 +283,18 @@ void __stable_sort(_RandomAccessIterator __first, |
| 235 | 283 | } |
| 236 | 284 | |
| 237 | 285 | template <class _AlgPolicy, class _RandomAccessIterator, class _Compare> |
| 238 | inline _LIBCPP_HIDE_FROM_ABI void | |
| 286 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void | |
| 239 | 287 | __stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) { |
| 240 | 288 | using value_type = typename iterator_traits<_RandomAccessIterator>::value_type; |
| 241 | 289 | using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type; |
| 242 | 290 | |
| 243 | 291 | difference_type __len = __last - __first; |
| 292 | __unique_temporary_buffer<value_type> __unique_buf; | |
| 244 | 293 | pair<value_type*, ptrdiff_t> __buf(0, 0); |
| 245 | unique_ptr<value_type, __return_temporary_buffer> __h; | |
| 246 | 294 | if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value)) { |
| 247 | // TODO: Remove the use of std::get_temporary_buffer | |
| 248 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 249 | __buf = std::get_temporary_buffer<value_type>(__len); | |
| 250 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 251 | __h.reset(__buf.first); | |
| 295 | __unique_buf = std::__allocate_unique_temporary_buffer<value_type>(__len); | |
| 296 | __buf.first = __unique_buf.get(); | |
| 297 | __buf.second = __unique_buf.get_deleter().__count_; | |
| 252 | 298 | } |
| 253 | 299 | |
| 254 | 300 | std::__stable_sort<_AlgPolicy, __comp_ref_type<_Compare> >(__first, __last, __comp, __len, __buf.first, __buf.second); |
| ... | ... | @@ -256,18 +302,18 @@ __stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, |
| 256 | 302 | } |
| 257 | 303 | |
| 258 | 304 | template <class _RandomAccessIterator, class _Compare> |
| 259 | inline _LIBCPP_HIDE_FROM_ABI void | |
| 305 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void | |
| 260 | 306 | stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { |
| 261 | 307 | std::__stable_sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp); |
| 262 | 308 | } |
| 263 | 309 | |
| 264 | 310 | template <class _RandomAccessIterator> |
| 265 | inline _LIBCPP_HIDE_FROM_ABI void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) { | |
| 311 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void | |
| 312 | stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) { | |
| 266 | 313 | std::stable_sort(__first, __last, __less<>()); |
| 267 | 314 | } |
| 268 | 315 | |
| 269 | 316 | _LIBCPP_END_NAMESPACE_STD |
| 270 | ||
| 271 | 317 | _LIBCPP_POP_MACROS |
| 272 | 318 | |
| 273 | 319 | #endif // _LIBCPP___ALGORITHM_STABLE_SORT_H |
lib/libcxx/include/__algorithm/three_way_comp_ref_type.h+2-2| ... | ... | @@ -61,10 +61,10 @@ struct __debug_three_way_comp { |
| 61 | 61 | // Pass the comparator by lvalue reference. Or in the debug mode, using a debugging wrapper that stores a reference. |
| 62 | 62 | # if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG |
| 63 | 63 | template <class _Comp> |
| 64 | using __three_way_comp_ref_type = __debug_three_way_comp<_Comp>; | |
| 64 | using __three_way_comp_ref_type _LIBCPP_NODEBUG = __debug_three_way_comp<_Comp>; | |
| 65 | 65 | # else |
| 66 | 66 | template <class _Comp> |
| 67 | using __three_way_comp_ref_type = _Comp&; | |
| 67 | using __three_way_comp_ref_type _LIBCPP_NODEBUG = _Comp&; | |
| 68 | 68 | # endif |
| 69 | 69 | |
| 70 | 70 | #endif // _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h+1-1| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__functional/invoke.h> | |
| 13 | #include <__type_traits/invoke.h> | |
| 14 | 14 | #include <__type_traits/remove_cvref.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__algorithm/unique.h+6-4| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | 14 | #include <__algorithm/iterator_operations.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__functional/identity.h> | |
| 16 | 17 | #include <__iterator/iterator_traits.h> |
| 17 | 18 | #include <__utility/move.h> |
| 18 | 19 | #include <__utility/pair.h> |
| ... | ... | @@ -29,9 +30,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 30 | // unique |
| 30 | 31 | |
| 31 | 32 | template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate> |
| 32 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter> | |
| 33 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter> | |
| 33 | 34 | __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { |
| 34 | __first = std::__adjacent_find(__first, __last, __pred); | |
| 35 | __identity __proj; | |
| 36 | __first = std::__adjacent_find(__first, __last, __pred, __proj); | |
| 35 | 37 | if (__first != __last) { |
| 36 | 38 | // ... a a ? ... |
| 37 | 39 | // f i |
| ... | ... | @@ -46,13 +48,13 @@ __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | template <class _ForwardIterator, class _BinaryPredicate> |
| 49 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 51 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 50 | 52 | unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { |
| 51 | 53 | return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first; |
| 52 | 54 | } |
| 53 | 55 | |
| 54 | 56 | template <class _ForwardIterator> |
| 55 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 57 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 56 | 58 | unique(_ForwardIterator __first, _ForwardIterator __last) { |
| 57 | 59 | return std::unique(__first, __last, __equal_to()); |
| 58 | 60 | } |
lib/libcxx/include/__algorithm/unwrap_iter.h+1-1| ... | ... | @@ -46,7 +46,7 @@ struct __unwrap_iter_impl { |
| 46 | 46 | // It's a contiguous iterator, so we can use a raw pointer instead |
| 47 | 47 | template <class _Iter> |
| 48 | 48 | struct __unwrap_iter_impl<_Iter, true> { |
| 49 | using _ToAddressT = decltype(std::__to_address(std::declval<_Iter>())); | |
| 49 | using _ToAddressT _LIBCPP_NODEBUG = decltype(std::__to_address(std::declval<_Iter>())); | |
| 50 | 50 | |
| 51 | 51 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter __orig_iter, _ToAddressT __unwrapped_iter) { |
| 52 | 52 | return __orig_iter + (__unwrapped_iter - std::__to_address(__orig_iter)); |
lib/libcxx/include/__algorithm/upper_bound.h+5-2| ... | ... | @@ -18,6 +18,8 @@ |
| 18 | 18 | #include <__iterator/advance.h> |
| 19 | 19 | #include <__iterator/distance.h> |
| 20 | 20 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__type_traits/invoke.h> | |
| 22 | #include <__type_traits/is_callable.h> | |
| 21 | 23 | #include <__type_traits/is_constructible.h> |
| 22 | 24 | #include <__utility/move.h> |
| 23 | 25 | |
| ... | ... | @@ -48,15 +50,16 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp |
| 48 | 50 | } |
| 49 | 51 | |
| 50 | 52 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 51 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 53 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 52 | 54 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { |
| 55 | static_assert(__is_callable<_Compare&, const _Tp&, decltype(*__first)>::value, "The comparator has to be callable"); | |
| 53 | 56 | static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible"); |
| 54 | 57 | return std::__upper_bound<_ClassicAlgPolicy>( |
| 55 | 58 | std::move(__first), std::move(__last), __value, std::move(__comp), std::__identity()); |
| 56 | 59 | } |
| 57 | 60 | |
| 58 | 61 | template <class _ForwardIterator, class _Tp> |
| 59 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 62 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | |
| 60 | 63 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { |
| 61 | 64 | return std::upper_bound(std::move(__first), std::move(__last), __value, __less<>()); |
| 62 | 65 | } |
lib/libcxx/include/__assert+28-28| ... | ... | @@ -23,10 +23,10 @@ |
| 23 | 23 | : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING( \ |
| 24 | 24 | expression) " failed: " message "\n")) |
| 25 | 25 | |
| 26 | // TODO: __builtin_assume can currently inhibit optimizations. Until this has been fixed and we can add | |
| 27 | // assumptions without a clear optimization intent, disable that to avoid worsening the code generation. | |
| 28 | // See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a discussion. | |
| 29 | #if 0 && __has_builtin(__builtin_assume) | |
| 26 | // WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear | |
| 27 | // optimization intent. See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a | |
| 28 | // discussion. | |
| 29 | #if __has_builtin(__builtin_assume) | |
| 30 | 30 | # define _LIBCPP_ASSUME(expression) \ |
| 31 | 31 | (_LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \ |
| 32 | 32 | __builtin_assume(static_cast<bool>(expression)) _LIBCPP_DIAGNOSTIC_POP) |
| ... | ... | @@ -44,18 +44,18 @@ |
| 44 | 44 | # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) |
| 45 | 45 | // Disabled checks. |
| 46 | 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) | |
| 47 | # define _LIBCPP_ASSERT_NON_NULL(expression, message) ((void)0) | |
| 48 | 48 | // Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security |
| 49 | 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) | |
| 50 | # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) ((void)0) | |
| 51 | # define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) ((void)0) | |
| 52 | # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) ((void)0) | |
| 53 | # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) ((void)0) | |
| 54 | # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) ((void)0) | |
| 55 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) ((void)0) | |
| 56 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) ((void)0) | |
| 57 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) ((void)0) | |
| 58 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) ((void)0) | |
| 59 | 59 | |
| 60 | 60 | // Extensive hardening mode checks. |
| 61 | 61 | |
| ... | ... | @@ -73,8 +73,8 @@ |
| 73 | 73 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message) |
| 74 | 74 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message) |
| 75 | 75 | // Disabled checks. |
| 76 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression) | |
| 77 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) | |
| 76 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) ((void)0) | |
| 77 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) ((void)0) | |
| 78 | 78 | |
| 79 | 79 | // Debug hardening mode checks. |
| 80 | 80 | |
| ... | ... | @@ -99,18 +99,18 @@ |
| 99 | 99 | #else |
| 100 | 100 | |
| 101 | 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) | |
| 102 | # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) ((void)0) | |
| 103 | # define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) ((void)0) | |
| 104 | # define _LIBCPP_ASSERT_NON_NULL(expression, message) ((void)0) | |
| 105 | # define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) ((void)0) | |
| 106 | # define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) ((void)0) | |
| 107 | # define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) ((void)0) | |
| 108 | # define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) ((void)0) | |
| 109 | # define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) ((void)0) | |
| 110 | # define _LIBCPP_ASSERT_PEDANTIC(expression, message) ((void)0) | |
| 111 | # define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) ((void)0) | |
| 112 | # define _LIBCPP_ASSERT_INTERNAL(expression, message) ((void)0) | |
| 113 | # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) ((void)0) | |
| 114 | 114 | |
| 115 | 115 | #endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST |
| 116 | 116 | // clang-format on |
lib/libcxx/include/__assertion_handler+9-3| ... | ... | @@ -10,8 +10,13 @@ |
| 10 | 10 | #ifndef _LIBCPP___ASSERTION_HANDLER |
| 11 | 11 | #define _LIBCPP___ASSERTION_HANDLER |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | #include <__verbose_abort> | |
| 13 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 14 | # include <__cxx03/__config> | |
| 15 | # include <__cxx03/__verbose_abort> | |
| 16 | #else | |
| 17 | # include <__config> | |
| 18 | # include <__verbose_abort> | |
| 19 | #endif | |
| 15 | 20 | |
| 16 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 22 | # pragma GCC system_header |
| ... | ... | @@ -26,7 +31,8 @@ |
| 26 | 31 | # if __has_builtin(__builtin_verbose_trap) |
| 27 | 32 | // AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream |
| 28 | 33 | // version before upstream Clang actually got the builtin. |
| 29 | # if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 17000 | |
| 34 | // TODO: Remove once AppleClang supports the two-arguments version of the builtin. | |
| 35 | # if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700 | |
| 30 | 36 | # define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message) |
| 31 | 37 | # else |
| 32 | 38 | # define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message) |
lib/libcxx/include/__atomic/aliases.h+9-8| ... | ... | @@ -14,9 +14,10 @@ |
| 14 | 14 | #include <__atomic/contention_t.h> |
| 15 | 15 | #include <__atomic/is_always_lock_free.h> |
| 16 | 16 | #include <__config> |
| 17 | #include <__cstddef/ptrdiff_t.h> | |
| 18 | #include <__cstddef/size_t.h> | |
| 17 | 19 | #include <__type_traits/conditional.h> |
| 18 | 20 | #include <__type_traits/make_unsigned.h> |
| 19 | #include <cstddef> | |
| 20 | 21 | #include <cstdint> |
| 21 | 22 | |
| 22 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -37,12 +38,12 @@ using atomic_long = atomic<long>; |
| 37 | 38 | using atomic_ulong = atomic<unsigned long>; |
| 38 | 39 | using atomic_llong = atomic<long long>; |
| 39 | 40 | using atomic_ullong = atomic<unsigned long long>; |
| 40 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 41 | #if _LIBCPP_HAS_CHAR8_T | |
| 41 | 42 | using atomic_char8_t = atomic<char8_t>; |
| 42 | 43 | #endif |
| 43 | 44 | using atomic_char16_t = atomic<char16_t>; |
| 44 | 45 | using atomic_char32_t = atomic<char32_t>; |
| 45 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 46 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 46 | 47 | using atomic_wchar_t = atomic<wchar_t>; |
| 47 | 48 | #endif |
| 48 | 49 | |
| ... | ... | @@ -83,19 +84,19 @@ using atomic_uintmax_t = atomic<uintmax_t>; |
| 83 | 84 | // C++20 atomic_{signed,unsigned}_lock_free: prefer the contention type most highly, then the largest lock-free type |
| 84 | 85 | #if _LIBCPP_STD_VER >= 20 |
| 85 | 86 | # if ATOMIC_LLONG_LOCK_FREE == 2 |
| 86 | using __largest_lock_free_type = long long; | |
| 87 | using __largest_lock_free_type _LIBCPP_NODEBUG = long long; | |
| 87 | 88 | # elif ATOMIC_INT_LOCK_FREE == 2 |
| 88 | using __largest_lock_free_type = int; | |
| 89 | using __largest_lock_free_type _LIBCPP_NODEBUG = int; | |
| 89 | 90 | # elif ATOMIC_SHORT_LOCK_FREE == 2 |
| 90 | using __largest_lock_free_type = short; | |
| 91 | using __largest_lock_free_type _LIBCPP_NODEBUG = short; | |
| 91 | 92 | # elif ATOMIC_CHAR_LOCK_FREE == 2 |
| 92 | using __largest_lock_free_type = char; | |
| 93 | using __largest_lock_free_type _LIBCPP_NODEBUG = char; | |
| 93 | 94 | # else |
| 94 | 95 | # define _LIBCPP_NO_LOCK_FREE_TYPES // There are no lockfree types (this can happen on unusual platforms) |
| 95 | 96 | # endif |
| 96 | 97 | |
| 97 | 98 | # ifndef _LIBCPP_NO_LOCK_FREE_TYPES |
| 98 | using __contention_t_or_largest = | |
| 99 | using __contention_t_or_largest _LIBCPP_NODEBUG = | |
| 99 | 100 | __conditional_t<__libcpp_is_always_lock_free<__cxx_contention_t>::__value, |
| 100 | 101 | __cxx_contention_t, |
| 101 | 102 | __largest_lock_free_type>; |
lib/libcxx/include/__atomic/atomic.h+222-23| ... | ... | @@ -9,21 +9,24 @@ |
| 9 | 9 | #ifndef _LIBCPP___ATOMIC_ATOMIC_H |
| 10 | 10 | #define _LIBCPP___ATOMIC_ATOMIC_H |
| 11 | 11 | |
| 12 | #include <__atomic/atomic_base.h> | |
| 12 | #include <__atomic/atomic_sync.h> | |
| 13 | 13 | #include <__atomic/check_memory_order.h> |
| 14 | #include <__atomic/cxx_atomic_impl.h> | |
| 14 | #include <__atomic/is_always_lock_free.h> | |
| 15 | 15 | #include <__atomic/memory_order.h> |
| 16 | #include <__atomic/support.h> | |
| 16 | 17 | #include <__config> |
| 17 | #include <__functional/operations.h> | |
| 18 | #include <__cstddef/ptrdiff_t.h> | |
| 18 | 19 | #include <__memory/addressof.h> |
| 20 | #include <__type_traits/enable_if.h> | |
| 19 | 21 | #include <__type_traits/is_floating_point.h> |
| 20 | 22 | #include <__type_traits/is_function.h> |
| 23 | #include <__type_traits/is_integral.h> | |
| 24 | #include <__type_traits/is_nothrow_constructible.h> | |
| 21 | 25 | #include <__type_traits/is_same.h> |
| 22 | 26 | #include <__type_traits/remove_const.h> |
| 23 | 27 | #include <__type_traits/remove_pointer.h> |
| 24 | 28 | #include <__type_traits/remove_volatile.h> |
| 25 | 29 | #include <__utility/forward.h> |
| 26 | #include <cstddef> | |
| 27 | 30 | #include <cstring> |
| 28 | 31 | |
| 29 | 32 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -32,11 +35,202 @@ |
| 32 | 35 | |
| 33 | 36 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 37 | |
| 38 | template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value> | |
| 39 | struct __atomic_base // false | |
| 40 | { | |
| 41 | mutable __cxx_atomic_impl<_Tp> __a_; | |
| 42 | ||
| 43 | #if _LIBCPP_STD_VER >= 17 | |
| 44 | static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value; | |
| 45 | #endif | |
| 46 | ||
| 47 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT { | |
| 48 | return __cxx_atomic_is_lock_free(sizeof(__cxx_atomic_impl<_Tp>)); | |
| 49 | } | |
| 50 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const _NOEXCEPT { | |
| 51 | return static_cast<__atomic_base const volatile*>(this)->is_lock_free(); | |
| 52 | } | |
| 53 | _LIBCPP_HIDE_FROM_ABI void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT | |
| 54 | _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) { | |
| 55 | std::__cxx_atomic_store(std::addressof(__a_), __d, __m); | |
| 56 | } | |
| 57 | _LIBCPP_HIDE_FROM_ABI void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT | |
| 58 | _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) { | |
| 59 | std::__cxx_atomic_store(std::addressof(__a_), __d, __m); | |
| 60 | } | |
| 61 | _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT | |
| 62 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { | |
| 63 | return std::__cxx_atomic_load(std::addressof(__a_), __m); | |
| 64 | } | |
| 65 | _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT | |
| 66 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { | |
| 67 | return std::__cxx_atomic_load(std::addressof(__a_), __m); | |
| 68 | } | |
| 69 | _LIBCPP_HIDE_FROM_ABI operator _Tp() const volatile _NOEXCEPT { return load(); } | |
| 70 | _LIBCPP_HIDE_FROM_ABI operator _Tp() const _NOEXCEPT { return load(); } | |
| 71 | _LIBCPP_HIDE_FROM_ABI _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 72 | return std::__cxx_atomic_exchange(std::addressof(__a_), __d, __m); | |
| 73 | } | |
| 74 | _LIBCPP_HIDE_FROM_ABI _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 75 | return std::__cxx_atomic_exchange(std::addressof(__a_), __d, __m); | |
| 76 | } | |
| 77 | _LIBCPP_HIDE_FROM_ABI bool | |
| 78 | compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) volatile _NOEXCEPT | |
| 79 | _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) { | |
| 80 | return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __s, __f); | |
| 81 | } | |
| 82 | _LIBCPP_HIDE_FROM_ABI bool compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) _NOEXCEPT | |
| 83 | _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) { | |
| 84 | return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __s, __f); | |
| 85 | } | |
| 86 | _LIBCPP_HIDE_FROM_ABI bool | |
| 87 | compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) volatile _NOEXCEPT | |
| 88 | _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) { | |
| 89 | return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __s, __f); | |
| 90 | } | |
| 91 | _LIBCPP_HIDE_FROM_ABI bool compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) _NOEXCEPT | |
| 92 | _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) { | |
| 93 | return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __s, __f); | |
| 94 | } | |
| 95 | _LIBCPP_HIDE_FROM_ABI bool | |
| 96 | compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 97 | return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __m, __m); | |
| 98 | } | |
| 99 | _LIBCPP_HIDE_FROM_ABI bool | |
| 100 | compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 101 | return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __m, __m); | |
| 102 | } | |
| 103 | _LIBCPP_HIDE_FROM_ABI bool | |
| 104 | compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 105 | return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m); | |
| 106 | } | |
| 107 | _LIBCPP_HIDE_FROM_ABI bool | |
| 108 | compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 109 | return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m); | |
| 110 | } | |
| 111 | ||
| 112 | #if _LIBCPP_STD_VER >= 20 | |
| 113 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const | |
| 114 | volatile _NOEXCEPT { | |
| 115 | std::__atomic_wait(*this, __v, __m); | |
| 116 | } | |
| 117 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | |
| 118 | wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { | |
| 119 | std::__atomic_wait(*this, __v, __m); | |
| 120 | } | |
| 121 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { | |
| 122 | std::__atomic_notify_one(*this); | |
| 123 | } | |
| 124 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); } | |
| 125 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { | |
| 126 | std::__atomic_notify_all(*this); | |
| 127 | } | |
| 128 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); } | |
| 129 | #endif // _LIBCPP_STD_VER >= 20 | |
| 130 | ||
| 131 | #if _LIBCPP_STD_VER >= 20 | |
| 132 | _LIBCPP_HIDE_FROM_ABI constexpr __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {} | |
| 133 | #else | |
| 134 | _LIBCPP_HIDE_FROM_ABI __atomic_base() _NOEXCEPT = default; | |
| 135 | #endif | |
| 136 | ||
| 137 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} | |
| 138 | ||
| 139 | __atomic_base(const __atomic_base&) = delete; | |
| 140 | }; | |
| 141 | ||
| 142 | // atomic<Integral> | |
| 143 | ||
| 144 | template <class _Tp> | |
| 145 | struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> { | |
| 146 | using __base _LIBCPP_NODEBUG = __atomic_base<_Tp, false>; | |
| 147 | ||
| 148 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __atomic_base() _NOEXCEPT = default; | |
| 149 | ||
| 150 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} | |
| 151 | ||
| 152 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 153 | return std::__cxx_atomic_fetch_add(std::addressof(this->__a_), __op, __m); | |
| 154 | } | |
| 155 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 156 | return std::__cxx_atomic_fetch_add(std::addressof(this->__a_), __op, __m); | |
| 157 | } | |
| 158 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 159 | return std::__cxx_atomic_fetch_sub(std::addressof(this->__a_), __op, __m); | |
| 160 | } | |
| 161 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 162 | return std::__cxx_atomic_fetch_sub(std::addressof(this->__a_), __op, __m); | |
| 163 | } | |
| 164 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 165 | return std::__cxx_atomic_fetch_and(std::addressof(this->__a_), __op, __m); | |
| 166 | } | |
| 167 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 168 | return std::__cxx_atomic_fetch_and(std::addressof(this->__a_), __op, __m); | |
| 169 | } | |
| 170 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 171 | return std::__cxx_atomic_fetch_or(std::addressof(this->__a_), __op, __m); | |
| 172 | } | |
| 173 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 174 | return std::__cxx_atomic_fetch_or(std::addressof(this->__a_), __op, __m); | |
| 175 | } | |
| 176 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 177 | return std::__cxx_atomic_fetch_xor(std::addressof(this->__a_), __op, __m); | |
| 178 | } | |
| 179 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 180 | return std::__cxx_atomic_fetch_xor(std::addressof(this->__a_), __op, __m); | |
| 181 | } | |
| 182 | ||
| 183 | _LIBCPP_HIDE_FROM_ABI _Tp operator++(int) volatile _NOEXCEPT { return fetch_add(_Tp(1)); } | |
| 184 | _LIBCPP_HIDE_FROM_ABI _Tp operator++(int) _NOEXCEPT { return fetch_add(_Tp(1)); } | |
| 185 | _LIBCPP_HIDE_FROM_ABI _Tp operator--(int) volatile _NOEXCEPT { return fetch_sub(_Tp(1)); } | |
| 186 | _LIBCPP_HIDE_FROM_ABI _Tp operator--(int) _NOEXCEPT { return fetch_sub(_Tp(1)); } | |
| 187 | _LIBCPP_HIDE_FROM_ABI _Tp operator++() volatile _NOEXCEPT { return fetch_add(_Tp(1)) + _Tp(1); } | |
| 188 | _LIBCPP_HIDE_FROM_ABI _Tp operator++() _NOEXCEPT { return fetch_add(_Tp(1)) + _Tp(1); } | |
| 189 | _LIBCPP_HIDE_FROM_ABI _Tp operator--() volatile _NOEXCEPT { return fetch_sub(_Tp(1)) - _Tp(1); } | |
| 190 | _LIBCPP_HIDE_FROM_ABI _Tp operator--() _NOEXCEPT { return fetch_sub(_Tp(1)) - _Tp(1); } | |
| 191 | _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __op) volatile _NOEXCEPT { return fetch_add(__op) + __op; } | |
| 192 | _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __op) _NOEXCEPT { return fetch_add(__op) + __op; } | |
| 193 | _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __op) volatile _NOEXCEPT { return fetch_sub(__op) - __op; } | |
| 194 | _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __op) _NOEXCEPT { return fetch_sub(__op) - __op; } | |
| 195 | _LIBCPP_HIDE_FROM_ABI _Tp operator&=(_Tp __op) volatile _NOEXCEPT { return fetch_and(__op) & __op; } | |
| 196 | _LIBCPP_HIDE_FROM_ABI _Tp operator&=(_Tp __op) _NOEXCEPT { return fetch_and(__op) & __op; } | |
| 197 | _LIBCPP_HIDE_FROM_ABI _Tp operator|=(_Tp __op) volatile _NOEXCEPT { return fetch_or(__op) | __op; } | |
| 198 | _LIBCPP_HIDE_FROM_ABI _Tp operator|=(_Tp __op) _NOEXCEPT { return fetch_or(__op) | __op; } | |
| 199 | _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) volatile _NOEXCEPT { return fetch_xor(__op) ^ __op; } | |
| 200 | _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) _NOEXCEPT { return fetch_xor(__op) ^ __op; } | |
| 201 | }; | |
| 202 | ||
| 203 | // Here we need _IsIntegral because the default template argument is not enough | |
| 204 | // e.g __atomic_base<int> is __atomic_base<int, true>, which inherits from | |
| 205 | // __atomic_base<int, false> and the caller of the wait function is | |
| 206 | // __atomic_base<int, false>. So specializing __atomic_base<_Tp> does not work | |
| 207 | template <class _Tp, bool _IsIntegral> | |
| 208 | struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > { | |
| 209 | static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_base<_Tp, _IsIntegral>& __a, memory_order __order) { | |
| 210 | return __a.load(__order); | |
| 211 | } | |
| 212 | ||
| 213 | static _LIBCPP_HIDE_FROM_ABI _Tp | |
| 214 | __atomic_load(const volatile __atomic_base<_Tp, _IsIntegral>& __this, memory_order __order) { | |
| 215 | return __this.load(__order); | |
| 216 | } | |
| 217 | ||
| 218 | static _LIBCPP_HIDE_FROM_ABI const __cxx_atomic_impl<_Tp>* | |
| 219 | __atomic_contention_address(const __atomic_base<_Tp, _IsIntegral>& __a) { | |
| 220 | return std::addressof(__a.__a_); | |
| 221 | } | |
| 222 | ||
| 223 | static _LIBCPP_HIDE_FROM_ABI const volatile __cxx_atomic_impl<_Tp>* | |
| 224 | __atomic_contention_address(const volatile __atomic_base<_Tp, _IsIntegral>& __this) { | |
| 225 | return std::addressof(__this.__a_); | |
| 226 | } | |
| 227 | }; | |
| 228 | ||
| 35 | 229 | template <class _Tp> |
| 36 | 230 | struct atomic : public __atomic_base<_Tp> { |
| 37 | using __base = __atomic_base<_Tp>; | |
| 38 | using value_type = _Tp; | |
| 39 | using difference_type = value_type; | |
| 231 | using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>; | |
| 232 | using value_type = _Tp; | |
| 233 | using difference_type = value_type; | |
| 40 | 234 | |
| 41 | 235 | #if _LIBCPP_STD_VER >= 20 |
| 42 | 236 | _LIBCPP_HIDE_FROM_ABI atomic() = default; |
| ... | ... | @@ -63,9 +257,9 @@ struct atomic : public __atomic_base<_Tp> { |
| 63 | 257 | |
| 64 | 258 | template <class _Tp> |
| 65 | 259 | struct atomic<_Tp*> : public __atomic_base<_Tp*> { |
| 66 | using __base = __atomic_base<_Tp*>; | |
| 67 | using value_type = _Tp*; | |
| 68 | using difference_type = ptrdiff_t; | |
| 260 | using __base _LIBCPP_NODEBUG = __atomic_base<_Tp*>; | |
| 261 | using value_type = _Tp*; | |
| 262 | using difference_type = ptrdiff_t; | |
| 69 | 263 | |
| 70 | 264 | _LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default; |
| 71 | 265 | |
| ... | ... | @@ -121,6 +315,9 @@ struct atomic<_Tp*> : public __atomic_base<_Tp*> { |
| 121 | 315 | atomic& operator=(const atomic&) volatile = delete; |
| 122 | 316 | }; |
| 123 | 317 | |
| 318 | template <class _Tp> | |
| 319 | struct __atomic_waitable_traits<atomic<_Tp> > : __atomic_waitable_traits<__atomic_base<_Tp> > {}; | |
| 320 | ||
| 124 | 321 | #if _LIBCPP_STD_VER >= 20 |
| 125 | 322 | template <class _Tp> |
| 126 | 323 | requires is_floating_point_v<_Tp> |
| ... | ... | @@ -178,7 +375,8 @@ private: |
| 178 | 375 | auto __builtin_op = [](auto __a, auto __builtin_operand, auto __order) { |
| 179 | 376 | return std::__cxx_atomic_fetch_add(__a, __builtin_operand, __order); |
| 180 | 377 | }; |
| 181 | return __rmw_op(std::forward<_This>(__self), __operand, __m, std::plus<>{}, __builtin_op); | |
| 378 | auto __plus = [](auto __a, auto __b) { return __a + __b; }; | |
| 379 | return __rmw_op(std::forward<_This>(__self), __operand, __m, __plus, __builtin_op); | |
| 182 | 380 | } |
| 183 | 381 | |
| 184 | 382 | template <class _This> |
| ... | ... | @@ -186,13 +384,14 @@ private: |
| 186 | 384 | auto __builtin_op = [](auto __a, auto __builtin_operand, auto __order) { |
| 187 | 385 | return std::__cxx_atomic_fetch_sub(__a, __builtin_operand, __order); |
| 188 | 386 | }; |
| 189 | return __rmw_op(std::forward<_This>(__self), __operand, __m, std::minus<>{}, __builtin_op); | |
| 387 | auto __minus = [](auto __a, auto __b) { return __a - __b; }; | |
| 388 | return __rmw_op(std::forward<_This>(__self), __operand, __m, __minus, __builtin_op); | |
| 190 | 389 | } |
| 191 | 390 | |
| 192 | 391 | public: |
| 193 | using __base = __atomic_base<_Tp>; | |
| 194 | using value_type = _Tp; | |
| 195 | using difference_type = value_type; | |
| 392 | using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>; | |
| 393 | using value_type = _Tp; | |
| 394 | using difference_type = value_type; | |
| 196 | 395 | |
| 197 | 396 | _LIBCPP_HIDE_FROM_ABI constexpr atomic() noexcept = default; |
| 198 | 397 | _LIBCPP_HIDE_FROM_ABI constexpr atomic(_Tp __d) noexcept : __base(__d) {} |
| ... | ... | @@ -429,6 +628,8 @@ _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit( |
| 429 | 628 | return __o->compare_exchange_strong(*__e, __d, __s, __f); |
| 430 | 629 | } |
| 431 | 630 | |
| 631 | #if _LIBCPP_STD_VER >= 20 | |
| 632 | ||
| 432 | 633 | // atomic_wait |
| 433 | 634 | |
| 434 | 635 | template <class _Tp> |
| ... | ... | @@ -462,29 +663,27 @@ atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __ |
| 462 | 663 | // atomic_notify_one |
| 463 | 664 | |
| 464 | 665 | template <class _Tp> |
| 465 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | |
| 466 | atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT { | |
| 666 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT { | |
| 467 | 667 | __o->notify_one(); |
| 468 | 668 | } |
| 469 | 669 | template <class _Tp> |
| 470 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | |
| 471 | atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT { | |
| 670 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT { | |
| 472 | 671 | __o->notify_one(); |
| 473 | 672 | } |
| 474 | 673 | |
| 475 | 674 | // atomic_notify_all |
| 476 | 675 | |
| 477 | 676 | template <class _Tp> |
| 478 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | |
| 479 | atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT { | |
| 677 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT { | |
| 480 | 678 | __o->notify_all(); |
| 481 | 679 | } |
| 482 | 680 | template <class _Tp> |
| 483 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | |
| 484 | atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT { | |
| 681 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT { | |
| 485 | 682 | __o->notify_all(); |
| 486 | 683 | } |
| 487 | 684 | |
| 685 | #endif // _LIBCPP_STD_VER >= 20 | |
| 686 | ||
| 488 | 687 | // atomic_fetch_add |
| 489 | 688 | |
| 490 | 689 | template <class _Tp> |
lib/libcxx/include/__atomic/atomic_base.h deleted-221| ... | ... | @@ -1,221 +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___ATOMIC_ATOMIC_BASE_H | |
| 10 | #define _LIBCPP___ATOMIC_ATOMIC_BASE_H | |
| 11 | ||
| 12 | #include <__atomic/atomic_sync.h> | |
| 13 | #include <__atomic/check_memory_order.h> | |
| 14 | #include <__atomic/cxx_atomic_impl.h> | |
| 15 | #include <__atomic/is_always_lock_free.h> | |
| 16 | #include <__atomic/memory_order.h> | |
| 17 | #include <__config> | |
| 18 | #include <__memory/addressof.h> | |
| 19 | #include <__type_traits/is_integral.h> | |
| 20 | #include <__type_traits/is_nothrow_constructible.h> | |
| 21 | #include <__type_traits/is_same.h> | |
| 22 | #include <version> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value> | |
| 31 | struct __atomic_base // false | |
| 32 | { | |
| 33 | mutable __cxx_atomic_impl<_Tp> __a_; | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER >= 17 | |
| 36 | static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value; | |
| 37 | #endif | |
| 38 | ||
| 39 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT { | |
| 40 | return __cxx_atomic_is_lock_free(sizeof(__cxx_atomic_impl<_Tp>)); | |
| 41 | } | |
| 42 | _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const _NOEXCEPT { | |
| 43 | return static_cast<__atomic_base const volatile*>(this)->is_lock_free(); | |
| 44 | } | |
| 45 | _LIBCPP_HIDE_FROM_ABI void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT | |
| 46 | _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) { | |
| 47 | std::__cxx_atomic_store(std::addressof(__a_), __d, __m); | |
| 48 | } | |
| 49 | _LIBCPP_HIDE_FROM_ABI void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT | |
| 50 | _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) { | |
| 51 | std::__cxx_atomic_store(std::addressof(__a_), __d, __m); | |
| 52 | } | |
| 53 | _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT | |
| 54 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { | |
| 55 | return std::__cxx_atomic_load(std::addressof(__a_), __m); | |
| 56 | } | |
| 57 | _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT | |
| 58 | _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m) { | |
| 59 | return std::__cxx_atomic_load(std::addressof(__a_), __m); | |
| 60 | } | |
| 61 | _LIBCPP_HIDE_FROM_ABI operator _Tp() const volatile _NOEXCEPT { return load(); } | |
| 62 | _LIBCPP_HIDE_FROM_ABI operator _Tp() const _NOEXCEPT { return load(); } | |
| 63 | _LIBCPP_HIDE_FROM_ABI _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 64 | return std::__cxx_atomic_exchange(std::addressof(__a_), __d, __m); | |
| 65 | } | |
| 66 | _LIBCPP_HIDE_FROM_ABI _Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 67 | return std::__cxx_atomic_exchange(std::addressof(__a_), __d, __m); | |
| 68 | } | |
| 69 | _LIBCPP_HIDE_FROM_ABI bool | |
| 70 | compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) volatile _NOEXCEPT | |
| 71 | _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) { | |
| 72 | return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __s, __f); | |
| 73 | } | |
| 74 | _LIBCPP_HIDE_FROM_ABI bool compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) _NOEXCEPT | |
| 75 | _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) { | |
| 76 | return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __s, __f); | |
| 77 | } | |
| 78 | _LIBCPP_HIDE_FROM_ABI bool | |
| 79 | compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) volatile _NOEXCEPT | |
| 80 | _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) { | |
| 81 | return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __s, __f); | |
| 82 | } | |
| 83 | _LIBCPP_HIDE_FROM_ABI bool compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __s, memory_order __f) _NOEXCEPT | |
| 84 | _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f) { | |
| 85 | return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __s, __f); | |
| 86 | } | |
| 87 | _LIBCPP_HIDE_FROM_ABI bool | |
| 88 | compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 89 | return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __m, __m); | |
| 90 | } | |
| 91 | _LIBCPP_HIDE_FROM_ABI bool | |
| 92 | compare_exchange_weak(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 93 | return std::__cxx_atomic_compare_exchange_weak(std::addressof(__a_), std::addressof(__e), __d, __m, __m); | |
| 94 | } | |
| 95 | _LIBCPP_HIDE_FROM_ABI bool | |
| 96 | compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 97 | return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m); | |
| 98 | } | |
| 99 | _LIBCPP_HIDE_FROM_ABI bool | |
| 100 | compare_exchange_strong(_Tp& __e, _Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 101 | return std::__cxx_atomic_compare_exchange_strong(std::addressof(__a_), std::addressof(__e), __d, __m, __m); | |
| 102 | } | |
| 103 | ||
| 104 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const | |
| 105 | volatile _NOEXCEPT { | |
| 106 | std::__atomic_wait(*this, __v, __m); | |
| 107 | } | |
| 108 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | |
| 109 | wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { | |
| 110 | std::__atomic_wait(*this, __v, __m); | |
| 111 | } | |
| 112 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { | |
| 113 | std::__atomic_notify_one(*this); | |
| 114 | } | |
| 115 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); } | |
| 116 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { | |
| 117 | std::__atomic_notify_all(*this); | |
| 118 | } | |
| 119 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); } | |
| 120 | ||
| 121 | #if _LIBCPP_STD_VER >= 20 | |
| 122 | _LIBCPP_HIDE_FROM_ABI constexpr __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {} | |
| 123 | #else | |
| 124 | _LIBCPP_HIDE_FROM_ABI __atomic_base() _NOEXCEPT = default; | |
| 125 | #endif | |
| 126 | ||
| 127 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} | |
| 128 | ||
| 129 | __atomic_base(const __atomic_base&) = delete; | |
| 130 | }; | |
| 131 | ||
| 132 | // atomic<Integral> | |
| 133 | ||
| 134 | template <class _Tp> | |
| 135 | struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> { | |
| 136 | using __base = __atomic_base<_Tp, false>; | |
| 137 | ||
| 138 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __atomic_base() _NOEXCEPT = default; | |
| 139 | ||
| 140 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} | |
| 141 | ||
| 142 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 143 | return std::__cxx_atomic_fetch_add(std::addressof(this->__a_), __op, __m); | |
| 144 | } | |
| 145 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 146 | return std::__cxx_atomic_fetch_add(std::addressof(this->__a_), __op, __m); | |
| 147 | } | |
| 148 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 149 | return std::__cxx_atomic_fetch_sub(std::addressof(this->__a_), __op, __m); | |
| 150 | } | |
| 151 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 152 | return std::__cxx_atomic_fetch_sub(std::addressof(this->__a_), __op, __m); | |
| 153 | } | |
| 154 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 155 | return std::__cxx_atomic_fetch_and(std::addressof(this->__a_), __op, __m); | |
| 156 | } | |
| 157 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 158 | return std::__cxx_atomic_fetch_and(std::addressof(this->__a_), __op, __m); | |
| 159 | } | |
| 160 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 161 | return std::__cxx_atomic_fetch_or(std::addressof(this->__a_), __op, __m); | |
| 162 | } | |
| 163 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 164 | return std::__cxx_atomic_fetch_or(std::addressof(this->__a_), __op, __m); | |
| 165 | } | |
| 166 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 167 | return std::__cxx_atomic_fetch_xor(std::addressof(this->__a_), __op, __m); | |
| 168 | } | |
| 169 | _LIBCPP_HIDE_FROM_ABI _Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 170 | return std::__cxx_atomic_fetch_xor(std::addressof(this->__a_), __op, __m); | |
| 171 | } | |
| 172 | ||
| 173 | _LIBCPP_HIDE_FROM_ABI _Tp operator++(int) volatile _NOEXCEPT { return fetch_add(_Tp(1)); } | |
| 174 | _LIBCPP_HIDE_FROM_ABI _Tp operator++(int) _NOEXCEPT { return fetch_add(_Tp(1)); } | |
| 175 | _LIBCPP_HIDE_FROM_ABI _Tp operator--(int) volatile _NOEXCEPT { return fetch_sub(_Tp(1)); } | |
| 176 | _LIBCPP_HIDE_FROM_ABI _Tp operator--(int) _NOEXCEPT { return fetch_sub(_Tp(1)); } | |
| 177 | _LIBCPP_HIDE_FROM_ABI _Tp operator++() volatile _NOEXCEPT { return fetch_add(_Tp(1)) + _Tp(1); } | |
| 178 | _LIBCPP_HIDE_FROM_ABI _Tp operator++() _NOEXCEPT { return fetch_add(_Tp(1)) + _Tp(1); } | |
| 179 | _LIBCPP_HIDE_FROM_ABI _Tp operator--() volatile _NOEXCEPT { return fetch_sub(_Tp(1)) - _Tp(1); } | |
| 180 | _LIBCPP_HIDE_FROM_ABI _Tp operator--() _NOEXCEPT { return fetch_sub(_Tp(1)) - _Tp(1); } | |
| 181 | _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __op) volatile _NOEXCEPT { return fetch_add(__op) + __op; } | |
| 182 | _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __op) _NOEXCEPT { return fetch_add(__op) + __op; } | |
| 183 | _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __op) volatile _NOEXCEPT { return fetch_sub(__op) - __op; } | |
| 184 | _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __op) _NOEXCEPT { return fetch_sub(__op) - __op; } | |
| 185 | _LIBCPP_HIDE_FROM_ABI _Tp operator&=(_Tp __op) volatile _NOEXCEPT { return fetch_and(__op) & __op; } | |
| 186 | _LIBCPP_HIDE_FROM_ABI _Tp operator&=(_Tp __op) _NOEXCEPT { return fetch_and(__op) & __op; } | |
| 187 | _LIBCPP_HIDE_FROM_ABI _Tp operator|=(_Tp __op) volatile _NOEXCEPT { return fetch_or(__op) | __op; } | |
| 188 | _LIBCPP_HIDE_FROM_ABI _Tp operator|=(_Tp __op) _NOEXCEPT { return fetch_or(__op) | __op; } | |
| 189 | _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) volatile _NOEXCEPT { return fetch_xor(__op) ^ __op; } | |
| 190 | _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) _NOEXCEPT { return fetch_xor(__op) ^ __op; } | |
| 191 | }; | |
| 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 | ||
| 219 | _LIBCPP_END_NAMESPACE_STD | |
| 220 | ||
| 221 | #endif // _LIBCPP___ATOMIC_ATOMIC_BASE_H |
lib/libcxx/include/__atomic/atomic_flag.h+19-21| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__atomic/atomic_sync.h> |
| 13 | 13 | #include <__atomic/contention_t.h> |
| 14 | #include <__atomic/cxx_atomic_impl.h> | |
| 15 | 14 | #include <__atomic/memory_order.h> |
| 15 | #include <__atomic/support.h> | |
| 16 | 16 | #include <__chrono/duration.h> |
| 17 | 17 | #include <__config> |
| 18 | 18 | #include <__memory/addressof.h> |
| ... | ... | @@ -48,26 +48,24 @@ struct atomic_flag { |
| 48 | 48 | __cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | |
| 52 | wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT { | |
| 51 | #if _LIBCPP_STD_VER >= 20 | |
| 52 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const | |
| 53 | volatile _NOEXCEPT { | |
| 53 | 54 | std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); |
| 54 | 55 | } |
| 55 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | |
| 56 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void | |
| 56 | 57 | wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT { |
| 57 | 58 | std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m); |
| 58 | 59 | } |
| 59 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { | |
| 60 | std::__atomic_notify_one(*this); | |
| 61 | } | |
| 62 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { | |
| 60 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { | |
| 63 | 61 | std::__atomic_notify_one(*this); |
| 64 | 62 | } |
| 63 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); } | |
| 65 | 64 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT { |
| 66 | 65 | std::__atomic_notify_all(*this); |
| 67 | 66 | } |
| 68 | _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { | |
| 69 | std::__atomic_notify_all(*this); | |
| 70 | } | |
| 67 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); } | |
| 68 | #endif | |
| 71 | 69 | |
| 72 | 70 | #if _LIBCPP_STD_VER >= 20 |
| 73 | 71 | _LIBCPP_HIDE_FROM_ABI constexpr atomic_flag() _NOEXCEPT : __a_(false) {} |
| ... | ... | @@ -144,45 +142,45 @@ inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_clear_explicit(atomic_flag* __o, m |
| 144 | 142 | __o->clear(__m); |
| 145 | 143 | } |
| 146 | 144 | |
| 147 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 145 | #if _LIBCPP_STD_VER >= 20 | |
| 146 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 148 | 147 | atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT { |
| 149 | 148 | __o->wait(__v); |
| 150 | 149 | } |
| 151 | 150 | |
| 152 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 151 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 153 | 152 | atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT { |
| 154 | 153 | __o->wait(__v); |
| 155 | 154 | } |
| 156 | 155 | |
| 157 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 156 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 158 | 157 | atomic_flag_wait_explicit(const volatile atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { |
| 159 | 158 | __o->wait(__v, __m); |
| 160 | 159 | } |
| 161 | 160 | |
| 162 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 161 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 163 | 162 | atomic_flag_wait_explicit(const atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT { |
| 164 | 163 | __o->wait(__v, __m); |
| 165 | 164 | } |
| 166 | 165 | |
| 167 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 166 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 168 | 167 | atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT { |
| 169 | 168 | __o->notify_one(); |
| 170 | 169 | } |
| 171 | 170 | |
| 172 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 173 | atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT { | |
| 171 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT { | |
| 174 | 172 | __o->notify_one(); |
| 175 | 173 | } |
| 176 | 174 | |
| 177 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 175 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 178 | 176 | atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT { |
| 179 | 177 | __o->notify_all(); |
| 180 | 178 | } |
| 181 | 179 | |
| 182 | inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void | |
| 183 | atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT { | |
| 180 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT { | |
| 184 | 181 | __o->notify_all(); |
| 185 | 182 | } |
| 183 | #endif // _LIBCPP_STD_VER >= 20 | |
| 186 | 184 | |
| 187 | 185 | _LIBCPP_END_NAMESPACE_STD |
| 188 | 186 |
lib/libcxx/include/__atomic/atomic_lock_free.h+2-2| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE) |
| 19 | 19 | # define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE |
| 20 | 20 | # define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE |
| 21 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 21 | # if _LIBCPP_HAS_CHAR8_T | |
| 22 | 22 | # define ATOMIC_CHAR8_T_LOCK_FREE __CLANG_ATOMIC_CHAR8_T_LOCK_FREE |
| 23 | 23 | # endif |
| 24 | 24 | # define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE |
| ... | ... | @@ -32,7 +32,7 @@ |
| 32 | 32 | #elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE) |
| 33 | 33 | # define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE |
| 34 | 34 | # define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE |
| 35 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 35 | # if _LIBCPP_HAS_CHAR8_T | |
| 36 | 36 | # define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE |
| 37 | 37 | # endif |
| 38 | 38 | # define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE |
lib/libcxx/include/__atomic/atomic_ref.h+8-6| ... | ... | @@ -20,14 +20,16 @@ |
| 20 | 20 | #include <__assert> |
| 21 | 21 | #include <__atomic/atomic_sync.h> |
| 22 | 22 | #include <__atomic/check_memory_order.h> |
| 23 | #include <__atomic/memory_order.h> | |
| 23 | 24 | #include <__atomic/to_gcc_order.h> |
| 24 | 25 | #include <__concepts/arithmetic.h> |
| 25 | 26 | #include <__concepts/same_as.h> |
| 26 | 27 | #include <__config> |
| 28 | #include <__cstddef/byte.h> | |
| 29 | #include <__cstddef/ptrdiff_t.h> | |
| 27 | 30 | #include <__memory/addressof.h> |
| 28 | 31 | #include <__type_traits/has_unique_object_representation.h> |
| 29 | 32 | #include <__type_traits/is_trivially_copyable.h> |
| 30 | #include <cstddef> | |
| 31 | 33 | #include <cstdint> |
| 32 | 34 | #include <cstring> |
| 33 | 35 | |
| ... | ... | @@ -219,7 +221,7 @@ public: |
| 219 | 221 | _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); } |
| 220 | 222 | |
| 221 | 223 | protected: |
| 222 | typedef _Tp _Aligned_Tp __attribute__((aligned(required_alignment))); | |
| 224 | using _Aligned_Tp [[__gnu__::__aligned__(required_alignment), __gnu__::__nodebug__]] = _Tp; | |
| 223 | 225 | _Aligned_Tp* __ptr_; |
| 224 | 226 | |
| 225 | 227 | _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : __ptr_(std::addressof(__obj)) {} |
| ... | ... | @@ -239,7 +241,7 @@ template <class _Tp> |
| 239 | 241 | struct atomic_ref : public __atomic_ref_base<_Tp> { |
| 240 | 242 | static_assert(is_trivially_copyable_v<_Tp>, "std::atomic_ref<T> requires that 'T' be a trivially copyable type"); |
| 241 | 243 | |
| 242 | using __base = __atomic_ref_base<_Tp>; | |
| 244 | using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp>; | |
| 243 | 245 | |
| 244 | 246 | _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) { |
| 245 | 247 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| ... | ... | @@ -257,7 +259,7 @@ struct atomic_ref : public __atomic_ref_base<_Tp> { |
| 257 | 259 | template <class _Tp> |
| 258 | 260 | requires(std::integral<_Tp> && !std::same_as<bool, _Tp>) |
| 259 | 261 | struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> { |
| 260 | using __base = __atomic_ref_base<_Tp>; | |
| 262 | using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp>; | |
| 261 | 263 | |
| 262 | 264 | using difference_type = __base::value_type; |
| 263 | 265 | |
| ... | ... | @@ -303,7 +305,7 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> { |
| 303 | 305 | template <class _Tp> |
| 304 | 306 | requires std::floating_point<_Tp> |
| 305 | 307 | struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> { |
| 306 | using __base = __atomic_ref_base<_Tp>; | |
| 308 | using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp>; | |
| 307 | 309 | |
| 308 | 310 | using difference_type = __base::value_type; |
| 309 | 311 | |
| ... | ... | @@ -342,7 +344,7 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> { |
| 342 | 344 | |
| 343 | 345 | template <class _Tp> |
| 344 | 346 | struct atomic_ref<_Tp*> : public __atomic_ref_base<_Tp*> { |
| 345 | using __base = __atomic_ref_base<_Tp*>; | |
| 347 | using __base _LIBCPP_NODEBUG = __atomic_ref_base<_Tp*>; | |
| 346 | 348 | |
| 347 | 349 | using difference_type = ptrdiff_t; |
| 348 | 350 |
lib/libcxx/include/__atomic/atomic_sync.h+30-40| ... | ... | @@ -10,14 +10,12 @@ |
| 10 | 10 | #define _LIBCPP___ATOMIC_ATOMIC_SYNC_H |
| 11 | 11 | |
| 12 | 12 | #include <__atomic/contention_t.h> |
| 13 | #include <__atomic/cxx_atomic_impl.h> | |
| 14 | 13 | #include <__atomic/memory_order.h> |
| 15 | 14 | #include <__atomic/to_gcc_order.h> |
| 16 | 15 | #include <__chrono/duration.h> |
| 17 | 16 | #include <__config> |
| 18 | 17 | #include <__memory/addressof.h> |
| 19 | 18 | #include <__thread/poll_with_backoff.h> |
| 20 | #include <__thread/support.h> | |
| 21 | 19 | #include <__type_traits/conjunction.h> |
| 22 | 20 | #include <__type_traits/decay.h> |
| 23 | 21 | #include <__type_traits/invoke.h> |
| ... | ... | @@ -57,19 +55,8 @@ struct __atomic_waitable< _Tp, |
| 57 | 55 | decltype(__atomic_waitable_traits<__decay_t<_Tp> >::__atomic_contention_address( |
| 58 | 56 | std::declval<const _Tp&>()))> > : true_type {}; |
| 59 | 57 | |
| 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 | ||
| 72 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 58 | #if _LIBCPP_STD_VER >= 20 | |
| 59 | # if _LIBCPP_HAS_THREADS | |
| 73 | 60 | |
| 74 | 61 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*) _NOEXCEPT; |
| 75 | 62 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT; |
| ... | ... | @@ -93,7 +80,7 @@ struct __atomic_wait_backoff_impl { |
| 93 | 80 | _Poll __poll_; |
| 94 | 81 | memory_order __order_; |
| 95 | 82 | |
| 96 | using __waitable_traits = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >; | |
| 83 | using __waitable_traits _LIBCPP_NODEBUG = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >; | |
| 97 | 84 | |
| 98 | 85 | _LIBCPP_AVAILABILITY_SYNC |
| 99 | 86 | _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -120,15 +107,13 @@ struct __atomic_wait_backoff_impl { |
| 120 | 107 | |
| 121 | 108 | _LIBCPP_AVAILABILITY_SYNC |
| 122 | 109 | _LIBCPP_HIDE_FROM_ABI bool operator()(chrono::nanoseconds __elapsed) const { |
| 123 | if (__elapsed > chrono::microseconds(64)) { | |
| 110 | if (__elapsed > chrono::microseconds(4)) { | |
| 124 | 111 | auto __contention_address = __waitable_traits::__atomic_contention_address(__a_); |
| 125 | 112 | __cxx_contention_t __monitor_val; |
| 126 | 113 | if (__update_monitor_val_and_poll(__contention_address, __monitor_val)) |
| 127 | 114 | return true; |
| 128 | 115 | std::__libcpp_atomic_wait(__contention_address, __monitor_val); |
| 129 | } else if (__elapsed > chrono::microseconds(4)) | |
| 130 | __libcpp_thread_yield(); | |
| 131 | else { | |
| 116 | } else { | |
| 132 | 117 | } // poll |
| 133 | 118 | return false; |
| 134 | 119 | } |
| ... | ... | @@ -144,11 +129,16 @@ struct __atomic_wait_backoff_impl { |
| 144 | 129 | // value. The predicate function must not return `false` spuriously. |
| 145 | 130 | template <class _AtomicWaitable, class _Poll> |
| 146 | 131 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void |
| 147 | __atomic_wait_unless(const _AtomicWaitable& __a, _Poll&& __poll, memory_order __order) { | |
| 132 | __atomic_wait_unless(const _AtomicWaitable& __a, memory_order __order, _Poll&& __poll) { | |
| 148 | 133 | static_assert(__atomic_waitable<_AtomicWaitable>::value, ""); |
| 149 | __atomic_wait_poll_impl<_AtomicWaitable, __decay_t<_Poll> > __poll_impl = {__a, __poll, __order}; | |
| 150 | 134 | __atomic_wait_backoff_impl<_AtomicWaitable, __decay_t<_Poll> > __backoff_fn = {__a, __poll, __order}; |
| 151 | std::__libcpp_thread_poll_with_backoff(__poll_impl, __backoff_fn); | |
| 135 | std::__libcpp_thread_poll_with_backoff( | |
| 136 | /* poll */ | |
| 137 | [&]() { | |
| 138 | auto __current_val = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_load(__a, __order); | |
| 139 | return __poll(__current_val); | |
| 140 | }, | |
| 141 | /* backoff */ __backoff_fn); | |
| 152 | 142 | } |
| 153 | 143 | |
| 154 | 144 | template <class _AtomicWaitable> |
| ... | ... | @@ -163,12 +153,17 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _ |
| 163 | 153 | std::__cxx_atomic_notify_all(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a)); |
| 164 | 154 | } |
| 165 | 155 | |
| 166 | #else // _LIBCPP_HAS_NO_THREADS | |
| 156 | # else // _LIBCPP_HAS_THREADS | |
| 167 | 157 | |
| 168 | 158 | template <class _AtomicWaitable, class _Poll> |
| 169 | _LIBCPP_HIDE_FROM_ABI void __atomic_wait_unless(const _AtomicWaitable& __a, _Poll&& __poll, memory_order __order) { | |
| 170 | __atomic_wait_poll_impl<_AtomicWaitable, __decay_t<_Poll> > __poll_fn = {__a, __poll, __order}; | |
| 171 | std::__libcpp_thread_poll_with_backoff(__poll_fn, __spinning_backoff_policy()); | |
| 159 | _LIBCPP_HIDE_FROM_ABI void __atomic_wait_unless(const _AtomicWaitable& __a, memory_order __order, _Poll&& __poll) { | |
| 160 | std::__libcpp_thread_poll_with_backoff( | |
| 161 | /* poll */ | |
| 162 | [&]() { | |
| 163 | auto __current_val = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_load(__a, __order); | |
| 164 | return __poll(__current_val); | |
| 165 | }, | |
| 166 | /* backoff */ __spinning_backoff_policy()); | |
| 172 | 167 | } |
| 173 | 168 | |
| 174 | 169 | template <class _AtomicWaitable> |
| ... | ... | @@ -177,29 +172,24 @@ _LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable&) {} |
| 177 | 172 | template <class _AtomicWaitable> |
| 178 | 173 | _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable&) {} |
| 179 | 174 | |
| 180 | #endif // _LIBCPP_HAS_NO_THREADS | |
| 175 | # endif // _LIBCPP_HAS_THREADS | |
| 181 | 176 | |
| 182 | 177 | template <typename _Tp> |
| 183 | 178 | _LIBCPP_HIDE_FROM_ABI bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp const& __rhs) { |
| 184 | 179 | return std::memcmp(std::addressof(__lhs), std::addressof(__rhs), sizeof(_Tp)) == 0; |
| 185 | 180 | } |
| 186 | 181 | |
| 187 | template <class _Tp> | |
| 188 | struct __atomic_compare_unequal_to { | |
| 189 | _Tp __val_; | |
| 190 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __arg) const { | |
| 191 | return !std::__cxx_nonatomic_compare_equal(__arg, __val_); | |
| 192 | } | |
| 193 | }; | |
| 194 | ||
| 195 | template <class _AtomicWaitable, class _Up> | |
| 182 | template <class _AtomicWaitable, class _Tp> | |
| 196 | 183 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void |
| 197 | __atomic_wait(_AtomicWaitable& __a, _Up __val, memory_order __order) { | |
| 184 | __atomic_wait(_AtomicWaitable& __a, _Tp __val, memory_order __order) { | |
| 198 | 185 | static_assert(__atomic_waitable<_AtomicWaitable>::value, ""); |
| 199 | __atomic_compare_unequal_to<_Up> __nonatomic_equal = {__val}; | |
| 200 | std::__atomic_wait_unless(__a, __nonatomic_equal, __order); | |
| 186 | std::__atomic_wait_unless(__a, __order, [&](_Tp const& __current) { | |
| 187 | return !std::__cxx_nonatomic_compare_equal(__current, __val); | |
| 188 | }); | |
| 201 | 189 | } |
| 202 | 190 | |
| 191 | #endif // C++20 | |
| 192 | ||
| 203 | 193 | _LIBCPP_END_NAMESPACE_STD |
| 204 | 194 | |
| 205 | 195 | #endif // _LIBCPP___ATOMIC_ATOMIC_SYNC_H |
lib/libcxx/include/__atomic/contention_t.h+4-4| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | #ifndef _LIBCPP___ATOMIC_CONTENTION_T_H |
| 10 | 10 | #define _LIBCPP___ATOMIC_CONTENTION_T_H |
| 11 | 11 | |
| 12 | #include <__atomic/cxx_atomic_impl.h> | |
| 12 | #include <__atomic/support.h> | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <cstdint> |
| 15 | 15 | |
| ... | ... | @@ -20,12 +20,12 @@ |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | 22 | #if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__)) |
| 23 | using __cxx_contention_t = int32_t; | |
| 23 | using __cxx_contention_t _LIBCPP_NODEBUG = int32_t; | |
| 24 | 24 | #else |
| 25 | using __cxx_contention_t = int64_t; | |
| 25 | using __cxx_contention_t _LIBCPP_NODEBUG = int64_t; | |
| 26 | 26 | #endif // __linux__ || (_AIX && !__64BIT__) |
| 27 | 27 | |
| 28 | using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>; | |
| 28 | using __cxx_atomic_contention_t _LIBCPP_NODEBUG = __cxx_atomic_impl<__cxx_contention_t>; | |
| 29 | 29 | |
| 30 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 31 | 31 |
lib/libcxx/include/__atomic/cxx_atomic_impl.h deleted-510| ... | ... | @@ -1,510 +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___ATOMIC_CXX_ATOMIC_IMPL_H | |
| 10 | #define _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H | |
| 11 | ||
| 12 | #include <__atomic/memory_order.h> | |
| 13 | #include <__atomic/to_gcc_order.h> | |
| 14 | #include <__config> | |
| 15 | #include <__memory/addressof.h> | |
| 16 | #include <__type_traits/is_assignable.h> | |
| 17 | #include <__type_traits/is_trivially_copyable.h> | |
| 18 | #include <__type_traits/remove_const.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 defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) | |
| 28 | ||
| 29 | // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because | |
| 30 | // the default operator= in an object is not volatile, a byte-by-byte copy | |
| 31 | // is required. | |
| 32 | template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0> | |
| 33 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp& __a_value, _Tv const& __val) { | |
| 34 | __a_value = __val; | |
| 35 | } | |
| 36 | template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0> | |
| 37 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp volatile& __a_value, _Tv volatile const& __val) { | |
| 38 | volatile char* __to = reinterpret_cast<volatile char*>(std::addressof(__a_value)); | |
| 39 | volatile char* __end = __to + sizeof(_Tp); | |
| 40 | volatile const char* __from = reinterpret_cast<volatile const char*>(std::addressof(__val)); | |
| 41 | while (__to != __end) | |
| 42 | *__to++ = *__from++; | |
| 43 | } | |
| 44 | ||
| 45 | template <typename _Tp> | |
| 46 | struct __cxx_atomic_base_impl { | |
| 47 | _LIBCPP_HIDE_FROM_ABI | |
| 48 | # ifndef _LIBCPP_CXX03_LANG | |
| 49 | __cxx_atomic_base_impl() _NOEXCEPT = default; | |
| 50 | # else | |
| 51 | __cxx_atomic_base_impl() _NOEXCEPT : __a_value() { | |
| 52 | } | |
| 53 | # endif // _LIBCPP_CXX03_LANG | |
| 54 | _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT : __a_value(value) {} | |
| 55 | _Tp __a_value; | |
| 56 | }; | |
| 57 | ||
| 58 | template <typename _Tp> | |
| 59 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val) { | |
| 60 | __cxx_atomic_assign_volatile(__a->__a_value, __val); | |
| 61 | } | |
| 62 | ||
| 63 | template <typename _Tp> | |
| 64 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) { | |
| 65 | __a->__a_value = __val; | |
| 66 | } | |
| 67 | ||
| 68 | _LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_thread_fence(memory_order __order) { | |
| 69 | __atomic_thread_fence(__to_gcc_order(__order)); | |
| 70 | } | |
| 71 | ||
| 72 | _LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_signal_fence(memory_order __order) { | |
| 73 | __atomic_signal_fence(__to_gcc_order(__order)); | |
| 74 | } | |
| 75 | ||
| 76 | template <typename _Tp> | |
| 77 | _LIBCPP_HIDE_FROM_ABI void | |
| 78 | __cxx_atomic_store(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) { | |
| 79 | __atomic_store(std::addressof(__a->__a_value), std::addressof(__val), __to_gcc_order(__order)); | |
| 80 | } | |
| 81 | ||
| 82 | template <typename _Tp> | |
| 83 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) { | |
| 84 | __atomic_store(std::addressof(__a->__a_value), std::addressof(__val), __to_gcc_order(__order)); | |
| 85 | } | |
| 86 | ||
| 87 | template <typename _Tp> | |
| 88 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const volatile __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) { | |
| 89 | _Tp __ret; | |
| 90 | __atomic_load(std::addressof(__a->__a_value), std::addressof(__ret), __to_gcc_order(__order)); | |
| 91 | return __ret; | |
| 92 | } | |
| 93 | ||
| 94 | template <typename _Tp> | |
| 95 | _LIBCPP_HIDE_FROM_ABI void | |
| 96 | __cxx_atomic_load_inplace(const volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp* __dst, memory_order __order) { | |
| 97 | __atomic_load(std::addressof(__a->__a_value), __dst, __to_gcc_order(__order)); | |
| 98 | } | |
| 99 | ||
| 100 | template <typename _Tp> | |
| 101 | _LIBCPP_HIDE_FROM_ABI void | |
| 102 | __cxx_atomic_load_inplace(const __cxx_atomic_base_impl<_Tp>* __a, _Tp* __dst, memory_order __order) { | |
| 103 | __atomic_load(std::addressof(__a->__a_value), __dst, __to_gcc_order(__order)); | |
| 104 | } | |
| 105 | ||
| 106 | template <typename _Tp> | |
| 107 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) { | |
| 108 | _Tp __ret; | |
| 109 | __atomic_load(std::addressof(__a->__a_value), std::addressof(__ret), __to_gcc_order(__order)); | |
| 110 | return __ret; | |
| 111 | } | |
| 112 | ||
| 113 | template <typename _Tp> | |
| 114 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 115 | __cxx_atomic_exchange(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) { | |
| 116 | _Tp __ret; | |
| 117 | __atomic_exchange( | |
| 118 | std::addressof(__a->__a_value), std::addressof(__value), std::addressof(__ret), __to_gcc_order(__order)); | |
| 119 | return __ret; | |
| 120 | } | |
| 121 | ||
| 122 | template <typename _Tp> | |
| 123 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) { | |
| 124 | _Tp __ret; | |
| 125 | __atomic_exchange( | |
| 126 | std::addressof(__a->__a_value), std::addressof(__value), std::addressof(__ret), __to_gcc_order(__order)); | |
| 127 | return __ret; | |
| 128 | } | |
| 129 | ||
| 130 | template <typename _Tp> | |
| 131 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong( | |
| 132 | volatile __cxx_atomic_base_impl<_Tp>* __a, | |
| 133 | _Tp* __expected, | |
| 134 | _Tp __value, | |
| 135 | memory_order __success, | |
| 136 | memory_order __failure) { | |
| 137 | return __atomic_compare_exchange( | |
| 138 | std::addressof(__a->__a_value), | |
| 139 | __expected, | |
| 140 | std::addressof(__value), | |
| 141 | false, | |
| 142 | __to_gcc_order(__success), | |
| 143 | __to_gcc_failure_order(__failure)); | |
| 144 | } | |
| 145 | ||
| 146 | template <typename _Tp> | |
| 147 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong( | |
| 148 | __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) { | |
| 149 | return __atomic_compare_exchange( | |
| 150 | std::addressof(__a->__a_value), | |
| 151 | __expected, | |
| 152 | std::addressof(__value), | |
| 153 | false, | |
| 154 | __to_gcc_order(__success), | |
| 155 | __to_gcc_failure_order(__failure)); | |
| 156 | } | |
| 157 | ||
| 158 | template <typename _Tp> | |
| 159 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak( | |
| 160 | volatile __cxx_atomic_base_impl<_Tp>* __a, | |
| 161 | _Tp* __expected, | |
| 162 | _Tp __value, | |
| 163 | memory_order __success, | |
| 164 | memory_order __failure) { | |
| 165 | return __atomic_compare_exchange( | |
| 166 | std::addressof(__a->__a_value), | |
| 167 | __expected, | |
| 168 | std::addressof(__value), | |
| 169 | true, | |
| 170 | __to_gcc_order(__success), | |
| 171 | __to_gcc_failure_order(__failure)); | |
| 172 | } | |
| 173 | ||
| 174 | template <typename _Tp> | |
| 175 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak( | |
| 176 | __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) { | |
| 177 | return __atomic_compare_exchange( | |
| 178 | std::addressof(__a->__a_value), | |
| 179 | __expected, | |
| 180 | std::addressof(__value), | |
| 181 | true, | |
| 182 | __to_gcc_order(__success), | |
| 183 | __to_gcc_failure_order(__failure)); | |
| 184 | } | |
| 185 | ||
| 186 | template <typename _Tp> | |
| 187 | struct __skip_amt { | |
| 188 | enum { value = 1 }; | |
| 189 | }; | |
| 190 | ||
| 191 | template <typename _Tp> | |
| 192 | struct __skip_amt<_Tp*> { | |
| 193 | enum { value = sizeof(_Tp) }; | |
| 194 | }; | |
| 195 | ||
| 196 | // FIXME: Haven't figured out what the spec says about using arrays with | |
| 197 | // atomic_fetch_add. Force a failure rather than creating bad behavior. | |
| 198 | template <typename _Tp> | |
| 199 | struct __skip_amt<_Tp[]> {}; | |
| 200 | template <typename _Tp, int n> | |
| 201 | struct __skip_amt<_Tp[n]> {}; | |
| 202 | ||
| 203 | template <typename _Tp, typename _Td> | |
| 204 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 205 | __cxx_atomic_fetch_add(volatile __cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) { | |
| 206 | return __atomic_fetch_add(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order)); | |
| 207 | } | |
| 208 | ||
| 209 | template <typename _Tp, typename _Td> | |
| 210 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) { | |
| 211 | return __atomic_fetch_add(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order)); | |
| 212 | } | |
| 213 | ||
| 214 | template <typename _Tp, typename _Td> | |
| 215 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 216 | __cxx_atomic_fetch_sub(volatile __cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) { | |
| 217 | return __atomic_fetch_sub(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order)); | |
| 218 | } | |
| 219 | ||
| 220 | template <typename _Tp, typename _Td> | |
| 221 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) { | |
| 222 | return __atomic_fetch_sub(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order)); | |
| 223 | } | |
| 224 | ||
| 225 | template <typename _Tp> | |
| 226 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 227 | __cxx_atomic_fetch_and(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 228 | return __atomic_fetch_and(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 229 | } | |
| 230 | ||
| 231 | template <typename _Tp> | |
| 232 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 233 | __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 234 | return __atomic_fetch_and(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 235 | } | |
| 236 | ||
| 237 | template <typename _Tp> | |
| 238 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 239 | __cxx_atomic_fetch_or(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 240 | return __atomic_fetch_or(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 241 | } | |
| 242 | ||
| 243 | template <typename _Tp> | |
| 244 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 245 | return __atomic_fetch_or(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 246 | } | |
| 247 | ||
| 248 | template <typename _Tp> | |
| 249 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 250 | __cxx_atomic_fetch_xor(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 251 | return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 252 | } | |
| 253 | ||
| 254 | template <typename _Tp> | |
| 255 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 256 | __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 257 | return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 258 | } | |
| 259 | ||
| 260 | # define __cxx_atomic_is_lock_free(__s) __atomic_is_lock_free(__s, 0) | |
| 261 | ||
| 262 | #elif defined(_LIBCPP_HAS_C_ATOMIC_IMP) | |
| 263 | ||
| 264 | template <typename _Tp> | |
| 265 | struct __cxx_atomic_base_impl { | |
| 266 | _LIBCPP_HIDE_FROM_ABI | |
| 267 | # ifndef _LIBCPP_CXX03_LANG | |
| 268 | __cxx_atomic_base_impl() _NOEXCEPT = default; | |
| 269 | # else | |
| 270 | __cxx_atomic_base_impl() _NOEXCEPT : __a_value() { | |
| 271 | } | |
| 272 | # endif // _LIBCPP_CXX03_LANG | |
| 273 | _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT : __a_value(__value) {} | |
| 274 | _LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value; | |
| 275 | }; | |
| 276 | ||
| 277 | # define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s) | |
| 278 | ||
| 279 | _LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_thread_fence(memory_order __order) _NOEXCEPT { | |
| 280 | __c11_atomic_thread_fence(static_cast<__memory_order_underlying_t>(__order)); | |
| 281 | } | |
| 282 | ||
| 283 | _LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_signal_fence(memory_order __order) _NOEXCEPT { | |
| 284 | __c11_atomic_signal_fence(static_cast<__memory_order_underlying_t>(__order)); | |
| 285 | } | |
| 286 | ||
| 287 | template <class _Tp> | |
| 288 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val) _NOEXCEPT { | |
| 289 | __c11_atomic_init(std::addressof(__a->__a_value), __val); | |
| 290 | } | |
| 291 | template <class _Tp> | |
| 292 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) _NOEXCEPT { | |
| 293 | __c11_atomic_init(std::addressof(__a->__a_value), __val); | |
| 294 | } | |
| 295 | ||
| 296 | template <class _Tp> | |
| 297 | _LIBCPP_HIDE_FROM_ABI void | |
| 298 | __cxx_atomic_store(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val, memory_order __order) _NOEXCEPT { | |
| 299 | __c11_atomic_store(std::addressof(__a->__a_value), __val, static_cast<__memory_order_underlying_t>(__order)); | |
| 300 | } | |
| 301 | template <class _Tp> | |
| 302 | _LIBCPP_HIDE_FROM_ABI void | |
| 303 | __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) _NOEXCEPT { | |
| 304 | __c11_atomic_store(std::addressof(__a->__a_value), __val, static_cast<__memory_order_underlying_t>(__order)); | |
| 305 | } | |
| 306 | ||
| 307 | template <class _Tp> | |
| 308 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 309 | __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const volatile* __a, memory_order __order) _NOEXCEPT { | |
| 310 | using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*; | |
| 311 | return __c11_atomic_load( | |
| 312 | const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order)); | |
| 313 | } | |
| 314 | template <class _Tp> | |
| 315 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const* __a, memory_order __order) _NOEXCEPT { | |
| 316 | using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*; | |
| 317 | return __c11_atomic_load( | |
| 318 | const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order)); | |
| 319 | } | |
| 320 | ||
| 321 | template <class _Tp> | |
| 322 | _LIBCPP_HIDE_FROM_ABI void | |
| 323 | __cxx_atomic_load_inplace(__cxx_atomic_base_impl<_Tp> const volatile* __a, _Tp* __dst, memory_order __order) _NOEXCEPT { | |
| 324 | using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*; | |
| 325 | *__dst = __c11_atomic_load( | |
| 326 | const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order)); | |
| 327 | } | |
| 328 | template <class _Tp> | |
| 329 | _LIBCPP_HIDE_FROM_ABI void | |
| 330 | __cxx_atomic_load_inplace(__cxx_atomic_base_impl<_Tp> const* __a, _Tp* __dst, memory_order __order) _NOEXCEPT { | |
| 331 | using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*; | |
| 332 | *__dst = __c11_atomic_load( | |
| 333 | const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order)); | |
| 334 | } | |
| 335 | ||
| 336 | template <class _Tp> | |
| 337 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 338 | __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __value, memory_order __order) _NOEXCEPT { | |
| 339 | return __c11_atomic_exchange( | |
| 340 | std::addressof(__a->__a_value), __value, static_cast<__memory_order_underlying_t>(__order)); | |
| 341 | } | |
| 342 | template <class _Tp> | |
| 343 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 344 | __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) _NOEXCEPT { | |
| 345 | return __c11_atomic_exchange( | |
| 346 | std::addressof(__a->__a_value), __value, static_cast<__memory_order_underlying_t>(__order)); | |
| 347 | } | |
| 348 | ||
| 349 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR memory_order __to_failure_order(memory_order __order) { | |
| 350 | // Avoid switch statement to make this a constexpr. | |
| 351 | return __order == memory_order_release | |
| 352 | ? memory_order_relaxed | |
| 353 | : (__order == memory_order_acq_rel ? memory_order_acquire : __order); | |
| 354 | } | |
| 355 | ||
| 356 | template <class _Tp> | |
| 357 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong( | |
| 358 | __cxx_atomic_base_impl<_Tp> volatile* __a, | |
| 359 | _Tp* __expected, | |
| 360 | _Tp __value, | |
| 361 | memory_order __success, | |
| 362 | memory_order __failure) _NOEXCEPT { | |
| 363 | return __c11_atomic_compare_exchange_strong( | |
| 364 | std::addressof(__a->__a_value), | |
| 365 | __expected, | |
| 366 | __value, | |
| 367 | static_cast<__memory_order_underlying_t>(__success), | |
| 368 | static_cast<__memory_order_underlying_t>(__to_failure_order(__failure))); | |
| 369 | } | |
| 370 | template <class _Tp> | |
| 371 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong( | |
| 372 | __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) | |
| 373 | _NOEXCEPT { | |
| 374 | return __c11_atomic_compare_exchange_strong( | |
| 375 | std::addressof(__a->__a_value), | |
| 376 | __expected, | |
| 377 | __value, | |
| 378 | static_cast<__memory_order_underlying_t>(__success), | |
| 379 | static_cast<__memory_order_underlying_t>(__to_failure_order(__failure))); | |
| 380 | } | |
| 381 | ||
| 382 | template <class _Tp> | |
| 383 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak( | |
| 384 | __cxx_atomic_base_impl<_Tp> volatile* __a, | |
| 385 | _Tp* __expected, | |
| 386 | _Tp __value, | |
| 387 | memory_order __success, | |
| 388 | memory_order __failure) _NOEXCEPT { | |
| 389 | return __c11_atomic_compare_exchange_weak( | |
| 390 | std::addressof(__a->__a_value), | |
| 391 | __expected, | |
| 392 | __value, | |
| 393 | static_cast<__memory_order_underlying_t>(__success), | |
| 394 | static_cast<__memory_order_underlying_t>(__to_failure_order(__failure))); | |
| 395 | } | |
| 396 | template <class _Tp> | |
| 397 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak( | |
| 398 | __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) | |
| 399 | _NOEXCEPT { | |
| 400 | return __c11_atomic_compare_exchange_weak( | |
| 401 | std::addressof(__a->__a_value), | |
| 402 | __expected, | |
| 403 | __value, | |
| 404 | static_cast<__memory_order_underlying_t>(__success), | |
| 405 | static_cast<__memory_order_underlying_t>(__to_failure_order(__failure))); | |
| 406 | } | |
| 407 | ||
| 408 | template <class _Tp> | |
| 409 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 410 | __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT { | |
| 411 | return __c11_atomic_fetch_add( | |
| 412 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 413 | } | |
| 414 | template <class _Tp> | |
| 415 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 416 | __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Tp __delta, memory_order __order) _NOEXCEPT { | |
| 417 | return __c11_atomic_fetch_add( | |
| 418 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 419 | } | |
| 420 | ||
| 421 | template <class _Tp> | |
| 422 | _LIBCPP_HIDE_FROM_ABI _Tp* | |
| 423 | __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT { | |
| 424 | return __c11_atomic_fetch_add( | |
| 425 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 426 | } | |
| 427 | template <class _Tp> | |
| 428 | _LIBCPP_HIDE_FROM_ABI _Tp* | |
| 429 | __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT { | |
| 430 | return __c11_atomic_fetch_add( | |
| 431 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 432 | } | |
| 433 | ||
| 434 | template <class _Tp> | |
| 435 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 436 | __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT { | |
| 437 | return __c11_atomic_fetch_sub( | |
| 438 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 439 | } | |
| 440 | template <class _Tp> | |
| 441 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 442 | __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Tp __delta, memory_order __order) _NOEXCEPT { | |
| 443 | return __c11_atomic_fetch_sub( | |
| 444 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 445 | } | |
| 446 | template <class _Tp> | |
| 447 | _LIBCPP_HIDE_FROM_ABI _Tp* | |
| 448 | __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT { | |
| 449 | return __c11_atomic_fetch_sub( | |
| 450 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 451 | } | |
| 452 | template <class _Tp> | |
| 453 | _LIBCPP_HIDE_FROM_ABI _Tp* | |
| 454 | __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT { | |
| 455 | return __c11_atomic_fetch_sub( | |
| 456 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 457 | } | |
| 458 | ||
| 459 | template <class _Tp> | |
| 460 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 461 | __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 462 | return __c11_atomic_fetch_and( | |
| 463 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 464 | } | |
| 465 | template <class _Tp> | |
| 466 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 467 | __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 468 | return __c11_atomic_fetch_and( | |
| 469 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 470 | } | |
| 471 | ||
| 472 | template <class _Tp> | |
| 473 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 474 | __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 475 | return __c11_atomic_fetch_or( | |
| 476 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 477 | } | |
| 478 | template <class _Tp> | |
| 479 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 480 | __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 481 | return __c11_atomic_fetch_or( | |
| 482 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 483 | } | |
| 484 | ||
| 485 | template <class _Tp> | |
| 486 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 487 | __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 488 | return __c11_atomic_fetch_xor( | |
| 489 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 490 | } | |
| 491 | template <class _Tp> | |
| 492 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 493 | __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 494 | return __c11_atomic_fetch_xor( | |
| 495 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 496 | } | |
| 497 | ||
| 498 | #endif // _LIBCPP_HAS_GCC_ATOMIC_IMP, _LIBCPP_HAS_C_ATOMIC_IMP | |
| 499 | ||
| 500 | template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> > | |
| 501 | struct __cxx_atomic_impl : public _Base { | |
| 502 | static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type"); | |
| 503 | ||
| 504 | _LIBCPP_HIDE_FROM_ABI __cxx_atomic_impl() _NOEXCEPT = default; | |
| 505 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT : _Base(__value) {} | |
| 506 | }; | |
| 507 | ||
| 508 | _LIBCPP_END_NAMESPACE_STD | |
| 509 | ||
| 510 | #endif // _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H |
lib/libcxx/include/__atomic/fence.h+1-1| ... | ... | @@ -9,8 +9,8 @@ |
| 9 | 9 | #ifndef _LIBCPP___ATOMIC_FENCE_H |
| 10 | 10 | #define _LIBCPP___ATOMIC_FENCE_H |
| 11 | 11 | |
| 12 | #include <__atomic/cxx_atomic_impl.h> | |
| 13 | 12 | #include <__atomic/memory_order.h> |
| 13 | #include <__atomic/support.h> | |
| 14 | 14 | #include <__config> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__atomic/memory_order.h+1-1| ... | ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | // to pin the underlying type in C++20. |
| 25 | 25 | enum __legacy_memory_order { __mo_relaxed, __mo_consume, __mo_acquire, __mo_release, __mo_acq_rel, __mo_seq_cst }; |
| 26 | 26 | |
| 27 | using __memory_order_underlying_t = underlying_type<__legacy_memory_order>::type; | |
| 27 | using __memory_order_underlying_t _LIBCPP_NODEBUG = underlying_type<__legacy_memory_order>::type; | |
| 28 | 28 | |
| 29 | 29 | #if _LIBCPP_STD_VER >= 20 |
| 30 | 30 |
lib/libcxx/include/__atomic/support.h created+124| ... | ... | @@ -0,0 +1,124 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_SUPPORT_H | |
| 10 | #define _LIBCPP___ATOMIC_SUPPORT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/is_trivially_copyable.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | // | |
| 20 | // This file implements base support for atomics on the platform. | |
| 21 | // | |
| 22 | // The following operations and types must be implemented (where _Atmc | |
| 23 | // is __cxx_atomic_base_impl for readability): | |
| 24 | // | |
| 25 | // clang-format off | |
| 26 | // | |
| 27 | // template <class _Tp> | |
| 28 | // struct __cxx_atomic_base_impl; | |
| 29 | // | |
| 30 | // #define __cxx_atomic_is_lock_free(__size) | |
| 31 | // | |
| 32 | // void __cxx_atomic_thread_fence(memory_order __order) noexcept; | |
| 33 | // void __cxx_atomic_signal_fence(memory_order __order) noexcept; | |
| 34 | // | |
| 35 | // template <class _Tp> | |
| 36 | // void __cxx_atomic_init(_Atmc<_Tp> volatile* __a, _Tp __val) noexcept; | |
| 37 | // template <class _Tp> | |
| 38 | // void __cxx_atomic_init(_Atmc<_Tp>* __a, _Tp __val) noexcept; | |
| 39 | // | |
| 40 | // template <class _Tp> | |
| 41 | // void __cxx_atomic_store(_Atmc<_Tp> volatile* __a, _Tp __val, memory_order __order) noexcept; | |
| 42 | // template <class _Tp> | |
| 43 | // void __cxx_atomic_store(_Atmc<_Tp>* __a, _Tp __val, memory_order __order) noexcept; | |
| 44 | // | |
| 45 | // template <class _Tp> | |
| 46 | // _Tp __cxx_atomic_load(_Atmc<_Tp> const volatile* __a, memory_order __order) noexcept; | |
| 47 | // template <class _Tp> | |
| 48 | // _Tp __cxx_atomic_load(_Atmc<_Tp> const* __a, memory_order __order) noexcept; | |
| 49 | // | |
| 50 | // template <class _Tp> | |
| 51 | // void __cxx_atomic_load_inplace(_Atmc<_Tp> const volatile* __a, _Tp* __dst, memory_order __order) noexcept; | |
| 52 | // template <class _Tp> | |
| 53 | // void __cxx_atomic_load_inplace(_Atmc<_Tp> const* __a, _Tp* __dst, memory_order __order) noexcept; | |
| 54 | // | |
| 55 | // template <class _Tp> | |
| 56 | // _Tp __cxx_atomic_exchange(_Atmc<_Tp> volatile* __a, _Tp __value, memory_order __order) noexcept; | |
| 57 | // template <class _Tp> | |
| 58 | // _Tp __cxx_atomic_exchange(_Atmc<_Tp>* __a, _Tp __value, memory_order __order) noexcept; | |
| 59 | // | |
| 60 | // template <class _Tp> | |
| 61 | // bool __cxx_atomic_compare_exchange_strong(_Atmc<_Tp> volatile* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) noexcept; | |
| 62 | // template <class _Tp> | |
| 63 | // bool __cxx_atomic_compare_exchange_strong(_Atmc<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) noexcept; | |
| 64 | // | |
| 65 | // template <class _Tp> | |
| 66 | // bool __cxx_atomic_compare_exchange_weak(_Atmc<_Tp> volatile* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) noexcept; | |
| 67 | // template <class _Tp> | |
| 68 | // bool __cxx_atomic_compare_exchange_weak(_Atmc<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) noexcept; | |
| 69 | // | |
| 70 | // template <class _Tp> | |
| 71 | // _Tp __cxx_atomic_fetch_add(_Atmc<_Tp> volatile* __a, _Tp __delta, memory_order __order) noexcept; | |
| 72 | // template <class _Tp> | |
| 73 | // _Tp __cxx_atomic_fetch_add(_Atmc<_Tp>* __a, _Tp __delta, memory_order __order) noexcept; | |
| 74 | // | |
| 75 | // template <class _Tp> | |
| 76 | // _Tp* __cxx_atomic_fetch_add(_Atmc<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) noexcept; | |
| 77 | // template <class _Tp> | |
| 78 | // _Tp* __cxx_atomic_fetch_add(_Atmc<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) noexcept; | |
| 79 | // | |
| 80 | // template <class _Tp> | |
| 81 | // _Tp __cxx_atomic_fetch_sub(_Atmc<_Tp> volatile* __a, _Tp __delta, memory_order __order) noexcept; | |
| 82 | // template <class _Tp> | |
| 83 | // _Tp __cxx_atomic_fetch_sub(_Atmc<_Tp>* __a, _Tp __delta, memory_order __order) noexcept; | |
| 84 | // template <class _Tp> | |
| 85 | // _Tp* __cxx_atomic_fetch_sub(_Atmc<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) noexcept; | |
| 86 | // template <class _Tp> | |
| 87 | // _Tp* __cxx_atomic_fetch_sub(_Atmc<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) noexcept; | |
| 88 | // | |
| 89 | // template <class _Tp> | |
| 90 | // _Tp __cxx_atomic_fetch_and(_Atmc<_Tp> volatile* __a, _Tp __pattern, memory_order __order) noexcept; | |
| 91 | // template <class _Tp> | |
| 92 | // _Tp __cxx_atomic_fetch_and(_Atmc<_Tp>* __a, _Tp __pattern, memory_order __order) noexcept; | |
| 93 | // | |
| 94 | // template <class _Tp> | |
| 95 | // _Tp __cxx_atomic_fetch_or(_Atmc<_Tp> volatile* __a, _Tp __pattern, memory_order __order) noexcept; | |
| 96 | // template <class _Tp> | |
| 97 | // _Tp __cxx_atomic_fetch_or(_Atmc<_Tp>* __a, _Tp __pattern, memory_order __order) noexcept; | |
| 98 | // template <class _Tp> | |
| 99 | // _Tp __cxx_atomic_fetch_xor(_Atmc<_Tp> volatile* __a, _Tp __pattern, memory_order __order) noexcept; | |
| 100 | // template <class _Tp> | |
| 101 | // _Tp __cxx_atomic_fetch_xor(_Atmc<_Tp>* __a, _Tp __pattern, memory_order __order) noexcept; | |
| 102 | // | |
| 103 | // clang-format on | |
| 104 | // | |
| 105 | ||
| 106 | #if _LIBCPP_HAS_GCC_ATOMIC_IMP | |
| 107 | # include <__atomic/support/gcc.h> | |
| 108 | #elif _LIBCPP_HAS_C_ATOMIC_IMP | |
| 109 | # include <__atomic/support/c11.h> | |
| 110 | #endif | |
| 111 | ||
| 112 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 113 | ||
| 114 | template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> > | |
| 115 | struct __cxx_atomic_impl : public _Base { | |
| 116 | static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type"); | |
| 117 | ||
| 118 | _LIBCPP_HIDE_FROM_ABI __cxx_atomic_impl() _NOEXCEPT = default; | |
| 119 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT : _Base(__value) {} | |
| 120 | }; | |
| 121 | ||
| 122 | _LIBCPP_END_NAMESPACE_STD | |
| 123 | ||
| 124 | #endif // _LIBCPP___ATOMIC_SUPPORT_H |
lib/libcxx/include/__atomic/support/c11.h created+264| ... | ... | @@ -0,0 +1,264 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_SUPPORT_C11_H | |
| 10 | #define _LIBCPP___ATOMIC_SUPPORT_C11_H | |
| 11 | ||
| 12 | #include <__atomic/memory_order.h> | |
| 13 | #include <__config> | |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 15 | #include <__memory/addressof.h> | |
| 16 | #include <__type_traits/remove_const.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | // | |
| 23 | // This file implements support for C11-style atomics | |
| 24 | // | |
| 25 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 27 | ||
| 28 | template <typename _Tp> | |
| 29 | struct __cxx_atomic_base_impl { | |
| 30 | _LIBCPP_HIDE_FROM_ABI | |
| 31 | #ifndef _LIBCPP_CXX03_LANG | |
| 32 | __cxx_atomic_base_impl() _NOEXCEPT = default; | |
| 33 | #else | |
| 34 | __cxx_atomic_base_impl() _NOEXCEPT : __a_value() { | |
| 35 | } | |
| 36 | #endif // _LIBCPP_CXX03_LANG | |
| 37 | _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT : __a_value(__value) {} | |
| 38 | _LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value; | |
| 39 | }; | |
| 40 | ||
| 41 | #define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s) | |
| 42 | ||
| 43 | _LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_thread_fence(memory_order __order) _NOEXCEPT { | |
| 44 | __c11_atomic_thread_fence(static_cast<__memory_order_underlying_t>(__order)); | |
| 45 | } | |
| 46 | ||
| 47 | _LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_signal_fence(memory_order __order) _NOEXCEPT { | |
| 48 | __c11_atomic_signal_fence(static_cast<__memory_order_underlying_t>(__order)); | |
| 49 | } | |
| 50 | ||
| 51 | template <class _Tp> | |
| 52 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val) _NOEXCEPT { | |
| 53 | __c11_atomic_init(std::addressof(__a->__a_value), __val); | |
| 54 | } | |
| 55 | template <class _Tp> | |
| 56 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) _NOEXCEPT { | |
| 57 | __c11_atomic_init(std::addressof(__a->__a_value), __val); | |
| 58 | } | |
| 59 | ||
| 60 | template <class _Tp> | |
| 61 | _LIBCPP_HIDE_FROM_ABI void | |
| 62 | __cxx_atomic_store(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val, memory_order __order) _NOEXCEPT { | |
| 63 | __c11_atomic_store(std::addressof(__a->__a_value), __val, static_cast<__memory_order_underlying_t>(__order)); | |
| 64 | } | |
| 65 | template <class _Tp> | |
| 66 | _LIBCPP_HIDE_FROM_ABI void | |
| 67 | __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) _NOEXCEPT { | |
| 68 | __c11_atomic_store(std::addressof(__a->__a_value), __val, static_cast<__memory_order_underlying_t>(__order)); | |
| 69 | } | |
| 70 | ||
| 71 | template <class _Tp> | |
| 72 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 73 | __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const volatile* __a, memory_order __order) _NOEXCEPT { | |
| 74 | using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*; | |
| 75 | return __c11_atomic_load( | |
| 76 | const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order)); | |
| 77 | } | |
| 78 | template <class _Tp> | |
| 79 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const* __a, memory_order __order) _NOEXCEPT { | |
| 80 | using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*; | |
| 81 | return __c11_atomic_load( | |
| 82 | const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order)); | |
| 83 | } | |
| 84 | ||
| 85 | template <class _Tp> | |
| 86 | _LIBCPP_HIDE_FROM_ABI void | |
| 87 | __cxx_atomic_load_inplace(__cxx_atomic_base_impl<_Tp> const volatile* __a, _Tp* __dst, memory_order __order) _NOEXCEPT { | |
| 88 | using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*; | |
| 89 | *__dst = __c11_atomic_load( | |
| 90 | const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order)); | |
| 91 | } | |
| 92 | template <class _Tp> | |
| 93 | _LIBCPP_HIDE_FROM_ABI void | |
| 94 | __cxx_atomic_load_inplace(__cxx_atomic_base_impl<_Tp> const* __a, _Tp* __dst, memory_order __order) _NOEXCEPT { | |
| 95 | using __ptr_type = __remove_const_t<decltype(__a->__a_value)>*; | |
| 96 | *__dst = __c11_atomic_load( | |
| 97 | const_cast<__ptr_type>(std::addressof(__a->__a_value)), static_cast<__memory_order_underlying_t>(__order)); | |
| 98 | } | |
| 99 | ||
| 100 | template <class _Tp> | |
| 101 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 102 | __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __value, memory_order __order) _NOEXCEPT { | |
| 103 | return __c11_atomic_exchange( | |
| 104 | std::addressof(__a->__a_value), __value, static_cast<__memory_order_underlying_t>(__order)); | |
| 105 | } | |
| 106 | template <class _Tp> | |
| 107 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 108 | __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) _NOEXCEPT { | |
| 109 | return __c11_atomic_exchange( | |
| 110 | std::addressof(__a->__a_value), __value, static_cast<__memory_order_underlying_t>(__order)); | |
| 111 | } | |
| 112 | ||
| 113 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR memory_order __to_failure_order(memory_order __order) { | |
| 114 | // Avoid switch statement to make this a constexpr. | |
| 115 | return __order == memory_order_release | |
| 116 | ? memory_order_relaxed | |
| 117 | : (__order == memory_order_acq_rel ? memory_order_acquire : __order); | |
| 118 | } | |
| 119 | ||
| 120 | template <class _Tp> | |
| 121 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong( | |
| 122 | __cxx_atomic_base_impl<_Tp> volatile* __a, | |
| 123 | _Tp* __expected, | |
| 124 | _Tp __value, | |
| 125 | memory_order __success, | |
| 126 | memory_order __failure) _NOEXCEPT { | |
| 127 | return __c11_atomic_compare_exchange_strong( | |
| 128 | std::addressof(__a->__a_value), | |
| 129 | __expected, | |
| 130 | __value, | |
| 131 | static_cast<__memory_order_underlying_t>(__success), | |
| 132 | static_cast<__memory_order_underlying_t>(__to_failure_order(__failure))); | |
| 133 | } | |
| 134 | template <class _Tp> | |
| 135 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong( | |
| 136 | __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) | |
| 137 | _NOEXCEPT { | |
| 138 | return __c11_atomic_compare_exchange_strong( | |
| 139 | std::addressof(__a->__a_value), | |
| 140 | __expected, | |
| 141 | __value, | |
| 142 | static_cast<__memory_order_underlying_t>(__success), | |
| 143 | static_cast<__memory_order_underlying_t>(__to_failure_order(__failure))); | |
| 144 | } | |
| 145 | ||
| 146 | template <class _Tp> | |
| 147 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak( | |
| 148 | __cxx_atomic_base_impl<_Tp> volatile* __a, | |
| 149 | _Tp* __expected, | |
| 150 | _Tp __value, | |
| 151 | memory_order __success, | |
| 152 | memory_order __failure) _NOEXCEPT { | |
| 153 | return __c11_atomic_compare_exchange_weak( | |
| 154 | std::addressof(__a->__a_value), | |
| 155 | __expected, | |
| 156 | __value, | |
| 157 | static_cast<__memory_order_underlying_t>(__success), | |
| 158 | static_cast<__memory_order_underlying_t>(__to_failure_order(__failure))); | |
| 159 | } | |
| 160 | template <class _Tp> | |
| 161 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak( | |
| 162 | __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) | |
| 163 | _NOEXCEPT { | |
| 164 | return __c11_atomic_compare_exchange_weak( | |
| 165 | std::addressof(__a->__a_value), | |
| 166 | __expected, | |
| 167 | __value, | |
| 168 | static_cast<__memory_order_underlying_t>(__success), | |
| 169 | static_cast<__memory_order_underlying_t>(__to_failure_order(__failure))); | |
| 170 | } | |
| 171 | ||
| 172 | template <class _Tp> | |
| 173 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 174 | __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT { | |
| 175 | return __c11_atomic_fetch_add( | |
| 176 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 177 | } | |
| 178 | template <class _Tp> | |
| 179 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 180 | __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Tp __delta, memory_order __order) _NOEXCEPT { | |
| 181 | return __c11_atomic_fetch_add( | |
| 182 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 183 | } | |
| 184 | ||
| 185 | template <class _Tp> | |
| 186 | _LIBCPP_HIDE_FROM_ABI _Tp* | |
| 187 | __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT { | |
| 188 | return __c11_atomic_fetch_add( | |
| 189 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 190 | } | |
| 191 | template <class _Tp> | |
| 192 | _LIBCPP_HIDE_FROM_ABI _Tp* | |
| 193 | __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT { | |
| 194 | return __c11_atomic_fetch_add( | |
| 195 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 196 | } | |
| 197 | ||
| 198 | template <class _Tp> | |
| 199 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 200 | __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT { | |
| 201 | return __c11_atomic_fetch_sub( | |
| 202 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 203 | } | |
| 204 | template <class _Tp> | |
| 205 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 206 | __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Tp __delta, memory_order __order) _NOEXCEPT { | |
| 207 | return __c11_atomic_fetch_sub( | |
| 208 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 209 | } | |
| 210 | template <class _Tp> | |
| 211 | _LIBCPP_HIDE_FROM_ABI _Tp* | |
| 212 | __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT { | |
| 213 | return __c11_atomic_fetch_sub( | |
| 214 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 215 | } | |
| 216 | template <class _Tp> | |
| 217 | _LIBCPP_HIDE_FROM_ABI _Tp* | |
| 218 | __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT { | |
| 219 | return __c11_atomic_fetch_sub( | |
| 220 | std::addressof(__a->__a_value), __delta, static_cast<__memory_order_underlying_t>(__order)); | |
| 221 | } | |
| 222 | ||
| 223 | template <class _Tp> | |
| 224 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 225 | __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 226 | return __c11_atomic_fetch_and( | |
| 227 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 228 | } | |
| 229 | template <class _Tp> | |
| 230 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 231 | __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 232 | return __c11_atomic_fetch_and( | |
| 233 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 234 | } | |
| 235 | ||
| 236 | template <class _Tp> | |
| 237 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 238 | __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 239 | return __c11_atomic_fetch_or( | |
| 240 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 241 | } | |
| 242 | template <class _Tp> | |
| 243 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 244 | __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 245 | return __c11_atomic_fetch_or( | |
| 246 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 247 | } | |
| 248 | ||
| 249 | template <class _Tp> | |
| 250 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 251 | __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 252 | return __c11_atomic_fetch_xor( | |
| 253 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 254 | } | |
| 255 | template <class _Tp> | |
| 256 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 257 | __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) _NOEXCEPT { | |
| 258 | return __c11_atomic_fetch_xor( | |
| 259 | std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order)); | |
| 260 | } | |
| 261 | ||
| 262 | _LIBCPP_END_NAMESPACE_STD | |
| 263 | ||
| 264 | #endif // _LIBCPP___ATOMIC_SUPPORT_C11_H |
lib/libcxx/include/__atomic/support/gcc.h created+265| ... | ... | @@ -0,0 +1,265 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_SUPPORT_GCC_H | |
| 10 | #define _LIBCPP___ATOMIC_SUPPORT_GCC_H | |
| 11 | ||
| 12 | #include <__atomic/memory_order.h> | |
| 13 | #include <__atomic/to_gcc_order.h> | |
| 14 | #include <__config> | |
| 15 | #include <__memory/addressof.h> | |
| 16 | #include <__type_traits/enable_if.h> | |
| 17 | #include <__type_traits/is_assignable.h> | |
| 18 | #include <__type_traits/remove_const.h> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | // | |
| 25 | // This file implements support for GCC-style atomics | |
| 26 | // | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because | |
| 31 | // the default operator= in an object is not volatile, a byte-by-byte copy | |
| 32 | // is required. | |
| 33 | template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0> | |
| 34 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp& __a_value, _Tv const& __val) { | |
| 35 | __a_value = __val; | |
| 36 | } | |
| 37 | template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0> | |
| 38 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp volatile& __a_value, _Tv volatile const& __val) { | |
| 39 | volatile char* __to = reinterpret_cast<volatile char*>(std::addressof(__a_value)); | |
| 40 | volatile char* __end = __to + sizeof(_Tp); | |
| 41 | volatile const char* __from = reinterpret_cast<volatile const char*>(std::addressof(__val)); | |
| 42 | while (__to != __end) | |
| 43 | *__to++ = *__from++; | |
| 44 | } | |
| 45 | ||
| 46 | template <typename _Tp> | |
| 47 | struct __cxx_atomic_base_impl { | |
| 48 | _LIBCPP_HIDE_FROM_ABI | |
| 49 | #ifndef _LIBCPP_CXX03_LANG | |
| 50 | __cxx_atomic_base_impl() _NOEXCEPT = default; | |
| 51 | #else | |
| 52 | __cxx_atomic_base_impl() _NOEXCEPT : __a_value() { | |
| 53 | } | |
| 54 | #endif // _LIBCPP_CXX03_LANG | |
| 55 | _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT : __a_value(value) {} | |
| 56 | _Tp __a_value; | |
| 57 | }; | |
| 58 | ||
| 59 | template <typename _Tp> | |
| 60 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val) { | |
| 61 | __cxx_atomic_assign_volatile(__a->__a_value, __val); | |
| 62 | } | |
| 63 | ||
| 64 | template <typename _Tp> | |
| 65 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) { | |
| 66 | __a->__a_value = __val; | |
| 67 | } | |
| 68 | ||
| 69 | _LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_thread_fence(memory_order __order) { | |
| 70 | __atomic_thread_fence(__to_gcc_order(__order)); | |
| 71 | } | |
| 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI inline void __cxx_atomic_signal_fence(memory_order __order) { | |
| 74 | __atomic_signal_fence(__to_gcc_order(__order)); | |
| 75 | } | |
| 76 | ||
| 77 | template <typename _Tp> | |
| 78 | _LIBCPP_HIDE_FROM_ABI void | |
| 79 | __cxx_atomic_store(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) { | |
| 80 | __atomic_store(std::addressof(__a->__a_value), std::addressof(__val), __to_gcc_order(__order)); | |
| 81 | } | |
| 82 | ||
| 83 | template <typename _Tp> | |
| 84 | _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val, memory_order __order) { | |
| 85 | __atomic_store(std::addressof(__a->__a_value), std::addressof(__val), __to_gcc_order(__order)); | |
| 86 | } | |
| 87 | ||
| 88 | template <typename _Tp> | |
| 89 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const volatile __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) { | |
| 90 | _Tp __ret; | |
| 91 | __atomic_load(std::addressof(__a->__a_value), std::addressof(__ret), __to_gcc_order(__order)); | |
| 92 | return __ret; | |
| 93 | } | |
| 94 | ||
| 95 | template <typename _Tp> | |
| 96 | _LIBCPP_HIDE_FROM_ABI void | |
| 97 | __cxx_atomic_load_inplace(const volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp* __dst, memory_order __order) { | |
| 98 | __atomic_load(std::addressof(__a->__a_value), __dst, __to_gcc_order(__order)); | |
| 99 | } | |
| 100 | ||
| 101 | template <typename _Tp> | |
| 102 | _LIBCPP_HIDE_FROM_ABI void | |
| 103 | __cxx_atomic_load_inplace(const __cxx_atomic_base_impl<_Tp>* __a, _Tp* __dst, memory_order __order) { | |
| 104 | __atomic_load(std::addressof(__a->__a_value), __dst, __to_gcc_order(__order)); | |
| 105 | } | |
| 106 | ||
| 107 | template <typename _Tp> | |
| 108 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) { | |
| 109 | _Tp __ret; | |
| 110 | __atomic_load(std::addressof(__a->__a_value), std::addressof(__ret), __to_gcc_order(__order)); | |
| 111 | return __ret; | |
| 112 | } | |
| 113 | ||
| 114 | template <typename _Tp> | |
| 115 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 116 | __cxx_atomic_exchange(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) { | |
| 117 | _Tp __ret; | |
| 118 | __atomic_exchange( | |
| 119 | std::addressof(__a->__a_value), std::addressof(__value), std::addressof(__ret), __to_gcc_order(__order)); | |
| 120 | return __ret; | |
| 121 | } | |
| 122 | ||
| 123 | template <typename _Tp> | |
| 124 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value, memory_order __order) { | |
| 125 | _Tp __ret; | |
| 126 | __atomic_exchange( | |
| 127 | std::addressof(__a->__a_value), std::addressof(__value), std::addressof(__ret), __to_gcc_order(__order)); | |
| 128 | return __ret; | |
| 129 | } | |
| 130 | ||
| 131 | template <typename _Tp> | |
| 132 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong( | |
| 133 | volatile __cxx_atomic_base_impl<_Tp>* __a, | |
| 134 | _Tp* __expected, | |
| 135 | _Tp __value, | |
| 136 | memory_order __success, | |
| 137 | memory_order __failure) { | |
| 138 | return __atomic_compare_exchange( | |
| 139 | std::addressof(__a->__a_value), | |
| 140 | __expected, | |
| 141 | std::addressof(__value), | |
| 142 | false, | |
| 143 | __to_gcc_order(__success), | |
| 144 | __to_gcc_failure_order(__failure)); | |
| 145 | } | |
| 146 | ||
| 147 | template <typename _Tp> | |
| 148 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong( | |
| 149 | __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) { | |
| 150 | return __atomic_compare_exchange( | |
| 151 | std::addressof(__a->__a_value), | |
| 152 | __expected, | |
| 153 | std::addressof(__value), | |
| 154 | false, | |
| 155 | __to_gcc_order(__success), | |
| 156 | __to_gcc_failure_order(__failure)); | |
| 157 | } | |
| 158 | ||
| 159 | template <typename _Tp> | |
| 160 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak( | |
| 161 | volatile __cxx_atomic_base_impl<_Tp>* __a, | |
| 162 | _Tp* __expected, | |
| 163 | _Tp __value, | |
| 164 | memory_order __success, | |
| 165 | memory_order __failure) { | |
| 166 | return __atomic_compare_exchange( | |
| 167 | std::addressof(__a->__a_value), | |
| 168 | __expected, | |
| 169 | std::addressof(__value), | |
| 170 | true, | |
| 171 | __to_gcc_order(__success), | |
| 172 | __to_gcc_failure_order(__failure)); | |
| 173 | } | |
| 174 | ||
| 175 | template <typename _Tp> | |
| 176 | _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak( | |
| 177 | __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) { | |
| 178 | return __atomic_compare_exchange( | |
| 179 | std::addressof(__a->__a_value), | |
| 180 | __expected, | |
| 181 | std::addressof(__value), | |
| 182 | true, | |
| 183 | __to_gcc_order(__success), | |
| 184 | __to_gcc_failure_order(__failure)); | |
| 185 | } | |
| 186 | ||
| 187 | template <typename _Tp> | |
| 188 | struct __skip_amt { | |
| 189 | enum { value = 1 }; | |
| 190 | }; | |
| 191 | ||
| 192 | template <typename _Tp> | |
| 193 | struct __skip_amt<_Tp*> { | |
| 194 | enum { value = sizeof(_Tp) }; | |
| 195 | }; | |
| 196 | ||
| 197 | // FIXME: Haven't figured out what the spec says about using arrays with | |
| 198 | // atomic_fetch_add. Force a failure rather than creating bad behavior. | |
| 199 | template <typename _Tp> | |
| 200 | struct __skip_amt<_Tp[]> {}; | |
| 201 | template <typename _Tp, int n> | |
| 202 | struct __skip_amt<_Tp[n]> {}; | |
| 203 | ||
| 204 | template <typename _Tp, typename _Td> | |
| 205 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 206 | __cxx_atomic_fetch_add(volatile __cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) { | |
| 207 | return __atomic_fetch_add(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order)); | |
| 208 | } | |
| 209 | ||
| 210 | template <typename _Tp, typename _Td> | |
| 211 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) { | |
| 212 | return __atomic_fetch_add(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order)); | |
| 213 | } | |
| 214 | ||
| 215 | template <typename _Tp, typename _Td> | |
| 216 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 217 | __cxx_atomic_fetch_sub(volatile __cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) { | |
| 218 | return __atomic_fetch_sub(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order)); | |
| 219 | } | |
| 220 | ||
| 221 | template <typename _Tp, typename _Td> | |
| 222 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta, memory_order __order) { | |
| 223 | return __atomic_fetch_sub(std::addressof(__a->__a_value), __delta * __skip_amt<_Tp>::value, __to_gcc_order(__order)); | |
| 224 | } | |
| 225 | ||
| 226 | template <typename _Tp> | |
| 227 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 228 | __cxx_atomic_fetch_and(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 229 | return __atomic_fetch_and(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 230 | } | |
| 231 | ||
| 232 | template <typename _Tp> | |
| 233 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 234 | __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 235 | return __atomic_fetch_and(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 236 | } | |
| 237 | ||
| 238 | template <typename _Tp> | |
| 239 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 240 | __cxx_atomic_fetch_or(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 241 | return __atomic_fetch_or(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 242 | } | |
| 243 | ||
| 244 | template <typename _Tp> | |
| 245 | _LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 246 | return __atomic_fetch_or(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 247 | } | |
| 248 | ||
| 249 | template <typename _Tp> | |
| 250 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 251 | __cxx_atomic_fetch_xor(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 252 | return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 253 | } | |
| 254 | ||
| 255 | template <typename _Tp> | |
| 256 | _LIBCPP_HIDE_FROM_ABI _Tp | |
| 257 | __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_order __order) { | |
| 258 | return __atomic_fetch_xor(std::addressof(__a->__a_value), __pattern, __to_gcc_order(__order)); | |
| 259 | } | |
| 260 | ||
| 261 | #define __cxx_atomic_is_lock_free(__s) __atomic_is_lock_free(__s, 0) | |
| 262 | ||
| 263 | _LIBCPP_END_NAMESPACE_STD | |
| 264 | ||
| 265 | #endif // _LIBCPP___ATOMIC_SUPPORT_GCC_H |
lib/libcxx/include/__bit/bit_cast.h+1-1| ... | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | #ifndef _LIBCPP_CXX03_LANG |
| 23 | 23 | |
| 24 | 24 | template <class _ToType, class _FromType> |
| 25 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr _ToType __bit_cast(const _FromType& __from) noexcept { | |
| 25 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr _ToType __bit_cast(const _FromType& __from) noexcept { | |
| 26 | 26 | return __builtin_bit_cast(_ToType, __from); |
| 27 | 27 | } |
| 28 | 28 |
lib/libcxx/include/__bit/bit_log2.h+6-5| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___BIT_BIT_LOG2_H |
| 11 | 11 | |
| 12 | 12 | #include <__bit/countl.h> |
| 13 | #include <__concepts/arithmetic.h> | |
| 14 | 13 | #include <__config> |
| 14 | #include <__type_traits/is_unsigned_integer.h> | |
| 15 | 15 | #include <limits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -20,14 +20,15 @@ |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if _LIBCPP_STD_VER >= 20 | |
| 23 | #if _LIBCPP_STD_VER >= 14 | |
| 24 | 24 | |
| 25 | template <__libcpp_unsigned_integer _Tp> | |
| 25 | template <class _Tp> | |
| 26 | 26 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept { |
| 27 | return numeric_limits<_Tp>::digits - 1 - std::countl_zero(__t); | |
| 27 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type"); | |
| 28 | return numeric_limits<_Tp>::digits - 1 - std::__countl_zero(__t); | |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | #endif // _LIBCPP_STD_VER >= 20 | |
| 31 | #endif // _LIBCPP_STD_VER >= 14 | |
| 31 | 32 | |
| 32 | 33 | _LIBCPP_END_NAMESPACE_STD |
| 33 | 34 |
lib/libcxx/include/__bit/byteswap.h+2-2| ... | ... | @@ -32,7 +32,7 @@ template <integral _Tp> |
| 32 | 32 | return __builtin_bswap32(__val); |
| 33 | 33 | } else if constexpr (sizeof(_Tp) == 8) { |
| 34 | 34 | return __builtin_bswap64(__val); |
| 35 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 35 | # if _LIBCPP_HAS_INT128 | |
| 36 | 36 | } else if constexpr (sizeof(_Tp) == 16) { |
| 37 | 37 | # if __has_builtin(__builtin_bswap128) |
| 38 | 38 | return __builtin_bswap128(__val); |
| ... | ... | @@ -40,7 +40,7 @@ template <integral _Tp> |
| 40 | 40 | return static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val))) << 64 | |
| 41 | 41 | static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val >> 64))); |
| 42 | 42 | # endif // __has_builtin(__builtin_bswap128) |
| 43 | # endif // _LIBCPP_HAS_NO_INT128 | |
| 43 | # endif // _LIBCPP_HAS_INT128 | |
| 44 | 44 | } else { |
| 45 | 45 | static_assert(sizeof(_Tp) == 0, "byteswap is unimplemented for integral types of this size"); |
| 46 | 46 | } |
lib/libcxx/include/__bit/countl.h+5-5| ... | ... | @@ -27,19 +27,19 @@ _LIBCPP_PUSH_MACROS |
| 27 | 27 | |
| 28 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | |
| 30 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned __x) _NOEXCEPT { | |
| 30 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned __x) _NOEXCEPT { | |
| 31 | 31 | return __builtin_clz(__x); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long __x) _NOEXCEPT { | |
| 34 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long __x) _NOEXCEPT { | |
| 35 | 35 | return __builtin_clzl(__x); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long long __x) _NOEXCEPT { | |
| 38 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long long __x) _NOEXCEPT { | |
| 39 | 39 | return __builtin_clzll(__x); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 42 | #if _LIBCPP_HAS_INT128 | |
| 43 | 43 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) _NOEXCEPT { |
| 44 | 44 | # if __has_builtin(__builtin_clzg) |
| 45 | 45 | return __builtin_clzg(__x); |
| ... | ... | @@ -57,7 +57,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) |
| 57 | 57 | : __builtin_clzll(static_cast<unsigned long long>(__x >> 64)); |
| 58 | 58 | # endif |
| 59 | 59 | } |
| 60 | #endif // _LIBCPP_HAS_NO_INT128 | |
| 60 | #endif // _LIBCPP_HAS_INT128 | |
| 61 | 61 | |
| 62 | 62 | template <class _Tp> |
| 63 | 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT { |
lib/libcxx/include/__bit/countr.h+4-4| ... | ... | @@ -26,20 +26,20 @@ _LIBCPP_PUSH_MACROS |
| 26 | 26 | |
| 27 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | |
| 29 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned __x) _NOEXCEPT { | |
| 29 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned __x) _NOEXCEPT { | |
| 30 | 30 | return __builtin_ctz(__x); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long __x) _NOEXCEPT { | |
| 33 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long __x) _NOEXCEPT { | |
| 34 | 34 | return __builtin_ctzl(__x); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { | |
| 37 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { | |
| 38 | 38 | return __builtin_ctzll(__x); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | template <class _Tp> |
| 42 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT { | |
| 42 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT { | |
| 43 | 43 | #if __has_builtin(__builtin_ctzg) |
| 44 | 44 | return __builtin_ctzg(__t, numeric_limits<_Tp>::digits); |
| 45 | 45 | #else // __has_builtin(__builtin_ctzg) |
lib/libcxx/include/__bit/rotate.h+8-8| ... | ... | @@ -26,31 +26,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | template <class _Tp> |
| 27 | 27 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT { |
| 28 | 28 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type"); |
| 29 | const int __N = numeric_limits<_Tp>::digits; | |
| 30 | int __r = __s % __N; | |
| 29 | const int __n = numeric_limits<_Tp>::digits; | |
| 30 | int __r = __s % __n; | |
| 31 | 31 | |
| 32 | 32 | if (__r == 0) |
| 33 | 33 | return __x; |
| 34 | 34 | |
| 35 | 35 | if (__r > 0) |
| 36 | return (__x << __r) | (__x >> (__N - __r)); | |
| 36 | return (__x << __r) | (__x >> (__n - __r)); | |
| 37 | 37 | |
| 38 | return (__x >> -__r) | (__x << (__N + __r)); | |
| 38 | return (__x >> -__r) | (__x << (__n + __r)); | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | template <class _Tp> |
| 42 | 42 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT { |
| 43 | 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; | |
| 44 | const int __n = numeric_limits<_Tp>::digits; | |
| 45 | int __r = __s % __n; | |
| 46 | 46 | |
| 47 | 47 | if (__r == 0) |
| 48 | 48 | return __x; |
| 49 | 49 | |
| 50 | 50 | if (__r > 0) |
| 51 | return (__x >> __r) | (__x << (__N - __r)); | |
| 51 | return (__x >> __r) | (__x << (__n - __r)); | |
| 52 | 52 | |
| 53 | return (__x << -__r) | (__x >> (__N + __r)); | |
| 53 | return (__x << -__r) | (__x >> (__n + __r)); | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | #if _LIBCPP_STD_VER >= 20 |
lib/libcxx/include/__bit_reference+33-21| ... | ... | @@ -11,20 +11,20 @@ |
| 11 | 11 | #define _LIBCPP___BIT_REFERENCE |
| 12 | 12 | |
| 13 | 13 | #include <__algorithm/copy_n.h> |
| 14 | #include <__algorithm/fill_n.h> | |
| 15 | 14 | #include <__algorithm/min.h> |
| 16 | 15 | #include <__bit/countr.h> |
| 17 | #include <__bit/invert_if.h> | |
| 18 | #include <__bit/popcount.h> | |
| 19 | 16 | #include <__compare/ordering.h> |
| 20 | 17 | #include <__config> |
| 18 | #include <__cstddef/ptrdiff_t.h> | |
| 19 | #include <__cstddef/size_t.h> | |
| 21 | 20 | #include <__fwd/bit_reference.h> |
| 22 | 21 | #include <__iterator/iterator_traits.h> |
| 23 | 22 | #include <__memory/construct_at.h> |
| 24 | 23 | #include <__memory/pointer_traits.h> |
| 25 | 24 | #include <__type_traits/conditional.h> |
| 25 | #include <__type_traits/is_constant_evaluated.h> | |
| 26 | #include <__type_traits/void_t.h> | |
| 26 | 27 | #include <__utility/swap.h> |
| 27 | #include <cstring> | |
| 28 | 28 | |
| 29 | 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 30 | 30 | # pragma GCC system_header |
| ... | ... | @@ -43,10 +43,22 @@ struct __has_storage_type { |
| 43 | 43 | static const bool value = false; |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | template <class, class> | |
| 47 | struct __size_difference_type_traits { | |
| 48 | using difference_type = ptrdiff_t; | |
| 49 | using size_type = size_t; | |
| 50 | }; | |
| 51 | ||
| 52 | template <class _Cp> | |
| 53 | struct __size_difference_type_traits<_Cp, __void_t<typename _Cp::difference_type, typename _Cp::size_type> > { | |
| 54 | using difference_type = typename _Cp::difference_type; | |
| 55 | using size_type = typename _Cp::size_type; | |
| 56 | }; | |
| 57 | ||
| 46 | 58 | template <class _Cp, bool = __has_storage_type<_Cp>::value> |
| 47 | 59 | class __bit_reference { |
| 48 | using __storage_type = typename _Cp::__storage_type; | |
| 49 | using __storage_pointer = typename _Cp::__storage_pointer; | |
| 60 | using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type; | |
| 61 | using __storage_pointer _LIBCPP_NODEBUG = typename _Cp::__storage_pointer; | |
| 50 | 62 | |
| 51 | 63 | __storage_pointer __seg_; |
| 52 | 64 | __storage_type __mask_; |
| ... | ... | @@ -57,7 +69,7 @@ class __bit_reference { |
| 57 | 69 | friend class __bit_iterator<_Cp, false>; |
| 58 | 70 | |
| 59 | 71 | public: |
| 60 | using __container = typename _Cp::__self; | |
| 72 | using __container _LIBCPP_NODEBUG = typename _Cp::__self; | |
| 61 | 73 | |
| 62 | 74 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_reference(const __bit_reference&) = default; |
| 63 | 75 | |
| ... | ... | @@ -137,8 +149,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(bool& __x, |
| 137 | 149 | |
| 138 | 150 | template <class _Cp> |
| 139 | 151 | class __bit_const_reference { |
| 140 | using __storage_type = typename _Cp::__storage_type; | |
| 141 | using __storage_pointer = typename _Cp::__const_storage_pointer; | |
| 152 | using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type; | |
| 153 | using __storage_pointer _LIBCPP_NODEBUG = typename _Cp::__const_storage_pointer; | |
| 142 | 154 | |
| 143 | 155 | __storage_pointer __seg_; |
| 144 | 156 | __storage_type __mask_; |
| ... | ... | @@ -147,7 +159,7 @@ class __bit_const_reference { |
| 147 | 159 | friend class __bit_iterator<_Cp, true>; |
| 148 | 160 | |
| 149 | 161 | public: |
| 150 | using __container = typename _Cp::__self; | |
| 162 | using __container _LIBCPP_NODEBUG = typename _Cp::__self; | |
| 151 | 163 | |
| 152 | 164 | _LIBCPP_HIDE_FROM_ABI __bit_const_reference(const __bit_const_reference&) = default; |
| 153 | 165 | __bit_const_reference& operator=(const __bit_const_reference&) = delete; |
| ... | ... | @@ -589,10 +601,10 @@ inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> swap_ranges( |
| 589 | 601 | |
| 590 | 602 | template <class _Cp> |
| 591 | 603 | struct __bit_array { |
| 592 | using difference_type = typename _Cp::difference_type; | |
| 593 | using __storage_type = typename _Cp::__storage_type; | |
| 594 | using __storage_pointer = typename _Cp::__storage_pointer; | |
| 595 | using iterator = typename _Cp::iterator; | |
| 604 | using difference_type _LIBCPP_NODEBUG = typename __size_difference_type_traits<_Cp>::difference_type; | |
| 605 | using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type; | |
| 606 | using __storage_pointer _LIBCPP_NODEBUG = typename _Cp::__storage_pointer; | |
| 607 | using iterator _LIBCPP_NODEBUG = typename _Cp::iterator; | |
| 596 | 608 | |
| 597 | 609 | static const unsigned __bits_per_word = _Cp::__bits_per_word; |
| 598 | 610 | static const unsigned _Np = 4; |
| ... | ... | @@ -781,7 +793,7 @@ equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __b |
| 781 | 793 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type> |
| 782 | 794 | class __bit_iterator { |
| 783 | 795 | public: |
| 784 | using difference_type = typename _Cp::difference_type; | |
| 796 | using difference_type = typename __size_difference_type_traits<_Cp>::difference_type; | |
| 785 | 797 | using value_type = bool; |
| 786 | 798 | using pointer = __bit_iterator; |
| 787 | 799 | #ifndef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL |
| ... | ... | @@ -792,8 +804,8 @@ public: |
| 792 | 804 | using iterator_category = random_access_iterator_tag; |
| 793 | 805 | |
| 794 | 806 | private: |
| 795 | using __storage_type = typename _Cp::__storage_type; | |
| 796 | using __storage_pointer = | |
| 807 | using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type; | |
| 808 | using __storage_pointer _LIBCPP_NODEBUG = | |
| 797 | 809 | __conditional_t<_IsConst, typename _Cp::__const_storage_pointer, typename _Cp::__storage_pointer>; |
| 798 | 810 | |
| 799 | 811 | static const unsigned __bits_per_word = _Cp::__bits_per_word; |
| ... | ... | @@ -968,7 +980,7 @@ private: |
| 968 | 980 | |
| 969 | 981 | template <bool _FillVal, class _Dp> |
| 970 | 982 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend void |
| 971 | __fill_n_bool(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); | |
| 983 | __fill_n_bool(__bit_iterator<_Dp, false> __first, typename __size_difference_type_traits<_Dp>::size_type __n); | |
| 972 | 984 | |
| 973 | 985 | template <class _Dp, bool _IC> |
| 974 | 986 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_aligned( |
| ... | ... | @@ -1011,10 +1023,10 @@ private: |
| 1011 | 1023 | equal(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>); |
| 1012 | 1024 | template <bool _ToFind, class _Dp, bool _IC> |
| 1013 | 1025 | _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC> |
| 1014 | __find_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); | |
| 1026 | __find_bool(__bit_iterator<_Dp, _IC>, typename __size_difference_type_traits<_Dp>::size_type); | |
| 1015 | 1027 | template <bool _ToCount, class _Dp, bool _IC> |
| 1016 | friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI | |
| 1017 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __count_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); | |
| 1028 | friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 1029 | __count_bool(__bit_iterator<_Dp, _IC>, typename __size_difference_type_traits<_Dp>::size_type); | |
| 1018 | 1030 | }; |
| 1019 | 1031 | |
| 1020 | 1032 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__charconv/from_chars_floating_point.h created+73| ... | ... | @@ -0,0 +1,73 @@ |
| 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___CHARCONV_FROM_CHARS_FLOATING_POINT_H | |
| 11 | #define _LIBCPP___CHARCONV_FROM_CHARS_FLOATING_POINT_H | |
| 12 | ||
| 13 | #include <__assert> | |
| 14 | #include <__charconv/chars_format.h> | |
| 15 | #include <__charconv/from_chars_result.h> | |
| 16 | #include <__config> | |
| 17 | #include <__cstddef/ptrdiff_t.h> | |
| 18 | #include <__system_error/errc.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 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER >= 17 | |
| 30 | ||
| 31 | template <class _Fp> | |
| 32 | struct __from_chars_result { | |
| 33 | _Fp __value; | |
| 34 | ptrdiff_t __n; | |
| 35 | errc __ec; | |
| 36 | }; | |
| 37 | ||
| 38 | template <class _Fp> | |
| 39 | _LIBCPP_EXPORTED_FROM_ABI __from_chars_result<_Fp> __from_chars_floating_point( | |
| 40 | _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt); | |
| 41 | ||
| 42 | extern template __from_chars_result<float> __from_chars_floating_point( | |
| 43 | _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt); | |
| 44 | ||
| 45 | extern template __from_chars_result<double> __from_chars_floating_point( | |
| 46 | _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt); | |
| 47 | ||
| 48 | template <class _Fp> | |
| 49 | _LIBCPP_HIDE_FROM_ABI from_chars_result | |
| 50 | __from_chars(const char* __first, const char* __last, _Fp& __value, chars_format __fmt) { | |
| 51 | __from_chars_result<_Fp> __r = std::__from_chars_floating_point<_Fp>(__first, __last, __fmt); | |
| 52 | if (__r.__ec != errc::invalid_argument) | |
| 53 | __value = __r.__value; | |
| 54 | return {__first + __r.__n, __r.__ec}; | |
| 55 | } | |
| 56 | ||
| 57 | _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_HIDE_FROM_ABI inline from_chars_result | |
| 58 | from_chars(const char* __first, const char* __last, float& __value, chars_format __fmt = chars_format::general) { | |
| 59 | return std::__from_chars<float>(__first, __last, __value, __fmt); | |
| 60 | } | |
| 61 | ||
| 62 | _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_HIDE_FROM_ABI inline from_chars_result | |
| 63 | from_chars(const char* __first, const char* __last, double& __value, chars_format __fmt = chars_format::general) { | |
| 64 | return std::__from_chars<double>(__first, __last, __value, __fmt); | |
| 65 | } | |
| 66 | ||
| 67 | #endif // _LIBCPP_STD_VER >= 17 | |
| 68 | ||
| 69 | _LIBCPP_END_NAMESPACE_STD | |
| 70 | ||
| 71 | _LIBCPP_POP_MACROS | |
| 72 | ||
| 73 | #endif // _LIBCPP___CHARCONV_FROM_CHARS_FLOATING_POINT_H |
lib/libcxx/include/__charconv/tables.h+1-1| ... | ... | @@ -95,7 +95,7 @@ inline constexpr uint64_t __pow10_64[20] = { |
| 95 | 95 | UINT64_C(1000000000000000000), |
| 96 | 96 | UINT64_C(10000000000000000000)}; |
| 97 | 97 | |
| 98 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 98 | # if _LIBCPP_HAS_INT128 | |
| 99 | 99 | inline constexpr int __pow10_128_offset = 0; |
| 100 | 100 | inline constexpr __uint128_t __pow10_128[40] = { |
| 101 | 101 | UINT64_C(0), |
lib/libcxx/include/__charconv/to_chars_base_10.h+1-1| ... | ... | @@ -124,7 +124,7 @@ __base_10_u64(char* __buffer, uint64_t __value) noexcept { |
| 124 | 124 | return __itoa::__append10(__buffer, __value); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 127 | # if _LIBCPP_HAS_INT128 | |
| 128 | 128 | /// \returns 10^\a exp |
| 129 | 129 | /// |
| 130 | 130 | /// \pre \a exp [19, 39] |
lib/libcxx/include/__charconv/to_chars_integral.h+3-2| ... | ... | @@ -18,14 +18,15 @@ |
| 18 | 18 | #include <__charconv/to_chars_result.h> |
| 19 | 19 | #include <__charconv/traits.h> |
| 20 | 20 | #include <__config> |
| 21 | #include <__cstddef/ptrdiff_t.h> | |
| 21 | 22 | #include <__system_error/errc.h> |
| 22 | 23 | #include <__type_traits/enable_if.h> |
| 23 | 24 | #include <__type_traits/integral_constant.h> |
| 25 | #include <__type_traits/is_integral.h> | |
| 24 | 26 | #include <__type_traits/is_same.h> |
| 25 | 27 | #include <__type_traits/make_32_64_or_128_bit.h> |
| 26 | 28 | #include <__type_traits/make_unsigned.h> |
| 27 | 29 | #include <__utility/unreachable.h> |
| 28 | #include <cstddef> | |
| 29 | 30 | #include <cstdint> |
| 30 | 31 | #include <limits> |
| 31 | 32 | |
| ... | ... | @@ -70,7 +71,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) { |
| 70 | 71 | return {__last, errc::value_too_large}; |
| 71 | 72 | } |
| 72 | 73 | |
| 73 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 74 | # if _LIBCPP_HAS_INT128 | |
| 74 | 75 | template <> |
| 75 | 76 | inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result |
| 76 | 77 | __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) { |
lib/libcxx/include/__charconv/traits.h+1-1| ... | ... | @@ -88,7 +88,7 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uin |
| 88 | 88 | } |
| 89 | 89 | }; |
| 90 | 90 | |
| 91 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 91 | # if _LIBCPP_HAS_INT128 | |
| 92 | 92 | template <typename _Tp> |
| 93 | 93 | struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__uint128_t)> > { |
| 94 | 94 | using type = __uint128_t; |
lib/libcxx/include/__chrono/convert_to_tm.h+27-5| ... | ... | @@ -24,6 +24,7 @@ |
| 24 | 24 | #include <__chrono/sys_info.h> |
| 25 | 25 | #include <__chrono/system_clock.h> |
| 26 | 26 | #include <__chrono/time_point.h> |
| 27 | #include <__chrono/utc_clock.h> | |
| 27 | 28 | #include <__chrono/weekday.h> |
| 28 | 29 | #include <__chrono/year.h> |
| 29 | 30 | #include <__chrono/year_month.h> |
| ... | ... | @@ -98,6 +99,22 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const chrono::sys_time<_Duration> __tp |
| 98 | 99 | return __result; |
| 99 | 100 | } |
| 100 | 101 | |
| 102 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 103 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 104 | ||
| 105 | template <class _Tm, class _Duration> | |
| 106 | _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::utc_time<_Duration> __tp) { | |
| 107 | _Tm __result = std::__convert_to_tm<_Tm>(chrono::utc_clock::to_sys(__tp)); | |
| 108 | ||
| 109 | if (chrono::get_leap_second_info(__tp).is_leap_second) | |
| 110 | ++__result.tm_sec; | |
| 111 | ||
| 112 | return __result; | |
| 113 | } | |
| 114 | ||
| 115 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 116 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 117 | ||
| 101 | 118 | // Convert a chrono (calendar) time point, or dururation to the given _Tm type, |
| 102 | 119 | // which must have the same properties as std::tm. |
| 103 | 120 | template <class _Tm, class _ChronoT> |
| ... | ... | @@ -110,13 +127,19 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) { |
| 110 | 127 | if constexpr (__is_time_point<_ChronoT>) { |
| 111 | 128 | if constexpr (same_as<typename _ChronoT::clock, chrono::system_clock>) |
| 112 | 129 | return std::__convert_to_tm<_Tm>(__value); |
| 130 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 131 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 132 | else if constexpr (same_as<typename _ChronoT::clock, chrono::utc_clock>) | |
| 133 | return std::__convert_to_tm<_Tm>(__value); | |
| 134 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 135 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 113 | 136 | else if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>) |
| 114 | 137 | return std::__convert_to_tm<_Tm>(_ChronoT::clock::to_sys(__value)); |
| 115 | 138 | else if constexpr (same_as<typename _ChronoT::clock, chrono::local_t>) |
| 116 | 139 | return std::__convert_to_tm<_Tm>(chrono::sys_time<typename _ChronoT::duration>{__value.time_since_epoch()}); |
| 117 | 140 | else |
| 118 | 141 | static_assert(sizeof(_ChronoT) == 0, "TODO: Add the missing clock specialization"); |
| 119 | } else if constexpr (chrono::__is_duration<_ChronoT>::value) { | |
| 142 | } else if constexpr (chrono::__is_duration_v<_ChronoT>) { | |
| 120 | 143 | // [time.format]/6 |
| 121 | 144 | // ... However, if a flag refers to a "time of day" (e.g. %H, %I, %p, |
| 122 | 145 | // etc.), then a specialization of duration is interpreted as the time of |
| ... | ... | @@ -175,18 +198,17 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) { |
| 175 | 198 | if (__value.hours().count() > std::numeric_limits<decltype(__result.tm_hour)>::max()) |
| 176 | 199 | std::__throw_format_error("Formatting hh_mm_ss, encountered an hour overflow"); |
| 177 | 200 | __result.tm_hour = __value.hours().count(); |
| 178 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 201 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 179 | 202 | } else if constexpr (same_as<_ChronoT, chrono::sys_info>) { |
| 180 | 203 | // Has no time information. |
| 181 | 204 | } else if constexpr (same_as<_ChronoT, chrono::local_info>) { |
| 182 | 205 | // Has no time information. |
| 183 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | |
| 184 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 206 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 185 | 207 | } else if constexpr (__is_specialization_v<_ChronoT, chrono::zoned_time>) { |
| 186 | 208 | return std::__convert_to_tm<_Tm>( |
| 187 | 209 | chrono::sys_time<typename _ChronoT::duration>{__value.get_local_time().time_since_epoch()}); |
| 188 | 210 | # endif |
| 189 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 211 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 190 | 212 | } else |
| 191 | 213 | static_assert(sizeof(_ChronoT) == 0, "Add the missing type specialization"); |
| 192 | 214 |
lib/libcxx/include/__chrono/day.h+1-1| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | #define _LIBCPP___CHRONO_DAY_H |
| 12 | 12 | |
| 13 | 13 | #include <__chrono/duration.h> |
| 14 | #include <__compare/ordering.h> | |
| 14 | 15 | #include <__config> |
| 15 | #include <compare> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | # pragma GCC system_header |
lib/libcxx/include/__chrono/duration.h+16-21| ... | ... | @@ -35,26 +35,25 @@ template <class _Rep, class _Period = ratio<1> > |
| 35 | 35 | class _LIBCPP_TEMPLATE_VIS duration; |
| 36 | 36 | |
| 37 | 37 | template <class _Tp> |
| 38 | struct __is_duration : false_type {}; | |
| 38 | inline const bool __is_duration_v = false; | |
| 39 | 39 | |
| 40 | 40 | template <class _Rep, class _Period> |
| 41 | struct __is_duration<duration<_Rep, _Period> > : true_type {}; | |
| 41 | inline const bool __is_duration_v<duration<_Rep, _Period> > = true; | |
| 42 | 42 | |
| 43 | 43 | template <class _Rep, class _Period> |
| 44 | struct __is_duration<const duration<_Rep, _Period> > : true_type {}; | |
| 44 | inline const bool __is_duration_v<const duration<_Rep, _Period> > = true; | |
| 45 | 45 | |
| 46 | 46 | template <class _Rep, class _Period> |
| 47 | struct __is_duration<volatile duration<_Rep, _Period> > : true_type {}; | |
| 47 | inline const bool __is_duration_v<volatile duration<_Rep, _Period> > = true; | |
| 48 | 48 | |
| 49 | 49 | template <class _Rep, class _Period> |
| 50 | struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {}; | |
| 50 | inline const bool __is_duration_v<const volatile duration<_Rep, _Period> > = true; | |
| 51 | 51 | |
| 52 | 52 | } // namespace chrono |
| 53 | 53 | |
| 54 | 54 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> |
| 55 | 55 | struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > { |
| 56 | typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, typename __ratio_gcd<_Period1, _Period2>::type> | |
| 57 | type; | |
| 56 | typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, __ratio_gcd<_Period1, _Period2> > type; | |
| 58 | 57 | }; |
| 59 | 58 | |
| 60 | 59 | namespace chrono { |
| ... | ... | @@ -102,7 +101,7 @@ struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> { |
| 102 | 101 | } |
| 103 | 102 | }; |
| 104 | 103 | |
| 105 | template <class _ToDuration, class _Rep, class _Period, __enable_if_t<__is_duration<_ToDuration>::value, int> = 0> | |
| 104 | template <class _ToDuration, class _Rep, class _Period, __enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | |
| 106 | 105 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const duration<_Rep, _Period>& __fd) { |
| 107 | 106 | return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd); |
| 108 | 107 | } |
| ... | ... | @@ -124,7 +123,7 @@ public: |
| 124 | 123 | }; |
| 125 | 124 | |
| 126 | 125 | #if _LIBCPP_STD_VER >= 17 |
| 127 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> | |
| 126 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | |
| 128 | 127 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration<_Rep, _Period>& __d) { |
| 129 | 128 | _ToDuration __t = chrono::duration_cast<_ToDuration>(__d); |
| 130 | 129 | if (__t > __d) |
| ... | ... | @@ -132,7 +131,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration floor(const duration< |
| 132 | 131 | return __t; |
| 133 | 132 | } |
| 134 | 133 | |
| 135 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> | |
| 134 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | |
| 136 | 135 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_Rep, _Period>& __d) { |
| 137 | 136 | _ToDuration __t = chrono::duration_cast<_ToDuration>(__d); |
| 138 | 137 | if (__t < __d) |
| ... | ... | @@ -140,7 +139,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration ceil(const duration<_ |
| 140 | 139 | return __t; |
| 141 | 140 | } |
| 142 | 141 | |
| 143 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> | |
| 142 | template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | |
| 144 | 143 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<_Rep, _Period>& __d) { |
| 145 | 144 | _ToDuration __lower = chrono::floor<_ToDuration>(__d); |
| 146 | 145 | _ToDuration __upper = __lower + _ToDuration{1}; |
| ... | ... | @@ -158,15 +157,15 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration< |
| 158 | 157 | |
| 159 | 158 | template <class _Rep, class _Period> |
| 160 | 159 | class _LIBCPP_TEMPLATE_VIS duration { |
| 161 | static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); | |
| 162 | static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); | |
| 160 | static_assert(!__is_duration_v<_Rep>, "A duration representation can not be a duration"); | |
| 161 | static_assert(__is_ratio_v<_Period>, "Second template parameter of duration must be a std::ratio"); | |
| 163 | 162 | static_assert(_Period::num > 0, "duration period must be positive"); |
| 164 | 163 | |
| 165 | 164 | template <class _R1, class _R2> |
| 166 | 165 | struct __no_overflow { |
| 167 | 166 | private: |
| 168 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; | |
| 169 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; | |
| 167 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>; | |
| 168 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>; | |
| 170 | 169 | static const intmax_t __n1 = _R1::num / __gcd_n1_n2; |
| 171 | 170 | static const intmax_t __d1 = _R1::den / __gcd_d1_d2; |
| 172 | 171 | static const intmax_t __n2 = _R2::num / __gcd_n1_n2; |
| ... | ... | @@ -434,7 +433,7 @@ operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) { |
| 434 | 433 | template <class _Rep1, |
| 435 | 434 | class _Period, |
| 436 | 435 | class _Rep2, |
| 437 | __enable_if_t<!__is_duration<_Rep2>::value && | |
| 436 | __enable_if_t<!__is_duration_v<_Rep2> && | |
| 438 | 437 | is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, |
| 439 | 438 | int> = 0> |
| 440 | 439 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> |
| ... | ... | @@ -456,7 +455,7 @@ operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2 |
| 456 | 455 | template <class _Rep1, |
| 457 | 456 | class _Period, |
| 458 | 457 | class _Rep2, |
| 459 | __enable_if_t<!__is_duration<_Rep2>::value && | |
| 458 | __enable_if_t<!__is_duration_v<_Rep2> && | |
| 460 | 459 | is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, |
| 461 | 460 | int> = 0> |
| 462 | 461 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period> |
| ... | ... | @@ -543,8 +542,4 @@ _LIBCPP_END_NAMESPACE_STD |
| 543 | 542 | |
| 544 | 543 | _LIBCPP_POP_MACROS |
| 545 | 544 | |
| 546 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 547 | # include <type_traits> | |
| 548 | #endif | |
| 549 | ||
| 550 | 545 | #endif // _LIBCPP___CHRONO_DURATION_H |
lib/libcxx/include/__chrono/exception.h+6-6| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | |
| 15 | 15 | #include <version> |
| 16 | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 17 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 18 | 18 | |
| 19 | 19 | # include <__chrono/calendar.h> |
| 20 | 20 | # include <__chrono/local_info.h> |
| ... | ... | @@ -71,9 +71,9 @@ private: |
| 71 | 71 | }; |
| 72 | 72 | |
| 73 | 73 | template <class _Duration> |
| 74 | _LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time( | |
| 74 | [[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time( | |
| 75 | 75 | [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) { |
| 76 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 76 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 77 | 77 | throw nonexistent_local_time(__time, __info); |
| 78 | 78 | # else |
| 79 | 79 | _LIBCPP_VERBOSE_ABORT("nonexistent_local_time was thrown in -fno-exceptions mode"); |
| ... | ... | @@ -115,9 +115,9 @@ private: |
| 115 | 115 | }; |
| 116 | 116 | |
| 117 | 117 | template <class _Duration> |
| 118 | _LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time( | |
| 118 | [[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time( | |
| 119 | 119 | [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) { |
| 120 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 120 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 121 | 121 | throw ambiguous_local_time(__time, __info); |
| 122 | 122 | # else |
| 123 | 123 | _LIBCPP_VERBOSE_ABORT("ambiguous_local_time was thrown in -fno-exceptions mode"); |
| ... | ... | @@ -130,6 +130,6 @@ _LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_am |
| 130 | 130 | |
| 131 | 131 | _LIBCPP_END_NAMESPACE_STD |
| 132 | 132 | |
| 133 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 133 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 134 | 134 | |
| 135 | 135 | #endif // _LIBCPP___CHRONO_EXCEPTION_H |
lib/libcxx/include/__chrono/file_clock.h+1-1| ... | ... | @@ -47,7 +47,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 47 | 47 | #ifndef _LIBCPP_CXX03_LANG |
| 48 | 48 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 49 | 49 | struct _FilesystemClock { |
| 50 | # if !defined(_LIBCPP_HAS_NO_INT128) | |
| 50 | # if _LIBCPP_HAS_INT128 | |
| 51 | 51 | typedef __int128_t rep; |
| 52 | 52 | typedef nano period; |
| 53 | 53 | # else |
lib/libcxx/include/__chrono/formatter.h+129-114| ... | ... | @@ -10,55 +10,60 @@ |
| 10 | 10 | #ifndef _LIBCPP___CHRONO_FORMATTER_H |
| 11 | 11 | #define _LIBCPP___CHRONO_FORMATTER_H |
| 12 | 12 | |
| 13 | #include <__algorithm/ranges_copy.h> | |
| 14 | #include <__chrono/calendar.h> | |
| 15 | #include <__chrono/concepts.h> | |
| 16 | #include <__chrono/convert_to_tm.h> | |
| 17 | #include <__chrono/day.h> | |
| 18 | #include <__chrono/duration.h> | |
| 19 | #include <__chrono/file_clock.h> | |
| 20 | #include <__chrono/hh_mm_ss.h> | |
| 21 | #include <__chrono/local_info.h> | |
| 22 | #include <__chrono/month.h> | |
| 23 | #include <__chrono/month_weekday.h> | |
| 24 | #include <__chrono/monthday.h> | |
| 25 | #include <__chrono/ostream.h> | |
| 26 | #include <__chrono/parser_std_format_spec.h> | |
| 27 | #include <__chrono/statically_widen.h> | |
| 28 | #include <__chrono/sys_info.h> | |
| 29 | #include <__chrono/system_clock.h> | |
| 30 | #include <__chrono/time_point.h> | |
| 31 | #include <__chrono/weekday.h> | |
| 32 | #include <__chrono/year.h> | |
| 33 | #include <__chrono/year_month.h> | |
| 34 | #include <__chrono/year_month_day.h> | |
| 35 | #include <__chrono/year_month_weekday.h> | |
| 36 | #include <__chrono/zoned_time.h> | |
| 37 | #include <__concepts/arithmetic.h> | |
| 38 | #include <__concepts/same_as.h> | |
| 39 | 13 | #include <__config> |
| 40 | #include <__format/concepts.h> | |
| 41 | #include <__format/format_error.h> | |
| 42 | #include <__format/format_functions.h> | |
| 43 | #include <__format/format_parse_context.h> | |
| 44 | #include <__format/formatter.h> | |
| 45 | #include <__format/parser_std_format_spec.h> | |
| 46 | #include <__format/write_escaped.h> | |
| 47 | #include <__memory/addressof.h> | |
| 48 | #include <__type_traits/is_specialization.h> | |
| 49 | #include <cmath> | |
| 50 | #include <ctime> | |
| 51 | #include <limits> | |
| 52 | #include <sstream> | |
| 53 | #include <string_view> | |
| 54 | ||
| 55 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 56 | # pragma GCC system_header | |
| 57 | #endif | |
| 14 | ||
| 15 | #if _LIBCPP_HAS_LOCALIZATION | |
| 16 | ||
| 17 | # include <__algorithm/ranges_copy.h> | |
| 18 | # include <__chrono/calendar.h> | |
| 19 | # include <__chrono/concepts.h> | |
| 20 | # include <__chrono/convert_to_tm.h> | |
| 21 | # include <__chrono/day.h> | |
| 22 | # include <__chrono/duration.h> | |
| 23 | # include <__chrono/file_clock.h> | |
| 24 | # include <__chrono/hh_mm_ss.h> | |
| 25 | # include <__chrono/local_info.h> | |
| 26 | # include <__chrono/month.h> | |
| 27 | # include <__chrono/month_weekday.h> | |
| 28 | # include <__chrono/monthday.h> | |
| 29 | # include <__chrono/ostream.h> | |
| 30 | # include <__chrono/parser_std_format_spec.h> | |
| 31 | # include <__chrono/statically_widen.h> | |
| 32 | # include <__chrono/sys_info.h> | |
| 33 | # include <__chrono/system_clock.h> | |
| 34 | # include <__chrono/time_point.h> | |
| 35 | # include <__chrono/utc_clock.h> | |
| 36 | # include <__chrono/weekday.h> | |
| 37 | # include <__chrono/year.h> | |
| 38 | # include <__chrono/year_month.h> | |
| 39 | # include <__chrono/year_month_day.h> | |
| 40 | # include <__chrono/year_month_weekday.h> | |
| 41 | # include <__chrono/zoned_time.h> | |
| 42 | # include <__concepts/arithmetic.h> | |
| 43 | # include <__concepts/same_as.h> | |
| 44 | # include <__format/concepts.h> | |
| 45 | # include <__format/format_error.h> | |
| 46 | # include <__format/format_functions.h> | |
| 47 | # include <__format/format_parse_context.h> | |
| 48 | # include <__format/formatter.h> | |
| 49 | # include <__format/parser_std_format_spec.h> | |
| 50 | # include <__format/write_escaped.h> | |
| 51 | # include <__memory/addressof.h> | |
| 52 | # include <__type_traits/is_specialization.h> | |
| 53 | # include <cmath> | |
| 54 | # include <ctime> | |
| 55 | # include <limits> | |
| 56 | # include <locale> | |
| 57 | # include <sstream> | |
| 58 | # include <string_view> | |
| 59 | ||
| 60 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 61 | # pragma GCC system_header | |
| 62 | # endif | |
| 58 | 63 | |
| 59 | 64 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 60 | 65 | |
| 61 | #if _LIBCPP_STD_VER >= 20 | |
| 66 | # if _LIBCPP_STD_VER >= 20 | |
| 62 | 67 | |
| 63 | 68 | namespace __formatter { |
| 64 | 69 | |
| ... | ... | @@ -139,25 +144,23 @@ __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss< |
| 139 | 144 | __value.fractional_width); |
| 140 | 145 | } |
| 141 | 146 | |
| 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) | |
| 147 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 144 | 148 | template <class _CharT, class _Duration, class _TimeZonePtr> |
| 145 | 149 | _LIBCPP_HIDE_FROM_ABI void |
| 146 | 150 | __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::zoned_time<_Duration, _TimeZonePtr>& __value) { |
| 147 | 151 | __formatter::__format_sub_seconds(__sstr, __value.get_local_time().time_since_epoch()); |
| 148 | 152 | } |
| 149 | # endif | |
| 153 | # endif | |
| 150 | 154 | |
| 151 | 155 | template <class _Tp> |
| 152 | 156 | consteval bool __use_fraction() { |
| 153 | 157 | if constexpr (__is_time_point<_Tp>) |
| 154 | 158 | 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) | |
| 159 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 157 | 160 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) |
| 158 | 161 | return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width; |
| 159 | # endif | |
| 160 | else if constexpr (chrono::__is_duration<_Tp>::value) | |
| 162 | # endif | |
| 163 | else if constexpr (chrono::__is_duration_v<_Tp>) | |
| 161 | 164 | return chrono::hh_mm_ss<_Tp>::fractional_width; |
| 162 | 165 | else if constexpr (__is_hh_mm_ss<_Tp>) |
| 163 | 166 | return _Tp::fractional_width; |
| ... | ... | @@ -225,16 +228,15 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone { |
| 225 | 228 | |
| 226 | 229 | template <class _Tp> |
| 227 | 230 | _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const _Tp& __value) { |
| 228 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 231 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 229 | 232 | if constexpr (same_as<_Tp, chrono::sys_info>) |
| 230 | 233 | 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) | |
| 234 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 233 | 235 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) |
| 234 | 236 | return __formatter::__convert_to_time_zone(__value.get_info()); |
| 235 | # endif | |
| 237 | # endif | |
| 236 | 238 | else |
| 237 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 239 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 238 | 240 | return {"UTC", chrono::seconds{0}}; |
| 239 | 241 | } |
| 240 | 242 | |
| ... | ... | @@ -272,7 +274,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 272 | 274 | } break; |
| 273 | 275 | |
| 274 | 276 | case _CharT('j'): |
| 275 | if constexpr (chrono::__is_duration<_Tp>::value) | |
| 277 | if constexpr (chrono::__is_duration_v<_Tp>) | |
| 276 | 278 | // Converting a duration where the period has a small ratio to days |
| 277 | 279 | // may fail to compile. This due to loss of precision in the |
| 278 | 280 | // conversion. In order to avoid that issue convert to seconds as |
| ... | ... | @@ -284,7 +286,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 284 | 286 | break; |
| 285 | 287 | |
| 286 | 288 | case _CharT('q'): |
| 287 | if constexpr (chrono::__is_duration<_Tp>::value) { | |
| 289 | if constexpr (chrono::__is_duration_v<_Tp>) { | |
| 288 | 290 | __sstr << chrono::__units_suffix<_CharT, typename _Tp::period>(); |
| 289 | 291 | break; |
| 290 | 292 | } |
| ... | ... | @@ -300,7 +302,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 300 | 302 | // MSVC STL ignores precision but uses separator |
| 301 | 303 | // FMT honours precision and has a bug for separator |
| 302 | 304 | // https://godbolt.org/z/78b7sMxns |
| 303 | if constexpr (chrono::__is_duration<_Tp>::value) { | |
| 305 | if constexpr (chrono::__is_duration_v<_Tp>) { | |
| 304 | 306 | __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{}"), __value.count()); |
| 305 | 307 | break; |
| 306 | 308 | } |
| ... | ... | @@ -341,16 +343,16 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs( |
| 341 | 343 | // |
| 342 | 344 | // TODO FMT evaluate the comment above. |
| 343 | 345 | |
| 344 | # if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32) | |
| 346 | # if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32) | |
| 345 | 347 | case _CharT('y'): |
| 346 | 348 | // Glibc fails for negative values, AIX for positive values too. |
| 347 | 349 | __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), (std::abs(__t.tm_year + 1900)) % 100); |
| 348 | 350 | break; |
| 349 | # endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32) | |
| 351 | # endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32) | |
| 350 | 352 | |
| 351 | 353 | case _CharT('Y'): |
| 352 | 354 | // Depending on the platform's libc the range of supported years is |
| 353 | // limited. Intead of of testing all conditions use the internal | |
| 355 | // limited. Instead of of testing all conditions use the internal | |
| 354 | 356 | // implementation unconditionally. |
| 355 | 357 | __formatter::__format_year(__sstr, __t.tm_year + 1900); |
| 356 | 358 | break; |
| ... | ... | @@ -442,17 +444,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) { |
| 442 | 444 | return __value.weekday().ok(); |
| 443 | 445 | else if constexpr (__is_hh_mm_ss<_Tp>) |
| 444 | 446 | return true; |
| 445 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 447 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 446 | 448 | else if constexpr (same_as<_Tp, chrono::sys_info>) |
| 447 | 449 | return true; |
| 448 | 450 | else if constexpr (same_as<_Tp, chrono::local_info>) |
| 449 | 451 | return true; |
| 450 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | |
| 451 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 452 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 452 | 453 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) |
| 453 | 454 | return true; |
| 454 | # endif | |
| 455 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 455 | # endif | |
| 456 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 456 | 457 | else |
| 457 | 458 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); |
| 458 | 459 | } |
| ... | ... | @@ -493,17 +494,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) { |
| 493 | 494 | return __value.weekday().ok(); |
| 494 | 495 | else if constexpr (__is_hh_mm_ss<_Tp>) |
| 495 | 496 | return true; |
| 496 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 497 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 497 | 498 | else if constexpr (same_as<_Tp, chrono::sys_info>) |
| 498 | 499 | return true; |
| 499 | 500 | else if constexpr (same_as<_Tp, chrono::local_info>) |
| 500 | 501 | return true; |
| 501 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | |
| 502 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 502 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 503 | 503 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) |
| 504 | 504 | return true; |
| 505 | # endif | |
| 506 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 505 | # endif | |
| 506 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 507 | 507 | else |
| 508 | 508 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); |
| 509 | 509 | } |
| ... | ... | @@ -544,17 +544,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) { |
| 544 | 544 | return __value.ok(); |
| 545 | 545 | else if constexpr (__is_hh_mm_ss<_Tp>) |
| 546 | 546 | return true; |
| 547 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 547 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 548 | 548 | else if constexpr (same_as<_Tp, chrono::sys_info>) |
| 549 | 549 | return true; |
| 550 | 550 | else if constexpr (same_as<_Tp, chrono::local_info>) |
| 551 | 551 | return true; |
| 552 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | |
| 553 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 552 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 554 | 553 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) |
| 555 | 554 | return true; |
| 556 | # endif | |
| 557 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 555 | # endif | |
| 556 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 558 | 557 | else |
| 559 | 558 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); |
| 560 | 559 | } |
| ... | ... | @@ -595,17 +594,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) { |
| 595 | 594 | return __value.month().ok(); |
| 596 | 595 | else if constexpr (__is_hh_mm_ss<_Tp>) |
| 597 | 596 | return true; |
| 598 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 597 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 599 | 598 | else if constexpr (same_as<_Tp, chrono::sys_info>) |
| 600 | 599 | return true; |
| 601 | 600 | else if constexpr (same_as<_Tp, chrono::local_info>) |
| 602 | 601 | return true; |
| 603 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | |
| 604 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 602 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 605 | 603 | else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>) |
| 606 | 604 | return true; |
| 607 | # endif | |
| 608 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 605 | # endif | |
| 606 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 609 | 607 | else |
| 610 | 608 | static_assert(sizeof(_Tp) == 0, "Add the missing type specialization"); |
| 611 | 609 | } |
| ... | ... | @@ -630,7 +628,7 @@ __format_chrono(const _Tp& __value, |
| 630 | 628 | if (__chrono_specs.empty()) |
| 631 | 629 | __sstr << __value; |
| 632 | 630 | else { |
| 633 | if constexpr (chrono::__is_duration<_Tp>::value) { | |
| 631 | if constexpr (chrono::__is_duration_v<_Tp>) { | |
| 634 | 632 | // A duration can be a user defined arithmetic type. Users may specialize |
| 635 | 633 | // numeric_limits, but they may not specialize is_signed. |
| 636 | 634 | if constexpr (numeric_limits<typename _Tp::rep>::is_signed) { |
| ... | ... | @@ -714,7 +712,7 @@ public: |
| 714 | 712 | template <class _Duration, __fmt_char_type _CharT> |
| 715 | 713 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::sys_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { |
| 716 | 714 | public: |
| 717 | using _Base = __formatter_chrono<_CharT>; | |
| 715 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 718 | 716 | |
| 719 | 717 | template <class _ParseContext> |
| 720 | 718 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -722,10 +720,27 @@ public: |
| 722 | 720 | } |
| 723 | 721 | }; |
| 724 | 722 | |
| 723 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 724 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 725 | ||
| 726 | template <class _Duration, __fmt_char_type _CharT> | |
| 727 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::utc_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { | |
| 728 | public: | |
| 729 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 730 | ||
| 731 | template <class _ParseContext> | |
| 732 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | |
| 733 | return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock); | |
| 734 | } | |
| 735 | }; | |
| 736 | ||
| 737 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 738 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 739 | ||
| 725 | 740 | template <class _Duration, __fmt_char_type _CharT> |
| 726 | 741 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::file_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { |
| 727 | 742 | public: |
| 728 | using _Base = __formatter_chrono<_CharT>; | |
| 743 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 729 | 744 | |
| 730 | 745 | template <class _ParseContext> |
| 731 | 746 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -736,7 +751,7 @@ public: |
| 736 | 751 | template <class _Duration, __fmt_char_type _CharT> |
| 737 | 752 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::local_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> { |
| 738 | 753 | public: |
| 739 | using _Base = __formatter_chrono<_CharT>; | |
| 754 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 740 | 755 | |
| 741 | 756 | template <class _ParseContext> |
| 742 | 757 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -748,7 +763,7 @@ public: |
| 748 | 763 | template <class _Rep, class _Period, __fmt_char_type _CharT> |
| 749 | 764 | struct formatter<chrono::duration<_Rep, _Period>, _CharT> : public __formatter_chrono<_CharT> { |
| 750 | 765 | public: |
| 751 | using _Base = __formatter_chrono<_CharT>; | |
| 766 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 752 | 767 | |
| 753 | 768 | template <class _ParseContext> |
| 754 | 769 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -770,7 +785,7 @@ public: |
| 770 | 785 | template <__fmt_char_type _CharT> |
| 771 | 786 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::day, _CharT> : public __formatter_chrono<_CharT> { |
| 772 | 787 | public: |
| 773 | using _Base = __formatter_chrono<_CharT>; | |
| 788 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 774 | 789 | |
| 775 | 790 | template <class _ParseContext> |
| 776 | 791 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -781,7 +796,7 @@ public: |
| 781 | 796 | template <__fmt_char_type _CharT> |
| 782 | 797 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month, _CharT> : public __formatter_chrono<_CharT> { |
| 783 | 798 | public: |
| 784 | using _Base = __formatter_chrono<_CharT>; | |
| 799 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 785 | 800 | |
| 786 | 801 | template <class _ParseContext> |
| 787 | 802 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -792,7 +807,7 @@ public: |
| 792 | 807 | template <__fmt_char_type _CharT> |
| 793 | 808 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year, _CharT> : public __formatter_chrono<_CharT> { |
| 794 | 809 | public: |
| 795 | using _Base = __formatter_chrono<_CharT>; | |
| 810 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 796 | 811 | |
| 797 | 812 | template <class _ParseContext> |
| 798 | 813 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -803,7 +818,7 @@ public: |
| 803 | 818 | template <__fmt_char_type _CharT> |
| 804 | 819 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday, _CharT> : public __formatter_chrono<_CharT> { |
| 805 | 820 | public: |
| 806 | using _Base = __formatter_chrono<_CharT>; | |
| 821 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 807 | 822 | |
| 808 | 823 | template <class _ParseContext> |
| 809 | 824 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -814,7 +829,7 @@ public: |
| 814 | 829 | template <__fmt_char_type _CharT> |
| 815 | 830 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_indexed, _CharT> : public __formatter_chrono<_CharT> { |
| 816 | 831 | public: |
| 817 | using _Base = __formatter_chrono<_CharT>; | |
| 832 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 818 | 833 | |
| 819 | 834 | template <class _ParseContext> |
| 820 | 835 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -825,7 +840,7 @@ public: |
| 825 | 840 | template <__fmt_char_type _CharT> |
| 826 | 841 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_last, _CharT> : public __formatter_chrono<_CharT> { |
| 827 | 842 | public: |
| 828 | using _Base = __formatter_chrono<_CharT>; | |
| 843 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 829 | 844 | |
| 830 | 845 | template <class _ParseContext> |
| 831 | 846 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -836,7 +851,7 @@ public: |
| 836 | 851 | template <__fmt_char_type _CharT> |
| 837 | 852 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day, _CharT> : public __formatter_chrono<_CharT> { |
| 838 | 853 | public: |
| 839 | using _Base = __formatter_chrono<_CharT>; | |
| 854 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 840 | 855 | |
| 841 | 856 | template <class _ParseContext> |
| 842 | 857 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -847,7 +862,7 @@ public: |
| 847 | 862 | template <__fmt_char_type _CharT> |
| 848 | 863 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day_last, _CharT> : public __formatter_chrono<_CharT> { |
| 849 | 864 | public: |
| 850 | using _Base = __formatter_chrono<_CharT>; | |
| 865 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 851 | 866 | |
| 852 | 867 | template <class _ParseContext> |
| 853 | 868 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -858,7 +873,7 @@ public: |
| 858 | 873 | template <__fmt_char_type _CharT> |
| 859 | 874 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday, _CharT> : public __formatter_chrono<_CharT> { |
| 860 | 875 | public: |
| 861 | using _Base = __formatter_chrono<_CharT>; | |
| 876 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 862 | 877 | |
| 863 | 878 | template <class _ParseContext> |
| 864 | 879 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -869,7 +884,7 @@ public: |
| 869 | 884 | template <__fmt_char_type _CharT> |
| 870 | 885 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday_last, _CharT> : public __formatter_chrono<_CharT> { |
| 871 | 886 | public: |
| 872 | using _Base = __formatter_chrono<_CharT>; | |
| 887 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 873 | 888 | |
| 874 | 889 | template <class _ParseContext> |
| 875 | 890 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -880,7 +895,7 @@ public: |
| 880 | 895 | template <__fmt_char_type _CharT> |
| 881 | 896 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month, _CharT> : public __formatter_chrono<_CharT> { |
| 882 | 897 | public: |
| 883 | using _Base = __formatter_chrono<_CharT>; | |
| 898 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 884 | 899 | |
| 885 | 900 | template <class _ParseContext> |
| 886 | 901 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -891,7 +906,7 @@ public: |
| 891 | 906 | template <__fmt_char_type _CharT> |
| 892 | 907 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day, _CharT> : public __formatter_chrono<_CharT> { |
| 893 | 908 | public: |
| 894 | using _Base = __formatter_chrono<_CharT>; | |
| 909 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 895 | 910 | |
| 896 | 911 | template <class _ParseContext> |
| 897 | 912 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -902,7 +917,7 @@ public: |
| 902 | 917 | template <__fmt_char_type _CharT> |
| 903 | 918 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day_last, _CharT> : public __formatter_chrono<_CharT> { |
| 904 | 919 | public: |
| 905 | using _Base = __formatter_chrono<_CharT>; | |
| 920 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 906 | 921 | |
| 907 | 922 | template <class _ParseContext> |
| 908 | 923 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -913,7 +928,7 @@ public: |
| 913 | 928 | template <__fmt_char_type _CharT> |
| 914 | 929 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday, _CharT> : public __formatter_chrono<_CharT> { |
| 915 | 930 | public: |
| 916 | using _Base = __formatter_chrono<_CharT>; | |
| 931 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 917 | 932 | |
| 918 | 933 | template <class _ParseContext> |
| 919 | 934 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -924,7 +939,7 @@ public: |
| 924 | 939 | template <__fmt_char_type _CharT> |
| 925 | 940 | struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday_last, _CharT> : public __formatter_chrono<_CharT> { |
| 926 | 941 | public: |
| 927 | using _Base = __formatter_chrono<_CharT>; | |
| 942 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 928 | 943 | |
| 929 | 944 | template <class _ParseContext> |
| 930 | 945 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -935,7 +950,7 @@ public: |
| 935 | 950 | template <class _Duration, __fmt_char_type _CharT> |
| 936 | 951 | struct formatter<chrono::hh_mm_ss<_Duration>, _CharT> : public __formatter_chrono<_CharT> { |
| 937 | 952 | public: |
| 938 | using _Base = __formatter_chrono<_CharT>; | |
| 953 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 939 | 954 | |
| 940 | 955 | template <class _ParseContext> |
| 941 | 956 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -943,11 +958,11 @@ public: |
| 943 | 958 | } |
| 944 | 959 | }; |
| 945 | 960 | |
| 946 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 961 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 947 | 962 | template <__fmt_char_type _CharT> |
| 948 | 963 | struct formatter<chrono::sys_info, _CharT> : public __formatter_chrono<_CharT> { |
| 949 | 964 | public: |
| 950 | using _Base = __formatter_chrono<_CharT>; | |
| 965 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 951 | 966 | |
| 952 | 967 | template <class _ParseContext> |
| 953 | 968 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| ... | ... | @@ -958,33 +973,33 @@ public: |
| 958 | 973 | template <__fmt_char_type _CharT> |
| 959 | 974 | struct formatter<chrono::local_info, _CharT> : public __formatter_chrono<_CharT> { |
| 960 | 975 | public: |
| 961 | using _Base = __formatter_chrono<_CharT>; | |
| 976 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 962 | 977 | |
| 963 | 978 | template <class _ParseContext> |
| 964 | 979 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| 965 | 980 | return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags{}); |
| 966 | 981 | } |
| 967 | 982 | }; |
| 968 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | |
| 969 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 983 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 970 | 984 | // Note due to how libc++'s formatters are implemented there is no need to add |
| 971 | 985 | // the exposition only local-time-format-t abstraction. |
| 972 | 986 | template <class _Duration, class _TimeZonePtr, __fmt_char_type _CharT> |
| 973 | 987 | struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : public __formatter_chrono<_CharT> { |
| 974 | 988 | public: |
| 975 | using _Base = __formatter_chrono<_CharT>; | |
| 989 | using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>; | |
| 976 | 990 | |
| 977 | 991 | template <class _ParseContext> |
| 978 | 992 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { |
| 979 | 993 | return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock); |
| 980 | 994 | } |
| 981 | 995 | }; |
| 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) | |
| 996 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 997 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 985 | 998 | |
| 986 | #endif // if _LIBCPP_STD_VER >= 20 | |
| 999 | # endif // if _LIBCPP_STD_VER >= 20 | |
| 987 | 1000 | |
| 988 | 1001 | _LIBCPP_END_NAMESPACE_STD |
| 989 | 1002 | |
| 1003 | #endif // _LIBCPP_HAS_LOCALIZATION | |
| 1004 | ||
| 990 | 1005 | #endif // _LIBCPP___CHRONO_FORMATTER_H |
lib/libcxx/include/__chrono/hh_mm_ss.h+2-2| ... | ... | @@ -29,8 +29,8 @@ namespace chrono { |
| 29 | 29 | template <class _Duration> |
| 30 | 30 | class hh_mm_ss { |
| 31 | 31 | private: |
| 32 | static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration"); | |
| 33 | using __CommonType = common_type_t<_Duration, chrono::seconds>; | |
| 32 | static_assert(__is_duration_v<_Duration>, "template parameter of hh_mm_ss must be a std::chrono::duration"); | |
| 33 | using __CommonType _LIBCPP_NODEBUG = common_type_t<_Duration, chrono::seconds>; | |
| 34 | 34 | |
| 35 | 35 | _LIBCPP_HIDE_FROM_ABI static constexpr uint64_t __pow10(unsigned __exp) { |
| 36 | 36 | uint64_t __ret = 1; |
lib/libcxx/include/__chrono/high_resolution_clock.h+1-1| ... | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | namespace chrono { |
| 24 | 24 | |
| 25 | #ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK | |
| 25 | #if _LIBCPP_HAS_MONOTONIC_CLOCK | |
| 26 | 26 | typedef steady_clock high_resolution_clock; |
| 27 | 27 | #else |
| 28 | 28 | typedef system_clock high_resolution_clock; |
lib/libcxx/include/__chrono/leap_second.h+73-68| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | |
| 15 | 15 | #include <version> |
| 16 | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 17 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 18 | 18 | |
| 19 | 19 | # include <__chrono/duration.h> |
| 20 | 20 | # include <__chrono/system_clock.h> |
| ... | ... | @@ -43,84 +43,89 @@ public: |
| 43 | 43 | _LIBCPP_HIDE_FROM_ABI leap_second(const leap_second&) = default; |
| 44 | 44 | _LIBCPP_HIDE_FROM_ABI leap_second& operator=(const leap_second&) = default; |
| 45 | 45 | |
| 46 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; } | |
| 46 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; } | |
| 47 | 47 | |
| 48 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; } | |
| 48 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; } | |
| 49 | 49 | |
| 50 | 50 | private: |
| 51 | 51 | sys_seconds __date_; |
| 52 | 52 | seconds __value_; |
| 53 | }; | |
| 54 | 53 | |
| 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 | |
| 54 | // The function | |
| 55 | // template<class Duration> | |
| 56 | // requires three_way_comparable_with<sys_seconds, sys_time<Duration>> | |
| 57 | // constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept; | |
| 58 | // | |
| 59 | // Has constraints that are recursive (LWG4139). The proposed resolution is | |
| 60 | // to make the funcion a hidden friend. For consistency make this change for | |
| 61 | // all comparison functions. | |
| 62 | ||
| 63 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const leap_second& __x, const leap_second& __y) { | |
| 64 | return __x.date() == __y.date(); | |
| 65 | } | |
| 66 | ||
| 67 | _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering operator<=>(const leap_second& __x, const leap_second& __y) { | |
| 68 | return __x.date() <=> __y.date(); | |
| 69 | } | |
| 70 | ||
| 71 | template <class _Duration> | |
| 72 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const leap_second& __x, const sys_time<_Duration>& __y) { | |
| 73 | return __x.date() == __y; | |
| 74 | } | |
| 75 | ||
| 76 | template <class _Duration> | |
| 77 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const leap_second& __x, const sys_time<_Duration>& __y) { | |
| 78 | return __x.date() < __y; | |
| 79 | } | |
| 80 | ||
| 81 | template <class _Duration> | |
| 82 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const sys_time<_Duration>& __x, const leap_second& __y) { | |
| 83 | return __x < __y.date(); | |
| 84 | } | |
| 85 | ||
| 86 | template <class _Duration> | |
| 87 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const leap_second& __x, const sys_time<_Duration>& __y) { | |
| 88 | return __y < __x; | |
| 89 | } | |
| 90 | ||
| 91 | template <class _Duration> | |
| 92 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const sys_time<_Duration>& __x, const leap_second& __y) { | |
| 93 | return __y < __x; | |
| 94 | } | |
| 95 | ||
| 96 | template <class _Duration> | |
| 97 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const leap_second& __x, const sys_time<_Duration>& __y) { | |
| 98 | return !(__y < __x); | |
| 99 | } | |
| 100 | ||
| 101 | template <class _Duration> | |
| 102 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const sys_time<_Duration>& __x, const leap_second& __y) { | |
| 103 | return !(__y < __x); | |
| 104 | } | |
| 105 | ||
| 106 | template <class _Duration> | |
| 107 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const leap_second& __x, const sys_time<_Duration>& __y) { | |
| 108 | return !(__x < __y); | |
| 109 | } | |
| 110 | ||
| 111 | template <class _Duration> | |
| 112 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const sys_time<_Duration>& __x, const leap_second& __y) { | |
| 113 | return !(__x < __y); | |
| 114 | } | |
| 115 | ||
| 116 | template <class _Duration> | |
| 117 | requires three_way_comparable_with<sys_seconds, sys_time<_Duration>> | |
| 118 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const leap_second& __x, const sys_time<_Duration>& __y) { | |
| 119 | return __x.date() <=> __y; | |
| 120 | } | |
| 121 | }; | |
| 117 | 122 | |
| 118 | 123 | } // namespace chrono |
| 119 | 124 | |
| 120 | # endif //_LIBCPP_STD_VER >= 20 | |
| 125 | # endif // _LIBCPP_STD_VER >= 20 | |
| 121 | 126 | |
| 122 | 127 | _LIBCPP_END_NAMESPACE_STD |
| 123 | 128 | |
| 124 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 129 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 125 | 130 | |
| 126 | 131 | #endif // _LIBCPP___CHRONO_LEAP_SECOND_H |
lib/libcxx/include/__chrono/local_info.h+2-2| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | |
| 15 | 15 | #include <version> |
| 16 | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 17 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 18 | 18 | |
| 19 | 19 | # include <__chrono/sys_info.h> |
| 20 | 20 | # include <__config> |
| ... | ... | @@ -45,6 +45,6 @@ struct local_info { |
| 45 | 45 | |
| 46 | 46 | _LIBCPP_END_NAMESPACE_STD |
| 47 | 47 | |
| 48 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 48 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 49 | 49 | |
| 50 | 50 | #endif // _LIBCPP___CHRONO_LOCAL_INFO_H |
lib/libcxx/include/__chrono/month.h+1-1| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | #define _LIBCPP___CHRONO_MONTH_H |
| 12 | 12 | |
| 13 | 13 | #include <__chrono/duration.h> |
| 14 | #include <__compare/ordering.h> | |
| 14 | 15 | #include <__config> |
| 15 | #include <compare> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | # pragma GCC system_header |
lib/libcxx/include/__chrono/monthday.h+1-1| ... | ... | @@ -13,8 +13,8 @@ |
| 13 | 13 | #include <__chrono/calendar.h> |
| 14 | 14 | #include <__chrono/day.h> |
| 15 | 15 | #include <__chrono/month.h> |
| 16 | #include <__compare/ordering.h> | |
| 16 | 17 | #include <__config> |
| 17 | #include <compare> | |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 20 | # pragma GCC system_header |
lib/libcxx/include/__chrono/ostream.h+53-35| ... | ... | @@ -10,37 +10,42 @@ |
| 10 | 10 | #ifndef _LIBCPP___CHRONO_OSTREAM_H |
| 11 | 11 | #define _LIBCPP___CHRONO_OSTREAM_H |
| 12 | 12 | |
| 13 | #include <__chrono/calendar.h> | |
| 14 | #include <__chrono/day.h> | |
| 15 | #include <__chrono/duration.h> | |
| 16 | #include <__chrono/file_clock.h> | |
| 17 | #include <__chrono/hh_mm_ss.h> | |
| 18 | #include <__chrono/local_info.h> | |
| 19 | #include <__chrono/month.h> | |
| 20 | #include <__chrono/month_weekday.h> | |
| 21 | #include <__chrono/monthday.h> | |
| 22 | #include <__chrono/statically_widen.h> | |
| 23 | #include <__chrono/sys_info.h> | |
| 24 | #include <__chrono/system_clock.h> | |
| 25 | #include <__chrono/weekday.h> | |
| 26 | #include <__chrono/year.h> | |
| 27 | #include <__chrono/year_month.h> | |
| 28 | #include <__chrono/year_month_day.h> | |
| 29 | #include <__chrono/year_month_weekday.h> | |
| 30 | #include <__chrono/zoned_time.h> | |
| 31 | #include <__concepts/same_as.h> | |
| 32 | 13 | #include <__config> |
| 33 | #include <__format/format_functions.h> | |
| 34 | #include <__fwd/ostream.h> | |
| 35 | #include <ratio> | |
| 36 | 14 | |
| 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 38 | # pragma GCC system_header | |
| 39 | #endif | |
| 15 | #if _LIBCPP_HAS_LOCALIZATION | |
| 16 | ||
| 17 | # include <__chrono/calendar.h> | |
| 18 | # include <__chrono/day.h> | |
| 19 | # include <__chrono/duration.h> | |
| 20 | # include <__chrono/file_clock.h> | |
| 21 | # include <__chrono/hh_mm_ss.h> | |
| 22 | # include <__chrono/local_info.h> | |
| 23 | # include <__chrono/month.h> | |
| 24 | # include <__chrono/month_weekday.h> | |
| 25 | # include <__chrono/monthday.h> | |
| 26 | # include <__chrono/statically_widen.h> | |
| 27 | # include <__chrono/sys_info.h> | |
| 28 | # include <__chrono/system_clock.h> | |
| 29 | # include <__chrono/utc_clock.h> | |
| 30 | # include <__chrono/weekday.h> | |
| 31 | # include <__chrono/year.h> | |
| 32 | # include <__chrono/year_month.h> | |
| 33 | # include <__chrono/year_month_day.h> | |
| 34 | # include <__chrono/year_month_weekday.h> | |
| 35 | # include <__chrono/zoned_time.h> | |
| 36 | # include <__concepts/same_as.h> | |
| 37 | # include <__format/format_functions.h> | |
| 38 | # include <__fwd/ostream.h> | |
| 39 | # include <ratio> | |
| 40 | # include <sstream> | |
| 41 | ||
| 42 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 43 | # pragma GCC system_header | |
| 44 | # endif | |
| 40 | 45 | |
| 41 | 46 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 42 | 47 | |
| 43 | #if _LIBCPP_STD_VER >= 20 | |
| 48 | # if _LIBCPP_STD_VER >= 20 | |
| 44 | 49 | |
| 45 | 50 | namespace chrono { |
| 46 | 51 | |
| ... | ... | @@ -57,6 +62,18 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const sys_days& __dp) { |
| 57 | 62 | return __os << year_month_day{__dp}; |
| 58 | 63 | } |
| 59 | 64 | |
| 65 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 66 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 67 | ||
| 68 | template <class _CharT, class _Traits, class _Duration> | |
| 69 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | |
| 70 | operator<<(basic_ostream<_CharT, _Traits>& __os, const utc_time<_Duration>& __tp) { | |
| 71 | return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp); | |
| 72 | } | |
| 73 | ||
| 74 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 75 | # endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 76 | ||
| 60 | 77 | template <class _CharT, class _Traits, class _Duration> |
| 61 | 78 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| 62 | 79 | operator<<(basic_ostream<_CharT, _Traits>& __os, const file_time<_Duration> __tp) { |
| ... | ... | @@ -82,11 +99,11 @@ _LIBCPP_HIDE_FROM_ABI auto __units_suffix() { |
| 82 | 99 | else if constexpr (same_as<typename _Period::type, nano>) |
| 83 | 100 | return _LIBCPP_STATICALLY_WIDEN(_CharT, "ns"); |
| 84 | 101 | else if constexpr (same_as<typename _Period::type, micro>) |
| 85 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 102 | # if _LIBCPP_HAS_UNICODE | |
| 86 | 103 | return _LIBCPP_STATICALLY_WIDEN(_CharT, "\u00b5s"); |
| 87 | # else | |
| 104 | # else | |
| 88 | 105 | return _LIBCPP_STATICALLY_WIDEN(_CharT, "us"); |
| 89 | # endif | |
| 106 | # endif | |
| 90 | 107 | else if constexpr (same_as<typename _Period::type, milli>) |
| 91 | 108 | return _LIBCPP_STATICALLY_WIDEN(_CharT, "ms"); |
| 92 | 109 | else if constexpr (same_as<typename _Period::type, centi>) |
| ... | ... | @@ -265,7 +282,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const hh_mm_ss<_Duration> __hms |
| 265 | 282 | return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%T}"), __hms); |
| 266 | 283 | } |
| 267 | 284 | |
| 268 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 285 | # if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 269 | 286 | |
| 270 | 287 | template <class _CharT, class _Traits> |
| 271 | 288 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| ... | ... | @@ -303,20 +320,21 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const local_info& __info) { |
| 303 | 320 | _LIBCPP_STATICALLY_WIDEN(_CharT, "{}: {{{}, {}}}"), __result(), __info.first, __info.second); |
| 304 | 321 | } |
| 305 | 322 | |
| 306 | # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | |
| 307 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 323 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM | |
| 308 | 324 | template <class _CharT, class _Traits, class _Duration, class _TimeZonePtr> |
| 309 | 325 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| 310 | 326 | operator<<(basic_ostream<_CharT, _Traits>& __os, const zoned_time<_Duration, _TimeZonePtr>& __tp) { |
| 311 | 327 | return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T %Z}"), __tp); |
| 312 | 328 | } |
| 313 | # endif | |
| 314 | # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 329 | # endif | |
| 330 | # endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 315 | 331 | |
| 316 | 332 | } // namespace chrono |
| 317 | 333 | |
| 318 | #endif // if _LIBCPP_STD_VER >= 20 | |
| 334 | # endif // if _LIBCPP_STD_VER >= 20 | |
| 319 | 335 | |
| 320 | 336 | _LIBCPP_END_NAMESPACE_STD |
| 321 | 337 | |
| 338 | #endif // _LIBCPP_HAS_LOCALIZATION | |
| 339 | ||
| 322 | 340 | #endif // _LIBCPP___CHRONO_OSTREAM_H |
lib/libcxx/include/__chrono/parser_std_format_spec.h+17-12| ... | ... | @@ -11,20 +11,23 @@ |
| 11 | 11 | #define _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__format/concepts.h> | |
| 15 | #include <__format/format_error.h> | |
| 16 | #include <__format/format_parse_context.h> | |
| 17 | #include <__format/formatter_string.h> | |
| 18 | #include <__format/parser_std_format_spec.h> | |
| 19 | #include <string_view> | |
| 20 | 14 | |
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | # pragma GCC system_header | |
| 23 | #endif | |
| 15 | #if _LIBCPP_HAS_LOCALIZATION | |
| 16 | ||
| 17 | # include <__format/concepts.h> | |
| 18 | # include <__format/format_error.h> | |
| 19 | # include <__format/format_parse_context.h> | |
| 20 | # include <__format/formatter_string.h> | |
| 21 | # include <__format/parser_std_format_spec.h> | |
| 22 | # include <string_view> | |
| 23 | ||
| 24 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | # endif | |
| 24 | 27 | |
| 25 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 29 | |
| 27 | #if _LIBCPP_STD_VER >= 20 | |
| 30 | # if _LIBCPP_STD_VER >= 20 | |
| 28 | 31 | |
| 29 | 32 | namespace __format_spec { |
| 30 | 33 | |
| ... | ... | @@ -137,7 +140,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __validate_time_zone(__flags __flags) { |
| 137 | 140 | |
| 138 | 141 | template <class _CharT> |
| 139 | 142 | class _LIBCPP_TEMPLATE_VIS __parser_chrono { |
| 140 | using _ConstIterator = typename basic_format_parse_context<_CharT>::const_iterator; | |
| 143 | using _ConstIterator _LIBCPP_NODEBUG = typename basic_format_parse_context<_CharT>::const_iterator; | |
| 141 | 144 | |
| 142 | 145 | public: |
| 143 | 146 | template <class _ParseContext> |
| ... | ... | @@ -409,8 +412,10 @@ private: |
| 409 | 412 | |
| 410 | 413 | } // namespace __format_spec |
| 411 | 414 | |
| 412 | #endif //_LIBCPP_STD_VER >= 20 | |
| 415 | # endif // _LIBCPP_STD_VER >= 20 | |
| 413 | 416 | |
| 414 | 417 | _LIBCPP_END_NAMESPACE_STD |
| 415 | 418 | |
| 419 | #endif // _LIBCPP_HAS_LOCALIZATION | |
| 420 | ||
| 416 | 421 | #endif // _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H |
lib/libcxx/include/__chrono/statically_widen.h+4-4| ... | ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | 25 | #if _LIBCPP_STD_VER >= 20 |
| 26 | 26 | |
| 27 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 27 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 28 | 28 | template <__fmt_char_type _CharT> |
| 29 | 29 | _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __str, const wchar_t* __wstr) { |
| 30 | 30 | if constexpr (same_as<_CharT, char>) |
| ... | ... | @@ -33,7 +33,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __s |
| 33 | 33 | return __wstr; |
| 34 | 34 | } |
| 35 | 35 | # define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str, L##__str) |
| 36 | # else // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 36 | # else // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 37 | 37 | |
| 38 | 38 | // Without this indirection the unit test test/libcxx/modules_include.sh.cpp |
| 39 | 39 | // fails for the CI build "No wide characters". This seems like a bug. |
| ... | ... | @@ -43,9 +43,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __statically_widen(const char* __s |
| 43 | 43 | return __str; |
| 44 | 44 | } |
| 45 | 45 | # define _LIBCPP_STATICALLY_WIDEN(_CharT, __str) ::std::__statically_widen<_CharT>(__str) |
| 46 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 46 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 47 | 47 | |
| 48 | #endif //_LIBCPP_STD_VER >= 20 | |
| 48 | #endif // _LIBCPP_STD_VER >= 20 | |
| 49 | 49 | |
| 50 | 50 | _LIBCPP_END_NAMESPACE_STD |
| 51 | 51 |
lib/libcxx/include/__chrono/steady_clock.h+1-1| ... | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | namespace chrono { |
| 24 | 24 | |
| 25 | #ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK | |
| 25 | #if _LIBCPP_HAS_MONOTONIC_CLOCK | |
| 26 | 26 | class _LIBCPP_EXPORTED_FROM_ABI steady_clock { |
| 27 | 27 | public: |
| 28 | 28 | typedef nanoseconds duration; |
lib/libcxx/include/__chrono/sys_info.h+2-2| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | |
| 15 | 15 | #include <version> |
| 16 | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 17 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 18 | 18 | |
| 19 | 19 | # include <__chrono/duration.h> |
| 20 | 20 | # include <__chrono/system_clock.h> |
| ... | ... | @@ -46,6 +46,6 @@ struct sys_info { |
| 46 | 46 | |
| 47 | 47 | _LIBCPP_END_NAMESPACE_STD |
| 48 | 48 | |
| 49 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 49 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 50 | 50 | |
| 51 | 51 | #endif // _LIBCPP___CHRONO_SYS_INFO_H |
lib/libcxx/include/__chrono/time_point.h+4-5| ... | ... | @@ -32,8 +32,7 @@ namespace chrono { |
| 32 | 32 | |
| 33 | 33 | template <class _Clock, class _Duration = typename _Clock::duration> |
| 34 | 34 | class _LIBCPP_TEMPLATE_VIS time_point { |
| 35 | static_assert(__is_duration<_Duration>::value, | |
| 36 | "Second template parameter of time_point must be a std::chrono::duration"); | |
| 35 | static_assert(__is_duration_v<_Duration>, "Second template parameter of time_point must be a std::chrono::duration"); | |
| 37 | 36 | |
| 38 | 37 | public: |
| 39 | 38 | typedef _Clock clock; |
| ... | ... | @@ -91,17 +90,17 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) { |
| 91 | 90 | } |
| 92 | 91 | |
| 93 | 92 | #if _LIBCPP_STD_VER >= 17 |
| 94 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> | |
| 93 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | |
| 95 | 94 | inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> floor(const time_point<_Clock, _Duration>& __t) { |
| 96 | 95 | return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())}; |
| 97 | 96 | } |
| 98 | 97 | |
| 99 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> | |
| 98 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | |
| 100 | 99 | inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> ceil(const time_point<_Clock, _Duration>& __t) { |
| 101 | 100 | return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())}; |
| 102 | 101 | } |
| 103 | 102 | |
| 104 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> | |
| 103 | template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration_v<_ToDuration>, int> = 0> | |
| 105 | 104 | inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> round(const time_point<_Clock, _Duration>& __t) { |
| 106 | 105 | return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())}; |
| 107 | 106 | } |
lib/libcxx/include/__chrono/time_zone.h+11-8| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | |
| 15 | 15 | #include <version> |
| 16 | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 17 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 18 | 18 | |
| 19 | 19 | # include <__chrono/calendar.h> |
| 20 | 20 | # include <__chrono/duration.h> |
| ... | ... | @@ -37,8 +37,7 @@ _LIBCPP_PUSH_MACROS |
| 37 | 37 | |
| 38 | 38 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 39 | 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) | |
| 40 | # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 42 | 41 | |
| 43 | 42 | namespace chrono { |
| 44 | 43 | |
| ... | ... | @@ -104,10 +103,14 @@ public: |
| 104 | 103 | to_sys(const local_time<_Duration>& __time, choose __z) const { |
| 105 | 104 | local_info __info = get_info(__time); |
| 106 | 105 | switch (__info.result) { |
| 107 | case local_info::unique: | |
| 108 | case local_info::nonexistent: // first and second are the same | |
| 106 | case local_info::unique: // first and second are the same | |
| 109 | 107 | return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset}; |
| 110 | 108 | |
| 109 | case local_info::nonexistent: | |
| 110 | // first and second are the same | |
| 111 | // All non-existing values are converted to the same time. | |
| 112 | return sys_time<common_type_t<_Duration, seconds>>{__info.first.end}; | |
| 113 | ||
| 111 | 114 | case local_info::ambiguous: |
| 112 | 115 | switch (__z) { |
| 113 | 116 | case choose::earliest: |
| ... | ... | @@ -170,13 +173,13 @@ operator<=>(const time_zone& __x, const time_zone& __y) noexcept { |
| 170 | 173 | |
| 171 | 174 | } // namespace chrono |
| 172 | 175 | |
| 173 | # endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 174 | // && !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 176 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && | |
| 177 | // _LIBCPP_HAS_LOCALIZATION | |
| 175 | 178 | |
| 176 | 179 | _LIBCPP_END_NAMESPACE_STD |
| 177 | 180 | |
| 178 | 181 | _LIBCPP_POP_MACROS |
| 179 | 182 | |
| 180 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 183 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 181 | 184 | |
| 182 | 185 | #endif // _LIBCPP___CHRONO_TIME_ZONE_H |
lib/libcxx/include/__chrono/time_zone_link.h+5-5| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | |
| 15 | 15 | #include <version> |
| 16 | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 17 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 18 | 18 | |
| 19 | 19 | # include <__compare/strong_order.h> |
| 20 | 20 | # include <__config> |
| ... | ... | @@ -31,8 +31,7 @@ _LIBCPP_PUSH_MACROS |
| 31 | 31 | |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 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) | |
| 34 | # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 36 | 35 | |
| 37 | 36 | namespace chrono { |
| 38 | 37 | |
| ... | ... | @@ -68,12 +67,13 @@ operator<=>(const time_zone_link& __x, const time_zone_link& __y) noexcept { |
| 68 | 67 | |
| 69 | 68 | } // namespace chrono |
| 70 | 69 | |
| 71 | # endif //_LIBCPP_STD_VER >= 20 | |
| 70 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && | |
| 71 | // _LIBCPP_HAS_LOCALIZATION | |
| 72 | 72 | |
| 73 | 73 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 74 | |
| 75 | 75 | _LIBCPP_POP_MACROS |
| 76 | 76 | |
| 77 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 77 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 78 | 78 | |
| 79 | 79 | #endif // _LIBCPP___CHRONO_TIME_ZONE_LINK_H |
lib/libcxx/include/__chrono/tzdb.h+9-7| ... | ... | @@ -14,15 +14,18 @@ |
| 14 | 14 | |
| 15 | 15 | #include <version> |
| 16 | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 17 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 18 | 18 | |
| 19 | 19 | # include <__algorithm/ranges_lower_bound.h> |
| 20 | 20 | # include <__chrono/leap_second.h> |
| 21 | 21 | # include <__chrono/time_zone.h> |
| 22 | 22 | # include <__chrono/time_zone_link.h> |
| 23 | 23 | # include <__config> |
| 24 | # include <__memory/addressof.h> | |
| 25 | # include <__vector/vector.h> | |
| 26 | # include <stdexcept> | |
| 24 | 27 | # include <string> |
| 25 | # include <vector> | |
| 28 | # include <string_view> | |
| 26 | 29 | |
| 27 | 30 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | 31 | # pragma GCC system_header |
| ... | ... | @@ -33,8 +36,7 @@ _LIBCPP_PUSH_MACROS |
| 33 | 36 | |
| 34 | 37 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 38 | |
| 36 | # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | |
| 37 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 39 | # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 38 | 40 | |
| 39 | 41 | namespace chrono { |
| 40 | 42 | |
| ... | ... | @@ -82,13 +84,13 @@ private: |
| 82 | 84 | |
| 83 | 85 | } // namespace chrono |
| 84 | 86 | |
| 85 | # endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 86 | // && !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 87 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && | |
| 88 | // _LIBCPP_HAS_LOCALIZATION | |
| 87 | 89 | |
| 88 | 90 | _LIBCPP_END_NAMESPACE_STD |
| 89 | 91 | |
| 90 | 92 | _LIBCPP_POP_MACROS |
| 91 | 93 | |
| 92 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 94 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 93 | 95 | |
| 94 | 96 | #endif // _LIBCPP___CHRONO_TZDB_H |
lib/libcxx/include/__chrono/tzdb_list.h+6-6| ... | ... | @@ -14,13 +14,14 @@ |
| 14 | 14 | |
| 15 | 15 | #include <version> |
| 16 | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 17 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 18 | 18 | |
| 19 | 19 | # include <__chrono/time_zone.h> |
| 20 | 20 | # include <__chrono/tzdb.h> |
| 21 | 21 | # include <__config> |
| 22 | 22 | # include <__fwd/string.h> |
| 23 | 23 | # include <forward_list> |
| 24 | # include <string_view> | |
| 24 | 25 | |
| 25 | 26 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | 27 | # pragma GCC system_header |
| ... | ... | @@ -28,8 +29,7 @@ |
| 28 | 29 | |
| 29 | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 31 | |
| 31 | # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ | |
| 32 | !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 32 | # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 33 | 33 | |
| 34 | 34 | namespace chrono { |
| 35 | 35 | |
| ... | ... | @@ -98,11 +98,11 @@ _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb(); |
| 98 | 98 | |
| 99 | 99 | } // namespace chrono |
| 100 | 100 | |
| 101 | # endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 102 | // && !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 101 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && | |
| 102 | // _LIBCPP_HAS_LOCALIZATION | |
| 103 | 103 | |
| 104 | 104 | _LIBCPP_END_NAMESPACE_STD |
| 105 | 105 | |
| 106 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 106 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 107 | 107 | |
| 108 | 108 | #endif // _LIBCPP___CHRONO_TZDB_LIST_H |
lib/libcxx/include/__chrono/utc_clock.h created+163| ... | ... | @@ -0,0 +1,163 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_UTC_CLOCK_H | |
| 11 | #define _LIBCPP___CHRONO_UTC_CLOCK_H | |
| 12 | ||
| 13 | #include <version> | |
| 14 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | |
| 15 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 16 | ||
| 17 | # include <__chrono/duration.h> | |
| 18 | # include <__chrono/leap_second.h> | |
| 19 | # include <__chrono/system_clock.h> | |
| 20 | # include <__chrono/time_point.h> | |
| 21 | # include <__chrono/tzdb.h> | |
| 22 | # include <__chrono/tzdb_list.h> | |
| 23 | # include <__config> | |
| 24 | # include <__type_traits/common_type.h> | |
| 25 | ||
| 26 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | # endif | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 33 | ||
| 34 | namespace chrono { | |
| 35 | ||
| 36 | class utc_clock; | |
| 37 | ||
| 38 | template <class _Duration> | |
| 39 | using utc_time = time_point<utc_clock, _Duration>; | |
| 40 | using utc_seconds = utc_time<seconds>; | |
| 41 | ||
| 42 | class utc_clock { | |
| 43 | public: | |
| 44 | using rep = system_clock::rep; | |
| 45 | using period = system_clock::period; | |
| 46 | using duration = chrono::duration<rep, period>; | |
| 47 | using time_point = chrono::time_point<utc_clock>; | |
| 48 | static constexpr bool is_steady = false; // The system_clock is not steady. | |
| 49 | ||
| 50 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static time_point now() { return from_sys(system_clock::now()); } | |
| 51 | ||
| 52 | template <class _Duration> | |
| 53 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static sys_time<common_type_t<_Duration, seconds>> | |
| 54 | to_sys(const utc_time<_Duration>& __time); | |
| 55 | ||
| 56 | template <class _Duration> | |
| 57 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static utc_time<common_type_t<_Duration, seconds>> | |
| 58 | from_sys(const sys_time<_Duration>& __time) { | |
| 59 | using _Rp = utc_time<common_type_t<_Duration, seconds>>; | |
| 60 | // TODO TZDB investigate optimizations. | |
| 61 | // | |
| 62 | // The leap second database stores all transitions, this mean to calculate | |
| 63 | // the current number of leap seconds the code needs to iterate over all | |
| 64 | // leap seconds to accumulate the sum. Then the sum can be used to determine | |
| 65 | // the sys_time. Accessing the database involves acquiring a mutex. | |
| 66 | // | |
| 67 | // The historic entries in the database are immutable. Hard-coding these | |
| 68 | // values in a table would allow: | |
| 69 | // - To store the sum, allowing a binary search on the data. | |
| 70 | // - Avoid acquiring a mutex. | |
| 71 | // The disadvantage are: | |
| 72 | // - A slightly larger code size. | |
| 73 | // | |
| 74 | // There are two optimization directions | |
| 75 | // - hard-code the database and do a linear search for future entries. This | |
| 76 | // search can start at the back, and should probably contain very few | |
| 77 | // entries. (Adding leap seconds is quite rare and new release of libc++ | |
| 78 | // can add the new entries; they are announced half a year before they are | |
| 79 | // added.) | |
| 80 | // - During parsing the leap seconds store an additional database in the | |
| 81 | // dylib with the list of the sum of the leap seconds. In that case there | |
| 82 | // can be a private function __get_utc_to_sys_table that returns the | |
| 83 | // table. | |
| 84 | // | |
| 85 | // Note for to_sys there are no optimizations to be done; it uses | |
| 86 | // get_leap_second_info. The function get_leap_second_info could benefit | |
| 87 | // from optimizations as described above; again both options apply. | |
| 88 | ||
| 89 | // Both UTC and the system clock use the same epoch. The Standard | |
| 90 | // specifies from 1970-01-01 even when UTC starts at | |
| 91 | // 1972-01-01 00:00:10 TAI. So when the sys_time is before epoch we can be | |
| 92 | // sure there both clocks return the same value. | |
| 93 | ||
| 94 | const tzdb& __tzdb = chrono::get_tzdb(); | |
| 95 | _Rp __result{__time.time_since_epoch()}; | |
| 96 | for (const auto& __leap_second : __tzdb.leap_seconds) { | |
| 97 | if (__leap_second > __time) | |
| 98 | return __result; | |
| 99 | ||
| 100 | __result += __leap_second.value(); | |
| 101 | } | |
| 102 | return __result; | |
| 103 | } | |
| 104 | }; | |
| 105 | ||
| 106 | struct leap_second_info { | |
| 107 | bool is_leap_second; | |
| 108 | seconds elapsed; | |
| 109 | }; | |
| 110 | ||
| 111 | template <class _Duration> | |
| 112 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI leap_second_info get_leap_second_info(const utc_time<_Duration>& __time) { | |
| 113 | const tzdb& __tzdb = chrono::get_tzdb(); | |
| 114 | if (__tzdb.leap_seconds.empty()) [[unlikely]] | |
| 115 | return {false, chrono::seconds{0}}; | |
| 116 | ||
| 117 | sys_seconds __sys{chrono::floor<seconds>(__time).time_since_epoch()}; | |
| 118 | seconds __elapsed{0}; | |
| 119 | for (const auto& __leap_second : __tzdb.leap_seconds) { | |
| 120 | if (__sys == __leap_second.date() + __elapsed) | |
| 121 | // A time point may only be a leap second during a positive leap second | |
| 122 | // insertion, since time points that occur during a (theoretical) | |
| 123 | // negative leap second don't exist. | |
| 124 | return {__leap_second.value() > 0s, __elapsed + __leap_second.value()}; | |
| 125 | ||
| 126 | if (__sys < __leap_second.date() + __elapsed) | |
| 127 | return {false, __elapsed}; | |
| 128 | ||
| 129 | __elapsed += __leap_second.value(); | |
| 130 | } | |
| 131 | ||
| 132 | return {false, __elapsed}; | |
| 133 | } | |
| 134 | ||
| 135 | template <class _Duration> | |
| 136 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time<common_type_t<_Duration, seconds>> | |
| 137 | utc_clock::to_sys(const utc_time<_Duration>& __time) { | |
| 138 | using _Dp = common_type_t<_Duration, seconds>; | |
| 139 | leap_second_info __info = chrono::get_leap_second_info(__time); | |
| 140 | ||
| 141 | // [time.clock.utc.members]/2 | |
| 142 | // Returns: A sys_time t, such that from_sys(t) == u if such a mapping | |
| 143 | // exists. Otherwise u represents a time_point during a positive leap | |
| 144 | // second insertion, the conversion counts that leap second as not | |
| 145 | // inserted, and the last representable value of sys_time prior to the | |
| 146 | // insertion of the leap second is returned. | |
| 147 | sys_time<common_type_t<_Duration, seconds>> __result{__time.time_since_epoch() - __info.elapsed}; | |
| 148 | if (__info.is_leap_second) | |
| 149 | return chrono::floor<seconds>(__result) + chrono::seconds{1} - _Dp{1}; | |
| 150 | ||
| 151 | return __result; | |
| 152 | } | |
| 153 | ||
| 154 | } // namespace chrono | |
| 155 | ||
| 156 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && | |
| 157 | // _LIBCPP_HAS_LOCALIZATION | |
| 158 | ||
| 159 | _LIBCPP_END_NAMESPACE_STD | |
| 160 | ||
| 161 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 162 | ||
| 163 | #endif // _LIBCPP___CHRONO_UTC_CLOCK_H |
lib/libcxx/include/__chrono/weekday.h-19| ... | ... | @@ -79,25 +79,6 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const weekday& __lhs, con |
| 79 | 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 | |
| 84 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<(const weekday& __lhs, const weekday& __rhs) noexcept { | |
| 85 | return __lhs.c_encoding() < __rhs.c_encoding(); | |
| 86 | } | |
| 87 | ||
| 88 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>(const weekday& __lhs, const weekday& __rhs) noexcept { | |
| 89 | return __rhs < __lhs; | |
| 90 | } | |
| 91 | ||
| 92 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept { | |
| 93 | return !(__rhs < __lhs); | |
| 94 | } | |
| 95 | ||
| 96 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept { | |
| 97 | return !(__lhs < __rhs); | |
| 98 | } | |
| 99 | # endif // _LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS | |
| 100 | ||
| 101 | 82 | _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept { |
| 102 | 83 | auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count(); |
| 103 | 84 | auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7; |
lib/libcxx/include/__chrono/year.h+1-1| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | #define _LIBCPP___CHRONO_YEAR_H |
| 12 | 12 | |
| 13 | 13 | #include <__chrono/duration.h> |
| 14 | #include <__compare/ordering.h> | |
| 14 | 15 | #include <__config> |
| 15 | #include <compare> | |
| 16 | 16 | #include <limits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__chrono/year_month.h+1-1| ... | ... | @@ -13,8 +13,8 @@ |
| 13 | 13 | #include <__chrono/duration.h> |
| 14 | 14 | #include <__chrono/month.h> |
| 15 | 15 | #include <__chrono/year.h> |
| 16 | #include <__compare/ordering.h> | |
| 16 | 17 | #include <__config> |
| 17 | #include <compare> | |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 20 | # pragma GCC system_header |
lib/libcxx/include/__chrono/year_month_day.h+1-1| ... | ... | @@ -19,8 +19,8 @@ |
| 19 | 19 | #include <__chrono/time_point.h> |
| 20 | 20 | #include <__chrono/year.h> |
| 21 | 21 | #include <__chrono/year_month.h> |
| 22 | #include <__compare/ordering.h> | |
| 22 | 23 | #include <__config> |
| 23 | #include <compare> | |
| 24 | 24 | #include <limits> |
| 25 | 25 | |
| 26 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__chrono/zoned_time.h+13-12| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | |
| 15 | 15 | #include <version> |
| 16 | 16 | // Enable the contents of the header only when libc++ was built with experimental features enabled. |
| 17 | #if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 17 | #if _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 18 | 18 | |
| 19 | 19 | # include <__chrono/calendar.h> |
| 20 | 20 | # include <__chrono/duration.h> |
| ... | ... | @@ -22,12 +22,14 @@ |
| 22 | 22 | # include <__chrono/system_clock.h> |
| 23 | 23 | # include <__chrono/time_zone.h> |
| 24 | 24 | # include <__chrono/tzdb_list.h> |
| 25 | # include <__concepts/constructible.h> | |
| 25 | 26 | # include <__config> |
| 26 | # include <__fwd/string_view.h> | |
| 27 | 27 | # include <__type_traits/common_type.h> |
| 28 | 28 | # include <__type_traits/conditional.h> |
| 29 | 29 | # include <__type_traits/remove_cvref.h> |
| 30 | # include <__utility/declval.h> | |
| 30 | 31 | # include <__utility/move.h> |
| 32 | # include <string_view> | |
| 31 | 33 | |
| 32 | 34 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 33 | 35 | # pragma GCC system_header |
| ... | ... | @@ -38,8 +40,7 @@ _LIBCPP_PUSH_MACROS |
| 38 | 40 | |
| 39 | 41 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | 42 | |
| 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 | # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 43 | 44 | |
| 44 | 45 | namespace chrono { |
| 45 | 46 | |
| ... | ... | @@ -57,7 +58,7 @@ struct zoned_traits<const time_zone*> { |
| 57 | 58 | template <class _Duration, class _TimeZonePtr = const time_zone*> |
| 58 | 59 | class zoned_time { |
| 59 | 60 | // [time.zone.zonedtime.ctor]/2 |
| 60 | static_assert(__is_duration<_Duration>::value, | |
| 61 | static_assert(__is_duration_v<_Duration>, | |
| 61 | 62 | "the program is ill-formed since _Duration is not a specialization of std::chrono::duration"); |
| 62 | 63 | |
| 63 | 64 | // The wording uses the constraints like |
| ... | ... | @@ -65,7 +66,7 @@ class zoned_time { |
| 65 | 66 | // Using these constraints in the code causes the compiler to give an |
| 66 | 67 | // error that the constraint depends on itself. To avoid that issue use |
| 67 | 68 | // the fact it is possible to create this object from a _TimeZonePtr. |
| 68 | using __traits = zoned_traits<_TimeZonePtr>; | |
| 69 | using __traits _LIBCPP_NODEBUG = zoned_traits<_TimeZonePtr>; | |
| 69 | 70 | |
| 70 | 71 | public: |
| 71 | 72 | using duration = common_type_t<_Duration, seconds>; |
| ... | ... | @@ -185,7 +186,7 @@ template <class _Duration> |
| 185 | 186 | zoned_time(sys_time<_Duration>) -> zoned_time<common_type_t<_Duration, seconds>>; |
| 186 | 187 | |
| 187 | 188 | template <class _TimeZonePtrOrName> |
| 188 | using __time_zone_representation = | |
| 189 | using __time_zone_representation _LIBCPP_NODEBUG = | |
| 189 | 190 | conditional_t<is_convertible_v<_TimeZonePtrOrName, string_view>, |
| 190 | 191 | const time_zone*, |
| 191 | 192 | remove_cvref_t<_TimeZonePtrOrName>>; |
| ... | ... | @@ -201,8 +202,8 @@ template <class _TimeZonePtrOrName, class _Duration> |
| 201 | 202 | zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>, choose = choose::earliest) |
| 202 | 203 | -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>; |
| 203 | 204 | |
| 204 | template <class _Duration, class _TimeZonePtrOrName, class TimeZonePtr2> | |
| 205 | zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = choose::earliest) | |
| 205 | template <class _Duration, class _TimeZonePtrOrName, class _TimeZonePtr2> | |
| 206 | zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, _TimeZonePtr2>, choose = choose::earliest) | |
| 206 | 207 | -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>; |
| 207 | 208 | |
| 208 | 209 | using zoned_seconds = zoned_time<seconds>; |
| ... | ... | @@ -215,13 +216,13 @@ operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const zoned_time<_ |
| 215 | 216 | |
| 216 | 217 | } // namespace chrono |
| 217 | 218 | |
| 218 | # endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 219 | // && !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 219 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && | |
| 220 | // _LIBCPP_HAS_LOCALIZATION | |
| 220 | 221 | |
| 221 | 222 | _LIBCPP_END_NAMESPACE_STD |
| 222 | 223 | |
| 223 | 224 | _LIBCPP_POP_MACROS |
| 224 | 225 | |
| 225 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) | |
| 226 | #endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB | |
| 226 | 227 | |
| 227 | 228 | #endif // _LIBCPP___CHRONO_ZONED_TIME_H |
lib/libcxx/include/__compare/common_comparison_category.h+1-1| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__compare/ordering.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/size_t.h> | |
| 14 | 15 | #include <__type_traits/is_same.h> |
| 15 | #include <cstddef> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | # pragma GCC system_header |
lib/libcxx/include/__compare/compare_partial_order_fallback.h+11-12| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__compare/ordering.h> |
| 13 | 13 | #include <__compare/partial_order.h> |
| 14 | #include <__concepts/boolean_testable.h> | |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__type_traits/decay.h> |
| 16 | 17 | #include <__type_traits/is_same.h> |
| ... | ... | @@ -37,18 +38,16 @@ struct __fn { |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | template <class _Tp, class _Up> |
| 40 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 41 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept( | |
| 42 | std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? partial_ordering::equivalent | |
| 43 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? partial_ordering::less | |
| 44 | : std::forward<_Up>(__u) < std::forward<_Tp>(__t) | |
| 45 | ? partial_ordering::greater | |
| 46 | : partial_ordering::unordered)) | |
| 47 | -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? partial_ordering::equivalent | |
| 48 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? partial_ordering::less | |
| 49 | : std::forward<_Up>(__u) < std::forward<_Tp>(__t) | |
| 50 | ? partial_ordering::greater | |
| 51 | : partial_ordering::unordered) { | |
| 41 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> && requires(_Tp&& __t, _Up&& __u) { | |
| 42 | { std::forward<_Tp>(__t) == std::forward<_Up>(__u) } -> __boolean_testable; | |
| 43 | { std::forward<_Tp>(__t) < std::forward<_Up>(__u) } -> __boolean_testable; | |
| 44 | { std::forward<_Up>(__u) < std::forward<_Tp>(__t) } -> __boolean_testable; | |
| 45 | } | |
| 46 | _LIBCPP_HIDE_FROM_ABI static constexpr partial_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept( | |
| 47 | noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? partial_ordering::equivalent | |
| 48 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? partial_ordering::less | |
| 49 | : std::forward<_Up>(__u) < std::forward<_Tp>(__t) ? partial_ordering::greater | |
| 50 | : partial_ordering::unordered)) { | |
| 52 | 51 | return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? partial_ordering::equivalent |
| 53 | 52 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? partial_ordering::less |
| 54 | 53 | : std::forward<_Up>(__u) < std::forward<_Tp>(__t) |
lib/libcxx/include/__compare/compare_strong_order_fallback.h+9-10| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__compare/ordering.h> |
| 13 | 13 | #include <__compare/strong_order.h> |
| 14 | #include <__concepts/boolean_testable.h> | |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__type_traits/decay.h> |
| 16 | 17 | #include <__type_traits/is_same.h> |
| ... | ... | @@ -37,16 +38,14 @@ struct __fn { |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | template <class _Tp, class _Up> |
| 40 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 41 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept( | |
| 42 | std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? strong_ordering::equal | |
| 43 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) | |
| 44 | ? strong_ordering::less | |
| 45 | : strong_ordering::greater)) | |
| 46 | -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? strong_ordering::equal | |
| 47 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) | |
| 48 | ? strong_ordering::less | |
| 49 | : strong_ordering::greater) { | |
| 41 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> && requires(_Tp&& __t, _Up&& __u) { | |
| 42 | { std::forward<_Tp>(__t) == std::forward<_Up>(__u) } -> __boolean_testable; | |
| 43 | { std::forward<_Tp>(__t) < std::forward<_Up>(__u) } -> __boolean_testable; | |
| 44 | } | |
| 45 | _LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept( | |
| 46 | noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? strong_ordering::equal | |
| 47 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) ? strong_ordering::less | |
| 48 | : strong_ordering::greater)) { | |
| 50 | 49 | return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? strong_ordering::equal |
| 51 | 50 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) |
| 52 | 51 | ? strong_ordering::less |
lib/libcxx/include/__compare/compare_three_way_result.h+2-1| ... | ... | @@ -33,7 +33,8 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result< |
| 33 | 33 | }; |
| 34 | 34 | |
| 35 | 35 | template <class _Tp, class _Up = _Tp> |
| 36 | struct _LIBCPP_TEMPLATE_VIS compare_three_way_result : __compare_three_way_result<_Tp, _Up, void> {}; | |
| 36 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS compare_three_way_result | |
| 37 | : __compare_three_way_result<_Tp, _Up, void> {}; | |
| 37 | 38 | |
| 38 | 39 | template <class _Tp, class _Up = _Tp> |
| 39 | 40 | using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type; |
lib/libcxx/include/__compare/compare_weak_order_fallback.h+7-7| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__compare/ordering.h> |
| 13 | 13 | #include <__compare/weak_order.h> |
| 14 | #include <__concepts/boolean_testable.h> | |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__type_traits/decay.h> |
| 16 | 17 | #include <__type_traits/is_same.h> |
| ... | ... | @@ -37,16 +38,15 @@ struct __fn { |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | template <class _Tp, class _Up> |
| 40 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 41 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept( | |
| 41 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> && requires(_Tp&& __t, _Up&& __u) { | |
| 42 | { std::forward<_Tp>(__t) == std::forward<_Up>(__u) } -> __boolean_testable; | |
| 43 | { std::forward<_Tp>(__t) < std::forward<_Up>(__u) } -> __boolean_testable; | |
| 44 | } | |
| 45 | _LIBCPP_HIDE_FROM_ABI static constexpr weak_ordering __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(noexcept( | |
| 42 | 46 | std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? weak_ordering::equivalent |
| 43 | 47 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) |
| 44 | 48 | ? weak_ordering::less |
| 45 | : weak_ordering::greater)) | |
| 46 | -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? weak_ordering::equivalent | |
| 47 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) | |
| 48 | ? weak_ordering::less | |
| 49 | : weak_ordering::greater) { | |
| 49 | : weak_ordering::greater)) { | |
| 50 | 50 | return std::forward<_Tp>(__t) == std::forward<_Up>(__u) ? weak_ordering::equivalent |
| 51 | 51 | : std::forward<_Tp>(__t) < std::forward<_Up>(__u) |
| 52 | 52 | ? weak_ordering::less |
lib/libcxx/include/__compare/ordering.h+38-34| ... | ... | @@ -24,32 +24,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | // exposition only |
| 25 | 25 | enum class _OrdResult : signed char { __less = -1, __equiv = 0, __greater = 1 }; |
| 26 | 26 | |
| 27 | enum class _NCmpResult : signed char { __unordered = -127 }; | |
| 27 | enum class _PartialOrdResult : signed char { | |
| 28 | __less = static_cast<signed char>(_OrdResult::__less), | |
| 29 | __equiv = static_cast<signed char>(_OrdResult::__equiv), | |
| 30 | __greater = static_cast<signed char>(_OrdResult::__greater), | |
| 31 | __unordered = -127, | |
| 32 | }; | |
| 28 | 33 | |
| 29 | 34 | class partial_ordering; |
| 30 | 35 | class weak_ordering; |
| 31 | 36 | class strong_ordering; |
| 32 | 37 | |
| 33 | template <class _Tp, class... _Args> | |
| 34 | inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...); | |
| 35 | ||
| 36 | 38 | struct _CmpUnspecifiedParam { |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {} | |
| 38 | ||
| 39 | template <class _Tp, class = enable_if_t<!__one_of_v<_Tp, int, partial_ordering, weak_ordering, strong_ordering>>> | |
| 40 | _CmpUnspecifiedParam(_Tp) = delete; | |
| 39 | // If anything other than a literal 0 is provided, the behavior is undefined by the Standard. | |
| 40 | // | |
| 41 | // The alternative to the `__enable_if__` attribute would be to use the fact that a pointer | |
| 42 | // can be constructed from literal 0, but this conflicts with `-Wzero-as-null-pointer-constant`. | |
| 43 | template <class _Tp, class = __enable_if_t<is_same_v<_Tp, int> > > | |
| 44 | _LIBCPP_HIDE_FROM_ABI consteval _CmpUnspecifiedParam(_Tp __zero) noexcept | |
| 45 | # if __has_attribute(__enable_if__) | |
| 46 | __attribute__((__enable_if__( | |
| 47 | __zero == 0, "Only literal 0 is allowed as the operand of a comparison with one of the ordering types"))) | |
| 48 | # endif | |
| 49 | { | |
| 50 | (void)__zero; | |
| 51 | } | |
| 41 | 52 | }; |
| 42 | 53 | |
| 43 | 54 | class partial_ordering { |
| 44 | using _ValueT = signed char; | |
| 45 | ||
| 46 | _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} | |
| 47 | ||
| 48 | _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering(_NCmpResult __v) noexcept : __value_(_ValueT(__v)) {} | |
| 49 | ||
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr bool __is_ordered() const noexcept { | |
| 51 | return __value_ != _ValueT(_NCmpResult::__unordered); | |
| 52 | } | |
| 55 | _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering(_PartialOrdResult __v) noexcept : __value_(__v) {} | |
| 53 | 56 | |
| 54 | 57 | public: |
| 55 | 58 | // valid values |
| ... | ... | @@ -62,39 +65,39 @@ public: |
| 62 | 65 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default; |
| 63 | 66 | |
| 64 | 67 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept { |
| 65 | return __v.__is_ordered() && __v.__value_ == 0; | |
| 68 | return __v.__value_ == _PartialOrdResult::__equiv; | |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | 71 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept { |
| 69 | return __v.__is_ordered() && __v.__value_ < 0; | |
| 72 | return __v.__value_ == _PartialOrdResult::__less; | |
| 70 | 73 | } |
| 71 | 74 | |
| 72 | 75 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { |
| 73 | return __v.__is_ordered() && __v.__value_ <= 0; | |
| 76 | return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__less; | |
| 74 | 77 | } |
| 75 | 78 | |
| 76 | 79 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept { |
| 77 | return __v.__is_ordered() && __v.__value_ > 0; | |
| 80 | return __v.__value_ == _PartialOrdResult::__greater; | |
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { |
| 81 | return __v.__is_ordered() && __v.__value_ >= 0; | |
| 84 | return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__greater; | |
| 82 | 85 | } |
| 83 | 86 | |
| 84 | 87 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(_CmpUnspecifiedParam, partial_ordering __v) noexcept { |
| 85 | return __v.__is_ordered() && 0 < __v.__value_; | |
| 88 | return __v.__value_ == _PartialOrdResult::__greater; | |
| 86 | 89 | } |
| 87 | 90 | |
| 88 | 91 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { |
| 89 | return __v.__is_ordered() && 0 <= __v.__value_; | |
| 92 | return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__greater; | |
| 90 | 93 | } |
| 91 | 94 | |
| 92 | 95 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(_CmpUnspecifiedParam, partial_ordering __v) noexcept { |
| 93 | return __v.__is_ordered() && 0 > __v.__value_; | |
| 96 | return __v.__value_ == _PartialOrdResult::__less; | |
| 94 | 97 | } |
| 95 | 98 | |
| 96 | 99 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { |
| 97 | return __v.__is_ordered() && 0 >= __v.__value_; | |
| 100 | return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__less; | |
| 98 | 101 | } |
| 99 | 102 | |
| 100 | 103 | _LIBCPP_HIDE_FROM_ABI friend constexpr partial_ordering |
| ... | ... | @@ -108,16 +111,16 @@ public: |
| 108 | 111 | } |
| 109 | 112 | |
| 110 | 113 | private: |
| 111 | _ValueT __value_; | |
| 114 | _PartialOrdResult __value_; | |
| 112 | 115 | }; |
| 113 | 116 | |
| 114 | inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less); | |
| 115 | inline constexpr partial_ordering partial_ordering::equivalent(_OrdResult::__equiv); | |
| 116 | inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater); | |
| 117 | inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered); | |
| 117 | inline constexpr partial_ordering partial_ordering::less(_PartialOrdResult::__less); | |
| 118 | inline constexpr partial_ordering partial_ordering::equivalent(_PartialOrdResult::__equiv); | |
| 119 | inline constexpr partial_ordering partial_ordering::greater(_PartialOrdResult::__greater); | |
| 120 | inline constexpr partial_ordering partial_ordering::unordered(_PartialOrdResult::__unordered); | |
| 118 | 121 | |
| 119 | 122 | class weak_ordering { |
| 120 | using _ValueT = signed char; | |
| 123 | using _ValueT _LIBCPP_NODEBUG = signed char; | |
| 121 | 124 | |
| 122 | 125 | _LIBCPP_HIDE_FROM_ABI explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} |
| 123 | 126 | |
| ... | ... | @@ -187,7 +190,7 @@ inline constexpr weak_ordering weak_ordering::equivalent(_OrdResult::__equiv); |
| 187 | 190 | inline constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater); |
| 188 | 191 | |
| 189 | 192 | class strong_ordering { |
| 190 | using _ValueT = signed char; | |
| 193 | using _ValueT _LIBCPP_NODEBUG = signed char; | |
| 191 | 194 | |
| 192 | 195 | _LIBCPP_HIDE_FROM_ABI explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} |
| 193 | 196 | |
| ... | ... | @@ -269,7 +272,8 @@ inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater) |
| 269 | 272 | /// The types partial_ordering, weak_ordering, and strong_ordering are |
| 270 | 273 | /// collectively termed the comparison category types. |
| 271 | 274 | template <class _Tp> |
| 272 | concept __comparison_category = __one_of_v<_Tp, partial_ordering, weak_ordering, strong_ordering>; | |
| 275 | concept __comparison_category = | |
| 276 | is_same_v<_Tp, partial_ordering> || is_same_v<_Tp, weak_ordering> || is_same_v<_Tp, strong_ordering>; | |
| 273 | 277 | |
| 274 | 278 | #endif // _LIBCPP_STD_VER >= 20 |
| 275 | 279 |
lib/libcxx/include/__compare/synth_three_way.h+2-1| ... | ... | @@ -43,7 +43,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, cl |
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | 45 | template <class _Tp, class _Up = _Tp> |
| 46 | using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>())); | |
| 46 | using __synth_three_way_result _LIBCPP_NODEBUG = | |
| 47 | decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>())); | |
| 47 | 48 | |
| 48 | 49 | #endif // _LIBCPP_STD_VER >= 20 |
| 49 | 50 |
lib/libcxx/include/__concepts/predicate.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__concepts/boolean_testable.h> |
| 13 | 13 | #include <__concepts/invocable.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__functional/invoke.h> | |
| 15 | #include <__type_traits/invoke.h> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | # pragma GCC system_header |
lib/libcxx/include/__concepts/swappable.h+1-1| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | #include <__concepts/common_reference_with.h> |
| 15 | 15 | #include <__concepts/constructible.h> |
| 16 | 16 | #include <__config> |
| 17 | #include <__cstddef/size_t.h> | |
| 17 | 18 | #include <__type_traits/extent.h> |
| 18 | 19 | #include <__type_traits/is_nothrow_assignable.h> |
| 19 | 20 | #include <__type_traits/is_nothrow_constructible.h> |
| ... | ... | @@ -22,7 +23,6 @@ |
| 22 | 23 | #include <__utility/forward.h> |
| 23 | 24 | #include <__utility/move.h> |
| 24 | 25 | #include <__utility/swap.h> |
| 25 | #include <cstddef> | |
| 26 | 26 | |
| 27 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | 28 | # pragma GCC system_header |
lib/libcxx/include/__condition_variable/condition_variable.h+9-9| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <__config> |
| 17 | 17 | #include <__mutex/mutex.h> |
| 18 | 18 | #include <__mutex/unique_lock.h> |
| 19 | #include <__system_error/system_error.h> | |
| 19 | #include <__system_error/throw_system_error.h> | |
| 20 | 20 | #include <__thread/support.h> |
| 21 | 21 | #include <__type_traits/enable_if.h> |
| 22 | 22 | #include <__type_traits/is_floating_point.h> |
| ... | ... | @@ -33,7 +33,7 @@ _LIBCPP_PUSH_MACROS |
| 33 | 33 | |
| 34 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 35 | |
| 36 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 36 | #if _LIBCPP_HAS_THREADS | |
| 37 | 37 | |
| 38 | 38 | // enum class cv_status |
| 39 | 39 | _LIBCPP_DECLARE_STRONG_ENUM(cv_status){no_timeout, timeout}; |
| ... | ... | @@ -45,7 +45,7 @@ class _LIBCPP_EXPORTED_FROM_ABI condition_variable { |
| 45 | 45 | public: |
| 46 | 46 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default; |
| 47 | 47 | |
| 48 | # ifdef _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION | |
| 48 | # if _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION | |
| 49 | 49 | ~condition_variable() = default; |
| 50 | 50 | # else |
| 51 | 51 | ~condition_variable(); |
| ... | ... | @@ -83,7 +83,7 @@ public: |
| 83 | 83 | private: |
| 84 | 84 | void |
| 85 | 85 | __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT; |
| 86 | # if defined(_LIBCPP_HAS_COND_CLOCKWAIT) | |
| 86 | # if _LIBCPP_HAS_COND_CLOCKWAIT | |
| 87 | 87 | _LIBCPP_HIDE_FROM_ABI void |
| 88 | 88 | __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds>) _NOEXCEPT; |
| 89 | 89 | # endif |
| ... | ... | @@ -91,7 +91,7 @@ private: |
| 91 | 91 | _LIBCPP_HIDE_FROM_ABI void |
| 92 | 92 | __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<_Clock, chrono::nanoseconds>) _NOEXCEPT; |
| 93 | 93 | }; |
| 94 | #endif // !_LIBCPP_HAS_NO_THREADS | |
| 94 | #endif // _LIBCPP_HAS_THREADS | |
| 95 | 95 | |
| 96 | 96 | template <class _Rep, class _Period, __enable_if_t<is_floating_point<_Rep>::value, int> = 0> |
| 97 | 97 | inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) { |
| ... | ... | @@ -140,7 +140,7 @@ inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono:: |
| 140 | 140 | return nanoseconds(__result); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 143 | #if _LIBCPP_HAS_THREADS | |
| 144 | 144 | template <class _Predicate> |
| 145 | 145 | void condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred) { |
| 146 | 146 | while (!__pred()) |
| ... | ... | @@ -180,7 +180,7 @@ cv_status condition_variable::wait_for(unique_lock<mutex>& __lk, const chrono::d |
| 180 | 180 | using __ns_rep = nanoseconds::rep; |
| 181 | 181 | steady_clock::time_point __c_now = steady_clock::now(); |
| 182 | 182 | |
| 183 | # if defined(_LIBCPP_HAS_COND_CLOCKWAIT) | |
| 183 | # if _LIBCPP_HAS_COND_CLOCKWAIT | |
| 184 | 184 | using __clock_tp_ns = time_point<steady_clock, nanoseconds>; |
| 185 | 185 | __ns_rep __now_count_ns = std::__safe_nanosecond_cast(__c_now.time_since_epoch()).count(); |
| 186 | 186 | # else |
| ... | ... | @@ -205,7 +205,7 @@ condition_variable::wait_for(unique_lock<mutex>& __lk, const chrono::duration<_R |
| 205 | 205 | return wait_until(__lk, chrono::steady_clock::now() + __d, std::move(__pred)); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | # if defined(_LIBCPP_HAS_COND_CLOCKWAIT) | |
| 208 | # if _LIBCPP_HAS_COND_CLOCKWAIT | |
| 209 | 209 | inline void condition_variable::__do_timed_wait( |
| 210 | 210 | unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT { |
| 211 | 211 | using namespace chrono; |
| ... | ... | @@ -235,7 +235,7 @@ inline void condition_variable::__do_timed_wait(unique_lock<mutex>& __lk, |
| 235 | 235 | wait_for(__lk, __tp - _Clock::now()); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | #endif // _LIBCPP_HAS_NO_THREADS | |
| 238 | #endif // _LIBCPP_HAS_THREADS | |
| 239 | 239 | |
| 240 | 240 | _LIBCPP_END_NAMESPACE_STD |
| 241 | 241 |
lib/libcxx/include/__config+154-139| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | #include <__configuration/abi.h> |
| 15 | 15 | #include <__configuration/availability.h> |
| 16 | 16 | #include <__configuration/compiler.h> |
| 17 | #include <__configuration/language.h> | |
| 17 | 18 | #include <__configuration/platform.h> |
| 18 | 19 | |
| 19 | 20 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| ... | ... | @@ -27,10 +28,11 @@ |
| 27 | 28 | // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. |
| 28 | 29 | // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is |
| 29 | 30 | // defined to XXYYZZ. |
| 30 | # define _LIBCPP_VERSION 190100 | |
| 31 | # define _LIBCPP_VERSION 200100 | |
| 31 | 32 | |
| 32 | 33 | # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y |
| 33 | 34 | # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) |
| 35 | # define _LIBCPP_CONCAT3(X, Y, Z) _LIBCPP_CONCAT(X, _LIBCPP_CONCAT(Y, Z)) | |
| 34 | 36 | |
| 35 | 37 | # if __STDC_HOSTED__ == 0 |
| 36 | 38 | # define _LIBCPP_FREESTANDING |
| ... | ... | @@ -38,16 +40,9 @@ |
| 38 | 40 | |
| 39 | 41 | // HARDENING { |
| 40 | 42 | |
| 41 | // This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes) | |
| 42 | // equivalent to setting the extensive mode. This is deprecated and will be removed in LLVM 20. | |
| 43 | // TODO: Remove in LLVM 21. We're making this an error to catch folks who might not have migrated. | |
| 43 | 44 | # ifdef _LIBCPP_ENABLE_ASSERTIONS |
| 44 | # warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead" | |
| 45 | # if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1 | |
| 46 | # error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1" | |
| 47 | # endif | |
| 48 | # if _LIBCPP_ENABLE_ASSERTIONS | |
| 49 | # define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_EXTENSIVE | |
| 50 | # endif | |
| 45 | # error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE instead" | |
| 51 | 46 | # endif |
| 52 | 47 | |
| 53 | 48 | // The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values: |
| ... | ... | @@ -191,25 +186,6 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 191 | 186 | # error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11" |
| 192 | 187 | # endif |
| 193 | 188 | |
| 194 | // FIXME: ABI detection should be done via compiler builtin macros. This | |
| 195 | // is just a placeholder until Clang implements such macros. For now assume | |
| 196 | // that Windows compilers pretending to be MSVC++ target the Microsoft ABI, | |
| 197 | // and allow the user to explicitly specify the ABI to handle cases where this | |
| 198 | // heuristic falls short. | |
| 199 | # if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) | |
| 200 | # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" | |
| 201 | # elif defined(_LIBCPP_ABI_FORCE_ITANIUM) | |
| 202 | # define _LIBCPP_ABI_ITANIUM | |
| 203 | # elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) | |
| 204 | # define _LIBCPP_ABI_MICROSOFT | |
| 205 | # else | |
| 206 | # if defined(_WIN32) && defined(_MSC_VER) | |
| 207 | # define _LIBCPP_ABI_MICROSOFT | |
| 208 | # else | |
| 209 | # define _LIBCPP_ABI_ITANIUM | |
| 210 | # endif | |
| 211 | # endif | |
| 212 | ||
| 213 | 189 | # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) |
| 214 | 190 | # define _LIBCPP_ABI_VCRUNTIME |
| 215 | 191 | # endif |
| ... | ... | @@ -222,13 +198,16 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 222 | 198 | |
| 223 | 199 | // Incomplete features get their own specific disabling flags. This makes it |
| 224 | 200 | // easier to grep for target specific flags once the feature is complete. |
| 225 | # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) | |
| 226 | # define _LIBCPP_HAS_NO_INCOMPLETE_PSTL | |
| 227 | # define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN | |
| 228 | # define _LIBCPP_HAS_NO_EXPERIMENTAL_TZDB | |
| 229 | # define _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM | |
| 201 | # if defined(_LIBCPP_ENABLE_EXPERIMENTAL) || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 202 | # define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 1 | |
| 203 | # else | |
| 204 | # define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 0 | |
| 230 | 205 | # endif |
| 231 | 206 | |
| 207 | # define _LIBCPP_HAS_EXPERIMENTAL_PSTL _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | |
| 208 | # define _LIBCPP_HAS_EXPERIMENTAL_TZDB _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | |
| 209 | # define _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM _LIBCPP_HAS_EXPERIMENTAL_LIBRARY | |
| 210 | ||
| 232 | 211 | # if defined(__MVS__) |
| 233 | 212 | # include <features.h> // for __NATIVE_ASCII_F |
| 234 | 213 | # endif |
| ... | ... | @@ -244,9 +223,14 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 244 | 223 | # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library |
| 245 | 224 | # endif |
| 246 | 225 | # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) |
| 247 | # define _LIBCPP_HAS_BITSCAN64 | |
| 226 | # define _LIBCPP_HAS_BITSCAN64 1 | |
| 227 | # else | |
| 228 | # define _LIBCPP_HAS_BITSCAN64 0 | |
| 248 | 229 | # endif |
| 249 | # define _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 230 | # define _LIBCPP_HAS_OPEN_WITH_WCHAR 1 | |
| 231 | # else | |
| 232 | # define _LIBCPP_HAS_OPEN_WITH_WCHAR 0 | |
| 233 | # define _LIBCPP_HAS_BITSCAN64 0 | |
| 250 | 234 | # endif // defined(_WIN32) |
| 251 | 235 | |
| 252 | 236 | # if defined(_AIX) && !defined(__64BIT__) |
| ... | ... | @@ -312,7 +296,6 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 312 | 296 | # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) |
| 313 | 297 | # define _ALIGNAS_TYPE(x) alignas(x) |
| 314 | 298 | # define _ALIGNAS(x) alignas(x) |
| 315 | # define _LIBCPP_NORETURN [[noreturn]] | |
| 316 | 299 | # define _NOEXCEPT noexcept |
| 317 | 300 | # define _NOEXCEPT_(...) noexcept(__VA_ARGS__) |
| 318 | 301 | # define _LIBCPP_CONSTEXPR constexpr |
| ... | ... | @@ -322,8 +305,6 @@ _LIBCPP_HARDENING_MODE_DEBUG |
| 322 | 305 | # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) |
| 323 | 306 | # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) |
| 324 | 307 | # define _ALIGNAS(x) __attribute__((__aligned__(x))) |
| 325 | # define _LIBCPP_NORETURN __attribute__((__noreturn__)) | |
| 326 | # define _LIBCPP_HAS_NO_NOEXCEPT | |
| 327 | 308 | # define nullptr __nullptr |
| 328 | 309 | # define _NOEXCEPT throw() |
| 329 | 310 | # define _NOEXCEPT_(...) |
| ... | ... | @@ -340,23 +321,33 @@ typedef __char32_t char32_t; |
| 340 | 321 | |
| 341 | 322 | // Objective-C++ features (opt-in) |
| 342 | 323 | # if __has_feature(objc_arc) |
| 343 | # define _LIBCPP_HAS_OBJC_ARC | |
| 324 | # define _LIBCPP_HAS_OBJC_ARC 1 | |
| 325 | # else | |
| 326 | # define _LIBCPP_HAS_OBJC_ARC 0 | |
| 344 | 327 | # endif |
| 345 | 328 | |
| 346 | 329 | # if __has_feature(objc_arc_weak) |
| 347 | # define _LIBCPP_HAS_OBJC_ARC_WEAK | |
| 330 | # define _LIBCPP_HAS_OBJC_ARC_WEAK 1 | |
| 331 | # else | |
| 332 | # define _LIBCPP_HAS_OBJC_ARC_WEAK 0 | |
| 348 | 333 | # endif |
| 349 | 334 | |
| 350 | 335 | # if __has_extension(blocks) |
| 351 | # define _LIBCPP_HAS_EXTENSION_BLOCKS | |
| 336 | # define _LIBCPP_HAS_EXTENSION_BLOCKS 1 | |
| 337 | # else | |
| 338 | # define _LIBCPP_HAS_EXTENSION_BLOCKS 0 | |
| 352 | 339 | # endif |
| 353 | 340 | |
| 354 | # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) | |
| 355 | # define _LIBCPP_HAS_BLOCKS_RUNTIME | |
| 341 | # if _LIBCPP_HAS_EXTENSION_BLOCKS && defined(__APPLE__) | |
| 342 | # define _LIBCPP_HAS_BLOCKS_RUNTIME 1 | |
| 343 | # else | |
| 344 | # define _LIBCPP_HAS_BLOCKS_RUNTIME 0 | |
| 356 | 345 | # endif |
| 357 | 346 | |
| 358 | # if !__has_feature(address_sanitizer) | |
| 359 | # define _LIBCPP_HAS_NO_ASAN | |
| 347 | # if __has_feature(address_sanitizer) | |
| 348 | # define _LIBCPP_HAS_ASAN 1 | |
| 349 | # else | |
| 350 | # define _LIBCPP_HAS_ASAN 0 | |
| 360 | 351 | # endif |
| 361 | 352 | |
| 362 | 353 | # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) |
| ... | ... | @@ -479,7 +470,7 @@ typedef __char32_t char32_t; |
| 479 | 470 | # define _LIBCPP_HARDENING_SIG n // "none" |
| 480 | 471 | # endif |
| 481 | 472 | |
| 482 | # ifdef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 473 | # if !_LIBCPP_HAS_EXCEPTIONS | |
| 483 | 474 | # define _LIBCPP_EXCEPTIONS_SIG n |
| 484 | 475 | # else |
| 485 | 476 | # define _LIBCPP_EXCEPTIONS_SIG e |
| ... | ... | @@ -593,6 +584,15 @@ typedef __char32_t char32_t; |
| 593 | 584 | inline namespace _LIBCPP_ABI_NAMESPACE { |
| 594 | 585 | # define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_POP_EXTENSION_DIAGNOSTICS |
| 595 | 586 | |
| 587 | #define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental { | |
| 588 | #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL }} | |
| 589 | ||
| 590 | #define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 { | |
| 591 | #define _LIBCPP_END_NAMESPACE_LFTS } _LIBCPP_END_NAMESPACE_EXPERIMENTAL | |
| 592 | ||
| 593 | #define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 { | |
| 594 | #define _LIBCPP_END_NAMESPACE_LFTS_V2 } _LIBCPP_END_NAMESPACE_EXPERIMENTAL | |
| 595 | ||
| 596 | 596 | #ifdef _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE |
| 597 | 597 | # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD namespace filesystem { |
| 598 | 598 | # define _LIBCPP_END_NAMESPACE_FILESYSTEM } _LIBCPP_END_NAMESPACE_STD |
| ... | ... | @@ -610,7 +610,9 @@ typedef __char32_t char32_t; |
| 610 | 610 | # endif |
| 611 | 611 | |
| 612 | 612 | # if !defined(__SIZEOF_INT128__) || defined(_MSC_VER) |
| 613 | # define _LIBCPP_HAS_NO_INT128 | |
| 613 | # define _LIBCPP_HAS_INT128 0 | |
| 614 | # else | |
| 615 | # define _LIBCPP_HAS_INT128 1 | |
| 614 | 616 | # endif |
| 615 | 617 | |
| 616 | 618 | # ifdef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -631,10 +633,6 @@ typedef __char32_t char32_t; |
| 631 | 633 | # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) |
| 632 | 634 | # endif // _LIBCPP_CXX03_LANG |
| 633 | 635 | |
| 634 | # if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__NetBSD__) | |
| 635 | # define _LIBCPP_LOCALE__L_EXTENSIONS 1 | |
| 636 | # endif | |
| 637 | ||
| 638 | 636 | # ifdef __FreeBSD__ |
| 639 | 637 | # define _DECLARE_C99_LDBL_MATH 1 |
| 640 | 638 | # endif |
| ... | ... | @@ -642,29 +640,39 @@ typedef __char32_t char32_t; |
| 642 | 640 | // If we are getting operator new from the MSVC CRT, then allocation overloads |
| 643 | 641 | // for align_val_t were added in 19.12, aka VS 2017 version 15.3. |
| 644 | 642 | # if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 |
| 645 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 643 | # define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0 | |
| 646 | 644 | # elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) |
| 647 | 645 | // We're deferring to Microsoft's STL to provide aligned new et al. We don't |
| 648 | 646 | // have it unless the language feature test macro is defined. |
| 649 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 647 | # define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0 | |
| 650 | 648 | # elif defined(__MVS__) |
| 651 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 649 | # define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0 | |
| 650 | # else | |
| 651 | # define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 1 | |
| 652 | 652 | # endif |
| 653 | 653 | |
| 654 | # if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) | |
| 655 | # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION | |
| 654 | # if !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) | |
| 655 | # define _LIBCPP_HAS_ALIGNED_ALLOCATION 0 | |
| 656 | # else | |
| 657 | # define _LIBCPP_HAS_ALIGNED_ALLOCATION 1 | |
| 656 | 658 | # endif |
| 657 | 659 | |
| 658 | 660 | // It is not yet possible to use aligned_alloc() on all Apple platforms since |
| 659 | 661 | // 10.15 was the first version to ship an implementation of aligned_alloc(). |
| 660 | 662 | # if defined(__APPLE__) |
| 661 | 663 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ |
| 662 | __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) | |
| 663 | # define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC | |
| 664 | __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ | |
| 665 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ | |
| 666 | __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) | |
| 667 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0 | |
| 668 | # else | |
| 669 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1 | |
| 664 | 670 | # endif |
| 665 | 671 | # elif defined(__ANDROID__) && __ANDROID_API__ < 28 |
| 666 | 672 | // Android only provides aligned_alloc when targeting API 28 or higher. |
| 667 | # define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC | |
| 673 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0 | |
| 674 | # else | |
| 675 | # define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1 | |
| 668 | 676 | # endif |
| 669 | 677 | |
| 670 | 678 | # if defined(__APPLE__) || defined(__FreeBSD__) |
| ... | ... | @@ -676,7 +684,9 @@ typedef __char32_t char32_t; |
| 676 | 684 | # endif |
| 677 | 685 | |
| 678 | 686 | # if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) |
| 679 | # define _LIBCPP_HAS_NO_CHAR8_T | |
| 687 | # define _LIBCPP_HAS_CHAR8_T 0 | |
| 688 | # else | |
| 689 | # define _LIBCPP_HAS_CHAR8_T 1 | |
| 680 | 690 | # endif |
| 681 | 691 | |
| 682 | 692 | // Deprecation macros. |
| ... | ... | @@ -699,14 +709,6 @@ typedef __char32_t char32_t; |
| 699 | 709 | # define _LIBCPP_DEPRECATED_(m) |
| 700 | 710 | # endif |
| 701 | 711 | |
| 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 | ||
| 710 | 712 | # if !defined(_LIBCPP_CXX03_LANG) |
| 711 | 713 | # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED |
| 712 | 714 | # else |
| ... | ... | @@ -743,7 +745,7 @@ typedef __char32_t char32_t; |
| 743 | 745 | # define _LIBCPP_DEPRECATED_IN_CXX26 |
| 744 | 746 | # endif |
| 745 | 747 | |
| 746 | # if !defined(_LIBCPP_HAS_NO_CHAR8_T) | |
| 748 | # if _LIBCPP_HAS_CHAR8_T | |
| 747 | 749 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED |
| 748 | 750 | # else |
| 749 | 751 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T |
| ... | ... | @@ -796,16 +798,22 @@ typedef __char32_t char32_t; |
| 796 | 798 | # define _LIBCPP_CONSTEXPR_SINCE_CXX23 |
| 797 | 799 | # endif |
| 798 | 800 | |
| 801 | # if _LIBCPP_STD_VER >= 26 | |
| 802 | # define _LIBCPP_CONSTEXPR_SINCE_CXX26 constexpr | |
| 803 | # else | |
| 804 | # define _LIBCPP_CONSTEXPR_SINCE_CXX26 | |
| 805 | # endif | |
| 806 | ||
| 799 | 807 | # ifndef _LIBCPP_WEAK |
| 800 | 808 | # define _LIBCPP_WEAK __attribute__((__weak__)) |
| 801 | 809 | # endif |
| 802 | 810 | |
| 803 | 811 | // Thread API |
| 804 | 812 | // clang-format off |
| 805 | # if !defined(_LIBCPP_HAS_NO_THREADS) && \ | |
| 806 | !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ | |
| 807 | !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ | |
| 808 | !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | |
| 813 | # if _LIBCPP_HAS_THREADS && \ | |
| 814 | !_LIBCPP_HAS_THREAD_API_PTHREAD && \ | |
| 815 | !_LIBCPP_HAS_THREAD_API_WIN32 && \ | |
| 816 | !_LIBCPP_HAS_THREAD_API_EXTERNAL | |
| 809 | 817 | |
| 810 | 818 | # if defined(__FreeBSD__) || \ |
| 811 | 819 | defined(__wasi__) || \ |
| ... | ... | @@ -819,43 +827,49 @@ typedef __char32_t char32_t; |
| 819 | 827 | defined(_AIX) || \ |
| 820 | 828 | defined(__EMSCRIPTEN__) |
| 821 | 829 | // clang-format on |
| 822 | # define _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 830 | # undef _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 831 | # define _LIBCPP_HAS_THREAD_API_PTHREAD 1 | |
| 823 | 832 | # elif defined(__Fuchsia__) |
| 824 | 833 | // TODO(44575): Switch to C11 thread API when possible. |
| 825 | # define _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 834 | # undef _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 835 | # define _LIBCPP_HAS_THREAD_API_PTHREAD 1 | |
| 826 | 836 | # elif defined(_LIBCPP_WIN32API) |
| 827 | # define _LIBCPP_HAS_THREAD_API_WIN32 | |
| 837 | # undef _LIBCPP_HAS_THREAD_API_WIN32 | |
| 838 | # define _LIBCPP_HAS_THREAD_API_WIN32 1 | |
| 828 | 839 | # else |
| 829 | 840 | # error "No thread API" |
| 830 | 841 | # endif // _LIBCPP_HAS_THREAD_API |
| 831 | # endif // _LIBCPP_HAS_NO_THREADS | |
| 842 | # endif // _LIBCPP_HAS_THREADS | |
| 832 | 843 | |
| 833 | # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | |
| 844 | # if _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 834 | 845 | # if defined(__ANDROID__) && __ANDROID_API__ >= 30 |
| 835 | # define _LIBCPP_HAS_COND_CLOCKWAIT | |
| 846 | # define _LIBCPP_HAS_COND_CLOCKWAIT 1 | |
| 836 | 847 | # elif defined(_LIBCPP_GLIBC_PREREQ) |
| 837 | 848 | # if _LIBCPP_GLIBC_PREREQ(2, 30) |
| 838 | # define _LIBCPP_HAS_COND_CLOCKWAIT | |
| 849 | # define _LIBCPP_HAS_COND_CLOCKWAIT 1 | |
| 850 | # else | |
| 851 | # define _LIBCPP_HAS_COND_CLOCKWAIT 0 | |
| 839 | 852 | # endif |
| 853 | # else | |
| 854 | # define _LIBCPP_HAS_COND_CLOCKWAIT 0 | |
| 840 | 855 | # endif |
| 856 | # else | |
| 857 | # define _LIBCPP_HAS_COND_CLOCKWAIT 0 | |
| 841 | 858 | # endif |
| 842 | 859 | |
| 843 | # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | |
| 844 | # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ | |
| 845 | _LIBCPP_HAS_NO_THREADS is not defined. | |
| 860 | # if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 861 | # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be true when _LIBCPP_HAS_THREADS is true. | |
| 846 | 862 | # endif |
| 847 | 863 | |
| 848 | # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | |
| 849 | # error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ | |
| 850 | _LIBCPP_HAS_NO_THREADS is defined. | |
| 864 | # if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_EXTERNAL | |
| 865 | # error _LIBCPP_HAS_THREAD_API_EXTERNAL may only be true when _LIBCPP_HAS_THREADS is true. | |
| 851 | 866 | # endif |
| 852 | 867 | |
| 853 | # if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 854 | # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ | |
| 855 | _LIBCPP_HAS_NO_THREADS is defined. | |
| 868 | # if !_LIBCPP_HAS_MONOTONIC_CLOCK && _LIBCPP_HAS_THREADS | |
| 869 | # error _LIBCPP_HAS_MONOTONIC_CLOCK may only be false when _LIBCPP_HAS_THREADS is false. | |
| 856 | 870 | # endif |
| 857 | 871 | |
| 858 | # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) | |
| 872 | # if _LIBCPP_HAS_THREADS && !defined(__STDCPP_THREADS__) | |
| 859 | 873 | # define __STDCPP_THREADS__ 1 |
| 860 | 874 | # endif |
| 861 | 875 | |
| ... | ... | @@ -870,11 +884,13 @@ typedef __char32_t char32_t; |
| 870 | 884 | // TODO(EricWF): Enable this optimization on Bionic after speaking to their |
| 871 | 885 | // respective stakeholders. |
| 872 | 886 | // clang-format off |
| 873 | # if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \ | |
| 874 | (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ | |
| 875 | defined(_LIBCPP_HAS_THREAD_API_WIN32) | |
| 887 | # if (_LIBCPP_HAS_THREAD_API_PTHREAD && defined(__GLIBC__)) || \ | |
| 888 | (_LIBCPP_HAS_THREAD_API_C11 && defined(__Fuchsia__)) || \ | |
| 889 | _LIBCPP_HAS_THREAD_API_WIN32 | |
| 876 | 890 | // clang-format on |
| 877 | # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION | |
| 891 | # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 1 | |
| 892 | # else | |
| 893 | # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 0 | |
| 878 | 894 | # endif |
| 879 | 895 | |
| 880 | 896 | // Destroying a condvar is a nop on Windows. |
| ... | ... | @@ -885,25 +901,31 @@ typedef __char32_t char32_t; |
| 885 | 901 | // |
| 886 | 902 | // TODO(EricWF): This is potentially true for some pthread implementations |
| 887 | 903 | // as well. |
| 888 | # if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32) | |
| 889 | # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION | |
| 904 | # if (_LIBCPP_HAS_THREAD_API_C11 && defined(__Fuchsia__)) || _LIBCPP_HAS_THREAD_API_WIN32 | |
| 905 | # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 1 | |
| 906 | # else | |
| 907 | # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 0 | |
| 890 | 908 | # endif |
| 891 | 909 | |
| 892 | 910 | # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ |
| 893 | defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) | |
| 911 | _LIBCPP_HAS_MUSL_LIBC || defined(__OpenBSD__) || defined(__LLVM_LIBC__) | |
| 894 | 912 | # define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE |
| 895 | 913 | # endif |
| 896 | 914 | |
| 897 | 915 | # if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) |
| 898 | # define _LIBCPP_HAS_C_ATOMIC_IMP | |
| 916 | # define _LIBCPP_HAS_C_ATOMIC_IMP 1 | |
| 917 | # define _LIBCPP_HAS_GCC_ATOMIC_IMP 0 | |
| 918 | # define _LIBCPP_HAS_EXTERNAL_ATOMIC_IMP 0 | |
| 899 | 919 | # elif defined(_LIBCPP_COMPILER_GCC) |
| 900 | # define _LIBCPP_HAS_GCC_ATOMIC_IMP | |
| 920 | # define _LIBCPP_HAS_C_ATOMIC_IMP 0 | |
| 921 | # define _LIBCPP_HAS_GCC_ATOMIC_IMP 1 | |
| 922 | # define _LIBCPP_HAS_EXTERNAL_ATOMIC_IMP 0 | |
| 901 | 923 | # endif |
| 902 | 924 | |
| 903 | # if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ | |
| 904 | !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) | |
| 905 | # define _LIBCPP_HAS_NO_ATOMIC_HEADER | |
| 925 | # if !_LIBCPP_HAS_C_ATOMIC_IMP && !_LIBCPP_HAS_GCC_ATOMIC_IMP && !_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP | |
| 926 | # define _LIBCPP_HAS_ATOMIC_HEADER 0 | |
| 906 | 927 | # else |
| 928 | # define _LIBCPP_HAS_ATOMIC_HEADER 1 | |
| 907 | 929 | # ifndef _LIBCPP_ATOMIC_FLAG_TYPE |
| 908 | 930 | # define _LIBCPP_ATOMIC_FLAG_TYPE bool |
| 909 | 931 | # endif |
| ... | ... | @@ -915,19 +937,18 @@ typedef __char32_t char32_t; |
| 915 | 937 | # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS |
| 916 | 938 | # endif |
| 917 | 939 | |
| 918 | # if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) | |
| 919 | # if defined(__clang__) && __has_attribute(acquire_capability) | |
| 920 | 940 | // Work around the attribute handling in clang. When both __declspec and |
| 921 | 941 | // __attribute__ are present, the processing goes awry preventing the definition |
| 922 | 942 | // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus |
| 923 | 943 | // combining the two does work. |
| 924 | # if !defined(_MSC_VER) | |
| 925 | # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS | |
| 926 | # endif | |
| 927 | # endif | |
| 944 | # if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) && \ | |
| 945 | __has_attribute(acquire_capability) && !defined(_MSC_VER) | |
| 946 | # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1 | |
| 947 | # else | |
| 948 | # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 0 | |
| 928 | 949 | # endif |
| 929 | 950 | |
| 930 | # ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS | |
| 951 | # if _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS | |
| 931 | 952 | # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) |
| 932 | 953 | # else |
| 933 | 954 | # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) |
| ... | ... | @@ -962,7 +983,7 @@ typedef __char32_t char32_t; |
| 962 | 983 | // When wide characters are disabled, it can be useful to have a quick way of |
| 963 | 984 | // disabling it without having to resort to #if-#endif, which has a larger |
| 964 | 985 | // impact on readability. |
| 965 | # if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 986 | # if !_LIBCPP_HAS_WIDE_CHARACTERS | |
| 966 | 987 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) |
| 967 | 988 | # else |
| 968 | 989 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ |
| ... | ... | @@ -999,28 +1020,16 @@ typedef __char32_t char32_t; |
| 999 | 1020 | // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.) |
| 1000 | 1021 | // However, MSVC implements [[msvc::no_unique_address]] which does what |
| 1001 | 1022 | // [[no_unique_address]] is supposed to do, in general. |
| 1002 | ||
| 1003 | // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or | |
| 1004 | // [[msvc::no_unique_address]] though. If/when it does implement | |
| 1005 | // [[msvc::no_unique_address]], this should be preferred though. | |
| 1006 | 1023 | # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] |
| 1007 | # elif __has_cpp_attribute(no_unique_address) | |
| 1008 | # define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]] | |
| 1009 | 1024 | # else |
| 1010 | # define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */ | |
| 1011 | // Note that this can be replaced by #error as soon as clang-cl | |
| 1012 | // implements msvc::no_unique_address, since there should be no C++20 | |
| 1013 | // compiler that doesn't support one of the two attributes at that point. | |
| 1014 | // We generally don't want to use this macro outside of C++20-only code, | |
| 1015 | // because using it conditionally in one language version only would make | |
| 1016 | // the ABI inconsistent. | |
| 1025 | # define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]] | |
| 1017 | 1026 | # endif |
| 1018 | 1027 | |
| 1019 | 1028 | // c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these |
| 1020 | 1029 | // functions is gradually being added to existing C libraries. The conditions |
| 1021 | 1030 | // below check for known C library versions and conditions under which these |
| 1022 | 1031 | // functions are declared by the C library. |
| 1023 | # define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 | |
| 1032 | // | |
| 1024 | 1033 | // GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if |
| 1025 | 1034 | // __cpp_char8_t is defined or if C2X extensions are enabled. Determining |
| 1026 | 1035 | // the latter depends on internal GNU libc details that are not appropriate |
| ... | ... | @@ -1028,8 +1037,12 @@ typedef __char32_t char32_t; |
| 1028 | 1037 | // defined are ignored. |
| 1029 | 1038 | # if defined(_LIBCPP_GLIBC_PREREQ) |
| 1030 | 1039 | # if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t) |
| 1031 | # undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 | |
| 1040 | # define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1 | |
| 1041 | # else | |
| 1042 | # define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0 | |
| 1032 | 1043 | # endif |
| 1044 | # else | |
| 1045 | # define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0 | |
| 1033 | 1046 | # endif |
| 1034 | 1047 | |
| 1035 | 1048 | // There are a handful of public standard library types that are intended to |
| ... | ... | @@ -1124,15 +1137,6 @@ typedef __char32_t char32_t; |
| 1124 | 1137 | # define _LIBCPP_USING_IF_EXISTS |
| 1125 | 1138 | # endif |
| 1126 | 1139 | |
| 1127 | # if __has_cpp_attribute(__nodiscard__) | |
| 1128 | # define _LIBCPP_NODISCARD [[__nodiscard__]] | |
| 1129 | # else | |
| 1130 | // We can't use GCC's [[gnu::warn_unused_result]] and | |
| 1131 | // __attribute__((warn_unused_result)), because GCC does not silence them via | |
| 1132 | // (void) cast. | |
| 1133 | # define _LIBCPP_NODISCARD | |
| 1134 | # endif | |
| 1135 | ||
| 1136 | 1140 | # if __has_attribute(__no_destroy__) |
| 1137 | 1141 | # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) |
| 1138 | 1142 | # else |
| ... | ... | @@ -1160,10 +1164,19 @@ typedef __char32_t char32_t; |
| 1160 | 1164 | # define _LIBCPP_LIFETIMEBOUND |
| 1161 | 1165 | # endif |
| 1162 | 1166 | |
| 1163 | # if __has_attribute(__nodebug__) | |
| 1164 | # define _LIBCPP_NODEBUG __attribute__((__nodebug__)) | |
| 1167 | # if __has_cpp_attribute(_Clang::__noescape__) | |
| 1168 | # define _LIBCPP_NOESCAPE [[_Clang::__noescape__]] | |
| 1169 | # else | |
| 1170 | # define _LIBCPP_NOESCAPE | |
| 1171 | # endif | |
| 1172 | ||
| 1173 | # define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]] | |
| 1174 | ||
| 1175 | # if __has_cpp_attribute(_Clang::__no_specializations__) | |
| 1176 | # define _LIBCPP_NO_SPECIALIZATIONS \ | |
| 1177 | [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]] | |
| 1165 | 1178 | # else |
| 1166 | # define _LIBCPP_NODEBUG | |
| 1179 | # define _LIBCPP_NO_SPECIALIZATIONS | |
| 1167 | 1180 | # endif |
| 1168 | 1181 | |
| 1169 | 1182 | # if __has_attribute(__standalone_debug__) |
| ... | ... | @@ -1220,7 +1233,9 @@ typedef __char32_t char32_t; |
| 1220 | 1233 | |
| 1221 | 1234 | // Clang-18 has support for deducing this, but it does not set the FTM. |
| 1222 | 1235 | # if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800) |
| 1223 | # define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | |
| 1236 | # define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 1 | |
| 1237 | # else | |
| 1238 | # define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0 | |
| 1224 | 1239 | # endif |
| 1225 | 1240 | |
| 1226 | 1241 | #endif // __cplusplus |
lib/libcxx/include/__configuration/abi.h+46-4| ... | ... | @@ -18,6 +18,25 @@ |
| 18 | 18 | # pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | // FIXME: ABI detection should be done via compiler builtin macros. This | |
| 22 | // is just a placeholder until Clang implements such macros. For now assume | |
| 23 | // that Windows compilers pretending to be MSVC++ target the Microsoft ABI, | |
| 24 | // and allow the user to explicitly specify the ABI to handle cases where this | |
| 25 | // heuristic falls short. | |
| 26 | #if _LIBCPP_ABI_FORCE_ITANIUM && _LIBCPP_ABI_FORCE_MICROSOFT | |
| 27 | # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be true" | |
| 28 | #elif _LIBCPP_ABI_FORCE_ITANIUM | |
| 29 | # define _LIBCPP_ABI_ITANIUM | |
| 30 | #elif _LIBCPP_ABI_FORCE_MICROSOFT | |
| 31 | # define _LIBCPP_ABI_MICROSOFT | |
| 32 | #else | |
| 33 | # if defined(_WIN32) && defined(_MSC_VER) | |
| 34 | # define _LIBCPP_ABI_MICROSOFT | |
| 35 | # else | |
| 36 | # define _LIBCPP_ABI_ITANIUM | |
| 37 | # endif | |
| 38 | #endif | |
| 39 | ||
| 21 | 40 | #if _LIBCPP_ABI_VERSION >= 2 |
| 22 | 41 | // Change short string representation so that string data starts at offset 0, |
| 23 | 42 | // improving its alignment in some cases. |
| ... | ... | @@ -98,10 +117,13 @@ |
| 98 | 117 | // and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill |
| 99 | 118 | // value has been initialized using a separate boolean, which changes the ABI. |
| 100 | 119 | # 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 | |
| 120 | // Historically, libc++ used a type called `__compressed_pair` to reduce storage needs in cases of empty types (e.g. an | |
| 121 | // empty allocator in std::vector). We switched to using `[[no_unique_address]]`. However, for ABI compatibility reasons | |
| 122 | // we had to add artificial padding in a few places. | |
| 123 | // | |
| 124 | // This setting disables the addition of such artificial padding, leading to a more optimal | |
| 125 | // representation for several types. | |
| 126 | # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING | |
| 105 | 127 | #elif _LIBCPP_ABI_VERSION == 1 |
| 106 | 128 | # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) |
| 107 | 129 | // Enable compiling copies of now inline methods into the dylib to support |
| ... | ... | @@ -154,6 +176,26 @@ |
| 154 | 176 | // ABI impact: changes the iterator type of `vector` (except `vector<bool>`). |
| 155 | 177 | // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR |
| 156 | 178 | |
| 179 | // Changes the iterator type of `array` to a bounded iterator that keeps track of whether it's within the bounds of the | |
| 180 | // container and asserts it on every dereference and when performing iterator arithmetic. | |
| 181 | // | |
| 182 | // ABI impact: changes the iterator type of `array`, its size and its layout. | |
| 183 | // #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY | |
| 184 | ||
| 185 | // [[msvc::no_unique_address]] seems to mostly affect empty classes, so the padding scheme for Itanium doesn't work. | |
| 186 | #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING) | |
| 187 | # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING | |
| 188 | #endif | |
| 189 | ||
| 190 | // Tracks the bounds of the array owned by std::unique_ptr<T[]>, allowing it to trap when accessed out-of-bounds. | |
| 191 | // Note that limited bounds checking is also available outside of this ABI configuration, but only some categories | |
| 192 | // of types can be checked. | |
| 193 | // | |
| 194 | // ABI impact: This causes the layout of std::unique_ptr<T[]> to change and its size to increase. | |
| 195 | // This also affects the representation of a few library types that use std::unique_ptr | |
| 196 | // internally, such as the unordered containers. | |
| 197 | // #define _LIBCPP_ABI_BOUNDED_UNIQUE_PTR | |
| 198 | ||
| 157 | 199 | #if defined(_LIBCPP_COMPILER_CLANG_BASED) |
| 158 | 200 | # if defined(__APPLE__) |
| 159 | 201 | # if defined(__i386__) || defined(__x86_64__) |
lib/libcxx/include/__configuration/availability.h+53-69| ... | ... | @@ -67,25 +67,19 @@ |
| 67 | 67 | // |
| 68 | 68 | // [1]: https://clang.llvm.org/docs/AttributeReference.html#availability |
| 69 | 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 | 70 | // Availability markup is disabled when building the library, or when a non-Clang |
| 79 | 71 | // compiler is used because only Clang supports the necessary attributes. |
| 80 | 72 | #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 | |
| 73 | # undef _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS | |
| 74 | # define _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS 0 | |
| 84 | 75 | #endif |
| 85 | 76 | |
| 86 | 77 | // When availability annotations are disabled, we take for granted that features introduced |
| 87 | 78 | // in all versions of the library are available. |
| 88 | #if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) | |
| 79 | #if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS | |
| 80 | ||
| 81 | # define _LIBCPP_INTRODUCED_IN_LLVM_20 1 | |
| 82 | # define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE /* nothing */ | |
| 89 | 83 | |
| 90 | 84 | # define _LIBCPP_INTRODUCED_IN_LLVM_19 1 |
| 91 | 85 | # define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE /* nothing */ |
| ... | ... | @@ -93,9 +87,6 @@ |
| 93 | 87 | # define _LIBCPP_INTRODUCED_IN_LLVM_18 1 |
| 94 | 88 | # define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE /* nothing */ |
| 95 | 89 | |
| 96 | # define _LIBCPP_INTRODUCED_IN_LLVM_17 1 | |
| 97 | # define _LIBCPP_INTRODUCED_IN_LLVM_17_ATTRIBUTE /* nothing */ | |
| 98 | ||
| 99 | 90 | # define _LIBCPP_INTRODUCED_IN_LLVM_16 1 |
| 100 | 91 | # define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE /* nothing */ |
| 101 | 92 | |
| ... | ... | @@ -105,26 +96,17 @@ |
| 105 | 96 | # define _LIBCPP_INTRODUCED_IN_LLVM_14 1 |
| 106 | 97 | # define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE /* nothing */ |
| 107 | 98 | |
| 108 | # define _LIBCPP_INTRODUCED_IN_LLVM_13 1 | |
| 109 | # define _LIBCPP_INTRODUCED_IN_LLVM_13_ATTRIBUTE /* nothing */ | |
| 110 | ||
| 111 | 99 | # define _LIBCPP_INTRODUCED_IN_LLVM_12 1 |
| 112 | 100 | # define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE /* nothing */ |
| 113 | 101 | |
| 114 | 102 | # define _LIBCPP_INTRODUCED_IN_LLVM_11 1 |
| 115 | 103 | # define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE /* nothing */ |
| 116 | 104 | |
| 117 | # define _LIBCPP_INTRODUCED_IN_LLVM_10 1 | |
| 118 | # define _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE /* nothing */ | |
| 119 | ||
| 120 | 105 | # define _LIBCPP_INTRODUCED_IN_LLVM_9 1 |
| 121 | 106 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE /* nothing */ |
| 122 | 107 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */ |
| 123 | 108 | # define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */ |
| 124 | 109 | |
| 125 | # define _LIBCPP_INTRODUCED_IN_LLVM_8 1 | |
| 126 | # define _LIBCPP_INTRODUCED_IN_LLVM_8_ATTRIBUTE /* nothing */ | |
| 127 | ||
| 128 | 110 | # define _LIBCPP_INTRODUCED_IN_LLVM_4 1 |
| 129 | 111 | # define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE /* nothing */ |
| 130 | 112 | |
| ... | ... | @@ -132,36 +114,42 @@ |
| 132 | 114 | |
| 133 | 115 | // clang-format off |
| 134 | 116 | |
| 117 | // LLVM 20 | |
| 118 | // TODO: Fill this in | |
| 119 | # define _LIBCPP_INTRODUCED_IN_LLVM_20 0 | |
| 120 | # define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE __attribute__((unavailable)) | |
| 121 | ||
| 135 | 122 | // LLVM 19 |
| 136 | 123 | // TODO: Fill this in |
| 137 | 124 | # define _LIBCPP_INTRODUCED_IN_LLVM_19 0 |
| 138 | 125 | # define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE __attribute__((unavailable)) |
| 139 | 126 | |
| 140 | 127 | // 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 | |
| 128 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 150000) || \ | |
| 129 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 180000) || \ | |
| 130 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 180000) || \ | |
| 131 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 110000) || \ | |
| 132 | (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 90000) || \ | |
| 133 | (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 240000) | |
| 134 | # define _LIBCPP_INTRODUCED_IN_LLVM_18 0 | |
| 151 | 135 | # else |
| 152 | # define _LIBCPP_INTRODUCED_IN_LLVM_17 1 | |
| 136 | # define _LIBCPP_INTRODUCED_IN_LLVM_18 1 | |
| 153 | 137 | # 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))) | |
| 138 | # define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE \ | |
| 139 | __attribute__((availability(macos, strict, introduced = 15.0))) \ | |
| 140 | __attribute__((availability(ios, strict, introduced = 18.0))) \ | |
| 141 | __attribute__((availability(tvos, strict, introduced = 18.0))) \ | |
| 142 | __attribute__((availability(watchos, strict, introduced = 11.0))) \ | |
| 143 | __attribute__((availability(bridgeos, strict, introduced = 9.0))) \ | |
| 144 | __attribute__((availability(driverkit, strict, introduced = 24.0))) | |
| 159 | 145 | |
| 160 | 146 | // LLVM 16 |
| 161 | 147 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \ |
| 162 | 148 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \ |
| 163 | 149 | (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) | |
| 150 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000) || \ | |
| 151 | (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 80000) || \ | |
| 152 | (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 230000) | |
| 165 | 153 | # define _LIBCPP_INTRODUCED_IN_LLVM_16 0 |
| 166 | 154 | # else |
| 167 | 155 | # define _LIBCPP_INTRODUCED_IN_LLVM_16 1 |
| ... | ... | @@ -170,13 +158,17 @@ |
| 170 | 158 | __attribute__((availability(macos, strict, introduced = 14.0))) \ |
| 171 | 159 | __attribute__((availability(ios, strict, introduced = 17.0))) \ |
| 172 | 160 | __attribute__((availability(tvos, strict, introduced = 17.0))) \ |
| 173 | __attribute__((availability(watchos, strict, introduced = 10.0))) | |
| 161 | __attribute__((availability(watchos, strict, introduced = 10.0))) \ | |
| 162 | __attribute__((availability(bridgeos, strict, introduced = 8.0))) \ | |
| 163 | __attribute__((availability(driverkit, strict, introduced = 23.0))) | |
| 174 | 164 | |
| 175 | 165 | // LLVM 15 |
| 176 | 166 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130400) || \ |
| 177 | 167 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160500) || \ |
| 178 | 168 | (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) | |
| 169 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90500) || \ | |
| 170 | (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 70500) || \ | |
| 171 | (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 220400) | |
| 180 | 172 | # define _LIBCPP_INTRODUCED_IN_LLVM_15 0 |
| 181 | 173 | # else |
| 182 | 174 | # define _LIBCPP_INTRODUCED_IN_LLVM_15 1 |
| ... | ... | @@ -185,32 +177,21 @@ |
| 185 | 177 | __attribute__((availability(macos, strict, introduced = 13.4))) \ |
| 186 | 178 | __attribute__((availability(ios, strict, introduced = 16.5))) \ |
| 187 | 179 | __attribute__((availability(tvos, strict, introduced = 16.5))) \ |
| 188 | __attribute__((availability(watchos, strict, introduced = 9.5))) | |
| 180 | __attribute__((availability(watchos, strict, introduced = 9.5))) \ | |
| 181 | __attribute__((availability(bridgeos, strict, introduced = 7.5))) \ | |
| 182 | __attribute__((availability(driverkit, strict, introduced = 22.4))) | |
| 189 | 183 | |
| 190 | 184 | // LLVM 14 |
| 191 | 185 | # define _LIBCPP_INTRODUCED_IN_LLVM_14 _LIBCPP_INTRODUCED_IN_LLVM_15 |
| 192 | 186 | # define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE |
| 193 | 187 | |
| 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 | 188 | // LLVM 12 |
| 210 | 189 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120300) || \ |
| 211 | 190 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150300) || \ |
| 212 | 191 | (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) | |
| 192 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80300) || \ | |
| 193 | (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 60000) || \ | |
| 194 | (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 210300) | |
| 214 | 195 | # define _LIBCPP_INTRODUCED_IN_LLVM_12 0 |
| 215 | 196 | # else |
| 216 | 197 | # define _LIBCPP_INTRODUCED_IN_LLVM_12 1 |
| ... | ... | @@ -219,7 +200,9 @@ |
| 219 | 200 | __attribute__((availability(macos, strict, introduced = 12.3))) \ |
| 220 | 201 | __attribute__((availability(ios, strict, introduced = 15.3))) \ |
| 221 | 202 | __attribute__((availability(tvos, strict, introduced = 15.3))) \ |
| 222 | __attribute__((availability(watchos, strict, introduced = 8.3))) | |
| 203 | __attribute__((availability(watchos, strict, introduced = 8.3))) \ | |
| 204 | __attribute__((availability(bridgeos, strict, introduced = 6.0))) \ | |
| 205 | __attribute__((availability(driverkit, strict, introduced = 21.3))) | |
| 223 | 206 | |
| 224 | 207 | // LLVM 11 |
| 225 | 208 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \ |
| ... | ... | @@ -236,10 +219,6 @@ |
| 236 | 219 | __attribute__((availability(tvos, strict, introduced = 14.0))) \ |
| 237 | 220 | __attribute__((availability(watchos, strict, introduced = 7.0))) |
| 238 | 221 | |
| 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 | 222 | // LLVM 9 |
| 244 | 223 | # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ |
| 245 | 224 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \ |
| ... | ... | @@ -375,10 +354,15 @@ |
| 375 | 354 | #define _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19 |
| 376 | 355 | #define _LIBCPP_AVAILABILITY_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE |
| 377 | 356 | |
| 378 | // Define availability attributes that depend on _LIBCPP_HAS_NO_EXCEPTIONS. | |
| 357 | // This controls the availability of floating-point std::from_chars functions. | |
| 358 | // These overloads were added later than the integer overloads. | |
| 359 | #define _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20 | |
| 360 | #define _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE | |
| 361 | ||
| 362 | // Define availability attributes that depend on _LIBCPP_HAS_EXCEPTIONS. | |
| 379 | 363 | // Those are defined in terms of the availability attributes above, and |
| 380 | 364 | // should not be vendor-specific. |
| 381 | #if defined(_LIBCPP_HAS_NO_EXCEPTIONS) | |
| 365 | #if !_LIBCPP_HAS_EXCEPTIONS | |
| 382 | 366 | # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST |
| 383 | 367 | # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS |
| 384 | 368 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS |
| ... | ... | @@ -389,8 +373,8 @@ |
| 389 | 373 | #endif |
| 390 | 374 | |
| 391 | 375 | // 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) | |
| 376 | // _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI. | |
| 377 | #if !_LIBCPP_HAS_EXCEPTIONS || !_LIBCPP_HAS_RTTI | |
| 394 | 378 | # undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION |
| 395 | 379 | # undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION |
| 396 | 380 | # define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0 |
lib/libcxx/include/__configuration/compiler.h+2-2| ... | ... | @@ -33,8 +33,8 @@ |
| 33 | 33 | // Warn if a compiler version is used that is not supported anymore |
| 34 | 34 | // LLVM RELEASE Update the minimum compiler versions |
| 35 | 35 | # if defined(_LIBCPP_CLANG_VER) |
| 36 | # if _LIBCPP_CLANG_VER < 1700 | |
| 37 | # warning "Libc++ only supports Clang 17 and later" | |
| 36 | # if _LIBCPP_CLANG_VER < 1800 | |
| 37 | # warning "Libc++ only supports Clang 18 and later" | |
| 38 | 38 | # endif |
| 39 | 39 | # elif defined(_LIBCPP_APPLE_CLANG_VER) |
| 40 | 40 | # if _LIBCPP_APPLE_CLANG_VER < 1500 |
lib/libcxx/include/__configuration/language.h+8-4| ... | ... | @@ -35,12 +35,16 @@ |
| 35 | 35 | #endif // __cplusplus |
| 36 | 36 | // NOLINTEND(libcpp-cpp-version-check) |
| 37 | 37 | |
| 38 | #if !defined(__cpp_rtti) || __cpp_rtti < 199711L | |
| 39 | # define _LIBCPP_HAS_NO_RTTI | |
| 38 | #if defined(__cpp_rtti) && __cpp_rtti >= 199711L | |
| 39 | # define _LIBCPP_HAS_RTTI 1 | |
| 40 | #else | |
| 41 | # define _LIBCPP_HAS_RTTI 0 | |
| 40 | 42 | #endif |
| 41 | 43 | |
| 42 | #if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L | |
| 43 | # define _LIBCPP_HAS_NO_EXCEPTIONS | |
| 44 | #if defined(__cpp_exceptions) && __cpp_exceptions >= 199711L | |
| 45 | # define _LIBCPP_HAS_EXCEPTIONS 1 | |
| 46 | #else | |
| 47 | # define _LIBCPP_HAS_EXCEPTIONS 0 | |
| 44 | 48 | #endif |
| 45 | 49 | |
| 46 | 50 | #endif // _LIBCPP___CONFIGURATION_LANGUAGE_H |
lib/libcxx/include/__configuration/platform.h+10-8| ... | ... | @@ -31,14 +31,16 @@ |
| 31 | 31 | #endif |
| 32 | 32 | |
| 33 | 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__) | |
| 34 | #if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__) | |
| 35 | # if __has_include(<features.h>) | |
| 36 | # include <features.h> | |
| 37 | # if defined(__GLIBC_PREREQ) | |
| 38 | # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) | |
| 39 | # else | |
| 40 | # define _LIBCPP_GLIBC_PREREQ(a, b) 0 | |
| 41 | # endif // defined(__GLIBC_PREREQ) | |
| 42 | # endif | |
| 43 | #endif | |
| 42 | 44 | |
| 43 | 45 | #ifndef __BYTE_ORDER__ |
| 44 | 46 | # error \ |
lib/libcxx/include/__coroutine/coroutine_handle.h+2-1| ... | ... | @@ -11,11 +11,12 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__assert> |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/nullptr_t.h> | |
| 15 | #include <__cstddef/size_t.h> | |
| 14 | 16 | #include <__functional/hash.h> |
| 15 | 17 | #include <__memory/addressof.h> |
| 16 | 18 | #include <__type_traits/remove_cv.h> |
| 17 | 19 | #include <compare> |
| 18 | #include <cstddef> | |
| 19 | 20 | |
| 20 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | 22 | # pragma GCC system_header |
lib/libcxx/include/__cstddef/byte.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___CSTDDEF_BYTE_H | |
| 10 | #define _LIBCPP___CSTDDEF_BYTE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__fwd/byte.h> | |
| 14 | #include <__type_traits/enable_if.h> | |
| 15 | #include <__type_traits/is_integral.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER >= 17 | |
| 22 | namespace std { // purposefully not versioned | |
| 23 | ||
| 24 | enum class byte : unsigned char {}; | |
| 25 | ||
| 26 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept { | |
| 27 | return static_cast<byte>( | |
| 28 | static_cast<unsigned char>(static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs))); | |
| 29 | } | |
| 30 | ||
| 31 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept { | |
| 32 | return __lhs = __lhs | __rhs; | |
| 33 | } | |
| 34 | ||
| 35 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept { | |
| 36 | return static_cast<byte>( | |
| 37 | static_cast<unsigned char>(static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs))); | |
| 38 | } | |
| 39 | ||
| 40 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept { | |
| 41 | return __lhs = __lhs & __rhs; | |
| 42 | } | |
| 43 | ||
| 44 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept { | |
| 45 | return static_cast<byte>( | |
| 46 | static_cast<unsigned char>(static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs))); | |
| 47 | } | |
| 48 | ||
| 49 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept { | |
| 50 | return __lhs = __lhs ^ __rhs; | |
| 51 | } | |
| 52 | ||
| 53 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept { | |
| 54 | return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(__b))); | |
| 55 | } | |
| 56 | ||
| 57 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | |
| 58 | _LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept { | |
| 59 | return __lhs = __lhs << __shift; | |
| 60 | } | |
| 61 | ||
| 62 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | |
| 63 | _LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept { | |
| 64 | return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); | |
| 65 | } | |
| 66 | ||
| 67 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | |
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept { | |
| 69 | return __lhs = __lhs >> __shift; | |
| 70 | } | |
| 71 | ||
| 72 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | |
| 73 | _LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept { | |
| 74 | return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); | |
| 75 | } | |
| 76 | ||
| 77 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | |
| 78 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept { | |
| 79 | return static_cast<_Integer>(__b); | |
| 80 | } | |
| 81 | ||
| 82 | } // namespace std | |
| 83 | #endif // _LIBCPP_STD_VER >= 17 | |
| 84 | ||
| 85 | #endif // _LIBCPP___CSTDDEF_BYTE_H |
lib/libcxx/include/__cstddef/max_align_t.h created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | //===---------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===---------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___CSTDDEF_MAX_ALIGN_T_H | |
| 10 | #define _LIBCPP___CSTDDEF_MAX_ALIGN_T_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <stddef.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 !defined(_LIBCPP_CXX03_LANG) | |
| 22 | using ::max_align_t _LIBCPP_USING_IF_EXISTS; | |
| 23 | #endif | |
| 24 | ||
| 25 | _LIBCPP_END_NAMESPACE_STD | |
| 26 | ||
| 27 | #endif // _LIBCPP___CSTDDEF_MAX_ALIGN_T_H |
lib/libcxx/include/__cstddef/nullptr_t.h created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | //===---------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===---------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___CSTDDEF_NULLPTR_T_H | |
| 10 | #define _LIBCPP___CSTDDEF_NULLPTR_T_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 | using nullptr_t = decltype(nullptr); | |
| 21 | ||
| 22 | _LIBCPP_END_NAMESPACE_STD | |
| 23 | ||
| 24 | #endif // _LIBCPP___CSTDDEF_NULLPTR_T_H |
lib/libcxx/include/__cstddef/ptrdiff_t.h created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | //===---------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===---------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___CSTDDEF_PTRDIFF_T_H | |
| 10 | #define _LIBCPP___CSTDDEF_PTRDIFF_T_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 | using ptrdiff_t = decltype(static_cast<int*>(nullptr) - static_cast<int*>(nullptr)); | |
| 21 | ||
| 22 | _LIBCPP_END_NAMESPACE_STD | |
| 23 | ||
| 24 | #endif // _LIBCPP___CSTDDEF_PTRDIFF_T_H |
lib/libcxx/include/__cstddef/size_t.h created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | //===---------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===---------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___CSTDDEF_SIZE_T_H | |
| 10 | #define _LIBCPP___CSTDDEF_SIZE_T_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 | using size_t = decltype(sizeof(int)); | |
| 21 | ||
| 22 | _LIBCPP_END_NAMESPACE_STD | |
| 23 | ||
| 24 | #endif // _LIBCPP___CSTDDEF_SIZE_T_H |
lib/libcxx/include/__debug_utils/sanitizers.h+5-5| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | # pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 20 | #if _LIBCPP_HAS_ASAN | |
| 21 | 21 | |
| 22 | 22 | extern "C" { |
| 23 | 23 | _LIBCPP_EXPORTED_FROM_ABI void |
| ... | ... | @@ -28,12 +28,12 @@ _LIBCPP_EXPORTED_FROM_ABI int |
| 28 | 28 | __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | #endif // _LIBCPP_HAS_NO_ASAN | |
| 31 | #endif // _LIBCPP_HAS_ASAN | |
| 32 | 32 | |
| 33 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | |
| 35 | 35 | // ASan choices |
| 36 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 36 | #if _LIBCPP_HAS_ASAN | |
| 37 | 37 | # define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1 |
| 38 | 38 | #endif |
| 39 | 39 | |
| ... | ... | @@ -57,7 +57,7 @@ _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container( |
| 57 | 57 | const void* __last_old_contained, |
| 58 | 58 | const void* __first_new_contained, |
| 59 | 59 | const void* __last_new_contained) { |
| 60 | #ifdef _LIBCPP_HAS_NO_ASAN | |
| 60 | #if !_LIBCPP_HAS_ASAN | |
| 61 | 61 | (void)__first_storage; |
| 62 | 62 | (void)__last_storage; |
| 63 | 63 | (void)__first_old_contained; |
| ... | ... | @@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_c |
| 86 | 86 | const void* __last_storage, |
| 87 | 87 | const void* __old_last_contained, |
| 88 | 88 | const void* __new_last_contained) { |
| 89 | #ifdef _LIBCPP_HAS_NO_ASAN | |
| 89 | #if !_LIBCPP_HAS_ASAN | |
| 90 | 90 | (void)__first_storage; |
| 91 | 91 | (void)__last_storage; |
| 92 | 92 | (void)__old_last_contained; |
lib/libcxx/include/__exception/exception_ptr.h+4-5| ... | ... | @@ -10,13 +10,12 @@ |
| 10 | 10 | #define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/nullptr_t.h> | |
| 13 | 14 | #include <__exception/operations.h> |
| 14 | 15 | #include <__memory/addressof.h> |
| 15 | 16 | #include <__memory/construct_at.h> |
| 16 | 17 | #include <__type_traits/decay.h> |
| 17 | #include <cstddef> | |
| 18 | 18 | #include <cstdlib> |
| 19 | #include <new> | |
| 20 | 19 | #include <typeinfo> |
| 21 | 20 | |
| 22 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -67,7 +66,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { |
| 67 | 66 | |
| 68 | 67 | public: |
| 69 | 68 | // exception_ptr is basically a COW string. |
| 70 | using __trivially_relocatable = exception_ptr; | |
| 69 | using __trivially_relocatable _LIBCPP_NODEBUG = exception_ptr; | |
| 71 | 70 | |
| 72 | 71 | _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {} |
| 73 | 72 | _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {} |
| ... | ... | @@ -92,7 +91,7 @@ public: |
| 92 | 91 | |
| 93 | 92 | template <class _Ep> |
| 94 | 93 | _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { |
| 95 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 94 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 96 | 95 | # if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && __cplusplus >= 201103L |
| 97 | 96 | using _Ep2 = __decay_t<_Ep>; |
| 98 | 97 | |
| ... | ... | @@ -159,7 +158,7 @@ _LIBCPP_EXPORTED_FROM_ABI void swap(exception_ptr&, exception_ptr&) _NOEXCEPT; |
| 159 | 158 | |
| 160 | 159 | _LIBCPP_EXPORTED_FROM_ABI exception_ptr __copy_exception_ptr(void* __except, const void* __ptr); |
| 161 | 160 | _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT; |
| 162 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); | |
| 161 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); | |
| 163 | 162 | |
| 164 | 163 | // This is a built-in template function which automagically extracts the required |
| 165 | 164 | // information. |
lib/libcxx/include/__exception/nested_exception.h+8-7| ... | ... | @@ -13,6 +13,8 @@ |
| 13 | 13 | #include <__exception/exception_ptr.h> |
| 14 | 14 | #include <__memory/addressof.h> |
| 15 | 15 | #include <__type_traits/decay.h> |
| 16 | #include <__type_traits/enable_if.h> | |
| 17 | #include <__type_traits/integral_constant.h> | |
| 16 | 18 | #include <__type_traits/is_base_of.h> |
| 17 | 19 | #include <__type_traits/is_class.h> |
| 18 | 20 | #include <__type_traits/is_constructible.h> |
| ... | ... | @@ -20,7 +22,6 @@ |
| 20 | 22 | #include <__type_traits/is_final.h> |
| 21 | 23 | #include <__type_traits/is_polymorphic.h> |
| 22 | 24 | #include <__utility/forward.h> |
| 23 | #include <cstddef> | |
| 24 | 25 | |
| 25 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | 27 | # pragma GCC system_header |
| ... | ... | @@ -38,7 +39,7 @@ public: |
| 38 | 39 | virtual ~nested_exception() _NOEXCEPT; |
| 39 | 40 | |
| 40 | 41 | // access functions |
| 41 | _LIBCPP_NORETURN void rethrow_nested() const; | |
| 42 | [[__noreturn__]] void rethrow_nested() const; | |
| 42 | 43 | _LIBCPP_HIDE_FROM_ABI exception_ptr nested_ptr() const _NOEXCEPT { return __ptr_; } |
| 43 | 44 | }; |
| 44 | 45 | |
| ... | ... | @@ -47,26 +48,26 @@ struct __nested : public _Tp, public nested_exception { |
| 47 | 48 | _LIBCPP_HIDE_FROM_ABI explicit __nested(const _Tp& __t) : _Tp(__t) {} |
| 48 | 49 | }; |
| 49 | 50 | |
| 50 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 51 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 51 | 52 | template <class _Tp, class _Up, bool> |
| 52 | 53 | struct __throw_with_nested; |
| 53 | 54 | |
| 54 | 55 | template <class _Tp, class _Up> |
| 55 | 56 | struct __throw_with_nested<_Tp, _Up, true> { |
| 56 | _LIBCPP_NORETURN static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { | |
| 57 | [[__noreturn__]] static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { | |
| 57 | 58 | throw __nested<_Up>(std::forward<_Tp>(__t)); |
| 58 | 59 | } |
| 59 | 60 | }; |
| 60 | 61 | |
| 61 | 62 | template <class _Tp, class _Up> |
| 62 | 63 | struct __throw_with_nested<_Tp, _Up, false> { |
| 63 | _LIBCPP_NORETURN static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { throw std::forward<_Tp>(__t); } | |
| 64 | [[__noreturn__]] static inline _LIBCPP_HIDE_FROM_ABI void __do_throw(_Tp&& __t) { throw std::forward<_Tp>(__t); } | |
| 64 | 65 | }; |
| 65 | 66 | #endif |
| 66 | 67 | |
| 67 | 68 | template <class _Tp> |
| 68 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void throw_with_nested(_Tp&& __t) { | |
| 69 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 69 | [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void throw_with_nested(_Tp&& __t) { | |
| 70 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 70 | 71 | using _Up = __decay_t<_Tp>; |
| 71 | 72 | static_assert(is_copy_constructible<_Up>::value, "type thrown must be CopyConstructible"); |
| 72 | 73 | __throw_with_nested<_Tp, |
lib/libcxx/include/__exception/operations.h+5-4| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #define _LIBCPP___EXCEPTION_OPERATIONS_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 14 | 13 | |
| 15 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 15 | # pragma GCC system_header |
| ... | ... | @@ -22,20 +21,22 @@ namespace std { // purposefully not using versioning namespace |
| 22 | 21 | using unexpected_handler = void (*)(); |
| 23 | 22 | _LIBCPP_EXPORTED_FROM_ABI unexpected_handler set_unexpected(unexpected_handler) _NOEXCEPT; |
| 24 | 23 | _LIBCPP_EXPORTED_FROM_ABI unexpected_handler get_unexpected() _NOEXCEPT; |
| 25 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void unexpected(); | |
| 24 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void unexpected(); | |
| 26 | 25 | #endif |
| 27 | 26 | |
| 28 | 27 | using terminate_handler = void (*)(); |
| 29 | 28 | _LIBCPP_EXPORTED_FROM_ABI terminate_handler set_terminate(terminate_handler) _NOEXCEPT; |
| 30 | 29 | _LIBCPP_EXPORTED_FROM_ABI terminate_handler get_terminate() _NOEXCEPT; |
| 31 | 30 | |
| 32 | _LIBCPP_EXPORTED_FROM_ABI bool uncaught_exception() _NOEXCEPT; | |
| 31 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION) | |
| 32 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 bool uncaught_exception() _NOEXCEPT; | |
| 33 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION) | |
| 33 | 34 | _LIBCPP_EXPORTED_FROM_ABI int uncaught_exceptions() _NOEXCEPT; |
| 34 | 35 | |
| 35 | 36 | class _LIBCPP_EXPORTED_FROM_ABI exception_ptr; |
| 36 | 37 | |
| 37 | 38 | _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT; |
| 38 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); | |
| 39 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr); | |
| 39 | 40 | } // namespace std |
| 40 | 41 | |
| 41 | 42 | #endif // _LIBCPP___EXCEPTION_OPERATIONS_H |
lib/libcxx/include/__exception/terminate.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | namespace std { // purposefully not using versioning namespace |
| 19 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT; | |
| 19 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT; | |
| 20 | 20 | } // namespace std |
| 21 | 21 | |
| 22 | 22 | #endif // _LIBCPP___EXCEPTION_TERMINATE_H |
lib/libcxx/include/__expected/expected.h+33-34| ... | ... | @@ -17,9 +17,11 @@ |
| 17 | 17 | #include <__functional/invoke.h> |
| 18 | 18 | #include <__memory/addressof.h> |
| 19 | 19 | #include <__memory/construct_at.h> |
| 20 | #include <__type_traits/conditional.h> | |
| 20 | 21 | #include <__type_traits/conjunction.h> |
| 21 | 22 | #include <__type_traits/disjunction.h> |
| 22 | 23 | #include <__type_traits/integral_constant.h> |
| 24 | #include <__type_traits/invoke.h> | |
| 23 | 25 | #include <__type_traits/is_assignable.h> |
| 24 | 26 | #include <__type_traits/is_constructible.h> |
| 25 | 27 | #include <__type_traits/is_convertible.h> |
| ... | ... | @@ -71,7 +73,7 @@ struct __expected_construct_unexpected_from_invoke_tag {}; |
| 71 | 73 | |
| 72 | 74 | template <class _Err, class _Arg> |
| 73 | 75 | _LIBCPP_HIDE_FROM_ABI void __throw_bad_expected_access(_Arg&& __arg) { |
| 74 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 76 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 75 | 77 | throw bad_expected_access<_Err>(std::forward<_Arg>(__arg)); |
| 76 | 78 | # else |
| 77 | 79 | (void)__arg; |
| ... | ... | @@ -457,14 +459,14 @@ class expected : private __expected_base<_Tp, _Err> { |
| 457 | 459 | template <class _Up, class _OtherErr> |
| 458 | 460 | friend class expected; |
| 459 | 461 | |
| 460 | using __base = __expected_base<_Tp, _Err>; | |
| 462 | using __base _LIBCPP_NODEBUG = __expected_base<_Tp, _Err>; | |
| 461 | 463 | |
| 462 | 464 | public: |
| 463 | 465 | using value_type = _Tp; |
| 464 | 466 | using error_type = _Err; |
| 465 | 467 | using unexpected_type = unexpected<_Err>; |
| 466 | 468 | |
| 467 | using __trivially_relocatable = | |
| 469 | using __trivially_relocatable _LIBCPP_NODEBUG = | |
| 468 | 470 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value, |
| 469 | 471 | expected, |
| 470 | 472 | void>; |
| ... | ... | @@ -503,25 +505,24 @@ public: |
| 503 | 505 | |
| 504 | 506 | private: |
| 505 | 507 | template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual> |
| 506 | using __can_convert = | |
| 507 | _And< is_constructible<_Tp, _UfQual>, | |
| 508 | is_constructible<_Err, _OtherErrQual>, | |
| 509 | _If<_Not<is_same<remove_cv_t<_Tp>, bool>>::value, | |
| 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>&>>, | |
| 513 | _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>, | |
| 514 | _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>, | |
| 515 | _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>, | |
| 516 | _Not<is_convertible<expected<_Up, _OtherErr>&, _Tp>>, | |
| 517 | _Not<is_convertible<expected<_Up, _OtherErr>&&, _Tp>>, | |
| 518 | _Not<is_convertible<const expected<_Up, _OtherErr>&, _Tp>>, | |
| 519 | _Not<is_convertible<const expected<_Up, _OtherErr>&&, _Tp>>>, | |
| 520 | true_type>, | |
| 521 | _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>, | |
| 522 | _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>, | |
| 523 | _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>, | |
| 524 | _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>> >; | |
| 508 | using __can_convert _LIBCPP_NODEBUG = _And< | |
| 509 | is_constructible<_Tp, _UfQual>, | |
| 510 | is_constructible<_Err, _OtherErrQual>, | |
| 511 | _If<_Not<is_same<remove_cv_t<_Tp>, bool>>::value, | |
| 512 | _And< _Not<_And<is_same<_Tp, _Up>, is_same<_Err, _OtherErr>>>, // use the copy constructor instead, see #92676 | |
| 513 | _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>, | |
| 514 | _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>, | |
| 515 | _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>, | |
| 516 | _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>, | |
| 517 | _Not<is_convertible<expected<_Up, _OtherErr>&, _Tp>>, | |
| 518 | _Not<is_convertible<expected<_Up, _OtherErr>&&, _Tp>>, | |
| 519 | _Not<is_convertible<const expected<_Up, _OtherErr>&, _Tp>>, | |
| 520 | _Not<is_convertible<const expected<_Up, _OtherErr>&&, _Tp>>>, | |
| 521 | true_type>, | |
| 522 | _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>, | |
| 523 | _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>, | |
| 524 | _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>, | |
| 525 | _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>> >; | |
| 525 | 526 | |
| 526 | 527 | template <class _Func, class... _Args> |
| 527 | 528 | _LIBCPP_HIDE_FROM_ABI constexpr explicit expected( |
| ... | ... | @@ -918,9 +919,9 @@ public: |
| 918 | 919 | requires is_constructible_v<_Err, _Err&> |
| 919 | 920 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & { |
| 920 | 921 | using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>; |
| 921 | static_assert(__is_std_expected<_Up>::value, "The result of f(**this) must be a specialization of std::expected"); | |
| 922 | static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected"); | |
| 922 | 923 | static_assert(is_same_v<typename _Up::error_type, _Err>, |
| 923 | "The result of f(**this) must have the same error_type as this expected"); | |
| 924 | "The result of f(value()) must have the same error_type as this expected"); | |
| 924 | 925 | if (has_value()) { |
| 925 | 926 | return std::invoke(std::forward<_Func>(__f), this->__val()); |
| 926 | 927 | } |
| ... | ... | @@ -931,9 +932,9 @@ public: |
| 931 | 932 | requires is_constructible_v<_Err, const _Err&> |
| 932 | 933 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& { |
| 933 | 934 | using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&>>; |
| 934 | static_assert(__is_std_expected<_Up>::value, "The result of f(**this) must be a specialization of std::expected"); | |
| 935 | static_assert(__is_std_expected<_Up>::value, "The result of f(value()) must be a specialization of std::expected"); | |
| 935 | 936 | static_assert(is_same_v<typename _Up::error_type, _Err>, |
| 936 | "The result of f(**this) must have the same error_type as this expected"); | |
| 937 | "The result of f(value()) must have the same error_type as this expected"); | |
| 937 | 938 | if (has_value()) { |
| 938 | 939 | return std::invoke(std::forward<_Func>(__f), this->__val()); |
| 939 | 940 | } |
| ... | ... | @@ -945,9 +946,9 @@ public: |
| 945 | 946 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && { |
| 946 | 947 | using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&&>>; |
| 947 | 948 | static_assert( |
| 948 | __is_std_expected<_Up>::value, "The result of f(std::move(**this)) must be a specialization of std::expected"); | |
| 949 | __is_std_expected<_Up>::value, "The result of f(std::move(value())) must be a specialization of std::expected"); | |
| 949 | 950 | static_assert(is_same_v<typename _Up::error_type, _Err>, |
| 950 | "The result of f(std::move(**this)) must have the same error_type as this expected"); | |
| 951 | "The result of f(std::move(value())) must have the same error_type as this expected"); | |
| 951 | 952 | if (has_value()) { |
| 952 | 953 | return std::invoke(std::forward<_Func>(__f), std::move(this->__val())); |
| 953 | 954 | } |
| ... | ... | @@ -959,9 +960,9 @@ public: |
| 959 | 960 | _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& { |
| 960 | 961 | using _Up = remove_cvref_t<invoke_result_t<_Func, const _Tp&&>>; |
| 961 | 962 | static_assert( |
| 962 | __is_std_expected<_Up>::value, "The result of f(std::move(**this)) must be a specialization of std::expected"); | |
| 963 | __is_std_expected<_Up>::value, "The result of f(std::move(value())) must be a specialization of std::expected"); | |
| 963 | 964 | static_assert(is_same_v<typename _Up::error_type, _Err>, |
| 964 | "The result of f(std::move(**this)) must have the same error_type as this expected"); | |
| 965 | "The result of f(std::move(value())) must have the same error_type as this expected"); | |
| 965 | 966 | if (has_value()) { |
| 966 | 967 | return std::invoke(std::forward<_Func>(__f), std::move(this->__val())); |
| 967 | 968 | } |
| ... | ... | @@ -1362,7 +1363,7 @@ class expected<_Tp, _Err> : private __expected_void_base<_Err> { |
| 1362 | 1363 | friend class expected; |
| 1363 | 1364 | |
| 1364 | 1365 | template <class _Up, class _OtherErr, class _OtherErrQual> |
| 1365 | using __can_convert = | |
| 1366 | using __can_convert _LIBCPP_NODEBUG = | |
| 1366 | 1367 | _And< is_void<_Up>, |
| 1367 | 1368 | is_constructible<_Err, _OtherErrQual>, |
| 1368 | 1369 | _Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>, |
| ... | ... | @@ -1370,7 +1371,7 @@ class expected<_Tp, _Err> : private __expected_void_base<_Err> { |
| 1370 | 1371 | _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>, |
| 1371 | 1372 | _Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>>>; |
| 1372 | 1373 | |
| 1373 | using __base = __expected_void_base<_Err>; | |
| 1374 | using __base _LIBCPP_NODEBUG = __expected_void_base<_Err>; | |
| 1374 | 1375 | |
| 1375 | 1376 | public: |
| 1376 | 1377 | using value_type = _Tp; |
| ... | ... | @@ -1492,8 +1493,6 @@ public: |
| 1492 | 1493 | return *this; |
| 1493 | 1494 | } |
| 1494 | 1495 | |
| 1495 | _LIBCPP_HIDE_FROM_ABI constexpr expected& operator=(expected&&) = delete; | |
| 1496 | ||
| 1497 | 1496 | _LIBCPP_HIDE_FROM_ABI constexpr expected& |
| 1498 | 1497 | operator=(expected&& __rhs) noexcept(is_nothrow_move_assignable_v<_Err> && is_nothrow_move_constructible_v<_Err>) |
| 1499 | 1498 | requires(is_move_assignable_v<_Err> && is_move_constructible_v<_Err>) |
lib/libcxx/include/__expected/unexpected.h+7-7| ... | ... | @@ -48,12 +48,12 @@ template <class _Err> |
| 48 | 48 | struct __is_std_unexpected<unexpected<_Err>> : true_type {}; |
| 49 | 49 | |
| 50 | 50 | template <class _Tp> |
| 51 | using __valid_std_unexpected = _BoolConstant< // | |
| 52 | is_object_v<_Tp> && // | |
| 53 | !is_array_v<_Tp> && // | |
| 54 | !__is_std_unexpected<_Tp>::value && // | |
| 55 | !is_const_v<_Tp> && // | |
| 56 | !is_volatile_v<_Tp> // | |
| 51 | using __valid_std_unexpected _LIBCPP_NODEBUG = _BoolConstant< // | |
| 52 | is_object_v<_Tp> && // | |
| 53 | !is_array_v<_Tp> && // | |
| 54 | !__is_std_unexpected<_Tp>::value && // | |
| 55 | !is_const_v<_Tp> && // | |
| 56 | !is_volatile_v<_Tp> // | |
| 57 | 57 | >; |
| 58 | 58 | |
| 59 | 59 | template <class _Err> |
| ... | ... | @@ -108,7 +108,7 @@ public: |
| 108 | 108 | |
| 109 | 109 | template <class _Err2> |
| 110 | 110 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const unexpected& __x, const unexpected<_Err2>& __y) { |
| 111 | return __x.__unex_ == __y.__unex_; | |
| 111 | return __x.__unex_ == __y.error(); | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | private: |
lib/libcxx/include/__filesystem/directory_entry.h+48-13| ... | ... | @@ -20,8 +20,11 @@ |
| 20 | 20 | #include <__filesystem/operations.h> |
| 21 | 21 | #include <__filesystem/path.h> |
| 22 | 22 | #include <__filesystem/perms.h> |
| 23 | #include <__fwd/ostream.h> | |
| 23 | 24 | #include <__system_error/errc.h> |
| 25 | #include <__system_error/error_category.h> | |
| 24 | 26 | #include <__system_error/error_code.h> |
| 27 | #include <__system_error/error_condition.h> | |
| 25 | 28 | #include <__utility/move.h> |
| 26 | 29 | #include <__utility/unreachable.h> |
| 27 | 30 | #include <cstdint> |
| ... | ... | @@ -33,7 +36,7 @@ |
| 33 | 36 | _LIBCPP_PUSH_MACROS |
| 34 | 37 | #include <__undef_macros> |
| 35 | 38 | |
| 36 | #if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 39 | #if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM | |
| 37 | 40 | |
| 38 | 41 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 39 | 42 | |
| ... | ... | @@ -201,7 +204,9 @@ private: |
| 201 | 204 | _IterNonSymlink, |
| 202 | 205 | _RefreshSymlink, |
| 203 | 206 | _RefreshSymlinkUnresolved, |
| 204 | _RefreshNonSymlink | |
| 207 | _RefreshNonSymlink, | |
| 208 | _IterCachedSymlink, | |
| 209 | _IterCachedNonSymlink | |
| 205 | 210 | }; |
| 206 | 211 | |
| 207 | 212 | struct __cached_data { |
| ... | ... | @@ -240,6 +245,29 @@ private: |
| 240 | 245 | return __data; |
| 241 | 246 | } |
| 242 | 247 | |
| 248 | _LIBCPP_HIDE_FROM_ABI static __cached_data | |
| 249 | __create_iter_cached_result(file_type __ft, uintmax_t __size, perms __perm, file_time_type __write_time) { | |
| 250 | __cached_data __data; | |
| 251 | __data.__type_ = __ft; | |
| 252 | __data.__size_ = __size; | |
| 253 | __data.__write_time_ = __write_time; | |
| 254 | if (__ft == file_type::symlink) | |
| 255 | __data.__sym_perms_ = __perm; | |
| 256 | else | |
| 257 | __data.__non_sym_perms_ = __perm; | |
| 258 | __data.__cache_type_ = [&]() { | |
| 259 | switch (__ft) { | |
| 260 | case file_type::none: | |
| 261 | return _Empty; | |
| 262 | case file_type::symlink: | |
| 263 | return _IterCachedSymlink; | |
| 264 | default: | |
| 265 | return _IterCachedNonSymlink; | |
| 266 | } | |
| 267 | }(); | |
| 268 | return __data; | |
| 269 | } | |
| 270 | ||
| 243 | 271 | _LIBCPP_HIDE_FROM_ABI void __assign_iter_entry(_Path&& __p, __cached_data __dt) { |
| 244 | 272 | __p_ = std::move(__p); |
| 245 | 273 | __data_ = __dt; |
| ... | ... | @@ -248,15 +276,7 @@ private: |
| 248 | 276 | _LIBCPP_EXPORTED_FROM_ABI error_code __do_refresh() noexcept; |
| 249 | 277 | |
| 250 | 278 | _LIBCPP_HIDE_FROM_ABI static bool __is_dne_error(error_code const& __ec) { |
| 251 | if (!__ec) | |
| 252 | return true; | |
| 253 | switch (static_cast<errc>(__ec.value())) { | |
| 254 | case errc::no_such_file_or_directory: | |
| 255 | case errc::not_a_directory: | |
| 256 | return true; | |
| 257 | default: | |
| 258 | return false; | |
| 259 | } | |
| 279 | return !__ec || __ec == errc::no_such_file_or_directory || __ec == errc::not_a_directory; | |
| 260 | 280 | } |
| 261 | 281 | |
| 262 | 282 | _LIBCPP_HIDE_FROM_ABI void |
| ... | ... | @@ -281,13 +301,15 @@ private: |
| 281 | 301 | case _Empty: |
| 282 | 302 | return __symlink_status(__p_, __ec).type(); |
| 283 | 303 | case _IterSymlink: |
| 304 | case _IterCachedSymlink: | |
| 284 | 305 | case _RefreshSymlink: |
| 285 | 306 | case _RefreshSymlinkUnresolved: |
| 286 | 307 | if (__ec) |
| 287 | 308 | __ec->clear(); |
| 288 | 309 | return file_type::symlink; |
| 310 | case _IterCachedNonSymlink: | |
| 289 | 311 | case _IterNonSymlink: |
| 290 | case _RefreshNonSymlink: | |
| 312 | case _RefreshNonSymlink: { | |
| 291 | 313 | file_status __st(__data_.__type_); |
| 292 | 314 | if (__ec && !filesystem::exists(__st)) |
| 293 | 315 | *__ec = make_error_code(errc::no_such_file_or_directory); |
| ... | ... | @@ -295,6 +317,7 @@ private: |
| 295 | 317 | __ec->clear(); |
| 296 | 318 | return __data_.__type_; |
| 297 | 319 | } |
| 320 | } | |
| 298 | 321 | __libcpp_unreachable(); |
| 299 | 322 | } |
| 300 | 323 | |
| ... | ... | @@ -302,8 +325,10 @@ private: |
| 302 | 325 | switch (__data_.__cache_type_) { |
| 303 | 326 | case _Empty: |
| 304 | 327 | case _IterSymlink: |
| 328 | case _IterCachedSymlink: | |
| 305 | 329 | case _RefreshSymlinkUnresolved: |
| 306 | 330 | return __status(__p_, __ec).type(); |
| 331 | case _IterCachedNonSymlink: | |
| 307 | 332 | case _IterNonSymlink: |
| 308 | 333 | case _RefreshNonSymlink: |
| 309 | 334 | case _RefreshSymlink: { |
| ... | ... | @@ -323,8 +348,10 @@ private: |
| 323 | 348 | case _Empty: |
| 324 | 349 | case _IterNonSymlink: |
| 325 | 350 | case _IterSymlink: |
| 351 | case _IterCachedSymlink: | |
| 326 | 352 | case _RefreshSymlinkUnresolved: |
| 327 | 353 | return __status(__p_, __ec); |
| 354 | case _IterCachedNonSymlink: | |
| 328 | 355 | case _RefreshNonSymlink: |
| 329 | 356 | case _RefreshSymlink: |
| 330 | 357 | return file_status(__get_ft(__ec), __data_.__non_sym_perms_); |
| ... | ... | @@ -338,8 +365,10 @@ private: |
| 338 | 365 | case _IterNonSymlink: |
| 339 | 366 | case _IterSymlink: |
| 340 | 367 | return __symlink_status(__p_, __ec); |
| 368 | case _IterCachedNonSymlink: | |
| 341 | 369 | case _RefreshNonSymlink: |
| 342 | 370 | return file_status(__get_sym_ft(__ec), __data_.__non_sym_perms_); |
| 371 | case _IterCachedSymlink: | |
| 343 | 372 | case _RefreshSymlink: |
| 344 | 373 | case _RefreshSymlinkUnresolved: |
| 345 | 374 | return file_status(__get_sym_ft(__ec), __data_.__sym_perms_); |
| ... | ... | @@ -352,8 +381,10 @@ private: |
| 352 | 381 | case _Empty: |
| 353 | 382 | case _IterNonSymlink: |
| 354 | 383 | case _IterSymlink: |
| 384 | case _IterCachedSymlink: | |
| 355 | 385 | case _RefreshSymlinkUnresolved: |
| 356 | 386 | return filesystem::__file_size(__p_, __ec); |
| 387 | case _IterCachedNonSymlink: | |
| 357 | 388 | case _RefreshSymlink: |
| 358 | 389 | case _RefreshNonSymlink: { |
| 359 | 390 | error_code __m_ec; |
| ... | ... | @@ -374,6 +405,8 @@ private: |
| 374 | 405 | case _Empty: |
| 375 | 406 | case _IterNonSymlink: |
| 376 | 407 | case _IterSymlink: |
| 408 | case _IterCachedNonSymlink: | |
| 409 | case _IterCachedSymlink: | |
| 377 | 410 | case _RefreshSymlinkUnresolved: |
| 378 | 411 | return filesystem::__hard_link_count(__p_, __ec); |
| 379 | 412 | case _RefreshSymlink: |
| ... | ... | @@ -392,8 +425,10 @@ private: |
| 392 | 425 | case _Empty: |
| 393 | 426 | case _IterNonSymlink: |
| 394 | 427 | case _IterSymlink: |
| 428 | case _IterCachedSymlink: | |
| 395 | 429 | case _RefreshSymlinkUnresolved: |
| 396 | 430 | return filesystem::__last_write_time(__p_, __ec); |
| 431 | case _IterCachedNonSymlink: | |
| 397 | 432 | case _RefreshSymlink: |
| 398 | 433 | case _RefreshNonSymlink: { |
| 399 | 434 | error_code __m_ec; |
| ... | ... | @@ -428,7 +463,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP |
| 428 | 463 | |
| 429 | 464 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 430 | 465 | |
| 431 | #endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 466 | #endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM | |
| 432 | 467 | |
| 433 | 468 | _LIBCPP_POP_MACROS |
| 434 | 469 |
lib/libcxx/include/__filesystem/directory_iterator.h+2-3| ... | ... | @@ -22,7 +22,6 @@ |
| 22 | 22 | #include <__ranges/enable_view.h> |
| 23 | 23 | #include <__system_error/error_code.h> |
| 24 | 24 | #include <__utility/move.h> |
| 25 | #include <cstddef> | |
| 26 | 25 | |
| 27 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | 27 | # pragma GCC system_header |
| ... | ... | @@ -31,7 +30,7 @@ |
| 31 | 30 | _LIBCPP_PUSH_MACROS |
| 32 | 31 | #include <__undef_macros> |
| 33 | 32 | |
| 34 | #if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 33 | #if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM | |
| 35 | 34 | |
| 36 | 35 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 37 | 36 | |
| ... | ... | @@ -144,7 +143,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool |
| 144 | 143 | |
| 145 | 144 | # endif // _LIBCPP_STD_VER >= 20 |
| 146 | 145 | |
| 147 | #endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 146 | #endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM | |
| 148 | 147 | |
| 149 | 148 | _LIBCPP_POP_MACROS |
| 150 | 149 |
lib/libcxx/include/__filesystem/filesystem_error.h+3-3| ... | ... | @@ -67,15 +67,15 @@ private: |
| 67 | 67 | shared_ptr<_Storage> __storage_; |
| 68 | 68 | }; |
| 69 | 69 | |
| 70 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 70 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 71 | 71 | template <class... _Args> |
| 72 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void | |
| 72 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void | |
| 73 | 73 | __throw_filesystem_error(_Args&&... __args) { |
| 74 | 74 | throw filesystem_error(std::forward<_Args>(__args)...); |
| 75 | 75 | } |
| 76 | 76 | # else |
| 77 | 77 | template <class... _Args> |
| 78 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void | |
| 78 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void | |
| 79 | 79 | __throw_filesystem_error(_Args&&...) { |
| 80 | 80 | _LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode"); |
| 81 | 81 | } |
lib/libcxx/include/__filesystem/operations.h+2-2| ... | ... | @@ -27,7 +27,7 @@ |
| 27 | 27 | # pragma GCC system_header |
| 28 | 28 | #endif |
| 29 | 29 | |
| 30 | #if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 30 | #if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM | |
| 31 | 31 | |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 33 | 33 | |
| ... | ... | @@ -305,6 +305,6 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP |
| 305 | 305 | |
| 306 | 306 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 307 | 307 | |
| 308 | #endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 308 | #endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM | |
| 309 | 309 | |
| 310 | 310 | #endif // _LIBCPP___FILESYSTEM_OPERATIONS_H |
lib/libcxx/include/__filesystem/path.h+39-39| ... | ... | @@ -21,11 +21,11 @@ |
| 21 | 21 | #include <__type_traits/is_pointer.h> |
| 22 | 22 | #include <__type_traits/remove_const.h> |
| 23 | 23 | #include <__type_traits/remove_pointer.h> |
| 24 | #include <cstddef> | |
| 24 | #include <__utility/move.h> | |
| 25 | 25 | #include <string> |
| 26 | 26 | #include <string_view> |
| 27 | 27 | |
| 28 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 28 | #if _LIBCPP_HAS_LOCALIZATION | |
| 29 | 29 | # include <iomanip> // for quoted |
| 30 | 30 | # include <locale> |
| 31 | 31 | #endif |
| ... | ... | @@ -51,30 +51,30 @@ template <class _Tp> |
| 51 | 51 | struct __can_convert_char<const _Tp> : public __can_convert_char<_Tp> {}; |
| 52 | 52 | template <> |
| 53 | 53 | struct __can_convert_char<char> { |
| 54 | static const bool value = true; | |
| 55 | using __char_type = char; | |
| 54 | static const bool value = true; | |
| 55 | using __char_type _LIBCPP_NODEBUG = char; | |
| 56 | 56 | }; |
| 57 | 57 | template <> |
| 58 | 58 | struct __can_convert_char<wchar_t> { |
| 59 | static const bool value = true; | |
| 60 | using __char_type = wchar_t; | |
| 59 | static const bool value = true; | |
| 60 | using __char_type _LIBCPP_NODEBUG = wchar_t; | |
| 61 | 61 | }; |
| 62 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 62 | # if _LIBCPP_HAS_CHAR8_T | |
| 63 | 63 | template <> |
| 64 | 64 | struct __can_convert_char<char8_t> { |
| 65 | static const bool value = true; | |
| 66 | using __char_type = char8_t; | |
| 65 | static const bool value = true; | |
| 66 | using __char_type _LIBCPP_NODEBUG = char8_t; | |
| 67 | 67 | }; |
| 68 | 68 | # endif |
| 69 | 69 | template <> |
| 70 | 70 | struct __can_convert_char<char16_t> { |
| 71 | static const bool value = true; | |
| 72 | using __char_type = char16_t; | |
| 71 | static const bool value = true; | |
| 72 | using __char_type _LIBCPP_NODEBUG = char16_t; | |
| 73 | 73 | }; |
| 74 | 74 | template <> |
| 75 | 75 | struct __can_convert_char<char32_t> { |
| 76 | static const bool value = true; | |
| 77 | using __char_type = char32_t; | |
| 76 | static const bool value = true; | |
| 77 | using __char_type _LIBCPP_NODEBUG = char32_t; | |
| 78 | 78 | }; |
| 79 | 79 | |
| 80 | 80 | template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0> |
| ... | ... | @@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI bool __is_separator(_ECharT __e) { |
| 86 | 86 | # endif |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 89 | # if _LIBCPP_HAS_CHAR8_T | |
| 90 | 90 | typedef u8string __u8_string; |
| 91 | 91 | # else |
| 92 | 92 | typedef string __u8_string; |
| ... | ... | @@ -95,7 +95,7 @@ typedef string __u8_string; |
| 95 | 95 | struct _NullSentinel {}; |
| 96 | 96 | |
| 97 | 97 | template <class _Tp> |
| 98 | using _Void = void; | |
| 98 | using _Void _LIBCPP_NODEBUG = void; | |
| 99 | 99 | |
| 100 | 100 | template <class _Tp, class = void> |
| 101 | 101 | struct __is_pathable_string : public false_type {}; |
| ... | ... | @@ -104,7 +104,7 @@ template <class _ECharT, class _Traits, class _Alloc> |
| 104 | 104 | struct __is_pathable_string< basic_string<_ECharT, _Traits, _Alloc>, |
| 105 | 105 | _Void<typename __can_convert_char<_ECharT>::__char_type> > |
| 106 | 106 | : public __can_convert_char<_ECharT> { |
| 107 | using _Str = basic_string<_ECharT, _Traits, _Alloc>; | |
| 107 | using _Str _LIBCPP_NODEBUG = basic_string<_ECharT, _Traits, _Alloc>; | |
| 108 | 108 | |
| 109 | 109 | _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } |
| 110 | 110 | |
| ... | ... | @@ -117,7 +117,7 @@ template <class _ECharT, class _Traits> |
| 117 | 117 | struct __is_pathable_string< basic_string_view<_ECharT, _Traits>, |
| 118 | 118 | _Void<typename __can_convert_char<_ECharT>::__char_type> > |
| 119 | 119 | : public __can_convert_char<_ECharT> { |
| 120 | using _Str = basic_string_view<_ECharT, _Traits>; | |
| 120 | using _Str _LIBCPP_NODEBUG = basic_string_view<_ECharT, _Traits>; | |
| 121 | 121 | |
| 122 | 122 | _LIBCPP_HIDE_FROM_ABI static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } |
| 123 | 123 | |
| ... | ... | @@ -157,7 +157,7 @@ struct __is_pathable_iter< |
| 157 | 157 | true, |
| 158 | 158 | _Void<typename __can_convert_char< typename iterator_traits<_Iter>::value_type>::__char_type> > |
| 159 | 159 | : __can_convert_char<typename iterator_traits<_Iter>::value_type> { |
| 160 | using _ECharT = typename iterator_traits<_Iter>::value_type; | |
| 160 | using _ECharT _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::value_type; | |
| 161 | 161 | |
| 162 | 162 | _LIBCPP_HIDE_FROM_ABI static _Iter __range_begin(_Iter __b) { return __b; } |
| 163 | 163 | |
| ... | ... | @@ -199,7 +199,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t __char_to_wide(const string&, wchar_t*, size_t) |
| 199 | 199 | template <class _ECharT> |
| 200 | 200 | struct _PathCVT; |
| 201 | 201 | |
| 202 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 202 | # if _LIBCPP_HAS_LOCALIZATION | |
| 203 | 203 | template <class _ECharT> |
| 204 | 204 | struct _PathCVT { |
| 205 | 205 | static_assert(__can_convert_char<_ECharT>::value, "Char type not convertible"); |
| ... | ... | @@ -258,7 +258,7 @@ struct _PathCVT { |
| 258 | 258 | __append_range(__dest, _Traits::__range_begin(__s), _Traits::__range_end(__s)); |
| 259 | 259 | } |
| 260 | 260 | }; |
| 261 | # endif // !_LIBCPP_HAS_NO_LOCALIZATION | |
| 261 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 262 | 262 | |
| 263 | 263 | template <> |
| 264 | 264 | struct _PathCVT<__path_value> { |
| ... | ... | @@ -365,7 +365,7 @@ struct _PathExport<char16_t> { |
| 365 | 365 | } |
| 366 | 366 | }; |
| 367 | 367 | |
| 368 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 368 | # if _LIBCPP_HAS_CHAR8_T | |
| 369 | 369 | template <> |
| 370 | 370 | struct _PathExport<char8_t> { |
| 371 | 371 | typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower; |
| ... | ... | @@ -375,18 +375,18 @@ struct _PathExport<char8_t> { |
| 375 | 375 | _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size()); |
| 376 | 376 | } |
| 377 | 377 | }; |
| 378 | # endif /* !_LIBCPP_HAS_NO_CHAR8_T */ | |
| 378 | # endif // _LIBCPP_HAS_CHAR8_T | |
| 379 | 379 | # endif /* _LIBCPP_WIN32API */ |
| 380 | 380 | |
| 381 | 381 | class _LIBCPP_EXPORTED_FROM_ABI path { |
| 382 | 382 | template <class _SourceOrIter, class _Tp = path&> |
| 383 | using _EnableIfPathable = __enable_if_t<__is_pathable<_SourceOrIter>::value, _Tp>; | |
| 383 | using _EnableIfPathable _LIBCPP_NODEBUG = __enable_if_t<__is_pathable<_SourceOrIter>::value, _Tp>; | |
| 384 | 384 | |
| 385 | 385 | template <class _Tp> |
| 386 | using _SourceChar = typename __is_pathable<_Tp>::__char_type; | |
| 386 | using _SourceChar _LIBCPP_NODEBUG = typename __is_pathable<_Tp>::__char_type; | |
| 387 | 387 | |
| 388 | 388 | template <class _Tp> |
| 389 | using _SourceCVT = _PathCVT<_SourceChar<_Tp> >; | |
| 389 | using _SourceCVT _LIBCPP_NODEBUG = _PathCVT<_SourceChar<_Tp> >; | |
| 390 | 390 | |
| 391 | 391 | public: |
| 392 | 392 | # if defined(_LIBCPP_WIN32API) |
| ... | ... | @@ -420,7 +420,7 @@ public: |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | /* |
| 423 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 423 | #if _LIBCPP_HAS_LOCALIZATION | |
| 424 | 424 | // TODO Implement locale conversions. |
| 425 | 425 | template <class _Source, class = _EnableIfPathable<_Source, void> > |
| 426 | 426 | path(const _Source& __src, const locale& __loc, format = format::auto_format); |
| ... | ... | @@ -682,7 +682,7 @@ public: |
| 682 | 682 | return __s; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 685 | # if _LIBCPP_HAS_LOCALIZATION | |
| 686 | 686 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > |
| 687 | 687 | _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const { |
| 688 | 688 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; |
| ... | ... | @@ -725,17 +725,17 @@ public: |
| 725 | 725 | std::replace(__s.begin(), __s.end(), '\\', '/'); |
| 726 | 726 | return __s; |
| 727 | 727 | } |
| 728 | # endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ | |
| 728 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 729 | 729 | # else /* _LIBCPP_WIN32API */ |
| 730 | 730 | |
| 731 | 731 | _LIBCPP_HIDE_FROM_ABI std::string string() const { return __pn_; } |
| 732 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 732 | # if _LIBCPP_HAS_CHAR8_T | |
| 733 | 733 | _LIBCPP_HIDE_FROM_ABI std::u8string u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); } |
| 734 | 734 | # else |
| 735 | 735 | _LIBCPP_HIDE_FROM_ABI std::string u8string() const { return __pn_; } |
| 736 | 736 | # endif |
| 737 | 737 | |
| 738 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 738 | # if _LIBCPP_HAS_LOCALIZATION | |
| 739 | 739 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > |
| 740 | 740 | _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const { |
| 741 | 741 | using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>; |
| ... | ... | @@ -746,34 +746,34 @@ public: |
| 746 | 746 | return __s; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 749 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 750 | 750 | _LIBCPP_HIDE_FROM_ABI std::wstring wstring() const { return string<wchar_t>(); } |
| 751 | 751 | # endif |
| 752 | 752 | _LIBCPP_HIDE_FROM_ABI std::u16string u16string() const { return string<char16_t>(); } |
| 753 | 753 | _LIBCPP_HIDE_FROM_ABI std::u32string u32string() const { return string<char32_t>(); } |
| 754 | # endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ | |
| 754 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 755 | 755 | |
| 756 | 756 | // generic format observers |
| 757 | 757 | _LIBCPP_HIDE_FROM_ABI std::string generic_string() const { return __pn_; } |
| 758 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 758 | # if _LIBCPP_HAS_CHAR8_T | |
| 759 | 759 | _LIBCPP_HIDE_FROM_ABI std::u8string generic_u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); } |
| 760 | 760 | # else |
| 761 | 761 | _LIBCPP_HIDE_FROM_ABI std::string generic_u8string() const { return __pn_; } |
| 762 | 762 | # endif |
| 763 | 763 | |
| 764 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 764 | # if _LIBCPP_HAS_LOCALIZATION | |
| 765 | 765 | template <class _ECharT, class _Traits = char_traits<_ECharT>, class _Allocator = allocator<_ECharT> > |
| 766 | 766 | _LIBCPP_HIDE_FROM_ABI basic_string<_ECharT, _Traits, _Allocator> |
| 767 | 767 | generic_string(const _Allocator& __a = _Allocator()) const { |
| 768 | 768 | return string<_ECharT, _Traits, _Allocator>(__a); |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 771 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 772 | 772 | _LIBCPP_HIDE_FROM_ABI std::wstring generic_wstring() const { return string<wchar_t>(); } |
| 773 | 773 | # endif |
| 774 | 774 | _LIBCPP_HIDE_FROM_ABI std::u16string generic_u16string() const { return string<char16_t>(); } |
| 775 | 775 | _LIBCPP_HIDE_FROM_ABI std::u32string generic_u32string() const { return string<char32_t>(); } |
| 776 | # endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ | |
| 776 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 777 | 777 | # endif /* !_LIBCPP_WIN32API */ |
| 778 | 778 | |
| 779 | 779 | private: |
| ... | ... | @@ -811,7 +811,7 @@ public: |
| 811 | 811 | _LIBCPP_HIDE_FROM_ABI path extension() const { return string_type(__extension()); } |
| 812 | 812 | |
| 813 | 813 | // query |
| 814 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); } | |
| 814 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); } | |
| 815 | 815 | |
| 816 | 816 | _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { return !__root_name().empty(); } |
| 817 | 817 | _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { return !__root_directory().empty(); } |
| ... | ... | @@ -866,7 +866,7 @@ public: |
| 866 | 866 | iterator begin() const; |
| 867 | 867 | iterator end() const; |
| 868 | 868 | |
| 869 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 869 | # if _LIBCPP_HAS_LOCALIZATION | |
| 870 | 870 | template < |
| 871 | 871 | class _CharT, |
| 872 | 872 | class _Traits, |
| ... | ... | @@ -895,7 +895,7 @@ public: |
| 895 | 895 | __p = __tmp; |
| 896 | 896 | return __is; |
| 897 | 897 | } |
| 898 | # endif // !_LIBCPP_HAS_NO_LOCALIZATION | |
| 898 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 899 | 899 | |
| 900 | 900 | private: |
| 901 | 901 | inline _LIBCPP_HIDE_FROM_ABI path& __assign_view(__string_view const& __s) { |
lib/libcxx/include/__filesystem/path_iterator.h-3| ... | ... | @@ -14,9 +14,6 @@ |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__filesystem/path.h> |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <cstddef> | |
| 18 | #include <string> | |
| 19 | #include <string_view> | |
| 20 | 17 | |
| 21 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 19 | # pragma GCC system_header |
lib/libcxx/include/__filesystem/recursive_directory_iterator.h+2-3| ... | ... | @@ -21,7 +21,6 @@ |
| 21 | 21 | #include <__ranges/enable_view.h> |
| 22 | 22 | #include <__system_error/error_code.h> |
| 23 | 23 | #include <__utility/move.h> |
| 24 | #include <cstddef> | |
| 25 | 24 | |
| 26 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | 26 | # pragma GCC system_header |
| ... | ... | @@ -30,7 +29,7 @@ |
| 30 | 29 | _LIBCPP_PUSH_MACROS |
| 31 | 30 | #include <__undef_macros> |
| 32 | 31 | |
| 33 | #if _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 32 | #if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM | |
| 34 | 33 | |
| 35 | 34 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 36 | 35 | |
| ... | ... | @@ -157,7 +156,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY inline constexpr bool |
| 157 | 156 | |
| 158 | 157 | # endif // _LIBCPP_STD_VER >= 20 |
| 159 | 158 | |
| 160 | #endif // _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 159 | #endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM | |
| 161 | 160 | |
| 162 | 161 | _LIBCPP_POP_MACROS |
| 163 | 162 |
lib/libcxx/include/__filesystem/u8path.h+3-3| ... | ... | @@ -34,7 +34,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH |
| 34 | 34 | template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0> |
| 35 | 35 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _InputIt __l) { |
| 36 | 36 | static_assert( |
| 37 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 37 | # if _LIBCPP_HAS_CHAR8_T | |
| 38 | 38 | is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value || |
| 39 | 39 | # endif |
| 40 | 40 | is_same<typename __is_pathable<_InputIt>::__char_type, char>::value, |
| ... | ... | @@ -56,7 +56,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, |
| 56 | 56 | template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0> |
| 57 | 57 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _NullSentinel) { |
| 58 | 58 | static_assert( |
| 59 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 59 | # if _LIBCPP_HAS_CHAR8_T | |
| 60 | 60 | is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value || |
| 61 | 61 | # endif |
| 62 | 62 | is_same<typename __is_pathable<_InputIt>::__char_type, char>::value, |
| ... | ... | @@ -77,7 +77,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, |
| 77 | 77 | template <class _Source, __enable_if_t<__is_pathable<_Source>::value, int> = 0> |
| 78 | 78 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(const _Source& __s) { |
| 79 | 79 | static_assert( |
| 80 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 80 | # if _LIBCPP_HAS_CHAR8_T | |
| 81 | 81 | is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value || |
| 82 | 82 | # endif |
| 83 | 83 | is_same<typename __is_pathable<_Source>::__char_type, char>::value, |
lib/libcxx/include/__flat_map/flat_map.h created+1199| ... | ... | @@ -0,0 +1,1199 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FLAT_MAP_FLAT_MAP_H | |
| 11 | #define _LIBCPP___FLAT_MAP_FLAT_MAP_H | |
| 12 | ||
| 13 | #include <__algorithm/lexicographical_compare_three_way.h> | |
| 14 | #include <__algorithm/min.h> | |
| 15 | #include <__algorithm/ranges_adjacent_find.h> | |
| 16 | #include <__algorithm/ranges_equal.h> | |
| 17 | #include <__algorithm/ranges_inplace_merge.h> | |
| 18 | #include <__algorithm/ranges_lower_bound.h> | |
| 19 | #include <__algorithm/ranges_partition_point.h> | |
| 20 | #include <__algorithm/ranges_sort.h> | |
| 21 | #include <__algorithm/ranges_unique.h> | |
| 22 | #include <__algorithm/ranges_upper_bound.h> | |
| 23 | #include <__algorithm/remove_if.h> | |
| 24 | #include <__assert> | |
| 25 | #include <__compare/synth_three_way.h> | |
| 26 | #include <__concepts/swappable.h> | |
| 27 | #include <__config> | |
| 28 | #include <__cstddef/byte.h> | |
| 29 | #include <__cstddef/ptrdiff_t.h> | |
| 30 | #include <__flat_map/key_value_iterator.h> | |
| 31 | #include <__flat_map/sorted_unique.h> | |
| 32 | #include <__flat_map/utils.h> | |
| 33 | #include <__functional/invoke.h> | |
| 34 | #include <__functional/is_transparent.h> | |
| 35 | #include <__functional/operations.h> | |
| 36 | #include <__fwd/vector.h> | |
| 37 | #include <__iterator/concepts.h> | |
| 38 | #include <__iterator/distance.h> | |
| 39 | #include <__iterator/iterator_traits.h> | |
| 40 | #include <__iterator/next.h> | |
| 41 | #include <__iterator/ranges_iterator_traits.h> | |
| 42 | #include <__iterator/reverse_iterator.h> | |
| 43 | #include <__memory/allocator_traits.h> | |
| 44 | #include <__memory/uses_allocator.h> | |
| 45 | #include <__memory/uses_allocator_construction.h> | |
| 46 | #include <__ranges/access.h> | |
| 47 | #include <__ranges/concepts.h> | |
| 48 | #include <__ranges/container_compatible_range.h> | |
| 49 | #include <__ranges/drop_view.h> | |
| 50 | #include <__ranges/from_range.h> | |
| 51 | #include <__ranges/ref_view.h> | |
| 52 | #include <__ranges/size.h> | |
| 53 | #include <__ranges/subrange.h> | |
| 54 | #include <__ranges/zip_view.h> | |
| 55 | #include <__type_traits/conjunction.h> | |
| 56 | #include <__type_traits/container_traits.h> | |
| 57 | #include <__type_traits/invoke.h> | |
| 58 | #include <__type_traits/is_allocator.h> | |
| 59 | #include <__type_traits/is_nothrow_constructible.h> | |
| 60 | #include <__type_traits/is_same.h> | |
| 61 | #include <__utility/exception_guard.h> | |
| 62 | #include <__utility/move.h> | |
| 63 | #include <__utility/pair.h> | |
| 64 | #include <__utility/scope_guard.h> | |
| 65 | #include <__vector/vector.h> | |
| 66 | #include <initializer_list> | |
| 67 | #include <stdexcept> | |
| 68 | ||
| 69 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 70 | # pragma GCC system_header | |
| 71 | #endif | |
| 72 | ||
| 73 | _LIBCPP_PUSH_MACROS | |
| 74 | #include <__undef_macros> | |
| 75 | ||
| 76 | #if _LIBCPP_STD_VER >= 23 | |
| 77 | ||
| 78 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 79 | ||
| 80 | template <class _Key, | |
| 81 | class _Tp, | |
| 82 | class _Compare = less<_Key>, | |
| 83 | class _KeyContainer = vector<_Key>, | |
| 84 | class _MappedContainer = vector<_Tp>> | |
| 85 | class flat_map { | |
| 86 | template <class, class, class, class, class> | |
| 87 | friend class flat_map; | |
| 88 | ||
| 89 | static_assert(is_same_v<_Key, typename _KeyContainer::value_type>); | |
| 90 | static_assert(is_same_v<_Tp, typename _MappedContainer::value_type>); | |
| 91 | static_assert(!is_same_v<_KeyContainer, std::vector<bool>>, "vector<bool> is not a sequence container"); | |
| 92 | static_assert(!is_same_v<_MappedContainer, std::vector<bool>>, "vector<bool> is not a sequence container"); | |
| 93 | ||
| 94 | template <bool _Const> | |
| 95 | using __iterator _LIBCPP_NODEBUG = __key_value_iterator<flat_map, _KeyContainer, _MappedContainer, _Const>; | |
| 96 | ||
| 97 | public: | |
| 98 | // types | |
| 99 | using key_type = _Key; | |
| 100 | using mapped_type = _Tp; | |
| 101 | using value_type = pair<key_type, mapped_type>; | |
| 102 | using key_compare = __type_identity_t<_Compare>; | |
| 103 | using reference = pair<const key_type&, mapped_type&>; | |
| 104 | using const_reference = pair<const key_type&, const mapped_type&>; | |
| 105 | using size_type = size_t; | |
| 106 | using difference_type = ptrdiff_t; | |
| 107 | using iterator = __iterator<false>; // see [container.requirements] | |
| 108 | using const_iterator = __iterator<true>; // see [container.requirements] | |
| 109 | using reverse_iterator = std::reverse_iterator<iterator>; | |
| 110 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | |
| 111 | using key_container_type = _KeyContainer; | |
| 112 | using mapped_container_type = _MappedContainer; | |
| 113 | ||
| 114 | class value_compare { | |
| 115 | private: | |
| 116 | key_compare __comp_; | |
| 117 | _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {} | |
| 118 | friend flat_map; | |
| 119 | ||
| 120 | public: | |
| 121 | _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const { | |
| 122 | return __comp_(__x.first, __y.first); | |
| 123 | } | |
| 124 | }; | |
| 125 | ||
| 126 | struct containers { | |
| 127 | key_container_type keys; | |
| 128 | mapped_container_type values; | |
| 129 | }; | |
| 130 | ||
| 131 | private: | |
| 132 | template <class _Allocator> | |
| 133 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __allocator_ctor_constraint = | |
| 134 | _And<uses_allocator<key_container_type, _Allocator>, uses_allocator<mapped_container_type, _Allocator>>::value; | |
| 135 | ||
| 136 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __is_compare_transparent = __is_transparent_v<_Compare>; | |
| 137 | ||
| 138 | public: | |
| 139 | // [flat.map.cons], construct/copy/destroy | |
| 140 | _LIBCPP_HIDE_FROM_ABI flat_map() noexcept( | |
| 141 | is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_MappedContainer> && | |
| 142 | is_nothrow_default_constructible_v<_Compare>) | |
| 143 | : __containers_(), __compare_() {} | |
| 144 | ||
| 145 | _LIBCPP_HIDE_FROM_ABI flat_map(const flat_map&) = default; | |
| 146 | ||
| 147 | _LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other) noexcept( | |
| 148 | is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> && | |
| 149 | is_nothrow_move_constructible_v<_Compare>) | |
| 150 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 151 | try | |
| 152 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 153 | : __containers_(std::move(__other.__containers_)), __compare_(std::move(__other.__compare_)) { | |
| 154 | __other.clear(); | |
| 155 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 156 | } catch (...) { | |
| 157 | __other.clear(); | |
| 158 | // gcc does not like the `throw` keyword in a conditionally noexcept function | |
| 159 | if constexpr (!(is_nothrow_move_constructible_v<_KeyContainer> && | |
| 160 | is_nothrow_move_constructible_v<_MappedContainer> && is_nothrow_move_constructible_v<_Compare>)) { | |
| 161 | throw; | |
| 162 | } | |
| 163 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 164 | } | |
| 165 | ||
| 166 | template <class _Allocator> | |
| 167 | requires __allocator_ctor_constraint<_Allocator> | |
| 168 | _LIBCPP_HIDE_FROM_ABI flat_map(const flat_map& __other, const _Allocator& __alloc) | |
| 169 | : flat_map(__ctor_uses_allocator_tag{}, | |
| 170 | __alloc, | |
| 171 | __other.__containers_.keys, | |
| 172 | __other.__containers_.values, | |
| 173 | __other.__compare_) {} | |
| 174 | ||
| 175 | template <class _Allocator> | |
| 176 | requires __allocator_ctor_constraint<_Allocator> | |
| 177 | _LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other, const _Allocator& __alloc) | |
| 178 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 179 | try | |
| 180 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 181 | : flat_map(__ctor_uses_allocator_tag{}, | |
| 182 | __alloc, | |
| 183 | std::move(__other.__containers_.keys), | |
| 184 | std::move(__other.__containers_.values), | |
| 185 | std::move(__other.__compare_)) { | |
| 186 | __other.clear(); | |
| 187 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 188 | } catch (...) { | |
| 189 | __other.clear(); | |
| 190 | throw; | |
| 191 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 192 | } | |
| 193 | ||
| 194 | _LIBCPP_HIDE_FROM_ABI flat_map( | |
| 195 | key_container_type __key_cont, mapped_container_type __mapped_cont, const key_compare& __comp = key_compare()) | |
| 196 | : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) { | |
| 197 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 198 | "flat_map keys and mapped containers have different size"); | |
| 199 | __sort_and_unique(); | |
| 200 | } | |
| 201 | ||
| 202 | template <class _Allocator> | |
| 203 | requires __allocator_ctor_constraint<_Allocator> | |
| 204 | _LIBCPP_HIDE_FROM_ABI | |
| 205 | flat_map(const key_container_type& __key_cont, const mapped_container_type& __mapped_cont, const _Allocator& __alloc) | |
| 206 | : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) { | |
| 207 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 208 | "flat_map keys and mapped containers have different size"); | |
| 209 | __sort_and_unique(); | |
| 210 | } | |
| 211 | ||
| 212 | template <class _Allocator> | |
| 213 | requires __allocator_ctor_constraint<_Allocator> | |
| 214 | _LIBCPP_HIDE_FROM_ABI | |
| 215 | flat_map(const key_container_type& __key_cont, | |
| 216 | const mapped_container_type& __mapped_cont, | |
| 217 | const key_compare& __comp, | |
| 218 | const _Allocator& __alloc) | |
| 219 | : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) { | |
| 220 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 221 | "flat_map keys and mapped containers have different size"); | |
| 222 | __sort_and_unique(); | |
| 223 | } | |
| 224 | ||
| 225 | _LIBCPP_HIDE_FROM_ABI | |
| 226 | flat_map(sorted_unique_t, | |
| 227 | key_container_type __key_cont, | |
| 228 | mapped_container_type __mapped_cont, | |
| 229 | const key_compare& __comp = key_compare()) | |
| 230 | : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) { | |
| 231 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 232 | "flat_map keys and mapped containers have different size"); | |
| 233 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | |
| 234 | __is_sorted_and_unique(__containers_.keys), "Either the key container is not sorted or it contains duplicates"); | |
| 235 | } | |
| 236 | ||
| 237 | template <class _Allocator> | |
| 238 | requires __allocator_ctor_constraint<_Allocator> | |
| 239 | _LIBCPP_HIDE_FROM_ABI | |
| 240 | flat_map(sorted_unique_t, | |
| 241 | const key_container_type& __key_cont, | |
| 242 | const mapped_container_type& __mapped_cont, | |
| 243 | const _Allocator& __alloc) | |
| 244 | : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) { | |
| 245 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 246 | "flat_map keys and mapped containers have different size"); | |
| 247 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | |
| 248 | __is_sorted_and_unique(__containers_.keys), "Either the key container is not sorted or it contains duplicates"); | |
| 249 | } | |
| 250 | ||
| 251 | template <class _Allocator> | |
| 252 | requires __allocator_ctor_constraint<_Allocator> | |
| 253 | _LIBCPP_HIDE_FROM_ABI | |
| 254 | flat_map(sorted_unique_t, | |
| 255 | const key_container_type& __key_cont, | |
| 256 | const mapped_container_type& __mapped_cont, | |
| 257 | const key_compare& __comp, | |
| 258 | const _Allocator& __alloc) | |
| 259 | : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) { | |
| 260 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 261 | "flat_map keys and mapped containers have different size"); | |
| 262 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | |
| 263 | __is_sorted_and_unique(__containers_.keys), "Either the key container is not sorted or it contains duplicates"); | |
| 264 | } | |
| 265 | ||
| 266 | _LIBCPP_HIDE_FROM_ABI explicit flat_map(const key_compare& __comp) : __containers_(), __compare_(__comp) {} | |
| 267 | ||
| 268 | template <class _Allocator> | |
| 269 | requires __allocator_ctor_constraint<_Allocator> | |
| 270 | _LIBCPP_HIDE_FROM_ABI flat_map(const key_compare& __comp, const _Allocator& __alloc) | |
| 271 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {} | |
| 272 | ||
| 273 | template <class _Allocator> | |
| 274 | requires __allocator_ctor_constraint<_Allocator> | |
| 275 | _LIBCPP_HIDE_FROM_ABI explicit flat_map(const _Allocator& __alloc) | |
| 276 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {} | |
| 277 | ||
| 278 | template <class _InputIterator> | |
| 279 | requires __has_input_iterator_category<_InputIterator>::value | |
| 280 | _LIBCPP_HIDE_FROM_ABI | |
| 281 | flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | |
| 282 | : __containers_(), __compare_(__comp) { | |
| 283 | insert(__first, __last); | |
| 284 | } | |
| 285 | ||
| 286 | template <class _InputIterator, class _Allocator> | |
| 287 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | |
| 288 | _LIBCPP_HIDE_FROM_ABI | |
| 289 | flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc) | |
| 290 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | |
| 291 | insert(__first, __last); | |
| 292 | } | |
| 293 | ||
| 294 | template <class _InputIterator, class _Allocator> | |
| 295 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | |
| 296 | _LIBCPP_HIDE_FROM_ABI flat_map(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | |
| 297 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) { | |
| 298 | insert(__first, __last); | |
| 299 | } | |
| 300 | ||
| 301 | template <_ContainerCompatibleRange<value_type> _Range> | |
| 302 | _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t __fr, _Range&& __rg) | |
| 303 | : flat_map(__fr, std::forward<_Range>(__rg), key_compare()) {} | |
| 304 | ||
| 305 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | |
| 306 | requires __allocator_ctor_constraint<_Allocator> | |
| 307 | _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const _Allocator& __alloc) | |
| 308 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) { | |
| 309 | insert_range(std::forward<_Range>(__rg)); | |
| 310 | } | |
| 311 | ||
| 312 | template <_ContainerCompatibleRange<value_type> _Range> | |
| 313 | _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_map(__comp) { | |
| 314 | insert_range(std::forward<_Range>(__rg)); | |
| 315 | } | |
| 316 | ||
| 317 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | |
| 318 | requires __allocator_ctor_constraint<_Allocator> | |
| 319 | _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc) | |
| 320 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | |
| 321 | insert_range(std::forward<_Range>(__rg)); | |
| 322 | } | |
| 323 | ||
| 324 | template <class _InputIterator> | |
| 325 | requires __has_input_iterator_category<_InputIterator>::value | |
| 326 | _LIBCPP_HIDE_FROM_ABI | |
| 327 | flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | |
| 328 | : __containers_(), __compare_(__comp) { | |
| 329 | insert(sorted_unique, __first, __last); | |
| 330 | } | |
| 331 | template <class _InputIterator, class _Allocator> | |
| 332 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | |
| 333 | _LIBCPP_HIDE_FROM_ABI | |
| 334 | flat_map(sorted_unique_t, | |
| 335 | _InputIterator __first, | |
| 336 | _InputIterator __last, | |
| 337 | const key_compare& __comp, | |
| 338 | const _Allocator& __alloc) | |
| 339 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | |
| 340 | insert(sorted_unique, __first, __last); | |
| 341 | } | |
| 342 | ||
| 343 | template <class _InputIterator, class _Allocator> | |
| 344 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | |
| 345 | _LIBCPP_HIDE_FROM_ABI | |
| 346 | flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | |
| 347 | : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) { | |
| 348 | insert(sorted_unique, __first, __last); | |
| 349 | } | |
| 350 | ||
| 351 | _LIBCPP_HIDE_FROM_ABI flat_map(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | |
| 352 | : flat_map(__il.begin(), __il.end(), __comp) {} | |
| 353 | ||
| 354 | template <class _Allocator> | |
| 355 | requires __allocator_ctor_constraint<_Allocator> | |
| 356 | _LIBCPP_HIDE_FROM_ABI | |
| 357 | flat_map(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | |
| 358 | : flat_map(__il.begin(), __il.end(), __comp, __alloc) {} | |
| 359 | ||
| 360 | template <class _Allocator> | |
| 361 | requires __allocator_ctor_constraint<_Allocator> | |
| 362 | _LIBCPP_HIDE_FROM_ABI flat_map(initializer_list<value_type> __il, const _Allocator& __alloc) | |
| 363 | : flat_map(__il.begin(), __il.end(), __alloc) {} | |
| 364 | ||
| 365 | _LIBCPP_HIDE_FROM_ABI | |
| 366 | flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | |
| 367 | : flat_map(sorted_unique, __il.begin(), __il.end(), __comp) {} | |
| 368 | ||
| 369 | template <class _Allocator> | |
| 370 | requires __allocator_ctor_constraint<_Allocator> | |
| 371 | _LIBCPP_HIDE_FROM_ABI | |
| 372 | flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | |
| 373 | : flat_map(sorted_unique, __il.begin(), __il.end(), __comp, __alloc) {} | |
| 374 | ||
| 375 | template <class _Allocator> | |
| 376 | requires __allocator_ctor_constraint<_Allocator> | |
| 377 | _LIBCPP_HIDE_FROM_ABI flat_map(sorted_unique_t, initializer_list<value_type> __il, const _Allocator& __alloc) | |
| 378 | : flat_map(sorted_unique, __il.begin(), __il.end(), __alloc) {} | |
| 379 | ||
| 380 | _LIBCPP_HIDE_FROM_ABI flat_map& operator=(initializer_list<value_type> __il) { | |
| 381 | clear(); | |
| 382 | insert(__il); | |
| 383 | return *this; | |
| 384 | } | |
| 385 | ||
| 386 | _LIBCPP_HIDE_FROM_ABI flat_map& operator=(const flat_map&) = default; | |
| 387 | ||
| 388 | _LIBCPP_HIDE_FROM_ABI flat_map& operator=(flat_map&& __other) noexcept( | |
| 389 | is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> && | |
| 390 | is_nothrow_move_assignable_v<_Compare>) { | |
| 391 | // No matter what happens, we always want to clear the other container before returning | |
| 392 | // since we moved from it | |
| 393 | auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; }); | |
| 394 | { | |
| 395 | // If an exception is thrown, we have no choice but to clear *this to preserve invariants | |
| 396 | auto __on_exception = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 397 | __containers_ = std::move(__other.__containers_); | |
| 398 | __compare_ = std::move(__other.__compare_); | |
| 399 | __on_exception.__complete(); | |
| 400 | } | |
| 401 | return *this; | |
| 402 | } | |
| 403 | ||
| 404 | // iterators | |
| 405 | _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept { | |
| 406 | return iterator(__containers_.keys.begin(), __containers_.values.begin()); | |
| 407 | } | |
| 408 | ||
| 409 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { | |
| 410 | return const_iterator(__containers_.keys.begin(), __containers_.values.begin()); | |
| 411 | } | |
| 412 | ||
| 413 | _LIBCPP_HIDE_FROM_ABI iterator end() noexcept { | |
| 414 | return iterator(__containers_.keys.end(), __containers_.values.end()); | |
| 415 | } | |
| 416 | ||
| 417 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { | |
| 418 | return const_iterator(__containers_.keys.end(), __containers_.values.end()); | |
| 419 | } | |
| 420 | ||
| 421 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } | |
| 422 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } | |
| 423 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); } | |
| 424 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } | |
| 425 | ||
| 426 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); } | |
| 427 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); } | |
| 428 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } | |
| 429 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } | |
| 430 | ||
| 431 | // [flat.map.capacity], capacity | |
| 432 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __containers_.keys.empty(); } | |
| 433 | ||
| 434 | _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __containers_.keys.size(); } | |
| 435 | ||
| 436 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept { | |
| 437 | return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size()); | |
| 438 | } | |
| 439 | ||
| 440 | // [flat.map.access], element access | |
| 441 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __x) | |
| 442 | requires is_constructible_v<mapped_type> | |
| 443 | { | |
| 444 | return try_emplace(__x).first->second; | |
| 445 | } | |
| 446 | ||
| 447 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __x) | |
| 448 | requires is_constructible_v<mapped_type> | |
| 449 | { | |
| 450 | return try_emplace(std::move(__x)).first->second; | |
| 451 | } | |
| 452 | ||
| 453 | template <class _Kp> | |
| 454 | requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type> && | |
| 455 | !is_convertible_v<_Kp &&, const_iterator> && !is_convertible_v<_Kp &&, iterator>) | |
| 456 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](_Kp&& __x) { | |
| 457 | return try_emplace(std::forward<_Kp>(__x)).first->second; | |
| 458 | } | |
| 459 | ||
| 460 | _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __x) { | |
| 461 | auto __it = find(__x); | |
| 462 | if (__it == end()) { | |
| 463 | std::__throw_out_of_range("flat_map::at(const key_type&): Key does not exist"); | |
| 464 | } | |
| 465 | return __it->second; | |
| 466 | } | |
| 467 | ||
| 468 | _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __x) const { | |
| 469 | auto __it = find(__x); | |
| 470 | if (__it == end()) { | |
| 471 | std::__throw_out_of_range("flat_map::at(const key_type&) const: Key does not exist"); | |
| 472 | } | |
| 473 | return __it->second; | |
| 474 | } | |
| 475 | ||
| 476 | template <class _Kp> | |
| 477 | requires __is_compare_transparent | |
| 478 | _LIBCPP_HIDE_FROM_ABI mapped_type& at(const _Kp& __x) { | |
| 479 | auto __it = find(__x); | |
| 480 | if (__it == end()) { | |
| 481 | std::__throw_out_of_range("flat_map::at(const K&): Key does not exist"); | |
| 482 | } | |
| 483 | return __it->second; | |
| 484 | } | |
| 485 | ||
| 486 | template <class _Kp> | |
| 487 | requires __is_compare_transparent | |
| 488 | _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const _Kp& __x) const { | |
| 489 | auto __it = find(__x); | |
| 490 | if (__it == end()) { | |
| 491 | std::__throw_out_of_range("flat_map::at(const K&) const: Key does not exist"); | |
| 492 | } | |
| 493 | return __it->second; | |
| 494 | } | |
| 495 | ||
| 496 | // [flat.map.modifiers], modifiers | |
| 497 | template <class... _Args> | |
| 498 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> | |
| 499 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) { | |
| 500 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); | |
| 501 | return __try_emplace(std::move(__pair.first), std::move(__pair.second)); | |
| 502 | } | |
| 503 | ||
| 504 | template <class... _Args> | |
| 505 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> | |
| 506 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) { | |
| 507 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); | |
| 508 | return __try_emplace_hint(__hint, std::move(__pair.first), std::move(__pair.second)).first; | |
| 509 | } | |
| 510 | ||
| 511 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return emplace(__x); } | |
| 512 | ||
| 513 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) { return emplace(std::move(__x)); } | |
| 514 | ||
| 515 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) { | |
| 516 | return emplace_hint(__hint, __x); | |
| 517 | } | |
| 518 | ||
| 519 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) { | |
| 520 | return emplace_hint(__hint, std::move(__x)); | |
| 521 | } | |
| 522 | ||
| 523 | template <class _PairLike> | |
| 524 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> | |
| 525 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_PairLike&& __x) { | |
| 526 | return emplace(std::forward<_PairLike>(__x)); | |
| 527 | } | |
| 528 | ||
| 529 | template <class _PairLike> | |
| 530 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> | |
| 531 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, _PairLike&& __x) { | |
| 532 | return emplace_hint(__hint, std::forward<_PairLike>(__x)); | |
| 533 | } | |
| 534 | ||
| 535 | template <class _InputIterator> | |
| 536 | requires __has_input_iterator_category<_InputIterator>::value | |
| 537 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) { | |
| 538 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | |
| 539 | __reserve(__last - __first); | |
| 540 | } | |
| 541 | __append_sort_merge_unique</*WasSorted = */ false>(std::move(__first), std::move(__last)); | |
| 542 | } | |
| 543 | ||
| 544 | template <class _InputIterator> | |
| 545 | requires __has_input_iterator_category<_InputIterator>::value | |
| 546 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) { | |
| 547 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | |
| 548 | __reserve(__last - __first); | |
| 549 | } | |
| 550 | ||
| 551 | __append_sort_merge_unique</*WasSorted = */ true>(std::move(__first), std::move(__last)); | |
| 552 | } | |
| 553 | ||
| 554 | template <_ContainerCompatibleRange<value_type> _Range> | |
| 555 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | |
| 556 | if constexpr (ranges::sized_range<_Range>) { | |
| 557 | __reserve(ranges::size(__range)); | |
| 558 | } | |
| 559 | ||
| 560 | __append_sort_merge_unique</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range)); | |
| 561 | } | |
| 562 | ||
| 563 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | |
| 564 | ||
| 565 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, initializer_list<value_type> __il) { | |
| 566 | insert(sorted_unique, __il.begin(), __il.end()); | |
| 567 | } | |
| 568 | ||
| 569 | _LIBCPP_HIDE_FROM_ABI containers extract() && { | |
| 570 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 571 | auto __ret = std::move(__containers_); | |
| 572 | return __ret; | |
| 573 | } | |
| 574 | ||
| 575 | _LIBCPP_HIDE_FROM_ABI void replace(key_container_type&& __key_cont, mapped_container_type&& __mapped_cont) { | |
| 576 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( | |
| 577 | __key_cont.size() == __mapped_cont.size(), "flat_map keys and mapped containers have different size"); | |
| 578 | ||
| 579 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | |
| 580 | __is_sorted_and_unique(__key_cont), "Either the key container is not sorted or it contains duplicates"); | |
| 581 | auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 582 | __containers_.keys = std::move(__key_cont); | |
| 583 | __containers_.values = std::move(__mapped_cont); | |
| 584 | __guard.__complete(); | |
| 585 | } | |
| 586 | ||
| 587 | template <class... _Args> | |
| 588 | requires is_constructible_v<mapped_type, _Args...> | |
| 589 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __key, _Args&&... __args) { | |
| 590 | return __try_emplace(__key, std::forward<_Args>(__args)...); | |
| 591 | } | |
| 592 | ||
| 593 | template <class... _Args> | |
| 594 | requires is_constructible_v<mapped_type, _Args...> | |
| 595 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __key, _Args&&... __args) { | |
| 596 | return __try_emplace(std::move(__key), std::forward<_Args>(__args)...); | |
| 597 | } | |
| 598 | ||
| 599 | template <class _Kp, class... _Args> | |
| 600 | requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> && | |
| 601 | is_constructible_v<mapped_type, _Args...> && !is_convertible_v<_Kp &&, const_iterator> && | |
| 602 | !is_convertible_v<_Kp &&, iterator>) | |
| 603 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(_Kp&& __key, _Args&&... __args) { | |
| 604 | return __try_emplace(std::forward<_Kp>(__key), std::forward<_Args>(__args)...); | |
| 605 | } | |
| 606 | ||
| 607 | template <class... _Args> | |
| 608 | requires is_constructible_v<mapped_type, _Args...> | |
| 609 | _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, const key_type& __key, _Args&&... __args) { | |
| 610 | return __try_emplace_hint(__hint, __key, std::forward<_Args>(__args)...).first; | |
| 611 | } | |
| 612 | ||
| 613 | template <class... _Args> | |
| 614 | requires is_constructible_v<mapped_type, _Args...> | |
| 615 | _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, key_type&& __key, _Args&&... __args) { | |
| 616 | return __try_emplace_hint(__hint, std::move(__key), std::forward<_Args>(__args)...).first; | |
| 617 | } | |
| 618 | ||
| 619 | template <class _Kp, class... _Args> | |
| 620 | requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type, _Args...> | |
| 621 | _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, _Kp&& __key, _Args&&... __args) { | |
| 622 | return __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Args>(__args)...).first; | |
| 623 | } | |
| 624 | ||
| 625 | template <class _Mapped> | |
| 626 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> | |
| 627 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __key, _Mapped&& __obj) { | |
| 628 | return __insert_or_assign(__key, std::forward<_Mapped>(__obj)); | |
| 629 | } | |
| 630 | ||
| 631 | template <class _Mapped> | |
| 632 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> | |
| 633 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __key, _Mapped&& __obj) { | |
| 634 | return __insert_or_assign(std::move(__key), std::forward<_Mapped>(__obj)); | |
| 635 | } | |
| 636 | ||
| 637 | template <class _Kp, class _Mapped> | |
| 638 | requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> && | |
| 639 | is_constructible_v<mapped_type, _Mapped> | |
| 640 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(_Kp&& __key, _Mapped&& __obj) { | |
| 641 | return __insert_or_assign(std::forward<_Kp>(__key), std::forward<_Mapped>(__obj)); | |
| 642 | } | |
| 643 | ||
| 644 | template <class _Mapped> | |
| 645 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> | |
| 646 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, const key_type& __key, _Mapped&& __obj) { | |
| 647 | return __insert_or_assign(__hint, __key, std::forward<_Mapped>(__obj)); | |
| 648 | } | |
| 649 | ||
| 650 | template <class _Mapped> | |
| 651 | requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped> | |
| 652 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, key_type&& __key, _Mapped&& __obj) { | |
| 653 | return __insert_or_assign(__hint, std::move(__key), std::forward<_Mapped>(__obj)); | |
| 654 | } | |
| 655 | ||
| 656 | template <class _Kp, class _Mapped> | |
| 657 | requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> && | |
| 658 | is_constructible_v<mapped_type, _Mapped> | |
| 659 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __obj) { | |
| 660 | return __insert_or_assign(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__obj)); | |
| 661 | } | |
| 662 | ||
| 663 | _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) { | |
| 664 | return __erase(__position.__key_iter_, __position.__mapped_iter_); | |
| 665 | } | |
| 666 | ||
| 667 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position) { | |
| 668 | return __erase(__position.__key_iter_, __position.__mapped_iter_); | |
| 669 | } | |
| 670 | ||
| 671 | _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) { | |
| 672 | auto __iter = find(__x); | |
| 673 | if (__iter != end()) { | |
| 674 | erase(__iter); | |
| 675 | return 1; | |
| 676 | } | |
| 677 | return 0; | |
| 678 | } | |
| 679 | ||
| 680 | template <class _Kp> | |
| 681 | requires(__is_compare_transparent && !is_convertible_v<_Kp &&, iterator> && | |
| 682 | !is_convertible_v<_Kp &&, const_iterator>) | |
| 683 | _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) { | |
| 684 | auto [__first, __last] = equal_range(__x); | |
| 685 | auto __res = __last - __first; | |
| 686 | erase(__first, __last); | |
| 687 | return __res; | |
| 688 | } | |
| 689 | ||
| 690 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) { | |
| 691 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 692 | auto __key_it = __containers_.keys.erase(__first.__key_iter_, __last.__key_iter_); | |
| 693 | auto __mapped_it = __containers_.values.erase(__first.__mapped_iter_, __last.__mapped_iter_); | |
| 694 | __on_failure.__complete(); | |
| 695 | return iterator(std::move(__key_it), std::move(__mapped_it)); | |
| 696 | } | |
| 697 | ||
| 698 | _LIBCPP_HIDE_FROM_ABI void swap(flat_map& __y) noexcept { | |
| 699 | // warning: The spec has unconditional noexcept, which means that | |
| 700 | // if any of the following functions throw an exception, | |
| 701 | // std::terminate will be called. | |
| 702 | // This is discussed in P2767, which hasn't been voted on yet. | |
| 703 | ranges::swap(__compare_, __y.__compare_); | |
| 704 | ranges::swap(__containers_.keys, __y.__containers_.keys); | |
| 705 | ranges::swap(__containers_.values, __y.__containers_.values); | |
| 706 | } | |
| 707 | ||
| 708 | _LIBCPP_HIDE_FROM_ABI void clear() noexcept { | |
| 709 | __containers_.keys.clear(); | |
| 710 | __containers_.values.clear(); | |
| 711 | } | |
| 712 | ||
| 713 | // observers | |
| 714 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; } | |
| 715 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__compare_); } | |
| 716 | ||
| 717 | _LIBCPP_HIDE_FROM_ABI const key_container_type& keys() const noexcept { return __containers_.keys; } | |
| 718 | _LIBCPP_HIDE_FROM_ABI const mapped_container_type& values() const noexcept { return __containers_.values; } | |
| 719 | ||
| 720 | // map operations | |
| 721 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); } | |
| 722 | ||
| 723 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); } | |
| 724 | ||
| 725 | template <class _Kp> | |
| 726 | requires __is_compare_transparent | |
| 727 | _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) { | |
| 728 | return __find_impl(*this, __x); | |
| 729 | } | |
| 730 | ||
| 731 | template <class _Kp> | |
| 732 | requires __is_compare_transparent | |
| 733 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const { | |
| 734 | return __find_impl(*this, __x); | |
| 735 | } | |
| 736 | ||
| 737 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const { return contains(__x) ? 1 : 0; } | |
| 738 | ||
| 739 | template <class _Kp> | |
| 740 | requires __is_compare_transparent | |
| 741 | _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const { | |
| 742 | return contains(__x) ? 1 : 0; | |
| 743 | } | |
| 744 | ||
| 745 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); } | |
| 746 | ||
| 747 | template <class _Kp> | |
| 748 | requires __is_compare_transparent | |
| 749 | _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const { | |
| 750 | return find(__x) != end(); | |
| 751 | } | |
| 752 | ||
| 753 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) { return __lower_bound<iterator>(*this, __x); } | |
| 754 | ||
| 755 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const { | |
| 756 | return __lower_bound<const_iterator>(*this, __x); | |
| 757 | } | |
| 758 | ||
| 759 | template <class _Kp> | |
| 760 | requires __is_compare_transparent | |
| 761 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) { | |
| 762 | return __lower_bound<iterator>(*this, __x); | |
| 763 | } | |
| 764 | ||
| 765 | template <class _Kp> | |
| 766 | requires __is_compare_transparent | |
| 767 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const { | |
| 768 | return __lower_bound<const_iterator>(*this, __x); | |
| 769 | } | |
| 770 | ||
| 771 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) { return __upper_bound<iterator>(*this, __x); } | |
| 772 | ||
| 773 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const { | |
| 774 | return __upper_bound<const_iterator>(*this, __x); | |
| 775 | } | |
| 776 | ||
| 777 | template <class _Kp> | |
| 778 | requires __is_compare_transparent | |
| 779 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) { | |
| 780 | return __upper_bound<iterator>(*this, __x); | |
| 781 | } | |
| 782 | ||
| 783 | template <class _Kp> | |
| 784 | requires __is_compare_transparent | |
| 785 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const { | |
| 786 | return __upper_bound<const_iterator>(*this, __x); | |
| 787 | } | |
| 788 | ||
| 789 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) { | |
| 790 | return __equal_range_impl(*this, __x); | |
| 791 | } | |
| 792 | ||
| 793 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const { | |
| 794 | return __equal_range_impl(*this, __x); | |
| 795 | } | |
| 796 | ||
| 797 | template <class _Kp> | |
| 798 | requires __is_compare_transparent | |
| 799 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) { | |
| 800 | return __equal_range_impl(*this, __x); | |
| 801 | } | |
| 802 | template <class _Kp> | |
| 803 | requires __is_compare_transparent | |
| 804 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const { | |
| 805 | return __equal_range_impl(*this, __x); | |
| 806 | } | |
| 807 | ||
| 808 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_map& __x, const flat_map& __y) { | |
| 809 | return ranges::equal(__x, __y); | |
| 810 | } | |
| 811 | ||
| 812 | friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_map& __x, const flat_map& __y) { | |
| 813 | return std::lexicographical_compare_three_way( | |
| 814 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | |
| 815 | } | |
| 816 | ||
| 817 | friend _LIBCPP_HIDE_FROM_ABI void swap(flat_map& __x, flat_map& __y) noexcept { __x.swap(__y); } | |
| 818 | ||
| 819 | private: | |
| 820 | struct __ctor_uses_allocator_tag { | |
| 821 | explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_tag() = default; | |
| 822 | }; | |
| 823 | struct __ctor_uses_allocator_empty_tag { | |
| 824 | explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_empty_tag() = default; | |
| 825 | }; | |
| 826 | ||
| 827 | template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg> | |
| 828 | requires __allocator_ctor_constraint<_Allocator> | |
| 829 | _LIBCPP_HIDE_FROM_ABI | |
| 830 | flat_map(__ctor_uses_allocator_tag, | |
| 831 | const _Allocator& __alloc, | |
| 832 | _KeyCont&& __key_cont, | |
| 833 | _MappedCont&& __mapped_cont, | |
| 834 | _CompArg&&... __comp) | |
| 835 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>( | |
| 836 | __alloc, std::forward<_KeyCont>(__key_cont)), | |
| 837 | .values = std::make_obj_using_allocator<mapped_container_type>( | |
| 838 | __alloc, std::forward<_MappedCont>(__mapped_cont))}, | |
| 839 | __compare_(std::forward<_CompArg>(__comp)...) {} | |
| 840 | ||
| 841 | template <class _Allocator, class... _CompArg> | |
| 842 | requires __allocator_ctor_constraint<_Allocator> | |
| 843 | _LIBCPP_HIDE_FROM_ABI flat_map(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp) | |
| 844 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc), | |
| 845 | .values = std::make_obj_using_allocator<mapped_container_type>(__alloc)}, | |
| 846 | __compare_(std::forward<_CompArg>(__comp)...) {} | |
| 847 | ||
| 848 | _LIBCPP_HIDE_FROM_ABI bool __is_sorted_and_unique(auto&& __key_container) const { | |
| 849 | auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); }; | |
| 850 | return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container); | |
| 851 | } | |
| 852 | ||
| 853 | // This function is only used in constructors. So there is not exception handling in this function. | |
| 854 | // If the function exits via an exception, there will be no flat_map object constructed, thus, there | |
| 855 | // is no invariant state to preserve | |
| 856 | _LIBCPP_HIDE_FROM_ABI void __sort_and_unique() { | |
| 857 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); | |
| 858 | ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); }); | |
| 859 | auto __dup_start = ranges::unique(__zv, __key_equiv(__compare_)).begin(); | |
| 860 | auto __dist = ranges::distance(__zv.begin(), __dup_start); | |
| 861 | __containers_.keys.erase(__containers_.keys.begin() + __dist, __containers_.keys.end()); | |
| 862 | __containers_.values.erase(__containers_.values.begin() + __dist, __containers_.values.end()); | |
| 863 | } | |
| 864 | ||
| 865 | template <bool _WasSorted, class _InputIterator, class _Sentinel> | |
| 866 | _LIBCPP_HIDE_FROM_ABI void __append_sort_merge_unique(_InputIterator __first, _Sentinel __last) { | |
| 867 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 868 | size_t __num_of_appended = __flat_map_utils::__append(*this, std::move(__first), std::move(__last)); | |
| 869 | if (__num_of_appended != 0) { | |
| 870 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); | |
| 871 | auto __append_start_offset = __containers_.keys.size() - __num_of_appended; | |
| 872 | auto __end = __zv.end(); | |
| 873 | auto __compare_key = [this](const auto& __p1, const auto& __p2) { | |
| 874 | return __compare_(std::get<0>(__p1), std::get<0>(__p2)); | |
| 875 | }; | |
| 876 | if constexpr (!_WasSorted) { | |
| 877 | ranges::sort(__zv.begin() + __append_start_offset, __end, __compare_key); | |
| 878 | } else { | |
| 879 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | |
| 880 | __is_sorted_and_unique(__containers_.keys | ranges::views::drop(__append_start_offset)), | |
| 881 | "Either the key container is not sorted or it contains duplicates"); | |
| 882 | } | |
| 883 | ranges::inplace_merge(__zv.begin(), __zv.begin() + __append_start_offset, __end, __compare_key); | |
| 884 | ||
| 885 | auto __dup_start = ranges::unique(__zv, __key_equiv(__compare_)).begin(); | |
| 886 | auto __dist = ranges::distance(__zv.begin(), __dup_start); | |
| 887 | __containers_.keys.erase(__containers_.keys.begin() + __dist, __containers_.keys.end()); | |
| 888 | __containers_.values.erase(__containers_.values.begin() + __dist, __containers_.values.end()); | |
| 889 | } | |
| 890 | __on_failure.__complete(); | |
| 891 | } | |
| 892 | ||
| 893 | template <class _Self, class _Kp> | |
| 894 | _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) { | |
| 895 | auto __it = __self.lower_bound(__key); | |
| 896 | auto __last = __self.end(); | |
| 897 | if (__it == __last || __self.__compare_(__key, __it->first)) { | |
| 898 | return __last; | |
| 899 | } | |
| 900 | return __it; | |
| 901 | } | |
| 902 | ||
| 903 | template <class _Self, class _Kp> | |
| 904 | _LIBCPP_HIDE_FROM_ABI static auto __key_equal_range(_Self&& __self, const _Kp& __key) { | |
| 905 | auto __it = ranges::lower_bound(__self.__containers_.keys, __key, __self.__compare_); | |
| 906 | auto __last = __self.__containers_.keys.end(); | |
| 907 | if (__it == __last || __self.__compare_(__key, *__it)) { | |
| 908 | return std::make_pair(__it, __it); | |
| 909 | } | |
| 910 | return std::make_pair(__it, std::next(__it)); | |
| 911 | } | |
| 912 | ||
| 913 | template <class _Self, class _Kp> | |
| 914 | _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { | |
| 915 | auto [__key_first, __key_last] = __key_equal_range(__self, __key); | |
| 916 | ||
| 917 | const auto __make_mapped_iter = [&](const auto& __key_iter) { | |
| 918 | return __self.__containers_.values.begin() + | |
| 919 | static_cast<ranges::range_difference_t<mapped_container_type>>( | |
| 920 | ranges::distance(__self.__containers_.keys.begin(), __key_iter)); | |
| 921 | }; | |
| 922 | ||
| 923 | using __iterator_type = ranges::iterator_t<decltype(__self)>; | |
| 924 | return std::make_pair(__iterator_type(__key_first, __make_mapped_iter(__key_first)), | |
| 925 | __iterator_type(__key_last, __make_mapped_iter(__key_last))); | |
| 926 | } | |
| 927 | ||
| 928 | template <class _Res, class _Self, class _Kp> | |
| 929 | _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) { | |
| 930 | return __binary_search<_Res>(__self, ranges::lower_bound, __x); | |
| 931 | } | |
| 932 | ||
| 933 | template <class _Res, class _Self, class _Kp> | |
| 934 | _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) { | |
| 935 | return __binary_search<_Res>(__self, ranges::upper_bound, __x); | |
| 936 | } | |
| 937 | ||
| 938 | template <class _Res, class _Self, class _Fn, class _Kp> | |
| 939 | _LIBCPP_HIDE_FROM_ABI static _Res __binary_search(_Self&& __self, _Fn __search_fn, _Kp& __x) { | |
| 940 | auto __key_iter = __search_fn(__self.__containers_.keys, __x, __self.__compare_); | |
| 941 | auto __mapped_iter = | |
| 942 | __self.__containers_.values.begin() + | |
| 943 | static_cast<ranges::range_difference_t<mapped_container_type>>( | |
| 944 | ranges::distance(__self.__containers_.keys.begin(), __key_iter)); | |
| 945 | ||
| 946 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); | |
| 947 | } | |
| 948 | ||
| 949 | template <class _KeyArg, class... _MArgs> | |
| 950 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __try_emplace(_KeyArg&& __key, _MArgs&&... __mapped_args) { | |
| 951 | auto __key_it = ranges::lower_bound(__containers_.keys, __key, __compare_); | |
| 952 | auto __mapped_it = __containers_.values.begin() + ranges::distance(__containers_.keys.begin(), __key_it); | |
| 953 | ||
| 954 | if (__key_it == __containers_.keys.end() || __compare_(__key, *__key_it)) { | |
| 955 | return pair<iterator, bool>( | |
| 956 | __flat_map_utils::__emplace_exact_pos( | |
| 957 | *this, | |
| 958 | std::move(__key_it), | |
| 959 | std::move(__mapped_it), | |
| 960 | std::forward<_KeyArg>(__key), | |
| 961 | std::forward<_MArgs>(__mapped_args)...), | |
| 962 | true); | |
| 963 | } else { | |
| 964 | return pair<iterator, bool>(iterator(std::move(__key_it), std::move(__mapped_it)), false); | |
| 965 | } | |
| 966 | } | |
| 967 | ||
| 968 | template <class _Kp> | |
| 969 | _LIBCPP_HIDE_FROM_ABI bool __is_hint_correct(const_iterator __hint, _Kp&& __key) { | |
| 970 | if (__hint != cbegin() && !__compare_((__hint - 1)->first, __key)) { | |
| 971 | return false; | |
| 972 | } | |
| 973 | if (__hint != cend() && __compare_(__hint->first, __key)) { | |
| 974 | return false; | |
| 975 | } | |
| 976 | return true; | |
| 977 | } | |
| 978 | ||
| 979 | template <class _Kp, class... _Args> | |
| 980 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __try_emplace_hint(const_iterator __hint, _Kp&& __key, _Args&&... __args) { | |
| 981 | if (__is_hint_correct(__hint, __key)) { | |
| 982 | if (__hint == cend() || __compare_(__key, __hint->first)) { | |
| 983 | return {__flat_map_utils::__emplace_exact_pos( | |
| 984 | *this, | |
| 985 | __hint.__key_iter_, | |
| 986 | __hint.__mapped_iter_, | |
| 987 | std::forward<_Kp>(__key), | |
| 988 | std::forward<_Args>(__args)...), | |
| 989 | true}; | |
| 990 | } else { | |
| 991 | // key equals | |
| 992 | auto __dist = __hint - cbegin(); | |
| 993 | return {iterator(__containers_.keys.begin() + __dist, __containers_.values.begin() + __dist), false}; | |
| 994 | } | |
| 995 | } else { | |
| 996 | return __try_emplace(std::forward<_Kp>(__key), std::forward<_Args>(__args)...); | |
| 997 | } | |
| 998 | } | |
| 999 | ||
| 1000 | template <class _Kp, class _Mapped> | |
| 1001 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_or_assign(_Kp&& __key, _Mapped&& __mapped) { | |
| 1002 | auto __r = try_emplace(std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped)); | |
| 1003 | if (!__r.second) { | |
| 1004 | __r.first->second = std::forward<_Mapped>(__mapped); | |
| 1005 | } | |
| 1006 | return __r; | |
| 1007 | } | |
| 1008 | ||
| 1009 | template <class _Kp, class _Mapped> | |
| 1010 | _LIBCPP_HIDE_FROM_ABI iterator __insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __mapped) { | |
| 1011 | auto __r = __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped)); | |
| 1012 | if (!__r.second) { | |
| 1013 | __r.first->second = std::forward<_Mapped>(__mapped); | |
| 1014 | } | |
| 1015 | return __r.first; | |
| 1016 | } | |
| 1017 | ||
| 1018 | _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) { | |
| 1019 | if constexpr (requires { __containers_.keys.reserve(__size); }) { | |
| 1020 | __containers_.keys.reserve(__size); | |
| 1021 | } | |
| 1022 | ||
| 1023 | if constexpr (requires { __containers_.values.reserve(__size); }) { | |
| 1024 | __containers_.values.reserve(__size); | |
| 1025 | } | |
| 1026 | } | |
| 1027 | ||
| 1028 | template <class _KIter, class _MIter> | |
| 1029 | _LIBCPP_HIDE_FROM_ABI iterator __erase(_KIter __key_iter_to_remove, _MIter __mapped_iter_to_remove) { | |
| 1030 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 1031 | auto __key_iter = __containers_.keys.erase(__key_iter_to_remove); | |
| 1032 | auto __mapped_iter = __containers_.values.erase(__mapped_iter_to_remove); | |
| 1033 | __on_failure.__complete(); | |
| 1034 | return iterator(std::move(__key_iter), std::move(__mapped_iter)); | |
| 1035 | } | |
| 1036 | ||
| 1037 | template <class _Key2, class _Tp2, class _Compare2, class _KeyContainer2, class _MappedContainer2, class _Predicate> | |
| 1038 | friend typename flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>::size_type | |
| 1039 | erase_if(flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>&, _Predicate); | |
| 1040 | ||
| 1041 | friend __flat_map_utils; | |
| 1042 | ||
| 1043 | containers __containers_; | |
| 1044 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_; | |
| 1045 | ||
| 1046 | struct __key_equiv { | |
| 1047 | _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {} | |
| 1048 | _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const { | |
| 1049 | return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x)); | |
| 1050 | } | |
| 1051 | key_compare __comp_; | |
| 1052 | }; | |
| 1053 | }; | |
| 1054 | ||
| 1055 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> | |
| 1056 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | |
| 1057 | !__is_allocator<_MappedContainer>::value && | |
| 1058 | is_invocable_v<const _Compare&, | |
| 1059 | const typename _KeyContainer::value_type&, | |
| 1060 | const typename _KeyContainer::value_type&>) | |
| 1061 | flat_map(_KeyContainer, _MappedContainer, _Compare = _Compare()) | |
| 1062 | -> flat_map<typename _KeyContainer::value_type, | |
| 1063 | typename _MappedContainer::value_type, | |
| 1064 | _Compare, | |
| 1065 | _KeyContainer, | |
| 1066 | _MappedContainer>; | |
| 1067 | ||
| 1068 | template <class _KeyContainer, class _MappedContainer, class _Allocator> | |
| 1069 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && | |
| 1070 | !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value) | |
| 1071 | flat_map(_KeyContainer, _MappedContainer, _Allocator) | |
| 1072 | -> flat_map<typename _KeyContainer::value_type, | |
| 1073 | typename _MappedContainer::value_type, | |
| 1074 | less<typename _KeyContainer::value_type>, | |
| 1075 | _KeyContainer, | |
| 1076 | _MappedContainer>; | |
| 1077 | ||
| 1078 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> | |
| 1079 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | |
| 1080 | !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> && | |
| 1081 | uses_allocator_v<_MappedContainer, _Allocator> && | |
| 1082 | is_invocable_v<const _Compare&, | |
| 1083 | const typename _KeyContainer::value_type&, | |
| 1084 | const typename _KeyContainer::value_type&>) | |
| 1085 | flat_map(_KeyContainer, _MappedContainer, _Compare, _Allocator) | |
| 1086 | -> flat_map<typename _KeyContainer::value_type, | |
| 1087 | typename _MappedContainer::value_type, | |
| 1088 | _Compare, | |
| 1089 | _KeyContainer, | |
| 1090 | _MappedContainer>; | |
| 1091 | ||
| 1092 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> | |
| 1093 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | |
| 1094 | !__is_allocator<_MappedContainer>::value && | |
| 1095 | is_invocable_v<const _Compare&, | |
| 1096 | const typename _KeyContainer::value_type&, | |
| 1097 | const typename _KeyContainer::value_type&>) | |
| 1098 | flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare = _Compare()) | |
| 1099 | -> flat_map<typename _KeyContainer::value_type, | |
| 1100 | typename _MappedContainer::value_type, | |
| 1101 | _Compare, | |
| 1102 | _KeyContainer, | |
| 1103 | _MappedContainer>; | |
| 1104 | ||
| 1105 | template <class _KeyContainer, class _MappedContainer, class _Allocator> | |
| 1106 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && | |
| 1107 | !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value) | |
| 1108 | flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Allocator) | |
| 1109 | -> flat_map<typename _KeyContainer::value_type, | |
| 1110 | typename _MappedContainer::value_type, | |
| 1111 | less<typename _KeyContainer::value_type>, | |
| 1112 | _KeyContainer, | |
| 1113 | _MappedContainer>; | |
| 1114 | ||
| 1115 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> | |
| 1116 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | |
| 1117 | !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> && | |
| 1118 | uses_allocator_v<_MappedContainer, _Allocator> && | |
| 1119 | is_invocable_v<const _Compare&, | |
| 1120 | const typename _KeyContainer::value_type&, | |
| 1121 | const typename _KeyContainer::value_type&>) | |
| 1122 | flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare, _Allocator) | |
| 1123 | -> flat_map<typename _KeyContainer::value_type, | |
| 1124 | typename _MappedContainer::value_type, | |
| 1125 | _Compare, | |
| 1126 | _KeyContainer, | |
| 1127 | _MappedContainer>; | |
| 1128 | ||
| 1129 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> | |
| 1130 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | |
| 1131 | flat_map(_InputIterator, _InputIterator, _Compare = _Compare()) | |
| 1132 | -> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; | |
| 1133 | ||
| 1134 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> | |
| 1135 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | |
| 1136 | flat_map(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare()) | |
| 1137 | -> flat_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; | |
| 1138 | ||
| 1139 | template <ranges::input_range _Range, | |
| 1140 | class _Compare = less<__range_key_type<_Range>>, | |
| 1141 | class _Allocator = allocator<byte>, | |
| 1142 | class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>> | |
| 1143 | flat_map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_map< | |
| 1144 | __range_key_type<_Range>, | |
| 1145 | __range_mapped_type<_Range>, | |
| 1146 | _Compare, | |
| 1147 | vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>, | |
| 1148 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; | |
| 1149 | ||
| 1150 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1151 | flat_map(from_range_t, _Range&&, _Allocator) -> flat_map< | |
| 1152 | __range_key_type<_Range>, | |
| 1153 | __range_mapped_type<_Range>, | |
| 1154 | less<__range_key_type<_Range>>, | |
| 1155 | vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>, | |
| 1156 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; | |
| 1157 | ||
| 1158 | template <class _Key, class _Tp, class _Compare = less<_Key>> | |
| 1159 | requires(!__is_allocator<_Compare>::value) | |
| 1160 | flat_map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>; | |
| 1161 | ||
| 1162 | template <class _Key, class _Tp, class _Compare = less<_Key>> | |
| 1163 | requires(!__is_allocator<_Compare>::value) | |
| 1164 | flat_map(sorted_unique_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_map<_Key, _Tp, _Compare>; | |
| 1165 | ||
| 1166 | template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Allocator> | |
| 1167 | struct uses_allocator<flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>, _Allocator> | |
| 1168 | : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator>> {}; | |
| 1169 | ||
| 1170 | template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Predicate> | |
| 1171 | _LIBCPP_HIDE_FROM_ABI typename flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::size_type | |
| 1172 | erase_if(flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>& __flat_map, _Predicate __pred) { | |
| 1173 | auto __zv = ranges::views::zip(__flat_map.__containers_.keys, __flat_map.__containers_.values); | |
| 1174 | auto __first = __zv.begin(); | |
| 1175 | auto __last = __zv.end(); | |
| 1176 | auto __guard = std::__make_exception_guard([&] { __flat_map.clear(); }); | |
| 1177 | auto __it = std::remove_if(__first, __last, [&](auto&& __zipped) -> bool { | |
| 1178 | using _Ref = typename flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::const_reference; | |
| 1179 | return __pred(_Ref(std::get<0>(__zipped), std::get<1>(__zipped))); | |
| 1180 | }); | |
| 1181 | auto __res = __last - __it; | |
| 1182 | auto __offset = __it - __first; | |
| 1183 | ||
| 1184 | const auto __erase_container = [&](auto& __cont) { __cont.erase(__cont.begin() + __offset, __cont.end()); }; | |
| 1185 | ||
| 1186 | __erase_container(__flat_map.__containers_.keys); | |
| 1187 | __erase_container(__flat_map.__containers_.values); | |
| 1188 | ||
| 1189 | __guard.__complete(); | |
| 1190 | return __res; | |
| 1191 | } | |
| 1192 | ||
| 1193 | _LIBCPP_END_NAMESPACE_STD | |
| 1194 | ||
| 1195 | #endif // _LIBCPP_STD_VER >= 23 | |
| 1196 | ||
| 1197 | _LIBCPP_POP_MACROS | |
| 1198 | ||
| 1199 | #endif // _LIBCPP___FLAT_MAP_FLAT_MAP_H |
lib/libcxx/include/__flat_map/flat_multimap.h created+1010| ... | ... | @@ -0,0 +1,1010 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H | |
| 11 | #define _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H | |
| 12 | ||
| 13 | #include <__algorithm/lexicographical_compare_three_way.h> | |
| 14 | #include <__algorithm/min.h> | |
| 15 | #include <__algorithm/ranges_equal.h> | |
| 16 | #include <__algorithm/ranges_equal_range.h> | |
| 17 | #include <__algorithm/ranges_inplace_merge.h> | |
| 18 | #include <__algorithm/ranges_is_sorted.h> | |
| 19 | #include <__algorithm/ranges_lower_bound.h> | |
| 20 | #include <__algorithm/ranges_partition_point.h> | |
| 21 | #include <__algorithm/ranges_sort.h> | |
| 22 | #include <__algorithm/ranges_unique.h> | |
| 23 | #include <__algorithm/ranges_upper_bound.h> | |
| 24 | #include <__algorithm/remove_if.h> | |
| 25 | #include <__assert> | |
| 26 | #include <__compare/synth_three_way.h> | |
| 27 | #include <__concepts/convertible_to.h> | |
| 28 | #include <__concepts/swappable.h> | |
| 29 | #include <__config> | |
| 30 | #include <__cstddef/byte.h> | |
| 31 | #include <__cstddef/ptrdiff_t.h> | |
| 32 | #include <__flat_map/key_value_iterator.h> | |
| 33 | #include <__flat_map/sorted_equivalent.h> | |
| 34 | #include <__flat_map/utils.h> | |
| 35 | #include <__functional/invoke.h> | |
| 36 | #include <__functional/is_transparent.h> | |
| 37 | #include <__functional/operations.h> | |
| 38 | #include <__fwd/vector.h> | |
| 39 | #include <__iterator/concepts.h> | |
| 40 | #include <__iterator/distance.h> | |
| 41 | #include <__iterator/iterator_traits.h> | |
| 42 | #include <__iterator/ranges_iterator_traits.h> | |
| 43 | #include <__iterator/reverse_iterator.h> | |
| 44 | #include <__memory/allocator_traits.h> | |
| 45 | #include <__memory/uses_allocator.h> | |
| 46 | #include <__memory/uses_allocator_construction.h> | |
| 47 | #include <__ranges/access.h> | |
| 48 | #include <__ranges/concepts.h> | |
| 49 | #include <__ranges/container_compatible_range.h> | |
| 50 | #include <__ranges/drop_view.h> | |
| 51 | #include <__ranges/from_range.h> | |
| 52 | #include <__ranges/ref_view.h> | |
| 53 | #include <__ranges/size.h> | |
| 54 | #include <__ranges/subrange.h> | |
| 55 | #include <__ranges/zip_view.h> | |
| 56 | #include <__type_traits/conjunction.h> | |
| 57 | #include <__type_traits/container_traits.h> | |
| 58 | #include <__type_traits/invoke.h> | |
| 59 | #include <__type_traits/is_allocator.h> | |
| 60 | #include <__type_traits/is_nothrow_constructible.h> | |
| 61 | #include <__type_traits/is_same.h> | |
| 62 | #include <__type_traits/maybe_const.h> | |
| 63 | #include <__utility/exception_guard.h> | |
| 64 | #include <__utility/move.h> | |
| 65 | #include <__utility/pair.h> | |
| 66 | #include <__utility/scope_guard.h> | |
| 67 | #include <__vector/vector.h> | |
| 68 | #include <initializer_list> | |
| 69 | #include <stdexcept> | |
| 70 | ||
| 71 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 72 | # pragma GCC system_header | |
| 73 | #endif | |
| 74 | ||
| 75 | _LIBCPP_PUSH_MACROS | |
| 76 | #include <__undef_macros> | |
| 77 | ||
| 78 | #if _LIBCPP_STD_VER >= 23 | |
| 79 | ||
| 80 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 81 | ||
| 82 | template <class _Key, | |
| 83 | class _Tp, | |
| 84 | class _Compare = less<_Key>, | |
| 85 | class _KeyContainer = vector<_Key>, | |
| 86 | class _MappedContainer = vector<_Tp>> | |
| 87 | class flat_multimap { | |
| 88 | template <class, class, class, class, class> | |
| 89 | friend class flat_multimap; | |
| 90 | ||
| 91 | static_assert(is_same_v<_Key, typename _KeyContainer::value_type>); | |
| 92 | static_assert(is_same_v<_Tp, typename _MappedContainer::value_type>); | |
| 93 | static_assert(!is_same_v<_KeyContainer, std::vector<bool>>, "vector<bool> is not a sequence container"); | |
| 94 | static_assert(!is_same_v<_MappedContainer, std::vector<bool>>, "vector<bool> is not a sequence container"); | |
| 95 | ||
| 96 | template <bool _Const> | |
| 97 | using __iterator _LIBCPP_NODEBUG = __key_value_iterator<flat_multimap, _KeyContainer, _MappedContainer, _Const>; | |
| 98 | ||
| 99 | public: | |
| 100 | // types | |
| 101 | using key_type = _Key; | |
| 102 | using mapped_type = _Tp; | |
| 103 | using value_type = pair<key_type, mapped_type>; | |
| 104 | using key_compare = __type_identity_t<_Compare>; | |
| 105 | using reference = pair<const key_type&, mapped_type&>; | |
| 106 | using const_reference = pair<const key_type&, const mapped_type&>; | |
| 107 | using size_type = size_t; | |
| 108 | using difference_type = ptrdiff_t; | |
| 109 | using iterator = __iterator<false>; // see [container.requirements] | |
| 110 | using const_iterator = __iterator<true>; // see [container.requirements] | |
| 111 | using reverse_iterator = std::reverse_iterator<iterator>; | |
| 112 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | |
| 113 | using key_container_type = _KeyContainer; | |
| 114 | using mapped_container_type = _MappedContainer; | |
| 115 | ||
| 116 | class value_compare { | |
| 117 | private: | |
| 118 | key_compare __comp_; | |
| 119 | _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {} | |
| 120 | friend flat_multimap; | |
| 121 | ||
| 122 | public: | |
| 123 | _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const { | |
| 124 | return __comp_(__x.first, __y.first); | |
| 125 | } | |
| 126 | }; | |
| 127 | ||
| 128 | struct containers { | |
| 129 | key_container_type keys; | |
| 130 | mapped_container_type values; | |
| 131 | }; | |
| 132 | ||
| 133 | private: | |
| 134 | template <class _Allocator> | |
| 135 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __allocator_ctor_constraint = | |
| 136 | _And<uses_allocator<key_container_type, _Allocator>, uses_allocator<mapped_container_type, _Allocator>>::value; | |
| 137 | ||
| 138 | _LIBCPP_HIDE_FROM_ABI static constexpr bool __is_compare_transparent = __is_transparent_v<_Compare>; | |
| 139 | ||
| 140 | public: | |
| 141 | // [flat.map.cons], construct/copy/destroy | |
| 142 | _LIBCPP_HIDE_FROM_ABI flat_multimap() noexcept( | |
| 143 | is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_MappedContainer> && | |
| 144 | is_nothrow_default_constructible_v<_Compare>) | |
| 145 | : __containers_(), __compare_() {} | |
| 146 | ||
| 147 | _LIBCPP_HIDE_FROM_ABI flat_multimap(const flat_multimap&) = default; | |
| 148 | ||
| 149 | // The copy/move constructors are not specified in the spec, which means they should be defaulted. | |
| 150 | // However, the move constructor can potentially leave a moved-from object in an inconsistent | |
| 151 | // state if an exception is thrown. | |
| 152 | _LIBCPP_HIDE_FROM_ABI flat_multimap(flat_multimap&& __other) noexcept( | |
| 153 | is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> && | |
| 154 | is_nothrow_move_constructible_v<_Compare>) | |
| 155 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 156 | try | |
| 157 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 158 | : __containers_(std::move(__other.__containers_)), __compare_(std::move(__other.__compare_)) { | |
| 159 | __other.clear(); | |
| 160 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 161 | } catch (...) { | |
| 162 | __other.clear(); | |
| 163 | // gcc does not like the `throw` keyword in a conditionally noexcept function | |
| 164 | if constexpr (!(is_nothrow_move_constructible_v<_KeyContainer> && | |
| 165 | is_nothrow_move_constructible_v<_MappedContainer> && is_nothrow_move_constructible_v<_Compare>)) { | |
| 166 | throw; | |
| 167 | } | |
| 168 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 169 | } | |
| 170 | ||
| 171 | template <class _Allocator> | |
| 172 | requires __allocator_ctor_constraint<_Allocator> | |
| 173 | _LIBCPP_HIDE_FROM_ABI flat_multimap(const flat_multimap& __other, const _Allocator& __alloc) | |
| 174 | : flat_multimap(__ctor_uses_allocator_tag{}, | |
| 175 | __alloc, | |
| 176 | __other.__containers_.keys, | |
| 177 | __other.__containers_.values, | |
| 178 | __other.__compare_) {} | |
| 179 | ||
| 180 | template <class _Allocator> | |
| 181 | requires __allocator_ctor_constraint<_Allocator> | |
| 182 | _LIBCPP_HIDE_FROM_ABI flat_multimap(flat_multimap&& __other, const _Allocator& __alloc) | |
| 183 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 184 | try | |
| 185 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 186 | : flat_multimap(__ctor_uses_allocator_tag{}, | |
| 187 | __alloc, | |
| 188 | std::move(__other.__containers_.keys), | |
| 189 | std::move(__other.__containers_.values), | |
| 190 | std::move(__other.__compare_)) { | |
| 191 | __other.clear(); | |
| 192 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 193 | } catch (...) { | |
| 194 | __other.clear(); | |
| 195 | throw; | |
| 196 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 197 | } | |
| 198 | ||
| 199 | _LIBCPP_HIDE_FROM_ABI flat_multimap( | |
| 200 | key_container_type __key_cont, mapped_container_type __mapped_cont, const key_compare& __comp = key_compare()) | |
| 201 | : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) { | |
| 202 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 203 | "flat_multimap keys and mapped containers have different size"); | |
| 204 | __sort(); | |
| 205 | } | |
| 206 | ||
| 207 | template <class _Allocator> | |
| 208 | requires __allocator_ctor_constraint<_Allocator> | |
| 209 | _LIBCPP_HIDE_FROM_ABI flat_multimap( | |
| 210 | const key_container_type& __key_cont, const mapped_container_type& __mapped_cont, const _Allocator& __alloc) | |
| 211 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) { | |
| 212 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 213 | "flat_multimap keys and mapped containers have different size"); | |
| 214 | __sort(); | |
| 215 | } | |
| 216 | ||
| 217 | template <class _Allocator> | |
| 218 | requires __allocator_ctor_constraint<_Allocator> | |
| 219 | _LIBCPP_HIDE_FROM_ABI | |
| 220 | flat_multimap(const key_container_type& __key_cont, | |
| 221 | const mapped_container_type& __mapped_cont, | |
| 222 | const key_compare& __comp, | |
| 223 | const _Allocator& __alloc) | |
| 224 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) { | |
| 225 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 226 | "flat_multimap keys and mapped containers have different size"); | |
| 227 | __sort(); | |
| 228 | } | |
| 229 | ||
| 230 | _LIBCPP_HIDE_FROM_ABI | |
| 231 | flat_multimap(sorted_equivalent_t, | |
| 232 | key_container_type __key_cont, | |
| 233 | mapped_container_type __mapped_cont, | |
| 234 | const key_compare& __comp = key_compare()) | |
| 235 | : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) { | |
| 236 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 237 | "flat_multimap keys and mapped containers have different size"); | |
| 238 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted(__containers_.keys), "Key container is not sorted"); | |
| 239 | } | |
| 240 | ||
| 241 | template <class _Allocator> | |
| 242 | requires __allocator_ctor_constraint<_Allocator> | |
| 243 | _LIBCPP_HIDE_FROM_ABI | |
| 244 | flat_multimap(sorted_equivalent_t, | |
| 245 | const key_container_type& __key_cont, | |
| 246 | const mapped_container_type& __mapped_cont, | |
| 247 | const _Allocator& __alloc) | |
| 248 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) { | |
| 249 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 250 | "flat_multimap keys and mapped containers have different size"); | |
| 251 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted(__containers_.keys), "Key container is not sorted"); | |
| 252 | } | |
| 253 | ||
| 254 | template <class _Allocator> | |
| 255 | requires __allocator_ctor_constraint<_Allocator> | |
| 256 | _LIBCPP_HIDE_FROM_ABI | |
| 257 | flat_multimap(sorted_equivalent_t, | |
| 258 | const key_container_type& __key_cont, | |
| 259 | const mapped_container_type& __mapped_cont, | |
| 260 | const key_compare& __comp, | |
| 261 | const _Allocator& __alloc) | |
| 262 | : flat_multimap(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) { | |
| 263 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(), | |
| 264 | "flat_multimap keys and mapped containers have different size"); | |
| 265 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted(__containers_.keys), "Key container is not sorted"); | |
| 266 | } | |
| 267 | ||
| 268 | _LIBCPP_HIDE_FROM_ABI explicit flat_multimap(const key_compare& __comp) : __containers_(), __compare_(__comp) {} | |
| 269 | ||
| 270 | template <class _Allocator> | |
| 271 | requires __allocator_ctor_constraint<_Allocator> | |
| 272 | _LIBCPP_HIDE_FROM_ABI flat_multimap(const key_compare& __comp, const _Allocator& __alloc) | |
| 273 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {} | |
| 274 | ||
| 275 | template <class _Allocator> | |
| 276 | requires __allocator_ctor_constraint<_Allocator> | |
| 277 | _LIBCPP_HIDE_FROM_ABI explicit flat_multimap(const _Allocator& __alloc) | |
| 278 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) {} | |
| 279 | ||
| 280 | template <class _InputIterator> | |
| 281 | requires __has_input_iterator_category<_InputIterator>::value | |
| 282 | _LIBCPP_HIDE_FROM_ABI | |
| 283 | flat_multimap(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | |
| 284 | : __containers_(), __compare_(__comp) { | |
| 285 | insert(__first, __last); | |
| 286 | } | |
| 287 | ||
| 288 | template <class _InputIterator, class _Allocator> | |
| 289 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | |
| 290 | _LIBCPP_HIDE_FROM_ABI | |
| 291 | flat_multimap(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc) | |
| 292 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | |
| 293 | insert(__first, __last); | |
| 294 | } | |
| 295 | ||
| 296 | template <class _InputIterator, class _Allocator> | |
| 297 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | |
| 298 | _LIBCPP_HIDE_FROM_ABI flat_multimap(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | |
| 299 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) { | |
| 300 | insert(__first, __last); | |
| 301 | } | |
| 302 | ||
| 303 | template <_ContainerCompatibleRange<value_type> _Range> | |
| 304 | _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t __fr, _Range&& __rg) | |
| 305 | : flat_multimap(__fr, std::forward<_Range>(__rg), key_compare()) {} | |
| 306 | ||
| 307 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | |
| 308 | requires __allocator_ctor_constraint<_Allocator> | |
| 309 | _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t, _Range&& __rg, const _Allocator& __alloc) | |
| 310 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) { | |
| 311 | insert_range(std::forward<_Range>(__rg)); | |
| 312 | } | |
| 313 | ||
| 314 | template <_ContainerCompatibleRange<value_type> _Range> | |
| 315 | _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_multimap(__comp) { | |
| 316 | insert_range(std::forward<_Range>(__rg)); | |
| 317 | } | |
| 318 | ||
| 319 | template <_ContainerCompatibleRange<value_type> _Range, class _Allocator> | |
| 320 | requires __allocator_ctor_constraint<_Allocator> | |
| 321 | _LIBCPP_HIDE_FROM_ABI flat_multimap(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc) | |
| 322 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | |
| 323 | insert_range(std::forward<_Range>(__rg)); | |
| 324 | } | |
| 325 | ||
| 326 | template <class _InputIterator> | |
| 327 | requires __has_input_iterator_category<_InputIterator>::value | |
| 328 | _LIBCPP_HIDE_FROM_ABI flat_multimap( | |
| 329 | sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare()) | |
| 330 | : __containers_(), __compare_(__comp) { | |
| 331 | insert(sorted_equivalent, __first, __last); | |
| 332 | } | |
| 333 | template <class _InputIterator, class _Allocator> | |
| 334 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | |
| 335 | _LIBCPP_HIDE_FROM_ABI | |
| 336 | flat_multimap(sorted_equivalent_t, | |
| 337 | _InputIterator __first, | |
| 338 | _InputIterator __last, | |
| 339 | const key_compare& __comp, | |
| 340 | const _Allocator& __alloc) | |
| 341 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) { | |
| 342 | insert(sorted_equivalent, __first, __last); | |
| 343 | } | |
| 344 | ||
| 345 | template <class _InputIterator, class _Allocator> | |
| 346 | requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>) | |
| 347 | _LIBCPP_HIDE_FROM_ABI | |
| 348 | flat_multimap(sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc) | |
| 349 | : flat_multimap(__ctor_uses_allocator_empty_tag{}, __alloc) { | |
| 350 | insert(sorted_equivalent, __first, __last); | |
| 351 | } | |
| 352 | ||
| 353 | _LIBCPP_HIDE_FROM_ABI flat_multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | |
| 354 | : flat_multimap(__il.begin(), __il.end(), __comp) {} | |
| 355 | ||
| 356 | template <class _Allocator> | |
| 357 | requires __allocator_ctor_constraint<_Allocator> | |
| 358 | _LIBCPP_HIDE_FROM_ABI | |
| 359 | flat_multimap(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | |
| 360 | : flat_multimap(__il.begin(), __il.end(), __comp, __alloc) {} | |
| 361 | ||
| 362 | template <class _Allocator> | |
| 363 | requires __allocator_ctor_constraint<_Allocator> | |
| 364 | _LIBCPP_HIDE_FROM_ABI flat_multimap(initializer_list<value_type> __il, const _Allocator& __alloc) | |
| 365 | : flat_multimap(__il.begin(), __il.end(), __alloc) {} | |
| 366 | ||
| 367 | _LIBCPP_HIDE_FROM_ABI | |
| 368 | flat_multimap(sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare()) | |
| 369 | : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __comp) {} | |
| 370 | ||
| 371 | template <class _Allocator> | |
| 372 | requires __allocator_ctor_constraint<_Allocator> | |
| 373 | _LIBCPP_HIDE_FROM_ABI flat_multimap( | |
| 374 | sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc) | |
| 375 | : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __comp, __alloc) {} | |
| 376 | ||
| 377 | template <class _Allocator> | |
| 378 | requires __allocator_ctor_constraint<_Allocator> | |
| 379 | _LIBCPP_HIDE_FROM_ABI flat_multimap(sorted_equivalent_t, initializer_list<value_type> __il, const _Allocator& __alloc) | |
| 380 | : flat_multimap(sorted_equivalent, __il.begin(), __il.end(), __alloc) {} | |
| 381 | ||
| 382 | _LIBCPP_HIDE_FROM_ABI flat_multimap& operator=(initializer_list<value_type> __il) { | |
| 383 | clear(); | |
| 384 | insert(__il); | |
| 385 | return *this; | |
| 386 | } | |
| 387 | ||
| 388 | // copy/move assignment are not specified in the spec (defaulted) | |
| 389 | // but move assignment can potentially leave moved from object in an inconsistent | |
| 390 | // state if an exception is thrown | |
| 391 | _LIBCPP_HIDE_FROM_ABI flat_multimap& operator=(const flat_multimap&) = default; | |
| 392 | ||
| 393 | _LIBCPP_HIDE_FROM_ABI flat_multimap& operator=(flat_multimap&& __other) noexcept( | |
| 394 | is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> && | |
| 395 | is_nothrow_move_assignable_v<_Compare>) { | |
| 396 | auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; }); | |
| 397 | auto __clear_self_guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 398 | __containers_ = std::move(__other.__containers_); | |
| 399 | __compare_ = std::move(__other.__compare_); | |
| 400 | __clear_self_guard.__complete(); | |
| 401 | return *this; | |
| 402 | } | |
| 403 | ||
| 404 | // iterators | |
| 405 | _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept { | |
| 406 | return iterator(__containers_.keys.begin(), __containers_.values.begin()); | |
| 407 | } | |
| 408 | ||
| 409 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { | |
| 410 | return const_iterator(__containers_.keys.begin(), __containers_.values.begin()); | |
| 411 | } | |
| 412 | ||
| 413 | _LIBCPP_HIDE_FROM_ABI iterator end() noexcept { | |
| 414 | return iterator(__containers_.keys.end(), __containers_.values.end()); | |
| 415 | } | |
| 416 | ||
| 417 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { | |
| 418 | return const_iterator(__containers_.keys.end(), __containers_.values.end()); | |
| 419 | } | |
| 420 | ||
| 421 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } | |
| 422 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } | |
| 423 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); } | |
| 424 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } | |
| 425 | ||
| 426 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); } | |
| 427 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); } | |
| 428 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } | |
| 429 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } | |
| 430 | ||
| 431 | // [flat.map.capacity], capacity | |
| 432 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __containers_.keys.empty(); } | |
| 433 | ||
| 434 | _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __containers_.keys.size(); } | |
| 435 | ||
| 436 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept { | |
| 437 | return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size()); | |
| 438 | } | |
| 439 | ||
| 440 | // [flat.map.modifiers], modifiers | |
| 441 | template <class... _Args> | |
| 442 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> && is_move_constructible_v<key_type> && | |
| 443 | is_move_constructible_v<mapped_type> | |
| 444 | _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { | |
| 445 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); | |
| 446 | auto __key_it = ranges::upper_bound(__containers_.keys, __pair.first, __compare_); | |
| 447 | auto __mapped_it = __corresponding_mapped_it(*this, __key_it); | |
| 448 | ||
| 449 | return __flat_map_utils::__emplace_exact_pos( | |
| 450 | *this, std::move(__key_it), std::move(__mapped_it), std::move(__pair.first), std::move(__pair.second)); | |
| 451 | } | |
| 452 | ||
| 453 | template <class... _Args> | |
| 454 | requires is_constructible_v<pair<key_type, mapped_type>, _Args...> | |
| 455 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) { | |
| 456 | std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...); | |
| 457 | ||
| 458 | auto __prev_larger = __hint != cbegin() && __compare_(__pair.first, (__hint - 1)->first); | |
| 459 | auto __next_smaller = __hint != cend() && __compare_(__hint->first, __pair.first); | |
| 460 | ||
| 461 | auto __hint_distance = __hint.__key_iter_ - __containers_.keys.cbegin(); | |
| 462 | auto __key_iter = __containers_.keys.begin() + __hint_distance; | |
| 463 | auto __mapped_iter = __containers_.values.begin() + __hint_distance; | |
| 464 | ||
| 465 | if (!__prev_larger && !__next_smaller) [[likely]] { | |
| 466 | // hint correct, just use exact hint iterators | |
| 467 | } else if (__prev_larger && !__next_smaller) { | |
| 468 | // the hint position is more to the right than the key should have been. | |
| 469 | // we want to emplace the element to a position as right as possible | |
| 470 | // e.g. Insert new element "2" in the following range | |
| 471 | // 1, 1, 2, 2, 2, 3, 4, 6 | |
| 472 | // ^ | |
| 473 | // | | |
| 474 | // hint | |
| 475 | // We want to insert "2" after the last existing "2" | |
| 476 | __key_iter = ranges::upper_bound(__containers_.keys.begin(), __key_iter, __pair.first, __compare_); | |
| 477 | __mapped_iter = __corresponding_mapped_it(*this, __key_iter); | |
| 478 | } else { | |
| 479 | _LIBCPP_ASSERT_INTERNAL(!__prev_larger && __next_smaller, "this means that the multimap is not sorted"); | |
| 480 | ||
| 481 | // the hint position is more to the left than the key should have been. | |
| 482 | // we want to emplace the element to a position as left as possible | |
| 483 | // 1, 1, 2, 2, 2, 3, 4, 6 | |
| 484 | // ^ | |
| 485 | // | | |
| 486 | // hint | |
| 487 | // We want to insert "2" before the first existing "2" | |
| 488 | __key_iter = ranges::lower_bound(__key_iter, __containers_.keys.end(), __pair.first, __compare_); | |
| 489 | __mapped_iter = __corresponding_mapped_it(*this, __key_iter); | |
| 490 | } | |
| 491 | return __flat_map_utils::__emplace_exact_pos( | |
| 492 | *this, __key_iter, __mapped_iter, std::move(__pair.first), std::move(__pair.second)); | |
| 493 | } | |
| 494 | ||
| 495 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return emplace(__x); } | |
| 496 | ||
| 497 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return emplace(std::move(__x)); } | |
| 498 | ||
| 499 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) { | |
| 500 | return emplace_hint(__hint, __x); | |
| 501 | } | |
| 502 | ||
| 503 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) { | |
| 504 | return emplace_hint(__hint, std::move(__x)); | |
| 505 | } | |
| 506 | ||
| 507 | template <class _PairLike> | |
| 508 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> | |
| 509 | _LIBCPP_HIDE_FROM_ABI iterator insert(_PairLike&& __x) { | |
| 510 | return emplace(std::forward<_PairLike>(__x)); | |
| 511 | } | |
| 512 | ||
| 513 | template <class _PairLike> | |
| 514 | requires is_constructible_v<pair<key_type, mapped_type>, _PairLike> | |
| 515 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, _PairLike&& __x) { | |
| 516 | return emplace_hint(__hint, std::forward<_PairLike>(__x)); | |
| 517 | } | |
| 518 | ||
| 519 | template <class _InputIterator> | |
| 520 | requires __has_input_iterator_category<_InputIterator>::value | |
| 521 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) { | |
| 522 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | |
| 523 | __reserve(__last - __first); | |
| 524 | } | |
| 525 | __append_sort_merge</*WasSorted = */ false>(std::move(__first), std::move(__last)); | |
| 526 | } | |
| 527 | ||
| 528 | template <class _InputIterator> | |
| 529 | requires __has_input_iterator_category<_InputIterator>::value | |
| 530 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, _InputIterator __first, _InputIterator __last) { | |
| 531 | if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) { | |
| 532 | __reserve(__last - __first); | |
| 533 | } | |
| 534 | ||
| 535 | __append_sort_merge</*WasSorted = */ true>(std::move(__first), std::move(__last)); | |
| 536 | } | |
| 537 | ||
| 538 | template <_ContainerCompatibleRange<value_type> _Range> | |
| 539 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { | |
| 540 | if constexpr (ranges::sized_range<_Range>) { | |
| 541 | __reserve(ranges::size(__range)); | |
| 542 | } | |
| 543 | ||
| 544 | __append_sort_merge</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range)); | |
| 545 | } | |
| 546 | ||
| 547 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } | |
| 548 | ||
| 549 | _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, initializer_list<value_type> __il) { | |
| 550 | insert(sorted_equivalent, __il.begin(), __il.end()); | |
| 551 | } | |
| 552 | ||
| 553 | _LIBCPP_HIDE_FROM_ABI containers extract() && { | |
| 554 | auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 555 | auto __ret = std::move(__containers_); | |
| 556 | return __ret; | |
| 557 | } | |
| 558 | ||
| 559 | _LIBCPP_HIDE_FROM_ABI void replace(key_container_type&& __key_cont, mapped_container_type&& __mapped_cont) { | |
| 560 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( | |
| 561 | __key_cont.size() == __mapped_cont.size(), "flat_multimap keys and mapped containers have different size"); | |
| 562 | ||
| 563 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted(__key_cont), "Key container is not sorted"); | |
| 564 | auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 565 | __containers_.keys = std::move(__key_cont); | |
| 566 | __containers_.values = std::move(__mapped_cont); | |
| 567 | __guard.__complete(); | |
| 568 | } | |
| 569 | ||
| 570 | _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) { | |
| 571 | return __erase(__position.__key_iter_, __position.__mapped_iter_); | |
| 572 | } | |
| 573 | ||
| 574 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position) { | |
| 575 | return __erase(__position.__key_iter_, __position.__mapped_iter_); | |
| 576 | } | |
| 577 | ||
| 578 | _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) { | |
| 579 | auto [__first, __last] = equal_range(__x); | |
| 580 | auto __res = __last - __first; | |
| 581 | erase(__first, __last); | |
| 582 | return __res; | |
| 583 | } | |
| 584 | ||
| 585 | template <class _Kp> | |
| 586 | requires(__is_compare_transparent && !is_convertible_v<_Kp &&, iterator> && | |
| 587 | !is_convertible_v<_Kp &&, const_iterator>) | |
| 588 | _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) { | |
| 589 | auto [__first, __last] = equal_range(__x); | |
| 590 | auto __res = __last - __first; | |
| 591 | erase(__first, __last); | |
| 592 | return __res; | |
| 593 | } | |
| 594 | ||
| 595 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) { | |
| 596 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 597 | auto __key_it = __containers_.keys.erase(__first.__key_iter_, __last.__key_iter_); | |
| 598 | auto __mapped_it = __containers_.values.erase(__first.__mapped_iter_, __last.__mapped_iter_); | |
| 599 | __on_failure.__complete(); | |
| 600 | return iterator(std::move(__key_it), std::move(__mapped_it)); | |
| 601 | } | |
| 602 | ||
| 603 | _LIBCPP_HIDE_FROM_ABI void swap(flat_multimap& __y) noexcept { | |
| 604 | // warning: The spec has unconditional noexcept, which means that | |
| 605 | // if any of the following functions throw an exception, | |
| 606 | // std::terminate will be called | |
| 607 | ranges::swap(__compare_, __y.__compare_); | |
| 608 | ranges::swap(__containers_.keys, __y.__containers_.keys); | |
| 609 | ranges::swap(__containers_.values, __y.__containers_.values); | |
| 610 | } | |
| 611 | ||
| 612 | _LIBCPP_HIDE_FROM_ABI void clear() noexcept { | |
| 613 | __containers_.keys.clear(); | |
| 614 | __containers_.values.clear(); | |
| 615 | } | |
| 616 | ||
| 617 | // observers | |
| 618 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; } | |
| 619 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__compare_); } | |
| 620 | ||
| 621 | _LIBCPP_HIDE_FROM_ABI const key_container_type& keys() const noexcept { return __containers_.keys; } | |
| 622 | _LIBCPP_HIDE_FROM_ABI const mapped_container_type& values() const noexcept { return __containers_.values; } | |
| 623 | ||
| 624 | // map operations | |
| 625 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); } | |
| 626 | ||
| 627 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); } | |
| 628 | ||
| 629 | template <class _Kp> | |
| 630 | requires __is_compare_transparent | |
| 631 | _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) { | |
| 632 | return __find_impl(*this, __x); | |
| 633 | } | |
| 634 | ||
| 635 | template <class _Kp> | |
| 636 | requires __is_compare_transparent | |
| 637 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const { | |
| 638 | return __find_impl(*this, __x); | |
| 639 | } | |
| 640 | ||
| 641 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const { | |
| 642 | auto [__first, __last] = equal_range(__x); | |
| 643 | return __last - __first; | |
| 644 | } | |
| 645 | ||
| 646 | template <class _Kp> | |
| 647 | requires __is_compare_transparent | |
| 648 | _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const { | |
| 649 | auto [__first, __last] = equal_range(__x); | |
| 650 | return __last - __first; | |
| 651 | } | |
| 652 | ||
| 653 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); } | |
| 654 | ||
| 655 | template <class _Kp> | |
| 656 | requires __is_compare_transparent | |
| 657 | _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const { | |
| 658 | return find(__x) != end(); | |
| 659 | } | |
| 660 | ||
| 661 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) { return __lower_bound<iterator>(*this, __x); } | |
| 662 | ||
| 663 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const { | |
| 664 | return __lower_bound<const_iterator>(*this, __x); | |
| 665 | } | |
| 666 | ||
| 667 | template <class _Kp> | |
| 668 | requires __is_compare_transparent | |
| 669 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) { | |
| 670 | return __lower_bound<iterator>(*this, __x); | |
| 671 | } | |
| 672 | ||
| 673 | template <class _Kp> | |
| 674 | requires __is_compare_transparent | |
| 675 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const { | |
| 676 | return __lower_bound<const_iterator>(*this, __x); | |
| 677 | } | |
| 678 | ||
| 679 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) { return __upper_bound<iterator>(*this, __x); } | |
| 680 | ||
| 681 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const { | |
| 682 | return __upper_bound<const_iterator>(*this, __x); | |
| 683 | } | |
| 684 | ||
| 685 | template <class _Kp> | |
| 686 | requires __is_compare_transparent | |
| 687 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) { | |
| 688 | return __upper_bound<iterator>(*this, __x); | |
| 689 | } | |
| 690 | ||
| 691 | template <class _Kp> | |
| 692 | requires __is_compare_transparent | |
| 693 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const { | |
| 694 | return __upper_bound<const_iterator>(*this, __x); | |
| 695 | } | |
| 696 | ||
| 697 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) { | |
| 698 | return __equal_range_impl(*this, __x); | |
| 699 | } | |
| 700 | ||
| 701 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const { | |
| 702 | return __equal_range_impl(*this, __x); | |
| 703 | } | |
| 704 | ||
| 705 | template <class _Kp> | |
| 706 | requires __is_compare_transparent | |
| 707 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) { | |
| 708 | return __equal_range_impl(*this, __x); | |
| 709 | } | |
| 710 | template <class _Kp> | |
| 711 | requires __is_compare_transparent | |
| 712 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const { | |
| 713 | return __equal_range_impl(*this, __x); | |
| 714 | } | |
| 715 | ||
| 716 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_multimap& __x, const flat_multimap& __y) { | |
| 717 | return ranges::equal(__x, __y); | |
| 718 | } | |
| 719 | ||
| 720 | friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_multimap& __x, const flat_multimap& __y) { | |
| 721 | return std::lexicographical_compare_three_way( | |
| 722 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | |
| 723 | } | |
| 724 | ||
| 725 | friend _LIBCPP_HIDE_FROM_ABI void swap(flat_multimap& __x, flat_multimap& __y) noexcept { __x.swap(__y); } | |
| 726 | ||
| 727 | private: | |
| 728 | struct __ctor_uses_allocator_tag { | |
| 729 | explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_tag() = default; | |
| 730 | }; | |
| 731 | struct __ctor_uses_allocator_empty_tag { | |
| 732 | explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_empty_tag() = default; | |
| 733 | }; | |
| 734 | ||
| 735 | template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg> | |
| 736 | requires __allocator_ctor_constraint<_Allocator> | |
| 737 | _LIBCPP_HIDE_FROM_ABI | |
| 738 | flat_multimap(__ctor_uses_allocator_tag, | |
| 739 | const _Allocator& __alloc, | |
| 740 | _KeyCont&& __key_cont, | |
| 741 | _MappedCont&& __mapped_cont, | |
| 742 | _CompArg&&... __comp) | |
| 743 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>( | |
| 744 | __alloc, std::forward<_KeyCont>(__key_cont)), | |
| 745 | .values = std::make_obj_using_allocator<mapped_container_type>( | |
| 746 | __alloc, std::forward<_MappedCont>(__mapped_cont))}, | |
| 747 | __compare_(std::forward<_CompArg>(__comp)...) {} | |
| 748 | ||
| 749 | template <class _Allocator, class... _CompArg> | |
| 750 | requires __allocator_ctor_constraint<_Allocator> | |
| 751 | _LIBCPP_HIDE_FROM_ABI flat_multimap(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp) | |
| 752 | : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc), | |
| 753 | .values = std::make_obj_using_allocator<mapped_container_type>(__alloc)}, | |
| 754 | __compare_(std::forward<_CompArg>(__comp)...) {} | |
| 755 | ||
| 756 | _LIBCPP_HIDE_FROM_ABI bool __is_sorted(auto&& __key_container) const { | |
| 757 | return ranges::is_sorted(__key_container, __compare_); | |
| 758 | } | |
| 759 | ||
| 760 | _LIBCPP_HIDE_FROM_ABI void __sort() { | |
| 761 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); | |
| 762 | ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); }); | |
| 763 | } | |
| 764 | ||
| 765 | template <class _Self, class _KeyIter> | |
| 766 | _LIBCPP_HIDE_FROM_ABI static auto __corresponding_mapped_it(_Self&& __self, _KeyIter&& __key_iter) { | |
| 767 | return __self.__containers_.values.begin() + | |
| 768 | static_cast<ranges::range_difference_t<mapped_container_type>>( | |
| 769 | ranges::distance(__self.__containers_.keys.begin(), __key_iter)); | |
| 770 | } | |
| 771 | ||
| 772 | template <bool _WasSorted, class _InputIterator, class _Sentinel> | |
| 773 | _LIBCPP_HIDE_FROM_ABI void __append_sort_merge(_InputIterator __first, _Sentinel __last) { | |
| 774 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 775 | size_t __num_appended = __flat_map_utils::__append(*this, std::move(__first), std::move(__last)); | |
| 776 | if (__num_appended != 0) { | |
| 777 | auto __zv = ranges::views::zip(__containers_.keys, __containers_.values); | |
| 778 | auto __append_start_offset = __containers_.keys.size() - __num_appended; | |
| 779 | auto __end = __zv.end(); | |
| 780 | auto __compare_key = [this](const auto& __p1, const auto& __p2) { | |
| 781 | return __compare_(std::get<0>(__p1), std::get<0>(__p2)); | |
| 782 | }; | |
| 783 | if constexpr (!_WasSorted) { | |
| 784 | ranges::sort(__zv.begin() + __append_start_offset, __end, __compare_key); | |
| 785 | } else { | |
| 786 | _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT( | |
| 787 | __is_sorted(__containers_.keys | ranges::views::drop(__append_start_offset)), | |
| 788 | "Key container is not sorted"); | |
| 789 | } | |
| 790 | ranges::inplace_merge(__zv.begin(), __zv.begin() + __append_start_offset, __end, __compare_key); | |
| 791 | } | |
| 792 | __on_failure.__complete(); | |
| 793 | } | |
| 794 | ||
| 795 | template <class _Self, class _Kp> | |
| 796 | _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) { | |
| 797 | auto __it = __self.lower_bound(__key); | |
| 798 | auto __last = __self.end(); | |
| 799 | if (__it == __last || __self.__compare_(__key, __it->first)) { | |
| 800 | return __last; | |
| 801 | } | |
| 802 | return __it; | |
| 803 | } | |
| 804 | ||
| 805 | template <class _Self, class _Kp> | |
| 806 | _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) { | |
| 807 | auto [__key_first, __key_last] = ranges::equal_range(__self.__containers_.keys, __key, __self.__compare_); | |
| 808 | ||
| 809 | using __iterator_type = ranges::iterator_t<decltype(__self)>; | |
| 810 | return std::make_pair(__iterator_type(__key_first, __corresponding_mapped_it(__self, __key_first)), | |
| 811 | __iterator_type(__key_last, __corresponding_mapped_it(__self, __key_last))); | |
| 812 | } | |
| 813 | ||
| 814 | template <class _Res, class _Self, class _Kp> | |
| 815 | _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) { | |
| 816 | auto __key_iter = ranges::lower_bound(__self.__containers_.keys, __x, __self.__compare_); | |
| 817 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); | |
| 818 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); | |
| 819 | } | |
| 820 | ||
| 821 | template <class _Res, class _Self, class _Kp> | |
| 822 | _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) { | |
| 823 | auto __key_iter = ranges::upper_bound(__self.__containers_.keys, __x, __self.__compare_); | |
| 824 | auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter); | |
| 825 | return _Res(std::move(__key_iter), std::move(__mapped_iter)); | |
| 826 | } | |
| 827 | ||
| 828 | _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) { | |
| 829 | if constexpr (requires { __containers_.keys.reserve(__size); }) { | |
| 830 | __containers_.keys.reserve(__size); | |
| 831 | } | |
| 832 | ||
| 833 | if constexpr (requires { __containers_.values.reserve(__size); }) { | |
| 834 | __containers_.values.reserve(__size); | |
| 835 | } | |
| 836 | } | |
| 837 | ||
| 838 | template <class _KIter, class _MIter> | |
| 839 | _LIBCPP_HIDE_FROM_ABI iterator __erase(_KIter __key_iter_to_remove, _MIter __mapped_iter_to_remove) { | |
| 840 | auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; }); | |
| 841 | auto __key_iter = __containers_.keys.erase(__key_iter_to_remove); | |
| 842 | auto __mapped_iter = __containers_.values.erase(__mapped_iter_to_remove); | |
| 843 | __on_failure.__complete(); | |
| 844 | return iterator(std::move(__key_iter), std::move(__mapped_iter)); | |
| 845 | } | |
| 846 | ||
| 847 | template <class _Key2, class _Tp2, class _Compare2, class _KeyContainer2, class _MappedContainer2, class _Predicate> | |
| 848 | friend typename flat_multimap<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>::size_type | |
| 849 | erase_if(flat_multimap<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>&, _Predicate); | |
| 850 | ||
| 851 | friend __flat_map_utils; | |
| 852 | ||
| 853 | containers __containers_; | |
| 854 | _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_; | |
| 855 | ||
| 856 | struct __key_equiv { | |
| 857 | _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {} | |
| 858 | _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const { | |
| 859 | return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x)); | |
| 860 | } | |
| 861 | key_compare __comp_; | |
| 862 | }; | |
| 863 | }; | |
| 864 | ||
| 865 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> | |
| 866 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | |
| 867 | !__is_allocator<_MappedContainer>::value && | |
| 868 | is_invocable_v<const _Compare&, | |
| 869 | const typename _KeyContainer::value_type&, | |
| 870 | const typename _KeyContainer::value_type&>) | |
| 871 | flat_multimap(_KeyContainer, _MappedContainer, _Compare = _Compare()) | |
| 872 | -> flat_multimap<typename _KeyContainer::value_type, | |
| 873 | typename _MappedContainer::value_type, | |
| 874 | _Compare, | |
| 875 | _KeyContainer, | |
| 876 | _MappedContainer>; | |
| 877 | ||
| 878 | template <class _KeyContainer, class _MappedContainer, class _Allocator> | |
| 879 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && | |
| 880 | !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value) | |
| 881 | flat_multimap(_KeyContainer, _MappedContainer, _Allocator) | |
| 882 | -> flat_multimap<typename _KeyContainer::value_type, | |
| 883 | typename _MappedContainer::value_type, | |
| 884 | less<typename _KeyContainer::value_type>, | |
| 885 | _KeyContainer, | |
| 886 | _MappedContainer>; | |
| 887 | ||
| 888 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> | |
| 889 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | |
| 890 | !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> && | |
| 891 | uses_allocator_v<_MappedContainer, _Allocator> && | |
| 892 | is_invocable_v<const _Compare&, | |
| 893 | const typename _KeyContainer::value_type&, | |
| 894 | const typename _KeyContainer::value_type&>) | |
| 895 | flat_multimap(_KeyContainer, _MappedContainer, _Compare, _Allocator) | |
| 896 | -> flat_multimap<typename _KeyContainer::value_type, | |
| 897 | typename _MappedContainer::value_type, | |
| 898 | _Compare, | |
| 899 | _KeyContainer, | |
| 900 | _MappedContainer>; | |
| 901 | ||
| 902 | template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>> | |
| 903 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | |
| 904 | !__is_allocator<_MappedContainer>::value && | |
| 905 | is_invocable_v<const _Compare&, | |
| 906 | const typename _KeyContainer::value_type&, | |
| 907 | const typename _KeyContainer::value_type&>) | |
| 908 | flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare = _Compare()) | |
| 909 | -> flat_multimap<typename _KeyContainer::value_type, | |
| 910 | typename _MappedContainer::value_type, | |
| 911 | _Compare, | |
| 912 | _KeyContainer, | |
| 913 | _MappedContainer>; | |
| 914 | ||
| 915 | template <class _KeyContainer, class _MappedContainer, class _Allocator> | |
| 916 | requires(uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator> && | |
| 917 | !__is_allocator<_KeyContainer>::value && !__is_allocator<_MappedContainer>::value) | |
| 918 | flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Allocator) | |
| 919 | -> flat_multimap<typename _KeyContainer::value_type, | |
| 920 | typename _MappedContainer::value_type, | |
| 921 | less<typename _KeyContainer::value_type>, | |
| 922 | _KeyContainer, | |
| 923 | _MappedContainer>; | |
| 924 | ||
| 925 | template <class _KeyContainer, class _MappedContainer, class _Compare, class _Allocator> | |
| 926 | requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value && | |
| 927 | !__is_allocator<_MappedContainer>::value && uses_allocator_v<_KeyContainer, _Allocator> && | |
| 928 | uses_allocator_v<_MappedContainer, _Allocator> && | |
| 929 | is_invocable_v<const _Compare&, | |
| 930 | const typename _KeyContainer::value_type&, | |
| 931 | const typename _KeyContainer::value_type&>) | |
| 932 | flat_multimap(sorted_equivalent_t, _KeyContainer, _MappedContainer, _Compare, _Allocator) | |
| 933 | -> flat_multimap<typename _KeyContainer::value_type, | |
| 934 | typename _MappedContainer::value_type, | |
| 935 | _Compare, | |
| 936 | _KeyContainer, | |
| 937 | _MappedContainer>; | |
| 938 | ||
| 939 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> | |
| 940 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | |
| 941 | flat_multimap(_InputIterator, _InputIterator, _Compare = _Compare()) | |
| 942 | -> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; | |
| 943 | ||
| 944 | template <class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>> | |
| 945 | requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value) | |
| 946 | flat_multimap(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare()) | |
| 947 | -> flat_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare>; | |
| 948 | ||
| 949 | template <ranges::input_range _Range, | |
| 950 | class _Compare = less<__range_key_type<_Range>>, | |
| 951 | class _Allocator = allocator<byte>, | |
| 952 | class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>> | |
| 953 | flat_multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multimap< | |
| 954 | __range_key_type<_Range>, | |
| 955 | __range_mapped_type<_Range>, | |
| 956 | _Compare, | |
| 957 | vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>, | |
| 958 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; | |
| 959 | ||
| 960 | template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>> | |
| 961 | flat_multimap(from_range_t, _Range&&, _Allocator) -> flat_multimap< | |
| 962 | __range_key_type<_Range>, | |
| 963 | __range_mapped_type<_Range>, | |
| 964 | less<__range_key_type<_Range>>, | |
| 965 | vector<__range_key_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_key_type<_Range>>>, | |
| 966 | vector<__range_mapped_type<_Range>, __allocator_traits_rebind_t<_Allocator, __range_mapped_type<_Range>>>>; | |
| 967 | ||
| 968 | template <class _Key, class _Tp, class _Compare = less<_Key>> | |
| 969 | requires(!__is_allocator<_Compare>::value) | |
| 970 | flat_multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) -> flat_multimap<_Key, _Tp, _Compare>; | |
| 971 | ||
| 972 | template <class _Key, class _Tp, class _Compare = less<_Key>> | |
| 973 | requires(!__is_allocator<_Compare>::value) | |
| 974 | flat_multimap(sorted_equivalent_t, initializer_list<pair<_Key, _Tp>>, _Compare = _Compare()) | |
| 975 | -> flat_multimap<_Key, _Tp, _Compare>; | |
| 976 | ||
| 977 | template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Allocator> | |
| 978 | struct uses_allocator<flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>, _Allocator> | |
| 979 | : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator>> {}; | |
| 980 | ||
| 981 | template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Predicate> | |
| 982 | _LIBCPP_HIDE_FROM_ABI typename flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::size_type | |
| 983 | erase_if(flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>& __flat_multimap, _Predicate __pred) { | |
| 984 | auto __zv = ranges::views::zip(__flat_multimap.__containers_.keys, __flat_multimap.__containers_.values); | |
| 985 | auto __first = __zv.begin(); | |
| 986 | auto __last = __zv.end(); | |
| 987 | auto __guard = std::__make_exception_guard([&] { __flat_multimap.clear(); }); | |
| 988 | auto __it = std::remove_if(__first, __last, [&](auto&& __zipped) -> bool { | |
| 989 | using _Ref = typename flat_multimap<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::const_reference; | |
| 990 | return __pred(_Ref(std::get<0>(__zipped), std::get<1>(__zipped))); | |
| 991 | }); | |
| 992 | auto __res = __last - __it; | |
| 993 | auto __offset = __it - __first; | |
| 994 | ||
| 995 | const auto __erase_container = [&](auto& __cont) { __cont.erase(__cont.begin() + __offset, __cont.end()); }; | |
| 996 | ||
| 997 | __erase_container(__flat_multimap.__containers_.keys); | |
| 998 | __erase_container(__flat_multimap.__containers_.values); | |
| 999 | ||
| 1000 | __guard.__complete(); | |
| 1001 | return __res; | |
| 1002 | } | |
| 1003 | ||
| 1004 | _LIBCPP_END_NAMESPACE_STD | |
| 1005 | ||
| 1006 | #endif // _LIBCPP_STD_VER >= 23 | |
| 1007 | ||
| 1008 | _LIBCPP_POP_MACROS | |
| 1009 | ||
| 1010 | #endif // _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H |
lib/libcxx/include/__flat_map/key_value_iterator.h created+176| ... | ... | @@ -0,0 +1,176 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FLAT_MAP_KEY_VALUE_ITERATOR_H | |
| 11 | #define _LIBCPP___FLAT_MAP_KEY_VALUE_ITERATOR_H | |
| 12 | ||
| 13 | #include <__compare/three_way_comparable.h> | |
| 14 | #include <__concepts/convertible_to.h> | |
| 15 | #include <__config> | |
| 16 | #include <__iterator/iterator_traits.h> | |
| 17 | #include <__memory/addressof.h> | |
| 18 | #include <__type_traits/conditional.h> | |
| 19 | #include <__utility/move.h> | |
| 20 | #include <__utility/pair.h> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | _LIBCPP_PUSH_MACROS | |
| 27 | #include <__undef_macros> | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER >= 23 | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | /** | |
| 34 | * __key_value_iterator is a proxy iterator which zips the underlying | |
| 35 | * _KeyContainer::iterator and the underlying _MappedContainer::iterator. | |
| 36 | * The two underlying iterators will be incremented/decremented together. | |
| 37 | * And the reference is a pair of the const key reference and the value reference. | |
| 38 | */ | |
| 39 | template <class _Owner, class _KeyContainer, class _MappedContainer, bool _Const> | |
| 40 | struct __key_value_iterator { | |
| 41 | private: | |
| 42 | using __key_iterator _LIBCPP_NODEBUG = typename _KeyContainer::const_iterator; | |
| 43 | using __mapped_iterator _LIBCPP_NODEBUG = | |
| 44 | _If<_Const, typename _MappedContainer::const_iterator, typename _MappedContainer::iterator>; | |
| 45 | using __reference _LIBCPP_NODEBUG = _If<_Const, typename _Owner::const_reference, typename _Owner::reference>; | |
| 46 | ||
| 47 | struct __arrow_proxy { | |
| 48 | __reference __ref_; | |
| 49 | _LIBCPP_HIDE_FROM_ABI __reference* operator->() { return std::addressof(__ref_); } | |
| 50 | }; | |
| 51 | ||
| 52 | __key_iterator __key_iter_; | |
| 53 | __mapped_iterator __mapped_iter_; | |
| 54 | ||
| 55 | friend _Owner; | |
| 56 | ||
| 57 | template <class, class, class, bool> | |
| 58 | friend struct __key_value_iterator; | |
| 59 | ||
| 60 | public: | |
| 61 | using iterator_concept = random_access_iterator_tag; | |
| 62 | // `__key_value_iterator` only satisfy "Cpp17InputIterator" named requirements, because | |
| 63 | // its `reference` is not a reference type. | |
| 64 | // However, to avoid surprising runtime behaviour when it is used with the | |
| 65 | // Cpp17 algorithms or operations, iterator_category is set to random_access_iterator_tag. | |
| 66 | using iterator_category = random_access_iterator_tag; | |
| 67 | using value_type = typename _Owner::value_type; | |
| 68 | using difference_type = typename _Owner::difference_type; | |
| 69 | ||
| 70 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator() = default; | |
| 71 | ||
| 72 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator(__key_value_iterator<_Owner, _KeyContainer, _MappedContainer, !_Const> __i) | |
| 73 | requires _Const && convertible_to<typename _KeyContainer::iterator, __key_iterator> && | |
| 74 | convertible_to<typename _MappedContainer::iterator, __mapped_iterator> | |
| 75 | : __key_iter_(std::move(__i.__key_iter_)), __mapped_iter_(std::move(__i.__mapped_iter_)) {} | |
| 76 | ||
| 77 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator(__key_iterator __key_iter, __mapped_iterator __mapped_iter) | |
| 78 | : __key_iter_(std::move(__key_iter)), __mapped_iter_(std::move(__mapped_iter)) {} | |
| 79 | ||
| 80 | _LIBCPP_HIDE_FROM_ABI __reference operator*() const { return __reference(*__key_iter_, *__mapped_iter_); } | |
| 81 | _LIBCPP_HIDE_FROM_ABI __arrow_proxy operator->() const { return __arrow_proxy{**this}; } | |
| 82 | ||
| 83 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator++() { | |
| 84 | ++__key_iter_; | |
| 85 | ++__mapped_iter_; | |
| 86 | return *this; | |
| 87 | } | |
| 88 | ||
| 89 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator operator++(int) { | |
| 90 | __key_value_iterator __tmp(*this); | |
| 91 | ++*this; | |
| 92 | return __tmp; | |
| 93 | } | |
| 94 | ||
| 95 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator--() { | |
| 96 | --__key_iter_; | |
| 97 | --__mapped_iter_; | |
| 98 | return *this; | |
| 99 | } | |
| 100 | ||
| 101 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator operator--(int) { | |
| 102 | __key_value_iterator __tmp(*this); | |
| 103 | --*this; | |
| 104 | return __tmp; | |
| 105 | } | |
| 106 | ||
| 107 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator+=(difference_type __x) { | |
| 108 | __key_iter_ += __x; | |
| 109 | __mapped_iter_ += __x; | |
| 110 | return *this; | |
| 111 | } | |
| 112 | ||
| 113 | _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator-=(difference_type __x) { | |
| 114 | __key_iter_ -= __x; | |
| 115 | __mapped_iter_ -= __x; | |
| 116 | return *this; | |
| 117 | } | |
| 118 | ||
| 119 | _LIBCPP_HIDE_FROM_ABI __reference operator[](difference_type __n) const { return *(*this + __n); } | |
| 120 | ||
| 121 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | |
| 122 | operator==(const __key_value_iterator& __x, const __key_value_iterator& __y) { | |
| 123 | return __x.__key_iter_ == __y.__key_iter_; | |
| 124 | } | |
| 125 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __key_value_iterator& __x, const __key_value_iterator& __y) { | |
| 127 | return __x.__key_iter_ < __y.__key_iter_; | |
| 128 | } | |
| 129 | ||
| 130 | _LIBCPP_HIDE_FROM_ABI friend bool operator>(const __key_value_iterator& __x, const __key_value_iterator& __y) { | |
| 131 | return __y < __x; | |
| 132 | } | |
| 133 | ||
| 134 | _LIBCPP_HIDE_FROM_ABI friend bool operator<=(const __key_value_iterator& __x, const __key_value_iterator& __y) { | |
| 135 | return !(__y < __x); | |
| 136 | } | |
| 137 | ||
| 138 | _LIBCPP_HIDE_FROM_ABI friend bool operator>=(const __key_value_iterator& __x, const __key_value_iterator& __y) { | |
| 139 | return !(__x < __y); | |
| 140 | } | |
| 141 | ||
| 142 | _LIBCPP_HIDE_FROM_ABI friend auto operator<=>(const __key_value_iterator& __x, const __key_value_iterator& __y) | |
| 143 | requires three_way_comparable<__key_iterator> | |
| 144 | { | |
| 145 | return __x.__key_iter_ <=> __y.__key_iter_; | |
| 146 | } | |
| 147 | ||
| 148 | _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator+(const __key_value_iterator& __i, difference_type __n) { | |
| 149 | auto __tmp = __i; | |
| 150 | __tmp += __n; | |
| 151 | return __tmp; | |
| 152 | } | |
| 153 | ||
| 154 | _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator+(difference_type __n, const __key_value_iterator& __i) { | |
| 155 | return __i + __n; | |
| 156 | } | |
| 157 | ||
| 158 | _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator-(const __key_value_iterator& __i, difference_type __n) { | |
| 159 | auto __tmp = __i; | |
| 160 | __tmp -= __n; | |
| 161 | return __tmp; | |
| 162 | } | |
| 163 | ||
| 164 | _LIBCPP_HIDE_FROM_ABI friend difference_type | |
| 165 | operator-(const __key_value_iterator& __x, const __key_value_iterator& __y) { | |
| 166 | return difference_type(__x.__key_iter_ - __y.__key_iter_); | |
| 167 | } | |
| 168 | }; | |
| 169 | ||
| 170 | _LIBCPP_END_NAMESPACE_STD | |
| 171 | ||
| 172 | #endif // _LIBCPP_STD_VER >= 23 | |
| 173 | ||
| 174 | _LIBCPP_POP_MACROS | |
| 175 | ||
| 176 | #endif // _LIBCPP___FLAT_MAP_KEY_VALUE_ITERATOR_H |
lib/libcxx/include/__flat_map/sorted_equivalent.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 | #ifndef _LIBCPP___FLAT_MAP_SORTED_EQUIVALENT_H | |
| 10 | #define _LIBCPP___FLAT_MAP_SORTED_EQUIVALENT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | #if _LIBCPP_STD_VER >= 23 | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | struct sorted_equivalent_t { | |
| 23 | explicit sorted_equivalent_t() = default; | |
| 24 | }; | |
| 25 | inline constexpr sorted_equivalent_t sorted_equivalent{}; | |
| 26 | ||
| 27 | _LIBCPP_END_NAMESPACE_STD | |
| 28 | ||
| 29 | #endif // _LIBCPP_STD_VER >= 23 | |
| 30 | ||
| 31 | #endif // _LIBCPP___FLAT_MAP_SORTED_EQUIVALENT_H |
lib/libcxx/include/__flat_map/sorted_unique.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 | #ifndef _LIBCPP___FLAT_MAP_SORTED_UNIQUE_H | |
| 10 | #define _LIBCPP___FLAT_MAP_SORTED_UNIQUE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | #if _LIBCPP_STD_VER >= 23 | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | struct sorted_unique_t { | |
| 23 | explicit sorted_unique_t() = default; | |
| 24 | }; | |
| 25 | inline constexpr sorted_unique_t sorted_unique{}; | |
| 26 | ||
| 27 | _LIBCPP_END_NAMESPACE_STD | |
| 28 | ||
| 29 | #endif // _LIBCPP_STD_VER >= 23 | |
| 30 | ||
| 31 | #endif // _LIBCPP___FLAT_MAP_SORTED_UNIQUE_H |
lib/libcxx/include/__flat_map/utils.h created+103| ... | ... | @@ -0,0 +1,103 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FLAT_MAP_UTILS_H | |
| 11 | #define _LIBCPP___FLAT_MAP_UTILS_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__type_traits/container_traits.h> | |
| 15 | #include <__utility/exception_guard.h> | |
| 16 | #include <__utility/forward.h> | |
| 17 | #include <__utility/move.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 _LIBCPP_STD_VER >= 23 | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | // These utilities are defined in a class instead of a namespace so that this class can be befriended more easily. | |
| 31 | struct __flat_map_utils { | |
| 32 | // Emplace a {key: value} into a flat_{multi}map, at the exact position that | |
| 33 | // __it_key and __it_mapped point to, assuming that the key is not already present in the map. | |
| 34 | // When an exception is thrown during the emplacement, the function will try its best to | |
| 35 | // roll back the changes it made to the map. If it cannot roll back the changes, it will | |
| 36 | // clear the map. | |
| 37 | template <class _Map, class _IterK, class _IterM, class _KeyArg, class... _MArgs> | |
| 38 | _LIBCPP_HIDE_FROM_ABI static typename _Map::iterator __emplace_exact_pos( | |
| 39 | _Map& __map, _IterK&& __it_key, _IterM&& __it_mapped, _KeyArg&& __key, _MArgs&&... __mapped_args) { | |
| 40 | auto __on_key_failed = std::__make_exception_guard([&]() noexcept { | |
| 41 | using _KeyContainer = typename _Map::key_container_type; | |
| 42 | if constexpr (__container_traits<_KeyContainer>::__emplacement_has_strong_exception_safety_guarantee) { | |
| 43 | // Nothing to roll back! | |
| 44 | } else { | |
| 45 | // we need to clear both because we don't know the state of our keys anymore | |
| 46 | __map.clear() /* noexcept */; | |
| 47 | } | |
| 48 | }); | |
| 49 | auto __key_it = __map.__containers_.keys.emplace(__it_key, std::forward<_KeyArg>(__key)); | |
| 50 | __on_key_failed.__complete(); | |
| 51 | ||
| 52 | auto __on_value_failed = std::__make_exception_guard([&]() noexcept { | |
| 53 | using _MappedContainer = typename _Map::mapped_container_type; | |
| 54 | if constexpr (!__container_traits<_MappedContainer>::__emplacement_has_strong_exception_safety_guarantee) { | |
| 55 | // we need to clear both because we don't know the state of our values anymore | |
| 56 | __map.clear() /* noexcept */; | |
| 57 | } else { | |
| 58 | // In this case, we know the values are just like before we attempted emplacement, | |
| 59 | // and we also know that the keys have been emplaced successfully. Just roll back the keys. | |
| 60 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 61 | try { | |
| 62 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 63 | __map.__containers_.keys.erase(__key_it); | |
| 64 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 65 | } catch (...) { | |
| 66 | // Now things are funky for real. We're failing to rollback the keys. | |
| 67 | // Just give up and clear the whole thing. | |
| 68 | // | |
| 69 | // Also, swallow the exception that happened during the rollback and let the | |
| 70 | // original value-emplacement exception propagate normally. | |
| 71 | __map.clear() /* noexcept */; | |
| 72 | } | |
| 73 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 74 | } | |
| 75 | }); | |
| 76 | auto __mapped_it = __map.__containers_.values.emplace(__it_mapped, std::forward<_MArgs>(__mapped_args)...); | |
| 77 | __on_value_failed.__complete(); | |
| 78 | ||
| 79 | return typename _Map::iterator(std::move(__key_it), std::move(__mapped_it)); | |
| 80 | } | |
| 81 | ||
| 82 | // TODO: We could optimize this, see | |
| 83 | // https://github.com/llvm/llvm-project/issues/108624 | |
| 84 | template <class _Map, class _InputIterator, class _Sentinel> | |
| 85 | _LIBCPP_HIDE_FROM_ABI static typename _Map::size_type | |
| 86 | __append(_Map& __map, _InputIterator __first, _Sentinel __last) { | |
| 87 | typename _Map::size_type __num_appended = 0; | |
| 88 | for (; __first != __last; ++__first) { | |
| 89 | typename _Map::value_type __kv = *__first; | |
| 90 | __map.__containers_.keys.insert(__map.__containers_.keys.end(), std::move(__kv.first)); | |
| 91 | __map.__containers_.values.insert(__map.__containers_.values.end(), std::move(__kv.second)); | |
| 92 | ++__num_appended; | |
| 93 | } | |
| 94 | return __num_appended; | |
| 95 | } | |
| 96 | }; | |
| 97 | _LIBCPP_END_NAMESPACE_STD | |
| 98 | ||
| 99 | #endif // _LIBCPP_STD_VER >= 23 | |
| 100 | ||
| 101 | _LIBCPP_POP_MACROS | |
| 102 | ||
| 103 | #endif // #define _LIBCPP___FLAT_MAP_UTILS_H |
lib/libcxx/include/__format/buffer.h+341-287| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | #include <__algorithm/fill_n.h> |
| 15 | 15 | #include <__algorithm/max.h> |
| 16 | 16 | #include <__algorithm/min.h> |
| 17 | #include <__algorithm/ranges_copy.h> | |
| 17 | 18 | #include <__algorithm/ranges_copy_n.h> |
| 18 | 19 | #include <__algorithm/transform.h> |
| 19 | 20 | #include <__algorithm/unwrap_iter.h> |
| ... | ... | @@ -29,6 +30,7 @@ |
| 29 | 30 | #include <__iterator/wrap_iter.h> |
| 30 | 31 | #include <__memory/addressof.h> |
| 31 | 32 | #include <__memory/allocate_at_least.h> |
| 33 | #include <__memory/allocator.h> | |
| 32 | 34 | #include <__memory/allocator_traits.h> |
| 33 | 35 | #include <__memory/construct_at.h> |
| 34 | 36 | #include <__memory/ranges_construct_at.h> |
| ... | ... | @@ -37,7 +39,7 @@ |
| 37 | 39 | #include <__type_traits/conditional.h> |
| 38 | 40 | #include <__utility/exception_guard.h> |
| 39 | 41 | #include <__utility/move.h> |
| 40 | #include <cstddef> | |
| 42 | #include <stdexcept> | |
| 41 | 43 | #include <string_view> |
| 42 | 44 | |
| 43 | 45 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -53,24 +55,147 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 53 | 55 | |
| 54 | 56 | namespace __format { |
| 55 | 57 | |
| 58 | // A helper to limit the total size of code units written. | |
| 59 | class _LIBCPP_HIDE_FROM_ABI __max_output_size { | |
| 60 | public: | |
| 61 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __max_output_size(size_t __max_size) : __max_size_{__max_size} {} | |
| 62 | ||
| 63 | // This function adjusts the size of a (bulk) write operations. It ensures the | |
| 64 | // number of code units written by a __output_buffer never exceeds | |
| 65 | // __max_size_ code units. | |
| 66 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __write_request(size_t __code_units) { | |
| 67 | size_t __result = | |
| 68 | __code_units_written_ < __max_size_ ? std::min(__code_units, __max_size_ - __code_units_written_) : 0; | |
| 69 | __code_units_written_ += __code_units; | |
| 70 | return __result; | |
| 71 | } | |
| 72 | ||
| 73 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __code_units_written() const noexcept { return __code_units_written_; } | |
| 74 | ||
| 75 | private: | |
| 76 | size_t __max_size_; | |
| 77 | // The code units that would have been written if there was no limit. | |
| 78 | // format_to_n returns this value. | |
| 79 | size_t __code_units_written_{0}; | |
| 80 | }; | |
| 81 | ||
| 56 | 82 | /// A "buffer" that handles writing to the proper iterator. |
| 57 | 83 | /// |
| 58 | 84 | /// This helper is used together with the @ref back_insert_iterator to offer |
| 59 | 85 | /// type-erasure for the formatting functions. This reduces the number to |
| 60 | 86 | /// template instantiations. |
| 87 | /// | |
| 88 | /// The design is the following: | |
| 89 | /// - There is an external object that connects the buffer to the output. | |
| 90 | /// - This buffer object: | |
| 91 | /// - inherits publicly from this class. | |
| 92 | /// - has a static or dynamic buffer. | |
| 93 | /// - has a static member function to make space in its buffer write | |
| 94 | /// operations. This can be done by increasing the size of the internal | |
| 95 | /// buffer or by writing the contents of the buffer to the output iterator. | |
| 96 | /// | |
| 97 | /// This member function is a constructor argument, so its name is not | |
| 98 | /// fixed. The code uses the name __prepare_write. | |
| 99 | /// - The number of output code units can be limited by a __max_output_size | |
| 100 | /// object. This is used in format_to_n This object: | |
| 101 | /// - Contains the maximum number of code units to be written. | |
| 102 | /// - Contains the number of code units that are requested to be written. | |
| 103 | /// This number is returned to the user of format_to_n. | |
| 104 | /// - The write functions call the object's __request_write member function. | |
| 105 | /// This function: | |
| 106 | /// - Updates the number of code units that are requested to be written. | |
| 107 | /// - Returns the number of code units that can be written without | |
| 108 | /// exceeding the maximum number of code units to be written. | |
| 109 | /// | |
| 110 | /// Documentation for the buffer usage members: | |
| 111 | /// - __ptr_ | |
| 112 | /// The start of the buffer. | |
| 113 | /// - __capacity_ | |
| 114 | /// The number of code units that can be written. This means | |
| 115 | /// [__ptr_, __ptr_ + __capacity_) is a valid range to write to. | |
| 116 | /// - __size_ | |
| 117 | /// The number of code units written in the buffer. The next code unit will | |
| 118 | /// be written at __ptr_ + __size_. This __size_ may NOT contain the total | |
| 119 | /// number of code units written by the __output_buffer. Whether or not it | |
| 120 | /// does depends on the sub-class used. Typically the total number of code | |
| 121 | /// units written is not interesting. It is interesting for format_to_n which | |
| 122 | /// has its own way to track this number. | |
| 123 | /// | |
| 124 | /// Documentation for the modifying buffer operations: | |
| 125 | /// The subclasses have a function with the following signature: | |
| 126 | /// | |
| 127 | /// static void __prepare_write( | |
| 128 | /// __output_buffer<_CharT>& __buffer, size_t __code_units); | |
| 129 | /// | |
| 130 | /// This function is called when a write function writes more code units than | |
| 131 | /// the buffer's available space. When an __max_output_size object is provided | |
| 132 | /// the number of code units is the number of code units returned from | |
| 133 | /// __max_output_size::__request_write function. | |
| 134 | /// | |
| 135 | /// - The __buffer contains *this. Since the class containing this function | |
| 136 | /// inherits from __output_buffer it's safe to cast it to the subclass being | |
| 137 | /// used. | |
| 138 | /// - The __code_units is the number of code units the caller will write + 1. | |
| 139 | /// - This value does not take the available space of the buffer into account. | |
| 140 | /// - The push_back function is more efficient when writing before resizing, | |
| 141 | /// this means the buffer should always have room for one code unit. Hence | |
| 142 | /// the + 1 is the size. | |
| 143 | /// - When the function returns there is room for at least one additional code | |
| 144 | /// unit. There is no requirement there is room for __code_units code units: | |
| 145 | /// - The class has some "bulk" operations. For example, __copy which copies | |
| 146 | /// the contents of a basic_string_view to the output. If the sub-class has | |
| 147 | /// a fixed size buffer the size of the basic_string_view may be larger | |
| 148 | /// than the buffer. In that case it's impossible to honor the requested | |
| 149 | /// size. | |
| 150 | /// - When the buffer has room for at least one code unit the function may be | |
| 151 | /// a no-op. | |
| 152 | /// - When the function makes space for more code units it uses one for these | |
| 153 | /// functions to signal the change: | |
| 154 | /// - __buffer_flushed() | |
| 155 | /// - This function is typically used for a fixed sized buffer. | |
| 156 | /// - The current contents of [__ptr_, __ptr_ + __size_) have been | |
| 157 | /// processed. | |
| 158 | /// - __ptr_ remains unchanged. | |
| 159 | /// - __capacity_ remains unchanged. | |
| 160 | /// - __size_ will be set to 0. | |
| 161 | /// - __buffer_moved(_CharT* __ptr, size_t __capacity) | |
| 162 | /// - This function is typically used for a dynamic sized buffer. There the | |
| 163 | /// location of the buffer changes due to reallocations. | |
| 164 | /// - __ptr_ will be set to __ptr. (This value may be the old value of | |
| 165 | /// __ptr_). | |
| 166 | /// - __capacity_ will be set to __capacity. (This value may be the old | |
| 167 | /// value of __capacity_). | |
| 168 | /// - __size_ remains unchanged, | |
| 169 | /// - The range [__ptr, __ptr + __size_) contains the original data of the | |
| 170 | /// range [__ptr_, __ptr_ + __size_). | |
| 171 | /// | |
| 172 | /// The push_back function expects a valid buffer and a capacity of at least 1. | |
| 173 | /// This means: | |
| 174 | /// - The class is constructed with a valid buffer, | |
| 175 | /// - __buffer_moved is called with a valid buffer is used before the first | |
| 176 | /// write operation, | |
| 177 | /// - no write function is ever called, or | |
| 178 | /// - the class is constructed with a __max_output_size object with __max_size 0. | |
| 179 | /// | |
| 180 | /// The latter option allows formatted_size to use the output buffer without | |
| 181 | /// ever writing anything to the buffer. | |
| 61 | 182 | template <__fmt_char_type _CharT> |
| 62 | 183 | class _LIBCPP_TEMPLATE_VIS __output_buffer { |
| 63 | 184 | public: |
| 64 | using value_type = _CharT; | |
| 185 | using value_type _LIBCPP_NODEBUG = _CharT; | |
| 186 | using __prepare_write_type _LIBCPP_NODEBUG = void (*)(__output_buffer<_CharT>&, size_t); | |
| 65 | 187 | |
| 66 | template <class _Tp> | |
| 67 | _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t __capacity, _Tp* __obj) | |
| 68 | : __ptr_(__ptr), | |
| 69 | __capacity_(__capacity), | |
| 70 | __flush_([](_CharT* __p, size_t __n, void* __o) { static_cast<_Tp*>(__o)->__flush(__p, __n); }), | |
| 71 | __obj_(__obj) {} | |
| 188 | [[nodiscard]] | |
| 189 | _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t __capacity, __prepare_write_type __function) | |
| 190 | : __output_buffer{__ptr, __capacity, __function, nullptr} {} | |
| 72 | 191 | |
| 73 | _LIBCPP_HIDE_FROM_ABI void __reset(_CharT* __ptr, size_t __capacity) { | |
| 192 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __output_buffer( | |
| 193 | _CharT* __ptr, size_t __capacity, __prepare_write_type __function, __max_output_size* __max_output_size) | |
| 194 | : __ptr_(__ptr), __capacity_(__capacity), __prepare_write_(__function), __max_output_size_(__max_output_size) {} | |
| 195 | ||
| 196 | _LIBCPP_HIDE_FROM_ABI void __buffer_flushed() { __size_ = 0; } | |
| 197 | ||
| 198 | _LIBCPP_HIDE_FROM_ABI void __buffer_moved(_CharT* __ptr, size_t __capacity) { | |
| 74 | 199 | __ptr_ = __ptr; |
| 75 | 200 | __capacity_ = __capacity; |
| 76 | 201 | } |
| ... | ... | @@ -79,12 +204,18 @@ public: |
| 79 | 204 | |
| 80 | 205 | // Used in std::back_insert_iterator. |
| 81 | 206 | _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) { |
| 207 | if (__max_output_size_ && __max_output_size_->__write_request(1) == 0) | |
| 208 | return; | |
| 209 | ||
| 210 | _LIBCPP_ASSERT_INTERNAL( | |
| 211 | __ptr_ && __size_ < __capacity_ && __available() >= 1, "attempted to write outside the buffer"); | |
| 212 | ||
| 82 | 213 | __ptr_[__size_++] = __c; |
| 83 | 214 | |
| 84 | 215 | // Profiling showed flushing after adding is more efficient than flushing |
| 85 | 216 | // when entering the function. |
| 86 | 217 | if (__size_ == __capacity_) |
| 87 | __flush(); | |
| 218 | __prepare_write(0); | |
| 88 | 219 | } |
| 89 | 220 | |
| 90 | 221 | /// Copies the input __str to the buffer. |
| ... | ... | @@ -105,25 +236,20 @@ public: |
| 105 | 236 | // upper case. For integral these strings are short. |
| 106 | 237 | // TODO FMT Look at the improvements above. |
| 107 | 238 | size_t __n = __str.size(); |
| 108 | ||
| 109 | __flush_on_overflow(__n); | |
| 110 | if (__n < __capacity_) { // push_back requires the buffer to have room for at least one character (so use <). | |
| 111 | std::copy_n(__str.data(), __n, std::addressof(__ptr_[__size_])); | |
| 112 | __size_ += __n; | |
| 113 | return; | |
| 239 | if (__max_output_size_) { | |
| 240 | __n = __max_output_size_->__write_request(__n); | |
| 241 | if (__n == 0) | |
| 242 | return; | |
| 114 | 243 | } |
| 115 | 244 | |
| 116 | // The output doesn't fit in the internal buffer. | |
| 117 | // Copy the data in "__capacity_" sized chunks. | |
| 118 | _LIBCPP_ASSERT_INTERNAL(__size_ == 0, "the buffer should be flushed by __flush_on_overflow"); | |
| 119 | 245 | const _InCharT* __first = __str.data(); |
| 120 | 246 | do { |
| 121 | size_t __chunk = std::min(__n, __capacity_); | |
| 247 | __prepare_write(__n); | |
| 248 | size_t __chunk = std::min(__n, __available()); | |
| 122 | 249 | std::copy_n(__first, __chunk, std::addressof(__ptr_[__size_])); |
| 123 | __size_ = __chunk; | |
| 250 | __size_ += __chunk; | |
| 124 | 251 | __first += __chunk; |
| 125 | 252 | __n -= __chunk; |
| 126 | __flush(); | |
| 127 | 253 | } while (__n); |
| 128 | 254 | } |
| 129 | 255 | |
| ... | ... | @@ -137,121 +263,59 @@ public: |
| 137 | 263 | _LIBCPP_ASSERT_INTERNAL(__first <= __last, "not a valid range"); |
| 138 | 264 | |
| 139 | 265 | size_t __n = static_cast<size_t>(__last - __first); |
| 140 | __flush_on_overflow(__n); | |
| 141 | if (__n < __capacity_) { // push_back requires the buffer to have room for at least one character (so use <). | |
| 142 | std::transform(__first, __last, std::addressof(__ptr_[__size_]), std::move(__operation)); | |
| 143 | __size_ += __n; | |
| 144 | return; | |
| 266 | if (__max_output_size_) { | |
| 267 | __n = __max_output_size_->__write_request(__n); | |
| 268 | if (__n == 0) | |
| 269 | return; | |
| 145 | 270 | } |
| 146 | 271 | |
| 147 | // The output doesn't fit in the internal buffer. | |
| 148 | // Transform the data in "__capacity_" sized chunks. | |
| 149 | _LIBCPP_ASSERT_INTERNAL(__size_ == 0, "the buffer should be flushed by __flush_on_overflow"); | |
| 150 | 272 | do { |
| 151 | size_t __chunk = std::min(__n, __capacity_); | |
| 273 | __prepare_write(__n); | |
| 274 | size_t __chunk = std::min(__n, __available()); | |
| 152 | 275 | std::transform(__first, __first + __chunk, std::addressof(__ptr_[__size_]), __operation); |
| 153 | __size_ = __chunk; | |
| 276 | __size_ += __chunk; | |
| 154 | 277 | __first += __chunk; |
| 155 | 278 | __n -= __chunk; |
| 156 | __flush(); | |
| 157 | 279 | } while (__n); |
| 158 | 280 | } |
| 159 | 281 | |
| 160 | 282 | /// A \c fill_n wrapper. |
| 161 | 283 | _LIBCPP_HIDE_FROM_ABI void __fill(size_t __n, _CharT __value) { |
| 162 | __flush_on_overflow(__n); | |
| 163 | if (__n < __capacity_) { // push_back requires the buffer to have room for at least one character (so use <). | |
| 164 | std::fill_n(std::addressof(__ptr_[__size_]), __n, __value); | |
| 165 | __size_ += __n; | |
| 166 | return; | |
| 284 | if (__max_output_size_) { | |
| 285 | __n = __max_output_size_->__write_request(__n); | |
| 286 | if (__n == 0) | |
| 287 | return; | |
| 167 | 288 | } |
| 168 | 289 | |
| 169 | // The output doesn't fit in the internal buffer. | |
| 170 | // Fill the buffer in "__capacity_" sized chunks. | |
| 171 | _LIBCPP_ASSERT_INTERNAL(__size_ == 0, "the buffer should be flushed by __flush_on_overflow"); | |
| 172 | 290 | do { |
| 173 | size_t __chunk = std::min(__n, __capacity_); | |
| 291 | __prepare_write(__n); | |
| 292 | size_t __chunk = std::min(__n, __available()); | |
| 174 | 293 | std::fill_n(std::addressof(__ptr_[__size_]), __chunk, __value); |
| 175 | __size_ = __chunk; | |
| 294 | __size_ += __chunk; | |
| 176 | 295 | __n -= __chunk; |
| 177 | __flush(); | |
| 178 | 296 | } while (__n); |
| 179 | 297 | } |
| 180 | 298 | |
| 181 | _LIBCPP_HIDE_FROM_ABI void __flush() { | |
| 182 | __flush_(__ptr_, __size_, __obj_); | |
| 183 | __size_ = 0; | |
| 184 | } | |
| 299 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __capacity() const { return __capacity_; } | |
| 300 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __size() const { return __size_; } | |
| 185 | 301 | |
| 186 | 302 | private: |
| 187 | 303 | _CharT* __ptr_; |
| 188 | 304 | size_t __capacity_; |
| 189 | 305 | size_t __size_{0}; |
| 190 | void (*__flush_)(_CharT*, size_t, void*); | |
| 191 | void* __obj_; | |
| 306 | void (*__prepare_write_)(__output_buffer<_CharT>&, size_t); | |
| 307 | __max_output_size* __max_output_size_; | |
| 192 | 308 | |
| 193 | /// Flushes the buffer when the output operation would overflow the buffer. | |
| 194 | /// | |
| 195 | /// A simple approach for the overflow detection would be something along the | |
| 196 | /// lines: | |
| 197 | /// \code | |
| 198 | /// // The internal buffer is large enough. | |
| 199 | /// if (__n <= __capacity_) { | |
| 200 | /// // Flush when we really would overflow. | |
| 201 | /// if (__size_ + __n >= __capacity_) | |
| 202 | /// __flush(); | |
| 203 | /// ... | |
| 204 | /// } | |
| 205 | /// \endcode | |
| 206 | /// | |
| 207 | /// This approach works for all cases but one: | |
| 208 | /// A __format_to_n_buffer_base where \ref __enable_direct_output is true. | |
| 209 | /// In that case the \ref __capacity_ of the buffer changes during the first | |
| 210 | /// \ref __flush. During that operation the output buffer switches from its | |
| 211 | /// __writer_ to its __storage_. The \ref __capacity_ of the former depends | |
| 212 | /// on the value of n, of the latter is a fixed size. For example: | |
| 213 | /// - a format_to_n call with a 10'000 char buffer, | |
| 214 | /// - the buffer is filled with 9'500 chars, | |
| 215 | /// - adding 1'000 elements would overflow the buffer so the buffer gets | |
| 216 | /// changed and the \ref __capacity_ decreases from 10'000 to | |
| 217 | /// __buffer_size (256 at the time of writing). | |
| 218 | /// | |
| 219 | /// This means that the \ref __flush for this class may need to copy a part of | |
| 220 | /// the internal buffer to the proper output. In this example there will be | |
| 221 | /// 500 characters that need this copy operation. | |
| 222 | /// | |
| 223 | /// Note it would be more efficient to write 500 chars directly and then swap | |
| 224 | /// the buffers. This would make the code more complex and \ref format_to_n is | |
| 225 | /// not the most common use case. Therefore the optimization isn't done. | |
| 226 | _LIBCPP_HIDE_FROM_ABI void __flush_on_overflow(size_t __n) { | |
| 227 | if (__size_ + __n >= __capacity_) | |
| 228 | __flush(); | |
| 229 | } | |
| 230 | }; | |
| 231 | ||
| 232 | /// A storage using an internal buffer. | |
| 233 | /// | |
| 234 | /// This storage is used when writing a single element to the output iterator | |
| 235 | /// is expensive. | |
| 236 | template <__fmt_char_type _CharT> | |
| 237 | class _LIBCPP_TEMPLATE_VIS __internal_storage { | |
| 238 | public: | |
| 239 | _LIBCPP_HIDE_FROM_ABI _CharT* __begin() { return __buffer_; } | |
| 240 | ||
| 241 | static constexpr size_t __buffer_size = 256 / sizeof(_CharT); | |
| 309 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __available() const { return __capacity_ - __size_; } | |
| 242 | 310 | |
| 243 | private: | |
| 244 | _CharT __buffer_[__buffer_size]; | |
| 311 | _LIBCPP_HIDE_FROM_ABI void __prepare_write(size_t __code_units) { | |
| 312 | // Always have space for one additional code unit. This is a precondition of the push_back function. | |
| 313 | __code_units += 1; | |
| 314 | if (__available() < __code_units) | |
| 315 | __prepare_write_(*this, __code_units + 1); | |
| 316 | } | |
| 245 | 317 | }; |
| 246 | 318 | |
| 247 | /// A storage writing directly to the storage. | |
| 248 | /// | |
| 249 | /// This requires the storage to be a contiguous buffer of \a _CharT. | |
| 250 | /// Since the output is directly written to the underlying storage this class | |
| 251 | /// is just an empty class. | |
| 252 | template <__fmt_char_type _CharT> | |
| 253 | class _LIBCPP_TEMPLATE_VIS __direct_storage {}; | |
| 254 | ||
| 255 | 319 | template <class _OutIt, class _CharT> |
| 256 | 320 | concept __enable_direct_output = |
| 257 | 321 | __fmt_char_type<_CharT> && |
| ... | ... | @@ -260,40 +324,6 @@ concept __enable_direct_output = |
| 260 | 324 | // `#ifdef`. |
| 261 | 325 | || same_as<_OutIt, __wrap_iter<_CharT*>>); |
| 262 | 326 | |
| 263 | /// Write policy for directly writing to the underlying output. | |
| 264 | template <class _OutIt, __fmt_char_type _CharT> | |
| 265 | class _LIBCPP_TEMPLATE_VIS __writer_direct { | |
| 266 | public: | |
| 267 | _LIBCPP_HIDE_FROM_ABI explicit __writer_direct(_OutIt __out_it) : __out_it_(__out_it) {} | |
| 268 | ||
| 269 | _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() { return __out_it_; } | |
| 270 | ||
| 271 | _LIBCPP_HIDE_FROM_ABI void __flush(_CharT*, size_t __n) { | |
| 272 | // _OutIt can be a __wrap_iter<CharT*>. Therefore the original iterator | |
| 273 | // is adjusted. | |
| 274 | __out_it_ += __n; | |
| 275 | } | |
| 276 | ||
| 277 | private: | |
| 278 | _OutIt __out_it_; | |
| 279 | }; | |
| 280 | ||
| 281 | /// Write policy for copying the buffer to the output. | |
| 282 | template <class _OutIt, __fmt_char_type _CharT> | |
| 283 | class _LIBCPP_TEMPLATE_VIS __writer_iterator { | |
| 284 | public: | |
| 285 | _LIBCPP_HIDE_FROM_ABI explicit __writer_iterator(_OutIt __out_it) : __out_it_{std::move(__out_it)} {} | |
| 286 | ||
| 287 | _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && { return std::move(__out_it_); } | |
| 288 | ||
| 289 | _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) { | |
| 290 | __out_it_ = std::ranges::copy_n(__ptr, __n, std::move(__out_it_)).out; | |
| 291 | } | |
| 292 | ||
| 293 | private: | |
| 294 | _OutIt __out_it_; | |
| 295 | }; | |
| 296 | ||
| 297 | 327 | /// Concept to see whether a \a _Container is insertable. |
| 298 | 328 | /// |
| 299 | 329 | /// The concept is used to validate whether multiple calls to a |
| ... | ... | @@ -311,196 +341,220 @@ concept __insertable = |
| 311 | 341 | /// Extract the container type of a \ref back_insert_iterator. |
| 312 | 342 | template <class _It> |
| 313 | 343 | struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container { |
| 314 | using type = void; | |
| 344 | using type _LIBCPP_NODEBUG = void; | |
| 315 | 345 | }; |
| 316 | 346 | |
| 317 | 347 | template <__insertable _Container> |
| 318 | 348 | struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container<back_insert_iterator<_Container>> { |
| 319 | using type = _Container; | |
| 349 | using type _LIBCPP_NODEBUG = _Container; | |
| 320 | 350 | }; |
| 321 | 351 | |
| 322 | /// Write policy for inserting the buffer in a container. | |
| 323 | template <class _Container> | |
| 324 | class _LIBCPP_TEMPLATE_VIS __writer_container { | |
| 352 | // A dynamically growing buffer. | |
| 353 | template <__fmt_char_type _CharT> | |
| 354 | class _LIBCPP_TEMPLATE_VIS __allocating_buffer : public __output_buffer<_CharT> { | |
| 325 | 355 | public: |
| 326 | using _CharT = typename _Container::value_type; | |
| 356 | __allocating_buffer(const __allocating_buffer&) = delete; | |
| 357 | __allocating_buffer& operator=(const __allocating_buffer&) = delete; | |
| 327 | 358 | |
| 328 | _LIBCPP_HIDE_FROM_ABI explicit __writer_container(back_insert_iterator<_Container> __out_it) | |
| 329 | : __container_{__out_it.__get_container()} {} | |
| 359 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __allocating_buffer() : __allocating_buffer{nullptr} {} | |
| 330 | 360 | |
| 331 | _LIBCPP_HIDE_FROM_ABI auto __out_it() { return std::back_inserter(*__container_); } | |
| 361 | [[nodiscard]] | |
| 362 | _LIBCPP_HIDE_FROM_ABI explicit __allocating_buffer(__max_output_size* __max_output_size) | |
| 363 | : __output_buffer<_CharT>{__small_buffer_, __buffer_size_, __prepare_write, __max_output_size} {} | |
| 332 | 364 | |
| 333 | _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) { | |
| 334 | __container_->insert(__container_->end(), __ptr, __ptr + __n); | |
| 365 | _LIBCPP_HIDE_FROM_ABI ~__allocating_buffer() { | |
| 366 | if (__ptr_ != __small_buffer_) | |
| 367 | _Alloc{}.deallocate(__ptr_, this->__capacity()); | |
| 335 | 368 | } |
| 336 | 369 | |
| 337 | private: | |
| 338 | _Container* __container_; | |
| 339 | }; | |
| 370 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT> __view() { return {__ptr_, this->__size()}; } | |
| 340 | 371 | |
| 341 | /// Selects the type of the writer used for the output iterator. | |
| 342 | template <class _OutIt, class _CharT> | |
| 343 | class _LIBCPP_TEMPLATE_VIS __writer_selector { | |
| 344 | using _Container = typename __back_insert_iterator_container<_OutIt>::type; | |
| 372 | private: | |
| 373 | using _Alloc _LIBCPP_NODEBUG = allocator<_CharT>; | |
| 345 | 374 | |
| 346 | public: | |
| 347 | using type = | |
| 348 | conditional_t<!same_as<_Container, void>, | |
| 349 | __writer_container<_Container>, | |
| 350 | conditional_t<__enable_direct_output<_OutIt, _CharT>, | |
| 351 | __writer_direct<_OutIt, _CharT>, | |
| 352 | __writer_iterator<_OutIt, _CharT>>>; | |
| 353 | }; | |
| 375 | // Since allocating is expensive the class has a small internal buffer. When | |
| 376 | // its capacity is exceeded a dynamic buffer will be allocated. | |
| 377 | static constexpr size_t __buffer_size_ = 256; | |
| 378 | _CharT __small_buffer_[__buffer_size_]; | |
| 354 | 379 | |
| 355 | /// The generic formatting buffer. | |
| 356 | template <class _OutIt, __fmt_char_type _CharT> | |
| 357 | requires(output_iterator<_OutIt, const _CharT&>) | |
| 358 | class _LIBCPP_TEMPLATE_VIS __format_buffer { | |
| 359 | using _Storage = | |
| 360 | conditional_t<__enable_direct_output<_OutIt, _CharT>, __direct_storage<_CharT>, __internal_storage<_CharT>>; | |
| 380 | _CharT* __ptr_{__small_buffer_}; | |
| 361 | 381 | |
| 362 | public: | |
| 363 | _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) | |
| 364 | requires(same_as<_Storage, __internal_storage<_CharT>>) | |
| 365 | : __output_(__storage_.__begin(), __storage_.__buffer_size, this), __writer_(std::move(__out_it)) {} | |
| 382 | _LIBCPP_HIDE_FROM_ABI void __grow_buffer(size_t __capacity) { | |
| 383 | if (__capacity < __buffer_size_) | |
| 384 | return; | |
| 366 | 385 | |
| 367 | _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) | |
| 368 | requires(same_as<_Storage, __direct_storage<_CharT>>) | |
| 369 | : __output_(std::__unwrap_iter(__out_it), size_t(-1), this), __writer_(std::move(__out_it)) {} | |
| 386 | _LIBCPP_ASSERT_INTERNAL(__capacity > this->__capacity(), "the buffer must grow"); | |
| 370 | 387 | |
| 371 | _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); } | |
| 388 | // _CharT is an implicit lifetime type so can be used without explicit | |
| 389 | // construction or destruction. | |
| 390 | _Alloc __alloc; | |
| 391 | auto __result = std::__allocate_at_least(__alloc, __capacity); | |
| 392 | std::copy_n(__ptr_, this->__size(), __result.ptr); | |
| 393 | if (__ptr_ != __small_buffer_) | |
| 394 | __alloc.deallocate(__ptr_, this->__capacity()); | |
| 372 | 395 | |
| 373 | _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) { __writer_.__flush(__ptr, __n); } | |
| 396 | __ptr_ = __result.ptr; | |
| 397 | this->__buffer_moved(__ptr_, __result.count); | |
| 398 | } | |
| 374 | 399 | |
| 375 | _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && { | |
| 376 | __output_.__flush(); | |
| 377 | return std::move(__writer_).__out_it(); | |
| 400 | _LIBCPP_HIDE_FROM_ABI void __prepare_write(size_t __size_hint) { | |
| 401 | __grow_buffer(std::max<size_t>(this->__capacity() + __size_hint, this->__capacity() * 1.6)); | |
| 378 | 402 | } |
| 379 | 403 | |
| 380 | private: | |
| 381 | _LIBCPP_NO_UNIQUE_ADDRESS _Storage __storage_; | |
| 382 | __output_buffer<_CharT> __output_; | |
| 383 | typename __writer_selector<_OutIt, _CharT>::type __writer_; | |
| 404 | _LIBCPP_HIDE_FROM_ABI static void __prepare_write(__output_buffer<_CharT>& __buffer, size_t __size_hint) { | |
| 405 | static_cast<__allocating_buffer<_CharT>&>(__buffer).__prepare_write(__size_hint); | |
| 406 | } | |
| 384 | 407 | }; |
| 385 | 408 | |
| 386 | /// A buffer that counts the number of insertions. | |
| 387 | /// | |
| 388 | /// Since \ref formatted_size only needs to know the size, the output itself is | |
| 389 | /// discarded. | |
| 390 | template <__fmt_char_type _CharT> | |
| 391 | class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer { | |
| 409 | // A buffer that directly writes to the underlying buffer. | |
| 410 | template <class _OutIt, __fmt_char_type _CharT> | |
| 411 | class _LIBCPP_TEMPLATE_VIS __direct_iterator_buffer : public __output_buffer<_CharT> { | |
| 392 | 412 | public: |
| 393 | _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); } | |
| 413 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __direct_iterator_buffer(_OutIt __out_it) | |
| 414 | : __direct_iterator_buffer{__out_it, nullptr} {} | |
| 394 | 415 | |
| 395 | _LIBCPP_HIDE_FROM_ABI void __flush(const _CharT*, size_t __n) { __size_ += __n; } | |
| 416 | [[nodiscard]] | |
| 417 | _LIBCPP_HIDE_FROM_ABI explicit __direct_iterator_buffer(_OutIt __out_it, __max_output_size* __max_output_size) | |
| 418 | : __output_buffer<_CharT>{std::__unwrap_iter(__out_it), __buffer_size, __prepare_write, __max_output_size}, | |
| 419 | __out_it_(__out_it) {} | |
| 396 | 420 | |
| 397 | _LIBCPP_HIDE_FROM_ABI size_t __result() && { | |
| 398 | __output_.__flush(); | |
| 399 | return __size_; | |
| 400 | } | |
| 421 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && { return __out_it_ + this->__size(); } | |
| 401 | 422 | |
| 402 | 423 | private: |
| 403 | __internal_storage<_CharT> __storage_; | |
| 404 | __output_buffer<_CharT> __output_{__storage_.__begin(), __storage_.__buffer_size, this}; | |
| 405 | size_t __size_{0}; | |
| 406 | }; | |
| 424 | // The function format_to expects a buffer large enough for the output. The | |
| 425 | // function format_to_n has its own helper class that restricts the number of | |
| 426 | // write options. So this function class can pretend to have an infinite | |
| 427 | // buffer. | |
| 428 | static constexpr size_t __buffer_size = -1; | |
| 429 | ||
| 430 | _OutIt __out_it_; | |
| 407 | 431 | |
| 408 | /// The base of a buffer that counts and limits the number of insertions. | |
| 409 | template <class _OutIt, __fmt_char_type _CharT, bool> | |
| 410 | requires(output_iterator<_OutIt, const _CharT&>) | |
| 411 | struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base { | |
| 412 | using _Size = iter_difference_t<_OutIt>; | |
| 432 | _LIBCPP_HIDE_FROM_ABI static void | |
| 433 | __prepare_write([[maybe_unused]] __output_buffer<_CharT>& __buffer, [[maybe_unused]] size_t __size_hint) { | |
| 434 | std::__throw_length_error("__direct_iterator_buffer"); | |
| 435 | } | |
| 436 | }; | |
| 413 | 437 | |
| 438 | // A buffer that writes its output to the end of a container. | |
| 439 | template <class _OutIt, __fmt_char_type _CharT> | |
| 440 | class _LIBCPP_TEMPLATE_VIS __container_inserter_buffer : public __output_buffer<_CharT> { | |
| 414 | 441 | public: |
| 415 | _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size) | |
| 416 | : __writer_(std::move(__out_it)), __max_size_(std::max(_Size(0), __max_size)) {} | |
| 442 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __container_inserter_buffer(_OutIt __out_it) | |
| 443 | : __container_inserter_buffer{__out_it, nullptr} {} | |
| 417 | 444 | |
| 418 | _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) { | |
| 419 | if (_Size(__size_) <= __max_size_) | |
| 420 | __writer_.__flush(__ptr, std::min(_Size(__n), __max_size_ - __size_)); | |
| 421 | __size_ += __n; | |
| 445 | [[nodiscard]] | |
| 446 | _LIBCPP_HIDE_FROM_ABI explicit __container_inserter_buffer(_OutIt __out_it, __max_output_size* __max_output_size) | |
| 447 | : __output_buffer<_CharT>{__small_buffer_, __buffer_size, __prepare_write, __max_output_size}, | |
| 448 | __container_{__out_it.__get_container()} {} | |
| 449 | ||
| 450 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto __out_it() && { | |
| 451 | __container_->insert(__container_->end(), __small_buffer_, __small_buffer_ + this->__size()); | |
| 452 | return std::back_inserter(*__container_); | |
| 422 | 453 | } |
| 423 | 454 | |
| 424 | protected: | |
| 425 | __internal_storage<_CharT> __storage_; | |
| 426 | __output_buffer<_CharT> __output_{__storage_.__begin(), __storage_.__buffer_size, this}; | |
| 427 | typename __writer_selector<_OutIt, _CharT>::type __writer_; | |
| 455 | private: | |
| 456 | typename __back_insert_iterator_container<_OutIt>::type* __container_; | |
| 457 | ||
| 458 | // This class uses a fixed size buffer and appends the elements in | |
| 459 | // __buffer_size chunks. An alternative would be to use an allocating buffer | |
| 460 | // and append the output in a single write operation. Benchmarking showed no | |
| 461 | // performance difference. | |
| 462 | static constexpr size_t __buffer_size = 256; | |
| 463 | _CharT __small_buffer_[__buffer_size]; | |
| 464 | ||
| 465 | _LIBCPP_HIDE_FROM_ABI void __prepare_write() { | |
| 466 | __container_->insert(__container_->end(), __small_buffer_, __small_buffer_ + this->__size()); | |
| 467 | this->__buffer_flushed(); | |
| 468 | } | |
| 428 | 469 | |
| 429 | _Size __max_size_; | |
| 430 | _Size __size_{0}; | |
| 470 | _LIBCPP_HIDE_FROM_ABI static void | |
| 471 | __prepare_write(__output_buffer<_CharT>& __buffer, [[maybe_unused]] size_t __size_hint) { | |
| 472 | static_cast<__container_inserter_buffer<_OutIt, _CharT>&>(__buffer).__prepare_write(); | |
| 473 | } | |
| 431 | 474 | }; |
| 432 | 475 | |
| 433 | /// The base of a buffer that counts and limits the number of insertions. | |
| 434 | /// | |
| 435 | /// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true. | |
| 436 | /// | |
| 437 | /// This class limits the size available to the direct writer so it will not | |
| 438 | /// exceed the maximum number of code units. | |
| 476 | // A buffer that writes to an iterator. | |
| 477 | // | |
| 478 | // Unlike the __container_inserter_buffer this class' performance does benefit | |
| 479 | // from allocating and then inserting. | |
| 439 | 480 | template <class _OutIt, __fmt_char_type _CharT> |
| 440 | requires(output_iterator<_OutIt, const _CharT&>) | |
| 441 | class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> { | |
| 442 | using _Size = iter_difference_t<_OutIt>; | |
| 443 | ||
| 481 | class _LIBCPP_TEMPLATE_VIS __iterator_buffer : public __allocating_buffer<_CharT> { | |
| 444 | 482 | public: |
| 445 | _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size) | |
| 446 | : __output_(std::__unwrap_iter(__out_it), __max_size, this), | |
| 447 | __writer_(std::move(__out_it)), | |
| 448 | __max_size_(__max_size) { | |
| 449 | if (__max_size <= 0) [[unlikely]] | |
| 450 | __output_.__reset(__storage_.__begin(), __storage_.__buffer_size); | |
| 451 | } | |
| 483 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __iterator_buffer(_OutIt __out_it) | |
| 484 | : __allocating_buffer<_CharT>{}, __out_it_{std::move(__out_it)} {} | |
| 452 | 485 | |
| 453 | _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) { | |
| 454 | // A __flush to the direct writer happens in the following occasions: | |
| 455 | // - The format function has written the maximum number of allowed code | |
| 456 | // units. At this point it's no longer valid to write to this writer. So | |
| 457 | // switch to the internal storage. This internal storage doesn't need to | |
| 458 | // be written anywhere so the __flush for that storage writes no output. | |
| 459 | // - Like above, but the next "mass write" operation would overflow the | |
| 460 | // buffer. In that case the buffer is pre-emptively switched. The still | |
| 461 | // valid code units will be written separately. | |
| 462 | // - The format_to_n function is finished. In this case there's no need to | |
| 463 | // switch the buffer, but for simplicity the buffers are still switched. | |
| 464 | // When the __max_size <= 0 the constructor already switched the buffers. | |
| 465 | if (__size_ == 0 && __ptr != __storage_.__begin()) { | |
| 466 | __writer_.__flush(__ptr, __n); | |
| 467 | __output_.__reset(__storage_.__begin(), __storage_.__buffer_size); | |
| 468 | } else if (__size_ < __max_size_) { | |
| 469 | // Copies a part of the internal buffer to the output up to n characters. | |
| 470 | // See __output_buffer<_CharT>::__flush_on_overflow for more information. | |
| 471 | _Size __s = std::min(_Size(__n), __max_size_ - __size_); | |
| 472 | std::copy_n(__ptr, __s, __writer_.__out_it()); | |
| 473 | __writer_.__flush(__ptr, __s); | |
| 474 | } | |
| 486 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __iterator_buffer(_OutIt __out_it, __max_output_size* __max_output_size) | |
| 487 | : __allocating_buffer<_CharT>{__max_output_size}, __out_it_{std::move(__out_it)} {} | |
| 475 | 488 | |
| 476 | __size_ += __n; | |
| 489 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto __out_it() && { | |
| 490 | return std::ranges::copy(this->__view(), std::move(__out_it_)).out; | |
| 477 | 491 | } |
| 478 | 492 | |
| 479 | protected: | |
| 480 | __internal_storage<_CharT> __storage_; | |
| 481 | __output_buffer<_CharT> __output_; | |
| 482 | __writer_direct<_OutIt, _CharT> __writer_; | |
| 493 | private: | |
| 494 | _OutIt __out_it_; | |
| 495 | }; | |
| 496 | ||
| 497 | // Selects the type of the buffer used for the output iterator. | |
| 498 | template <class _OutIt, __fmt_char_type _CharT> | |
| 499 | class _LIBCPP_TEMPLATE_VIS __buffer_selector { | |
| 500 | using _Container _LIBCPP_NODEBUG = __back_insert_iterator_container<_OutIt>::type; | |
| 483 | 501 | |
| 484 | _Size __max_size_; | |
| 485 | _Size __size_{0}; | |
| 502 | public: | |
| 503 | using type _LIBCPP_NODEBUG = | |
| 504 | conditional_t<!same_as<_Container, void>, | |
| 505 | __container_inserter_buffer<_OutIt, _CharT>, | |
| 506 | conditional_t<__enable_direct_output<_OutIt, _CharT>, | |
| 507 | __direct_iterator_buffer<_OutIt, _CharT>, | |
| 508 | __iterator_buffer<_OutIt, _CharT>>>; | |
| 486 | 509 | }; |
| 487 | 510 | |
| 488 | /// The buffer that counts and limits the number of insertions. | |
| 511 | // A buffer that counts and limits the number of insertions. | |
| 489 | 512 | template <class _OutIt, __fmt_char_type _CharT> |
| 490 | requires(output_iterator<_OutIt, const _CharT&>) | |
| 491 | struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final | |
| 492 | : public __format_to_n_buffer_base< _OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>> { | |
| 493 | using _Base = __format_to_n_buffer_base<_OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>>; | |
| 494 | using _Size = iter_difference_t<_OutIt>; | |
| 513 | class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer : private __buffer_selector<_OutIt, _CharT>::type { | |
| 514 | public: | |
| 515 | using _Base _LIBCPP_NODEBUG = __buffer_selector<_OutIt, _CharT>::type; | |
| 516 | ||
| 517 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __format_to_n_buffer(_OutIt __out_it, iter_difference_t<_OutIt> __n) | |
| 518 | : _Base{std::move(__out_it), std::addressof(__max_output_size_)}, | |
| 519 | __max_output_size_{__n < 0 ? size_t{0} : static_cast<size_t>(__n)} {} | |
| 520 | ||
| 521 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return _Base::__make_output_iterator(); } | |
| 522 | ||
| 523 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __result() && { | |
| 524 | return {static_cast<_Base&&>(*this).__out_it(), | |
| 525 | static_cast<iter_difference_t<_OutIt>>(__max_output_size_.__code_units_written())}; | |
| 526 | } | |
| 527 | ||
| 528 | private: | |
| 529 | __max_output_size __max_output_size_; | |
| 530 | }; | |
| 495 | 531 | |
| 532 | // A buffer that counts the number of insertions. | |
| 533 | // | |
| 534 | // Since formatted_size only needs to know the size, the output itself is | |
| 535 | // discarded. | |
| 536 | template <__fmt_char_type _CharT> | |
| 537 | class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer : private __output_buffer<_CharT> { | |
| 496 | 538 | public: |
| 497 | _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __max_size) | |
| 498 | : _Base(std::move(__out_it), __max_size) {} | |
| 499 | _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return this->__output_.__make_output_iterator(); } | |
| 539 | using _Base _LIBCPP_NODEBUG = __output_buffer<_CharT>; | |
| 540 | ||
| 541 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __formatted_size_buffer() | |
| 542 | : _Base{nullptr, 0, __prepare_write, std::addressof(__max_output_size_)} {} | |
| 543 | ||
| 544 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return _Base::__make_output_iterator(); } | |
| 545 | ||
| 546 | // This function does not need to be r-value qualified, however this is | |
| 547 | // consistent with similar objects. | |
| 548 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_t __result() && { return __max_output_size_.__code_units_written(); } | |
| 549 | ||
| 550 | private: | |
| 551 | __max_output_size __max_output_size_{0}; | |
| 500 | 552 | |
| 501 | _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __result() && { | |
| 502 | this->__output_.__flush(); | |
| 503 | return {std::move(this->__writer_).__out_it(), this->__size_}; | |
| 553 | _LIBCPP_HIDE_FROM_ABI static void | |
| 554 | __prepare_write([[maybe_unused]] __output_buffer<_CharT>& __buffer, [[maybe_unused]] size_t __size_hint) { | |
| 555 | // Note this function does not satisfy the requirement of giving a 1 code unit buffer. | |
| 556 | _LIBCPP_ASSERT_INTERNAL( | |
| 557 | false, "Since __max_output_size_.__max_size_ == 0 there should never be call to this function."); | |
| 504 | 558 | } |
| 505 | 559 | }; |
| 506 | 560 | |
| ... | ... | @@ -524,14 +578,14 @@ public: |
| 524 | 578 | // would lead to a circular include with formatter for vector<bool>. |
| 525 | 579 | template <__fmt_char_type _CharT> |
| 526 | 580 | class _LIBCPP_TEMPLATE_VIS __retarget_buffer { |
| 527 | using _Alloc = allocator<_CharT>; | |
| 581 | using _Alloc _LIBCPP_NODEBUG = allocator<_CharT>; | |
| 528 | 582 | |
| 529 | 583 | public: |
| 530 | using value_type = _CharT; | |
| 584 | using value_type _LIBCPP_NODEBUG = _CharT; | |
| 531 | 585 | |
| 532 | 586 | struct __iterator { |
| 533 | using difference_type = ptrdiff_t; | |
| 534 | using value_type = _CharT; | |
| 587 | using difference_type _LIBCPP_NODEBUG = ptrdiff_t; | |
| 588 | using value_type _LIBCPP_NODEBUG = _CharT; | |
| 535 | 589 | |
| 536 | 590 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(__retarget_buffer& __buffer) |
| 537 | 591 | : __buffer_(std::addressof(__buffer)) {} |
| ... | ... | @@ -646,7 +700,7 @@ private: |
| 646 | 700 | |
| 647 | 701 | } // namespace __format |
| 648 | 702 | |
| 649 | #endif //_LIBCPP_STD_VER >= 20 | |
| 703 | #endif // _LIBCPP_STD_VER >= 20 | |
| 650 | 704 | |
| 651 | 705 | _LIBCPP_END_NAMESPACE_STD |
| 652 | 706 |
lib/libcxx/include/__format/concepts.h+4-4| ... | ... | @@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | template <class _CharT> |
| 35 | 35 | concept __fmt_char_type = |
| 36 | 36 | same_as<_CharT, char> |
| 37 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 37 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 38 | 38 | || same_as<_CharT, wchar_t> |
| 39 | 39 | # endif |
| 40 | 40 | ; |
| ... | ... | @@ -44,7 +44,7 @@ concept __fmt_char_type = |
| 44 | 44 | // (Note testing for (w)format_context would be a valid choice, but requires |
| 45 | 45 | // selecting the proper one depending on the type of _CharT.) |
| 46 | 46 | template <class _CharT> |
| 47 | using __fmt_iter_for = _CharT*; | |
| 47 | using __fmt_iter_for _LIBCPP_NODEBUG = _CharT*; | |
| 48 | 48 | |
| 49 | 49 | template <class _Tp, class _Context, class _Formatter = typename _Context::template formatter_type<remove_const_t<_Tp>>> |
| 50 | 50 | concept __formattable_with = |
| ... | ... | @@ -75,8 +75,8 @@ template <class _Tp> |
| 75 | 75 | concept __fmt_pair_like = |
| 76 | 76 | __is_specialization_v<_Tp, pair> || (__is_specialization_v<_Tp, tuple> && tuple_size_v<_Tp> == 2); |
| 77 | 77 | |
| 78 | # endif //_LIBCPP_STD_VER >= 23 | |
| 79 | #endif //_LIBCPP_STD_VER >= 20 | |
| 78 | # endif // _LIBCPP_STD_VER >= 23 | |
| 79 | #endif // _LIBCPP_STD_VER >= 20 | |
| 80 | 80 | |
| 81 | 81 | _LIBCPP_END_NAMESPACE_STD |
| 82 | 82 |
lib/libcxx/include/__format/container_adaptor.h+3-3| ... | ... | @@ -37,8 +37,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 37 | 37 | template <class _Adaptor, class _CharT> |
| 38 | 38 | struct _LIBCPP_TEMPLATE_VIS __formatter_container_adaptor { |
| 39 | 39 | private: |
| 40 | using __maybe_const_container = __fmt_maybe_const<typename _Adaptor::container_type, _CharT>; | |
| 41 | using __maybe_const_adaptor = __maybe_const<is_const_v<__maybe_const_container>, _Adaptor>; | |
| 40 | using __maybe_const_container _LIBCPP_NODEBUG = __fmt_maybe_const<typename _Adaptor::container_type, _CharT>; | |
| 41 | using __maybe_const_adaptor _LIBCPP_NODEBUG = __maybe_const<is_const_v<__maybe_const_container>, _Adaptor>; | |
| 42 | 42 | formatter<ranges::ref_view<__maybe_const_container>, _CharT> __underlying_; |
| 43 | 43 | |
| 44 | 44 | public: |
| ... | ... | @@ -66,7 +66,7 @@ template <class _CharT, class _Tp, formattable<_CharT> _Container> |
| 66 | 66 | struct _LIBCPP_TEMPLATE_VIS formatter<stack<_Tp, _Container>, _CharT> |
| 67 | 67 | : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {}; |
| 68 | 68 | |
| 69 | #endif //_LIBCPP_STD_VER >= 23 | |
| 69 | #endif // _LIBCPP_STD_VER >= 23 | |
| 70 | 70 | |
| 71 | 71 | _LIBCPP_END_NAMESPACE_STD |
| 72 | 72 |
lib/libcxx/include/__format/enable_insertable.h+1-1| ... | ... | @@ -28,7 +28,7 @@ inline constexpr bool __enable_insertable = false; |
| 28 | 28 | |
| 29 | 29 | } // namespace __format |
| 30 | 30 | |
| 31 | #endif //_LIBCPP_STD_VER >= 20 | |
| 31 | #endif // _LIBCPP_STD_VER >= 20 | |
| 32 | 32 | |
| 33 | 33 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 34 |
lib/libcxx/include/__format/escaped_output_table.h+2-2| ... | ... | @@ -63,7 +63,7 @@ |
| 63 | 63 | |
| 64 | 64 | #include <__algorithm/ranges_upper_bound.h> |
| 65 | 65 | #include <__config> |
| 66 | #include <cstddef> | |
| 66 | #include <__cstddef/ptrdiff_t.h> | |
| 67 | 67 | #include <cstdint> |
| 68 | 68 | |
| 69 | 69 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -856,7 +856,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = { |
| 856 | 856 | // clang-format on |
| 857 | 857 | } // namespace __escaped_output_table |
| 858 | 858 | |
| 859 | #endif //_LIBCPP_STD_VER >= 23 | |
| 859 | #endif // _LIBCPP_STD_VER >= 23 | |
| 860 | 860 | |
| 861 | 861 | _LIBCPP_END_NAMESPACE_STD |
| 862 | 862 |
lib/libcxx/include/__format/extended_grapheme_cluster_table.h+2-2| ... | ... | @@ -63,8 +63,8 @@ |
| 63 | 63 | |
| 64 | 64 | #include <__algorithm/ranges_upper_bound.h> |
| 65 | 65 | #include <__config> |
| 66 | #include <__cstddef/ptrdiff_t.h> | |
| 66 | 67 | #include <__iterator/access.h> |
| 67 | #include <cstddef> | |
| 68 | 68 | #include <cstdint> |
| 69 | 69 | |
| 70 | 70 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -1656,7 +1656,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = { |
| 1656 | 1656 | |
| 1657 | 1657 | } // namespace __extended_grapheme_custer_property_boundary |
| 1658 | 1658 | |
| 1659 | #endif //_LIBCPP_STD_VER >= 20 | |
| 1659 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1660 | 1660 | |
| 1661 | 1661 | _LIBCPP_END_NAMESPACE_STD |
| 1662 | 1662 |
lib/libcxx/include/__format/format_arg.h+19-18| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | #include <__assert> |
| 14 | 14 | #include <__concepts/arithmetic.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__cstddef/size_t.h> | |
| 16 | 17 | #include <__format/concepts.h> |
| 17 | 18 | #include <__format/format_parse_context.h> |
| 18 | 19 | #include <__functional/invoke.h> |
| ... | ... | @@ -113,7 +114,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ |
| 113 | 114 | case __format::__arg_t::__long_long: |
| 114 | 115 | return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__long_long_); |
| 115 | 116 | case __format::__arg_t::__i128: |
| 116 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 117 | # if _LIBCPP_HAS_INT128 | |
| 117 | 118 | return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__i128_); |
| 118 | 119 | # else |
| 119 | 120 | __libcpp_unreachable(); |
| ... | ... | @@ -123,7 +124,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ |
| 123 | 124 | case __format::__arg_t::__unsigned_long_long: |
| 124 | 125 | return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_); |
| 125 | 126 | case __format::__arg_t::__u128: |
| 126 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 127 | # if _LIBCPP_HAS_INT128 | |
| 127 | 128 | return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__u128_); |
| 128 | 129 | # else |
| 129 | 130 | __libcpp_unreachable(); |
| ... | ... | @@ -148,7 +149,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ |
| 148 | 149 | __libcpp_unreachable(); |
| 149 | 150 | } |
| 150 | 151 | |
| 151 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | |
| 152 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | |
| 152 | 153 | |
| 153 | 154 | template <class _Rp, class _Visitor, class _Context> |
| 154 | 155 | _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { |
| ... | ... | @@ -164,7 +165,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg< |
| 164 | 165 | case __format::__arg_t::__long_long: |
| 165 | 166 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__long_long_); |
| 166 | 167 | case __format::__arg_t::__i128: |
| 167 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 168 | # if _LIBCPP_HAS_INT128 | |
| 168 | 169 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__i128_); |
| 169 | 170 | # else |
| 170 | 171 | __libcpp_unreachable(); |
| ... | ... | @@ -174,7 +175,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg< |
| 174 | 175 | case __format::__arg_t::__unsigned_long_long: |
| 175 | 176 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_); |
| 176 | 177 | case __format::__arg_t::__u128: |
| 177 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 178 | # if _LIBCPP_HAS_INT128 | |
| 178 | 179 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__u128_); |
| 179 | 180 | # else |
| 180 | 181 | __libcpp_unreachable(); |
| ... | ... | @@ -199,7 +200,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg< |
| 199 | 200 | __libcpp_unreachable(); |
| 200 | 201 | } |
| 201 | 202 | |
| 202 | # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | |
| 203 | # endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | |
| 203 | 204 | |
| 204 | 205 | /// Contains the values used in basic_format_arg. |
| 205 | 206 | /// |
| ... | ... | @@ -207,7 +208,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg< |
| 207 | 208 | /// separate arrays. |
| 208 | 209 | template <class _Context> |
| 209 | 210 | class __basic_format_arg_value { |
| 210 | using _CharT = typename _Context::char_type; | |
| 211 | using _CharT _LIBCPP_NODEBUG = typename _Context::char_type; | |
| 211 | 212 | |
| 212 | 213 | public: |
| 213 | 214 | /// Contains the implementation for basic_format_arg::handle. |
| ... | ... | @@ -237,7 +238,7 @@ public: |
| 237 | 238 | unsigned __unsigned_; |
| 238 | 239 | long long __long_long_; |
| 239 | 240 | unsigned long long __unsigned_long_long_; |
| 240 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 241 | # if _LIBCPP_HAS_INT128 | |
| 241 | 242 | __int128_t __i128_; |
| 242 | 243 | __uint128_t __u128_; |
| 243 | 244 | # endif |
| ... | ... | @@ -261,7 +262,7 @@ public: |
| 261 | 262 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long long __value) noexcept : __long_long_(__value) {} |
| 262 | 263 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned long long __value) noexcept |
| 263 | 264 | : __unsigned_long_long_(__value) {} |
| 264 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 265 | # if _LIBCPP_HAS_INT128 | |
| 265 | 266 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__int128_t __value) noexcept : __i128_(__value) {} |
| 266 | 267 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__uint128_t __value) noexcept : __u128_(__value) {} |
| 267 | 268 | # endif |
| ... | ... | @@ -276,7 +277,7 @@ public: |
| 276 | 277 | }; |
| 277 | 278 | |
| 278 | 279 | template <class _Context> |
| 279 | class _LIBCPP_TEMPLATE_VIS basic_format_arg { | |
| 280 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS basic_format_arg { | |
| 280 | 281 | public: |
| 281 | 282 | class _LIBCPP_TEMPLATE_VIS handle; |
| 282 | 283 | |
| ... | ... | @@ -284,14 +285,14 @@ public: |
| 284 | 285 | |
| 285 | 286 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; } |
| 286 | 287 | |
| 287 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | |
| 288 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | |
| 288 | 289 | |
| 289 | 290 | // This function is user facing, so it must wrap the non-standard types of |
| 290 | 291 | // the "variant" in a handle to stay conforming. See __arg_t for more details. |
| 291 | 292 | template <class _Visitor> |
| 292 | 293 | _LIBCPP_HIDE_FROM_ABI decltype(auto) visit(this basic_format_arg __arg, _Visitor&& __vis) { |
| 293 | 294 | switch (__arg.__type_) { |
| 294 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 295 | # if _LIBCPP_HAS_INT128 | |
| 295 | 296 | case __format::__arg_t::__i128: { |
| 296 | 297 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_}; |
| 297 | 298 | return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); |
| ... | ... | @@ -312,7 +313,7 @@ public: |
| 312 | 313 | template <class _Rp, class _Visitor> |
| 313 | 314 | _LIBCPP_HIDE_FROM_ABI _Rp visit(this basic_format_arg __arg, _Visitor&& __vis) { |
| 314 | 315 | switch (__arg.__type_) { |
| 315 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 316 | # if _LIBCPP_HAS_INT128 | |
| 316 | 317 | case __format::__arg_t::__i128: { |
| 317 | 318 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_}; |
| 318 | 319 | return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); |
| ... | ... | @@ -328,7 +329,7 @@ public: |
| 328 | 329 | } |
| 329 | 330 | } |
| 330 | 331 | |
| 331 | # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | |
| 332 | # endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | |
| 332 | 333 | |
| 333 | 334 | private: |
| 334 | 335 | using char_type = typename _Context::char_type; |
| ... | ... | @@ -370,13 +371,13 @@ private: |
| 370 | 371 | // This function is user facing, so it must wrap the non-standard types of |
| 371 | 372 | // the "variant" in a handle to stay conforming. See __arg_t for more details. |
| 372 | 373 | template <class _Visitor, class _Context> |
| 373 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | |
| 374 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | |
| 374 | 375 | _LIBCPP_DEPRECATED_IN_CXX26 |
| 375 | 376 | # endif |
| 376 | 377 | _LIBCPP_HIDE_FROM_ABI decltype(auto) |
| 377 | 378 | visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { |
| 378 | 379 | switch (__arg.__type_) { |
| 379 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 380 | # if _LIBCPP_HAS_INT128 | |
| 380 | 381 | case __format::__arg_t::__i128: { |
| 381 | 382 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_}; |
| 382 | 383 | return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); |
| ... | ... | @@ -386,13 +387,13 @@ _LIBCPP_DEPRECATED_IN_CXX26 |
| 386 | 387 | typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_}; |
| 387 | 388 | return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); |
| 388 | 389 | } |
| 389 | # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | |
| 390 | # endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | |
| 390 | 391 | default: |
| 391 | 392 | return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg); |
| 392 | 393 | } |
| 393 | 394 | } |
| 394 | 395 | |
| 395 | #endif //_LIBCPP_STD_VER >= 20 | |
| 396 | #endif // _LIBCPP_STD_VER >= 20 | |
| 396 | 397 | |
| 397 | 398 | _LIBCPP_END_NAMESPACE_STD |
| 398 | 399 |
lib/libcxx/include/__format/format_arg_store.h+12-6| ... | ... | @@ -22,6 +22,7 @@ |
| 22 | 22 | #include <__type_traits/conditional.h> |
| 23 | 23 | #include <__type_traits/extent.h> |
| 24 | 24 | #include <__type_traits/remove_const.h> |
| 25 | #include <cstdint> | |
| 25 | 26 | #include <string> |
| 26 | 27 | #include <string_view> |
| 27 | 28 | |
| ... | ... | @@ -48,7 +49,7 @@ template <class _Context, same_as<typename _Context::char_type> _Tp> |
| 48 | 49 | consteval __arg_t __determine_arg_t() { |
| 49 | 50 | return __arg_t::__char_type; |
| 50 | 51 | } |
| 51 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 52 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 52 | 53 | template <class _Context, class _CharT> |
| 53 | 54 | requires(same_as<typename _Context::char_type, wchar_t> && same_as<_CharT, char>) |
| 54 | 55 | consteval __arg_t __determine_arg_t() { |
| ... | ... | @@ -63,7 +64,7 @@ consteval __arg_t __determine_arg_t() { |
| 63 | 64 | return __arg_t::__int; |
| 64 | 65 | else if constexpr (sizeof(_Tp) <= sizeof(long long)) |
| 65 | 66 | return __arg_t::__long_long; |
| 66 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 67 | # if _LIBCPP_HAS_INT128 | |
| 67 | 68 | else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) |
| 68 | 69 | return __arg_t::__i128; |
| 69 | 70 | # endif |
| ... | ... | @@ -78,7 +79,7 @@ consteval __arg_t __determine_arg_t() { |
| 78 | 79 | return __arg_t::__unsigned; |
| 79 | 80 | else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long)) |
| 80 | 81 | return __arg_t::__unsigned_long_long; |
| 81 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 82 | # if _LIBCPP_HAS_INT128 | |
| 82 | 83 | else if constexpr (sizeof(_Tp) == sizeof(__uint128_t)) |
| 83 | 84 | return __arg_t::__u128; |
| 84 | 85 | # endif |
| ... | ... | @@ -172,7 +173,7 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu |
| 172 | 173 | // final else requires no adjustment. |
| 173 | 174 | if constexpr (__arg == __arg_t::__char_type) |
| 174 | 175 | |
| 175 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 176 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 176 | 177 | if constexpr (same_as<typename _Context::char_type, wchar_t> && same_as<_Dp, char>) |
| 177 | 178 | return basic_format_arg<_Context>{__arg, static_cast<wchar_t>(static_cast<unsigned char>(__value))}; |
| 178 | 179 | else |
| ... | ... | @@ -233,6 +234,11 @@ struct __packed_format_arg_store { |
| 233 | 234 | uint64_t __types_ = 0; |
| 234 | 235 | }; |
| 235 | 236 | |
| 237 | template <class _Context> | |
| 238 | struct __packed_format_arg_store<_Context, 0> { | |
| 239 | uint64_t __types_ = 0; | |
| 240 | }; | |
| 241 | ||
| 236 | 242 | template <class _Context, size_t _Np> |
| 237 | 243 | struct __unpacked_format_arg_store { |
| 238 | 244 | basic_format_arg<_Context> __args_[_Np]; |
| ... | ... | @@ -251,7 +257,7 @@ struct _LIBCPP_TEMPLATE_VIS __format_arg_store { |
| 251 | 257 | } |
| 252 | 258 | } |
| 253 | 259 | |
| 254 | using _Storage = | |
| 260 | using _Storage _LIBCPP_NODEBUG = | |
| 255 | 261 | conditional_t<__format::__use_packed_format_arg_store(sizeof...(_Args)), |
| 256 | 262 | __format::__packed_format_arg_store<_Context, sizeof...(_Args)>, |
| 257 | 263 | __format::__unpacked_format_arg_store<_Context, sizeof...(_Args)>>; |
| ... | ... | @@ -259,7 +265,7 @@ struct _LIBCPP_TEMPLATE_VIS __format_arg_store { |
| 259 | 265 | _Storage __storage; |
| 260 | 266 | }; |
| 261 | 267 | |
| 262 | #endif //_LIBCPP_STD_VER >= 20 | |
| 268 | #endif // _LIBCPP_STD_VER >= 20 | |
| 263 | 269 | |
| 264 | 270 | _LIBCPP_END_NAMESPACE_STD |
| 265 | 271 |
lib/libcxx/include/__format/format_args.h+2-2| ... | ... | @@ -11,10 +11,10 @@ |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMAT_ARGS_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/size_t.h> | |
| 14 | 15 | #include <__format/format_arg.h> |
| 15 | 16 | #include <__format/format_arg_store.h> |
| 16 | 17 | #include <__fwd/format.h> |
| 17 | #include <cstddef> | |
| 18 | 18 | #include <cstdint> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -71,7 +71,7 @@ private: |
| 71 | 71 | template <class _Context, class... _Args> |
| 72 | 72 | basic_format_args(__format_arg_store<_Context, _Args...>) -> basic_format_args<_Context>; |
| 73 | 73 | |
| 74 | #endif //_LIBCPP_STD_VER >= 20 | |
| 74 | #endif // _LIBCPP_STD_VER >= 20 | |
| 75 | 75 | |
| 76 | 76 | _LIBCPP_END_NAMESPACE_STD |
| 77 | 77 |
lib/libcxx/include/__format/format_context.h+12-12| ... | ... | @@ -23,9 +23,8 @@ |
| 23 | 23 | #include <__memory/addressof.h> |
| 24 | 24 | #include <__utility/move.h> |
| 25 | 25 | #include <__variant/monostate.h> |
| 26 | #include <cstddef> | |
| 27 | 26 | |
| 28 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 27 | #if _LIBCPP_HAS_LOCALIZATION | |
| 29 | 28 | # include <__locale> |
| 30 | 29 | # include <optional> |
| 31 | 30 | #endif |
| ... | ... | @@ -45,7 +44,7 @@ template <class _OutIt, class _CharT> |
| 45 | 44 | requires output_iterator<_OutIt, const _CharT&> |
| 46 | 45 | class _LIBCPP_TEMPLATE_VIS basic_format_context; |
| 47 | 46 | |
| 48 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 47 | # if _LIBCPP_HAS_LOCALIZATION | |
| 49 | 48 | /** |
| 50 | 49 | * Helper to create a basic_format_context. |
| 51 | 50 | * |
| ... | ... | @@ -67,7 +66,7 @@ __format_context_create(_OutIt __out_it, basic_format_args<basic_format_context< |
| 67 | 66 | # endif |
| 68 | 67 | |
| 69 | 68 | using format_context = basic_format_context<back_insert_iterator<__format::__output_buffer<char>>, char>; |
| 70 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 69 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 71 | 70 | using wformat_context = basic_format_context< back_insert_iterator<__format::__output_buffer<wchar_t>>, wchar_t>; |
| 72 | 71 | # endif |
| 73 | 72 | |
| ... | ... | @@ -89,7 +88,7 @@ public: |
| 89 | 88 | _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept { |
| 90 | 89 | return __args_.get(__id); |
| 91 | 90 | } |
| 92 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 91 | # if _LIBCPP_HAS_LOCALIZATION | |
| 93 | 92 | _LIBCPP_HIDE_FROM_ABI std::locale locale() { |
| 94 | 93 | if (!__loc_) |
| 95 | 94 | __loc_ = std::locale{}; |
| ... | ... | @@ -102,7 +101,7 @@ public: |
| 102 | 101 | private: |
| 103 | 102 | iterator __out_it_; |
| 104 | 103 | basic_format_args<basic_format_context> __args_; |
| 105 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 104 | # if _LIBCPP_HAS_LOCALIZATION | |
| 106 | 105 | |
| 107 | 106 | // The Standard doesn't specify how the locale is stored. |
| 108 | 107 | // [format.context]/6 |
| ... | ... | @@ -132,6 +131,7 @@ private: |
| 132 | 131 | : __out_it_(std::move(__out_it)), __args_(__args) {} |
| 133 | 132 | # endif |
| 134 | 133 | |
| 134 | public: | |
| 135 | 135 | basic_format_context(const basic_format_context&) = delete; |
| 136 | 136 | basic_format_context& operator=(const basic_format_context&) = delete; |
| 137 | 137 | }; |
| ... | ... | @@ -163,7 +163,7 @@ public: |
| 163 | 163 | template <class _Context> |
| 164 | 164 | _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(iterator __out_it, _Context& __ctx) |
| 165 | 165 | : __out_it_(std::move(__out_it)), |
| 166 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 166 | # if _LIBCPP_HAS_LOCALIZATION | |
| 167 | 167 | __loc_([](void* __c) { return static_cast<_Context*>(__c)->locale(); }), |
| 168 | 168 | # endif |
| 169 | 169 | __ctx_(std::addressof(__ctx)), |
| ... | ... | @@ -180,20 +180,20 @@ public: |
| 180 | 180 | __format::__determine_arg_t<basic_format_context, decltype(__arg)>(), |
| 181 | 181 | __basic_format_arg_value<basic_format_context>(__arg)}; |
| 182 | 182 | }; |
| 183 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | |
| 183 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | |
| 184 | 184 | return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor)); |
| 185 | 185 | # else |
| 186 | 186 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 187 | 187 | return std::visit_format_arg(std::move(__visitor), static_cast<_Context*>(__c)->arg(__id)); |
| 188 | 188 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 189 | # endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | |
| 189 | # endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | |
| 190 | 190 | }) { |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept { |
| 194 | 194 | return __arg_(__ctx_, __id); |
| 195 | 195 | } |
| 196 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 196 | # if _LIBCPP_HAS_LOCALIZATION | |
| 197 | 197 | _LIBCPP_HIDE_FROM_ABI std::locale locale() { return __loc_(__ctx_); } |
| 198 | 198 | # endif |
| 199 | 199 | _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); } |
| ... | ... | @@ -202,7 +202,7 @@ public: |
| 202 | 202 | private: |
| 203 | 203 | iterator __out_it_; |
| 204 | 204 | |
| 205 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 205 | # if _LIBCPP_HAS_LOCALIZATION | |
| 206 | 206 | std::locale (*__loc_)(void* __ctx); |
| 207 | 207 | # endif |
| 208 | 208 | |
| ... | ... | @@ -211,7 +211,7 @@ private: |
| 211 | 211 | }; |
| 212 | 212 | |
| 213 | 213 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_context); |
| 214 | #endif //_LIBCPP_STD_VER >= 20 | |
| 214 | #endif // _LIBCPP_STD_VER >= 20 | |
| 215 | 215 | |
| 216 | 216 | _LIBCPP_END_NAMESPACE_STD |
| 217 | 217 |
lib/libcxx/include/__format/format_error.h+3-3| ... | ... | @@ -35,15 +35,15 @@ public: |
| 35 | 35 | }; |
| 36 | 36 | _LIBCPP_DIAGNOSTIC_POP |
| 37 | 37 | |
| 38 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) { | |
| 39 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 38 | [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) { | |
| 39 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 40 | 40 | throw format_error(__s); |
| 41 | 41 | # else |
| 42 | 42 | _LIBCPP_VERBOSE_ABORT("format_error was thrown in -fno-exceptions mode with message \"%s\"", __s); |
| 43 | 43 | # endif |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | #endif //_LIBCPP_STD_VER >= 20 | |
| 46 | #endif // _LIBCPP_STD_VER >= 20 | |
| 47 | 47 | |
| 48 | 48 | _LIBCPP_END_NAMESPACE_STD |
| 49 | 49 |
lib/libcxx/include/__format/format_functions.h+38-39| ... | ... | @@ -31,7 +31,6 @@ |
| 31 | 31 | #include <__format/formatter_pointer.h> |
| 32 | 32 | #include <__format/formatter_string.h> |
| 33 | 33 | #include <__format/parser_std_format_spec.h> |
| 34 | #include <__iterator/back_insert_iterator.h> | |
| 35 | 34 | #include <__iterator/concepts.h> |
| 36 | 35 | #include <__iterator/incrementable_traits.h> |
| 37 | 36 | #include <__iterator/iterator_traits.h> // iter_value_t |
| ... | ... | @@ -40,7 +39,7 @@ |
| 40 | 39 | #include <string> |
| 41 | 40 | #include <string_view> |
| 42 | 41 | |
| 43 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 42 | #if _LIBCPP_HAS_LOCALIZATION | |
| 44 | 43 | # include <__locale> |
| 45 | 44 | #endif |
| 46 | 45 | |
| ... | ... | @@ -61,7 +60,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 61 | 60 | // to do this optimization now. |
| 62 | 61 | |
| 63 | 62 | using format_args = basic_format_args<format_context>; |
| 64 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 63 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 65 | 64 | using wformat_args = basic_format_args<wformat_context>; |
| 66 | 65 | # endif |
| 67 | 66 | |
| ... | ... | @@ -70,7 +69,7 @@ template <class _Context = format_context, class... _Args> |
| 70 | 69 | return std::__format_arg_store<_Context, _Args...>(__args...); |
| 71 | 70 | } |
| 72 | 71 | |
| 73 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 72 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 74 | 73 | template <class... _Args> |
| 75 | 74 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&... __args) { |
| 76 | 75 | return std::__format_arg_store<wformat_context, _Args...>(__args...); |
| ... | ... | @@ -206,7 +205,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg( |
| 206 | 205 | case __arg_t::__long_long: |
| 207 | 206 | return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx); |
| 208 | 207 | case __arg_t::__i128: |
| 209 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 208 | # if _LIBCPP_HAS_INT128 | |
| 210 | 209 | return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx); |
| 211 | 210 | # else |
| 212 | 211 | std::__throw_format_error("Invalid argument"); |
| ... | ... | @@ -217,7 +216,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg( |
| 217 | 216 | case __arg_t::__unsigned_long_long: |
| 218 | 217 | return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx); |
| 219 | 218 | case __arg_t::__u128: |
| 220 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 219 | # if _LIBCPP_HAS_INT128 | |
| 221 | 220 | return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx); |
| 222 | 221 | # else |
| 223 | 222 | std::__throw_format_error("Invalid argument"); |
| ... | ... | @@ -355,12 +354,12 @@ public: |
| 355 | 354 | }; |
| 356 | 355 | |
| 357 | 356 | _LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<char> runtime_format(string_view __fmt) noexcept { return __fmt; } |
| 358 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 357 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 359 | 358 | _LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<wchar_t> runtime_format(wstring_view __fmt) noexcept { |
| 360 | 359 | return __fmt; |
| 361 | 360 | } |
| 362 | 361 | # endif |
| 363 | # endif //_LIBCPP_STD_VER >= 26 | |
| 362 | # endif // _LIBCPP_STD_VER >= 26 | |
| 364 | 363 | |
| 365 | 364 | template <class _CharT, class... _Args> |
| 366 | 365 | struct _LIBCPP_TEMPLATE_VIS basic_format_string { |
| ... | ... | @@ -379,7 +378,7 @@ struct _LIBCPP_TEMPLATE_VIS basic_format_string { |
| 379 | 378 | private: |
| 380 | 379 | basic_string_view<_CharT> __str_; |
| 381 | 380 | |
| 382 | using _Context = __format::__compile_time_basic_format_context<_CharT>; | |
| 381 | using _Context _LIBCPP_NODEBUG = __format::__compile_time_basic_format_context<_CharT>; | |
| 383 | 382 | |
| 384 | 383 | static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{ |
| 385 | 384 | __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...}; |
| ... | ... | @@ -397,7 +396,7 @@ private: |
| 397 | 396 | template <class... _Args> |
| 398 | 397 | using format_string = basic_format_string<char, type_identity_t<_Args>...>; |
| 399 | 398 | |
| 400 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 399 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 401 | 400 | template <class... _Args> |
| 402 | 401 | using wformat_string = basic_format_string<wchar_t, type_identity_t<_Args>...>; |
| 403 | 402 | # endif |
| ... | ... | @@ -411,7 +410,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __vformat_to(_OutIt __out_it, |
| 411 | 410 | return std::__format::__vformat_to( |
| 412 | 411 | basic_format_parse_context{__fmt, __args.__size()}, std::__format_context_create(std::move(__out_it), __args)); |
| 413 | 412 | else { |
| 414 | __format::__format_buffer<_OutIt, _CharT> __buffer{std::move(__out_it)}; | |
| 413 | typename __format::__buffer_selector<_OutIt, _CharT>::type __buffer{std::move(__out_it)}; | |
| 415 | 414 | std::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()}, |
| 416 | 415 | std::__format_context_create(__buffer.__make_output_iterator(), __args)); |
| 417 | 416 | return std::move(__buffer).__out_it(); |
| ... | ... | @@ -426,7 +425,7 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt vformat_to(_OutIt __out_it, s |
| 426 | 425 | return std::__vformat_to(std::move(__out_it), __fmt, __args); |
| 427 | 426 | } |
| 428 | 427 | |
| 429 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 428 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 430 | 429 | template <output_iterator<const wchar_t&> _OutIt> |
| 431 | 430 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt |
| 432 | 431 | vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) { |
| ... | ... | @@ -440,7 +439,7 @@ format_to(_OutIt __out_it, format_string<_Args...> __fmt, _Args&&... __args) { |
| 440 | 439 | return std::vformat_to(std::move(__out_it), __fmt.get(), std::make_format_args(__args...)); |
| 441 | 440 | } |
| 442 | 441 | |
| 443 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 442 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 444 | 443 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> |
| 445 | 444 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt |
| 446 | 445 | format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| ... | ... | @@ -452,20 +451,20 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 452 | 451 | // fires too eagerly, see http://llvm.org/PR61563. |
| 453 | 452 | template <class = void> |
| 454 | 453 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string vformat(string_view __fmt, format_args __args) { |
| 455 | string __res; | |
| 456 | std::vformat_to(std::back_inserter(__res), __fmt, __args); | |
| 457 | return __res; | |
| 454 | __format::__allocating_buffer<char> __buffer; | |
| 455 | std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args); | |
| 456 | return string{__buffer.__view()}; | |
| 458 | 457 | } |
| 459 | 458 | |
| 460 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 459 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 461 | 460 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup |
| 462 | 461 | // fires too eagerly, see http://llvm.org/PR61563. |
| 463 | 462 | template <class = void> |
| 464 | 463 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring |
| 465 | 464 | vformat(wstring_view __fmt, wformat_args __args) { |
| 466 | wstring __res; | |
| 467 | std::vformat_to(std::back_inserter(__res), __fmt, __args); | |
| 468 | return __res; | |
| 465 | __format::__allocating_buffer<wchar_t> __buffer; | |
| 466 | std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args); | |
| 467 | return wstring{__buffer.__view()}; | |
| 469 | 468 | } |
| 470 | 469 | # endif |
| 471 | 470 | |
| ... | ... | @@ -475,7 +474,7 @@ format(format_string<_Args...> __fmt, _Args&&... __args) { |
| 475 | 474 | return std::vformat(__fmt.get(), std::make_format_args(__args...)); |
| 476 | 475 | } |
| 477 | 476 | |
| 478 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 477 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 479 | 478 | template <class... _Args> |
| 480 | 479 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring |
| 481 | 480 | format(wformat_string<_Args...> __fmt, _Args&&... __args) { |
| ... | ... | @@ -501,7 +500,7 @@ format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, format_string<_Args. |
| 501 | 500 | return std::__vformat_to_n<format_context>(std::move(__out_it), __n, __fmt.get(), std::make_format_args(__args...)); |
| 502 | 501 | } |
| 503 | 502 | |
| 504 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 503 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 505 | 504 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> |
| 506 | 505 | _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> |
| 507 | 506 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| ... | ... | @@ -523,7 +522,7 @@ formatted_size(format_string<_Args...> __fmt, _Args&&... __args) { |
| 523 | 522 | return std::__vformatted_size(__fmt.get(), basic_format_args{std::make_format_args(__args...)}); |
| 524 | 523 | } |
| 525 | 524 | |
| 526 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 525 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 527 | 526 | template <class... _Args> |
| 528 | 527 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t |
| 529 | 528 | formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) { |
| ... | ... | @@ -531,7 +530,7 @@ formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 531 | 530 | } |
| 532 | 531 | # endif |
| 533 | 532 | |
| 534 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 533 | # if _LIBCPP_HAS_LOCALIZATION | |
| 535 | 534 | |
| 536 | 535 | template <class _OutIt, class _CharT, class _FormatOutIt> |
| 537 | 536 | requires(output_iterator<_OutIt, const _CharT&>) |
| ... | ... | @@ -544,7 +543,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __vformat_to( |
| 544 | 543 | return std::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()}, |
| 545 | 544 | std::__format_context_create(std::move(__out_it), __args, std::move(__loc))); |
| 546 | 545 | else { |
| 547 | __format::__format_buffer<_OutIt, _CharT> __buffer{std::move(__out_it)}; | |
| 546 | typename __format::__buffer_selector<_OutIt, _CharT>::type __buffer{std::move(__out_it)}; | |
| 548 | 547 | std::__format::__vformat_to( |
| 549 | 548 | basic_format_parse_context{__fmt, __args.__size()}, |
| 550 | 549 | std::__format_context_create(__buffer.__make_output_iterator(), __args, std::move(__loc))); |
| ... | ... | @@ -558,7 +557,7 @@ vformat_to(_OutIt __out_it, locale __loc, string_view __fmt, format_args __args) |
| 558 | 557 | return std::__vformat_to(std::move(__out_it), std::move(__loc), __fmt, __args); |
| 559 | 558 | } |
| 560 | 559 | |
| 561 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 560 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 562 | 561 | template <output_iterator<const wchar_t&> _OutIt> |
| 563 | 562 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt |
| 564 | 563 | vformat_to(_OutIt __out_it, locale __loc, wstring_view __fmt, wformat_args __args) { |
| ... | ... | @@ -572,7 +571,7 @@ format_to(_OutIt __out_it, locale __loc, format_string<_Args...> __fmt, _Args&&. |
| 572 | 571 | return std::vformat_to(std::move(__out_it), std::move(__loc), __fmt.get(), std::make_format_args(__args...)); |
| 573 | 572 | } |
| 574 | 573 | |
| 575 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 574 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 576 | 575 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> |
| 577 | 576 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _OutIt |
| 578 | 577 | format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| ... | ... | @@ -585,20 +584,20 @@ format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&& |
| 585 | 584 | template <class = void> |
| 586 | 585 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string |
| 587 | 586 | vformat(locale __loc, string_view __fmt, format_args __args) { |
| 588 | string __res; | |
| 589 | std::vformat_to(std::back_inserter(__res), std::move(__loc), __fmt, __args); | |
| 590 | return __res; | |
| 587 | __format::__allocating_buffer<char> __buffer; | |
| 588 | std::vformat_to(__buffer.__make_output_iterator(), std::move(__loc), __fmt, __args); | |
| 589 | return string{__buffer.__view()}; | |
| 591 | 590 | } |
| 592 | 591 | |
| 593 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 592 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 594 | 593 | // TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup |
| 595 | 594 | // fires too eagerly, see http://llvm.org/PR61563. |
| 596 | 595 | template <class = void> |
| 597 | 596 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring |
| 598 | 597 | vformat(locale __loc, wstring_view __fmt, wformat_args __args) { |
| 599 | wstring __res; | |
| 600 | std::vformat_to(std::back_inserter(__res), std::move(__loc), __fmt, __args); | |
| 601 | return __res; | |
| 598 | __format::__allocating_buffer<wchar_t> __buffer; | |
| 599 | std::vformat_to(__buffer.__make_output_iterator(), std::move(__loc), __fmt, __args); | |
| 600 | return wstring{__buffer.__view()}; | |
| 602 | 601 | } |
| 603 | 602 | # endif |
| 604 | 603 | |
| ... | ... | @@ -608,7 +607,7 @@ format(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) { |
| 608 | 607 | return std::vformat(std::move(__loc), __fmt.get(), std::make_format_args(__args...)); |
| 609 | 608 | } |
| 610 | 609 | |
| 611 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 610 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 612 | 611 | template <class... _Args> |
| 613 | 612 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring |
| 614 | 613 | format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| ... | ... | @@ -637,7 +636,7 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> format_to |
| 637 | 636 | std::move(__out_it), __n, std::move(__loc), __fmt.get(), std::make_format_args(__args...)); |
| 638 | 637 | } |
| 639 | 638 | |
| 640 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 639 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 641 | 640 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> |
| 642 | 641 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> format_to_n( |
| 643 | 642 | _OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| ... | ... | @@ -661,7 +660,7 @@ formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) { |
| 661 | 660 | return std::__vformatted_size(std::move(__loc), __fmt.get(), basic_format_args{std::make_format_args(__args...)}); |
| 662 | 661 | } |
| 663 | 662 | |
| 664 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 663 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 665 | 664 | template <class... _Args> |
| 666 | 665 | [[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t |
| 667 | 666 | formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| ... | ... | @@ -669,9 +668,9 @@ formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) |
| 669 | 668 | } |
| 670 | 669 | # endif |
| 671 | 670 | |
| 672 | # endif // _LIBCPP_HAS_NO_LOCALIZATION | |
| 671 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 673 | 672 | |
| 674 | #endif //_LIBCPP_STD_VER >= 20 | |
| 673 | #endif // _LIBCPP_STD_VER >= 20 | |
| 675 | 674 | |
| 676 | 675 | _LIBCPP_END_NAMESPACE_STD |
| 677 | 676 |
lib/libcxx/include/__format/format_parse_context.h+2-2| ... | ... | @@ -94,11 +94,11 @@ private: |
| 94 | 94 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_parse_context); |
| 95 | 95 | |
| 96 | 96 | using format_parse_context = basic_format_parse_context<char>; |
| 97 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 97 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 98 | 98 | using wformat_parse_context = basic_format_parse_context<wchar_t>; |
| 99 | 99 | # endif |
| 100 | 100 | |
| 101 | #endif //_LIBCPP_STD_VER >= 20 | |
| 101 | #endif // _LIBCPP_STD_VER >= 20 | |
| 102 | 102 | |
| 103 | 103 | _LIBCPP_END_NAMESPACE_STD |
| 104 | 104 |
lib/libcxx/include/__format/format_string.h+2-2| ... | ... | @@ -12,10 +12,10 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__assert> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/size_t.h> | |
| 15 | 16 | #include <__format/format_error.h> |
| 16 | 17 | #include <__iterator/concepts.h> |
| 17 | 18 | #include <__iterator/iterator_traits.h> // iter_value_t |
| 18 | #include <cstddef> | |
| 19 | 19 | #include <cstdint> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -153,7 +153,7 @@ __parse_arg_id(_Iterator __begin, _Iterator __end, auto& __parse_ctx) { |
| 153 | 153 | |
| 154 | 154 | } // namespace __format |
| 155 | 155 | |
| 156 | #endif //_LIBCPP_STD_VER >= 20 | |
| 156 | #endif // _LIBCPP_STD_VER >= 20 | |
| 157 | 157 | |
| 158 | 158 | _LIBCPP_END_NAMESPACE_STD |
| 159 | 159 |
lib/libcxx/include/__format/format_to_n_result.h+1-1| ... | ... | @@ -28,7 +28,7 @@ struct _LIBCPP_TEMPLATE_VIS format_to_n_result { |
| 28 | 28 | }; |
| 29 | 29 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(format_to_n_result); |
| 30 | 30 | |
| 31 | #endif //_LIBCPP_STD_VER >= 20 | |
| 31 | #endif // _LIBCPP_STD_VER >= 20 | |
| 32 | 32 | |
| 33 | 33 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 34 |
lib/libcxx/include/__format/formatter.h+3| ... | ... | @@ -39,6 +39,9 @@ struct _LIBCPP_TEMPLATE_VIS formatter { |
| 39 | 39 | |
| 40 | 40 | # if _LIBCPP_STD_VER >= 23 |
| 41 | 41 | |
| 42 | template <class _Tp> | |
| 43 | constexpr bool enable_nonlocking_formatter_optimization = false; | |
| 44 | ||
| 42 | 45 | template <class _Tp> |
| 43 | 46 | _LIBCPP_HIDE_FROM_ABI constexpr void __set_debug_format(_Tp& __formatter) { |
| 44 | 47 | if constexpr (requires { __formatter.set_debug_format(); }) |
lib/libcxx/include/__format/formatter_bool.h+6-2| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | #include <__format/parser_std_format_spec.h> |
| 21 | 21 | #include <__utility/unreachable.h> |
| 22 | 22 | |
| 23 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 23 | #if _LIBCPP_HAS_LOCALIZATION | |
| 24 | 24 | # include <__locale> |
| 25 | 25 | #endif |
| 26 | 26 | |
| ... | ... | @@ -69,7 +69,11 @@ public: |
| 69 | 69 | __format_spec::__parser<_CharT> __parser_; |
| 70 | 70 | }; |
| 71 | 71 | |
| 72 | #endif //_LIBCPP_STD_VER >= 20 | |
| 72 | # if _LIBCPP_STD_VER >= 23 | |
| 73 | template <> | |
| 74 | inline constexpr bool enable_nonlocking_formatter_optimization<bool> = true; | |
| 75 | # endif // _LIBCPP_STD_VER >= 23 | |
| 76 | #endif // _LIBCPP_STD_VER >= 20 | |
| 73 | 77 | |
| 74 | 78 | _LIBCPP_END_NAMESPACE_STD |
| 75 | 79 |
lib/libcxx/include/__format/formatter_char.h+11-3| ... | ... | @@ -77,16 +77,24 @@ public: |
| 77 | 77 | template <> |
| 78 | 78 | struct _LIBCPP_TEMPLATE_VIS formatter<char, char> : public __formatter_char<char> {}; |
| 79 | 79 | |
| 80 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 80 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 81 | 81 | template <> |
| 82 | 82 | struct _LIBCPP_TEMPLATE_VIS formatter<char, wchar_t> : public __formatter_char<wchar_t> {}; |
| 83 | 83 | |
| 84 | 84 | template <> |
| 85 | 85 | struct _LIBCPP_TEMPLATE_VIS formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {}; |
| 86 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 86 | 87 | |
| 87 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 88 | # if _LIBCPP_STD_VER >= 23 | |
| 89 | template <> | |
| 90 | inline constexpr bool enable_nonlocking_formatter_optimization<char> = true; | |
| 91 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 92 | template <> | |
| 93 | inline constexpr bool enable_nonlocking_formatter_optimization<wchar_t> = true; | |
| 94 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 95 | # endif // _LIBCPP_STD_VER >= 23 | |
| 88 | 96 | |
| 89 | #endif //_LIBCPP_STD_VER >= 20 | |
| 97 | #endif // _LIBCPP_STD_VER >= 20 | |
| 90 | 98 | |
| 91 | 99 | _LIBCPP_END_NAMESPACE_STD |
| 92 | 100 |
lib/libcxx/include/__format/formatter_floating_point.h+15-7| ... | ... | @@ -23,6 +23,7 @@ |
| 23 | 23 | #include <__concepts/arithmetic.h> |
| 24 | 24 | #include <__concepts/same_as.h> |
| 25 | 25 | #include <__config> |
| 26 | #include <__cstddef/ptrdiff_t.h> | |
| 26 | 27 | #include <__format/concepts.h> |
| 27 | 28 | #include <__format/format_parse_context.h> |
| 28 | 29 | #include <__format/formatter.h> |
| ... | ... | @@ -36,9 +37,8 @@ |
| 36 | 37 | #include <__utility/move.h> |
| 37 | 38 | #include <__utility/unreachable.h> |
| 38 | 39 | #include <cmath> |
| 39 | #include <cstddef> | |
| 40 | 40 | |
| 41 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 41 | #if _LIBCPP_HAS_LOCALIZATION | |
| 42 | 42 | # include <__locale> |
| 43 | 43 | #endif |
| 44 | 44 | |
| ... | ... | @@ -141,7 +141,7 @@ struct __traits<double> { |
| 141 | 141 | /// on the stack or the heap. |
| 142 | 142 | template <floating_point _Fp> |
| 143 | 143 | class _LIBCPP_TEMPLATE_VIS __float_buffer { |
| 144 | using _Traits = __traits<_Fp>; | |
| 144 | using _Traits _LIBCPP_NODEBUG = __traits<_Fp>; | |
| 145 | 145 | |
| 146 | 146 | public: |
| 147 | 147 | // TODO FMT Improve this constructor to do a better estimate. |
| ... | ... | @@ -491,7 +491,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer( |
| 491 | 491 | } |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 494 | # if _LIBCPP_HAS_LOCALIZATION | |
| 495 | 495 | template <class _OutIt, class _Fp, class _CharT> |
| 496 | 496 | _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form( |
| 497 | 497 | _OutIt __out_it, |
| ... | ... | @@ -576,7 +576,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form( |
| 576 | 576 | // alignment |
| 577 | 577 | return __formatter::__fill(std::move(__out_it), __padding.__after_, __specs.__fill_); |
| 578 | 578 | } |
| 579 | # endif // _LIBCPP_HAS_NO_LOCALIZATION | |
| 579 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 580 | 580 | |
| 581 | 581 | template <class _OutIt, class _CharT> |
| 582 | 582 | _LIBCPP_HIDE_FROM_ABI _OutIt __format_floating_point_non_finite( |
| ... | ... | @@ -705,7 +705,7 @@ __format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__par |
| 705 | 705 | } |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 708 | # if _LIBCPP_HAS_LOCALIZATION | |
| 709 | 709 | if (__specs.__std_.__locale_specific_form_) |
| 710 | 710 | return __formatter::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(), __specs); |
| 711 | 711 | # endif |
| ... | ... | @@ -774,7 +774,15 @@ struct _LIBCPP_TEMPLATE_VIS formatter<double, _CharT> : public __formatter_float |
| 774 | 774 | template <__fmt_char_type _CharT> |
| 775 | 775 | struct _LIBCPP_TEMPLATE_VIS formatter<long double, _CharT> : public __formatter_floating_point<_CharT> {}; |
| 776 | 776 | |
| 777 | #endif //_LIBCPP_STD_VER >= 20 | |
| 777 | # if _LIBCPP_STD_VER >= 23 | |
| 778 | template <> | |
| 779 | inline constexpr bool enable_nonlocking_formatter_optimization<float> = true; | |
| 780 | template <> | |
| 781 | inline constexpr bool enable_nonlocking_formatter_optimization<double> = true; | |
| 782 | template <> | |
| 783 | inline constexpr bool enable_nonlocking_formatter_optimization<long double> = true; | |
| 784 | # endif // _LIBCPP_STD_VER >= 23 | |
| 785 | #endif // _LIBCPP_STD_VER >= 20 | |
| 778 | 786 | |
| 779 | 787 | _LIBCPP_END_NAMESPACE_STD |
| 780 | 788 |
lib/libcxx/include/__format/formatter_integer.h+34-3| ... | ... | @@ -67,7 +67,7 @@ template <__fmt_char_type _CharT> |
| 67 | 67 | struct _LIBCPP_TEMPLATE_VIS formatter<long, _CharT> : public __formatter_integer<_CharT> {}; |
| 68 | 68 | template <__fmt_char_type _CharT> |
| 69 | 69 | struct _LIBCPP_TEMPLATE_VIS formatter<long long, _CharT> : public __formatter_integer<_CharT> {}; |
| 70 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 70 | # if _LIBCPP_HAS_INT128 | |
| 71 | 71 | template <__fmt_char_type _CharT> |
| 72 | 72 | struct _LIBCPP_TEMPLATE_VIS formatter<__int128_t, _CharT> : public __formatter_integer<_CharT> {}; |
| 73 | 73 | # endif |
| ... | ... | @@ -83,12 +83,43 @@ template <__fmt_char_type _CharT> |
| 83 | 83 | struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long, _CharT> : public __formatter_integer<_CharT> {}; |
| 84 | 84 | template <__fmt_char_type _CharT> |
| 85 | 85 | struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long long, _CharT> : public __formatter_integer<_CharT> {}; |
| 86 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 86 | # if _LIBCPP_HAS_INT128 | |
| 87 | 87 | template <__fmt_char_type _CharT> |
| 88 | 88 | struct _LIBCPP_TEMPLATE_VIS formatter<__uint128_t, _CharT> : public __formatter_integer<_CharT> {}; |
| 89 | 89 | # endif |
| 90 | 90 | |
| 91 | #endif //_LIBCPP_STD_VER >= 20 | |
| 91 | # if _LIBCPP_STD_VER >= 23 | |
| 92 | template <> | |
| 93 | inline constexpr bool enable_nonlocking_formatter_optimization<signed char> = true; | |
| 94 | template <> | |
| 95 | inline constexpr bool enable_nonlocking_formatter_optimization<short> = true; | |
| 96 | template <> | |
| 97 | inline constexpr bool enable_nonlocking_formatter_optimization<int> = true; | |
| 98 | template <> | |
| 99 | inline constexpr bool enable_nonlocking_formatter_optimization<long> = true; | |
| 100 | template <> | |
| 101 | inline constexpr bool enable_nonlocking_formatter_optimization<long long> = true; | |
| 102 | # if _LIBCPP_HAS_INT128 | |
| 103 | template <> | |
| 104 | inline constexpr bool enable_nonlocking_formatter_optimization<__int128_t> = true; | |
| 105 | # endif | |
| 106 | ||
| 107 | template <> | |
| 108 | inline constexpr bool enable_nonlocking_formatter_optimization<unsigned char> = true; | |
| 109 | template <> | |
| 110 | inline constexpr bool enable_nonlocking_formatter_optimization<unsigned short> = true; | |
| 111 | template <> | |
| 112 | inline constexpr bool enable_nonlocking_formatter_optimization<unsigned> = true; | |
| 113 | template <> | |
| 114 | inline constexpr bool enable_nonlocking_formatter_optimization<unsigned long> = true; | |
| 115 | template <> | |
| 116 | inline constexpr bool enable_nonlocking_formatter_optimization<unsigned long long> = true; | |
| 117 | # if _LIBCPP_HAS_INT128 | |
| 118 | template <> | |
| 119 | inline constexpr bool enable_nonlocking_formatter_optimization<__uint128_t> = true; | |
| 120 | # endif | |
| 121 | # endif // _LIBCPP_STD_VER >= 23 | |
| 122 | #endif // _LIBCPP_STD_VER >= 20 | |
| 92 | 123 | |
| 93 | 124 | _LIBCPP_END_NAMESPACE_STD |
| 94 | 125 |
lib/libcxx/include/__format/formatter_integral.h+6-5| ... | ... | @@ -27,11 +27,12 @@ |
| 27 | 27 | #include <__type_traits/make_unsigned.h> |
| 28 | 28 | #include <__utility/unreachable.h> |
| 29 | 29 | #include <array> |
| 30 | #include <cstdint> | |
| 30 | 31 | #include <limits> |
| 31 | 32 | #include <string> |
| 32 | 33 | #include <string_view> |
| 33 | 34 | |
| 34 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 35 | #if _LIBCPP_HAS_LOCALIZATION | |
| 35 | 36 | # include <__locale> |
| 36 | 37 | #endif |
| 37 | 38 | |
| ... | ... | @@ -297,7 +298,7 @@ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_integer( |
| 297 | 298 | |
| 298 | 299 | _Iterator __last = __formatter::__to_buffer(__first, __end, __value, __base); |
| 299 | 300 | |
| 300 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 301 | # if _LIBCPP_HAS_LOCALIZATION | |
| 301 | 302 | if (__specs.__std_.__locale_specific_form_) { |
| 302 | 303 | const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale()); |
| 303 | 304 | string __grouping = __np.grouping(); |
| ... | ... | @@ -411,7 +412,7 @@ struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> { |
| 411 | 412 | static constexpr string_view __false{"false"}; |
| 412 | 413 | }; |
| 413 | 414 | |
| 414 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 415 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 415 | 416 | template <> |
| 416 | 417 | struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> { |
| 417 | 418 | static constexpr wstring_view __true{L"true"}; |
| ... | ... | @@ -422,7 +423,7 @@ struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> { |
| 422 | 423 | template <class _CharT, class _FormatContext> |
| 423 | 424 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator |
| 424 | 425 | __format_bool(bool __value, _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) { |
| 425 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 426 | # if _LIBCPP_HAS_LOCALIZATION | |
| 426 | 427 | if (__specs.__std_.__locale_specific_form_) { |
| 427 | 428 | const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale()); |
| 428 | 429 | basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename(); |
| ... | ... | @@ -436,7 +437,7 @@ __format_bool(bool __value, _FormatContext& __ctx, __format_spec::__parsed_speci |
| 436 | 437 | |
| 437 | 438 | } // namespace __formatter |
| 438 | 439 | |
| 439 | #endif //_LIBCPP_STD_VER >= 20 | |
| 440 | #endif // _LIBCPP_STD_VER >= 20 | |
| 440 | 441 | |
| 441 | 442 | _LIBCPP_END_NAMESPACE_STD |
| 442 | 443 |
lib/libcxx/include/__format/formatter_output.h+9-9| ... | ... | @@ -16,6 +16,8 @@ |
| 16 | 16 | #include <__bit/countl.h> |
| 17 | 17 | #include <__concepts/same_as.h> |
| 18 | 18 | #include <__config> |
| 19 | #include <__cstddef/ptrdiff_t.h> | |
| 20 | #include <__cstddef/size_t.h> | |
| 19 | 21 | #include <__format/buffer.h> |
| 20 | 22 | #include <__format/concepts.h> |
| 21 | 23 | #include <__format/formatter.h> |
| ... | ... | @@ -28,7 +30,6 @@ |
| 28 | 30 | #include <__memory/pointer_traits.h> |
| 29 | 31 | #include <__utility/move.h> |
| 30 | 32 | #include <__utility/unreachable.h> |
| 31 | #include <cstddef> | |
| 32 | 33 | #include <string_view> |
| 33 | 34 | |
| 34 | 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -168,7 +169,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, _CharT __value) |
| 168 | 169 | } |
| 169 | 170 | } |
| 170 | 171 | |
| 171 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 172 | # if _LIBCPP_HAS_UNICODE | |
| 172 | 173 | template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt> |
| 173 | 174 | requires(same_as<_CharT, char>) |
| 174 | 175 | _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) { |
| ... | ... | @@ -182,7 +183,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec:: |
| 182 | 183 | return __out_it; |
| 183 | 184 | } |
| 184 | 185 | |
| 185 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 186 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 186 | 187 | template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt> |
| 187 | 188 | requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) |
| 188 | 189 | _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) { |
| ... | ... | @@ -200,13 +201,13 @@ template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt> |
| 200 | 201 | _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) { |
| 201 | 202 | return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]); |
| 202 | 203 | } |
| 203 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 204 | # else // _LIBCPP_HAS_NO_UNICODE | |
| 204 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 205 | # else // _LIBCPP_HAS_UNICODE | |
| 205 | 206 | template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt> |
| 206 | 207 | _LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, __format_spec::__code_point<_CharT> __value) { |
| 207 | 208 | return __formatter::__fill(std::move(__out_it), __n, __value.__data[0]); |
| 208 | 209 | } |
| 209 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 210 | # endif // _LIBCPP_HAS_UNICODE | |
| 210 | 211 | |
| 211 | 212 | /// Writes the input to the output with the required padding. |
| 212 | 213 | /// |
| ... | ... | @@ -294,8 +295,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_transformed( |
| 294 | 295 | /// |
| 295 | 296 | /// \pre !__specs.__has_precision() |
| 296 | 297 | /// |
| 297 | /// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the | |
| 298 | /// input is ASCII. | |
| 298 | /// \note When \c _LIBCPP_HAS_UNICODE is false the function assumes the input is ASCII. | |
| 299 | 299 | template <class _CharT> |
| 300 | 300 | _LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision( |
| 301 | 301 | basic_string_view<_CharT> __str, |
| ... | ... | @@ -326,7 +326,7 @@ _LIBCPP_HIDE_FROM_ABI int __truncate(basic_string_view<_CharT>& __str, int __pre |
| 326 | 326 | |
| 327 | 327 | } // namespace __formatter |
| 328 | 328 | |
| 329 | #endif //_LIBCPP_STD_VER >= 20 | |
| 329 | #endif // _LIBCPP_STD_VER >= 20 | |
| 330 | 330 | |
| 331 | 331 | _LIBCPP_END_NAMESPACE_STD |
| 332 | 332 |
lib/libcxx/include/__format/formatter_pointer.h+10-2| ... | ... | @@ -11,13 +11,13 @@ |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMATTER_POINTER_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/nullptr_t.h> | |
| 14 | 15 | #include <__format/concepts.h> |
| 15 | 16 | #include <__format/format_parse_context.h> |
| 16 | 17 | #include <__format/formatter.h> |
| 17 | 18 | #include <__format/formatter_integral.h> |
| 18 | 19 | #include <__format/formatter_output.h> |
| 19 | 20 | #include <__format/parser_std_format_spec.h> |
| 20 | #include <cstddef> | |
| 21 | 21 | #include <cstdint> |
| 22 | 22 | |
| 23 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -65,7 +65,15 @@ struct _LIBCPP_TEMPLATE_VIS formatter<void*, _CharT> : public __formatter_pointe |
| 65 | 65 | template <__fmt_char_type _CharT> |
| 66 | 66 | struct _LIBCPP_TEMPLATE_VIS formatter<const void*, _CharT> : public __formatter_pointer<_CharT> {}; |
| 67 | 67 | |
| 68 | #endif //_LIBCPP_STD_VER >= 20 | |
| 68 | # if _LIBCPP_STD_VER >= 23 | |
| 69 | template <> | |
| 70 | inline constexpr bool enable_nonlocking_formatter_optimization<nullptr_t> = true; | |
| 71 | template <> | |
| 72 | inline constexpr bool enable_nonlocking_formatter_optimization<void*> = true; | |
| 73 | template <> | |
| 74 | inline constexpr bool enable_nonlocking_formatter_optimization<const void*> = true; | |
| 75 | # endif // _LIBCPP_STD_VER >= 23 | |
| 76 | #endif // _LIBCPP_STD_VER >= 20 | |
| 69 | 77 | |
| 70 | 78 | _LIBCPP_END_NAMESPACE_STD |
| 71 | 79 |
lib/libcxx/include/__format/formatter_string.h+38-31| ... | ... | @@ -59,44 +59,26 @@ public: |
| 59 | 59 | // Formatter const char*. |
| 60 | 60 | template <__fmt_char_type _CharT> |
| 61 | 61 | struct _LIBCPP_TEMPLATE_VIS formatter<const _CharT*, _CharT> : public __formatter_string<_CharT> { |
| 62 | using _Base = __formatter_string<_CharT>; | |
| 62 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; | |
| 63 | 63 | |
| 64 | 64 | template <class _FormatContext> |
| 65 | 65 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _CharT* __str, _FormatContext& __ctx) const { |
| 66 | 66 | _LIBCPP_ASSERT_INTERNAL(__str, "The basic_format_arg constructor should have prevented an invalid pointer."); |
| 67 | ||
| 68 | __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx); | |
| 69 | # if _LIBCPP_STD_VER >= 23 | |
| 70 | if (_Base::__parser_.__type_ == __format_spec::__type::__debug) | |
| 71 | return __formatter::__format_escaped_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs); | |
| 72 | # endif | |
| 73 | ||
| 74 | // When using a center or right alignment and the width option the length | |
| 75 | // of __str must be known to add the padding upfront. This case is handled | |
| 76 | // by the base class by converting the argument to a basic_string_view. | |
| 67 | // Converting the input to a basic_string_view means the data is looped over twice; | |
| 68 | // - once to determine the length, and | |
| 69 | // - once to process the data. | |
| 77 | 70 | // |
| 78 | // When using left alignment and the width option the padding is added | |
| 79 | // after outputting __str so the length can be determined while outputting | |
| 80 | // __str. The same holds true for the precision, during outputting __str it | |
| 81 | // can be validated whether the precision threshold has been reached. For | |
| 82 | // now these optimizations aren't implemented. Instead the base class | |
| 83 | // handles these options. | |
| 84 | // TODO FMT Implement these improvements. | |
| 85 | if (__specs.__has_width() || __specs.__has_precision()) | |
| 86 | return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs); | |
| 87 | ||
| 88 | // No formatting required, copy the string to the output. | |
| 89 | auto __out_it = __ctx.out(); | |
| 90 | while (*__str) | |
| 91 | *__out_it++ = *__str++; | |
| 92 | return __out_it; | |
| 71 | // This sounds slower than writing the output directly. However internally | |
| 72 | // the output algorithms have optimizations for "bulk" operations, which | |
| 73 | // makes this faster than a single-pass character-by-character output. | |
| 74 | return _Base::format(basic_string_view<_CharT>(__str), __ctx); | |
| 93 | 75 | } |
| 94 | 76 | }; |
| 95 | 77 | |
| 96 | 78 | // Formatter char*. |
| 97 | 79 | template <__fmt_char_type _CharT> |
| 98 | 80 | struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> { |
| 99 | using _Base = formatter<const _CharT*, _CharT>; | |
| 81 | using _Base _LIBCPP_NODEBUG = formatter<const _CharT*, _CharT>; | |
| 100 | 82 | |
| 101 | 83 | template <class _FormatContext> |
| 102 | 84 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(_CharT* __str, _FormatContext& __ctx) const { |
| ... | ... | @@ -107,7 +89,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const |
| 107 | 89 | // Formatter char[]. |
| 108 | 90 | template <__fmt_char_type _CharT, size_t _Size> |
| 109 | 91 | struct _LIBCPP_TEMPLATE_VIS formatter<_CharT[_Size], _CharT> : public __formatter_string<_CharT> { |
| 110 | using _Base = __formatter_string<_CharT>; | |
| 92 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; | |
| 111 | 93 | |
| 112 | 94 | template <class _FormatContext> |
| 113 | 95 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator |
| ... | ... | @@ -120,7 +102,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<_CharT[_Size], _CharT> : public __formatte |
| 120 | 102 | template <__fmt_char_type _CharT, class _Traits, class _Allocator> |
| 121 | 103 | struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT> |
| 122 | 104 | : public __formatter_string<_CharT> { |
| 123 | using _Base = __formatter_string<_CharT>; | |
| 105 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; | |
| 124 | 106 | |
| 125 | 107 | template <class _FormatContext> |
| 126 | 108 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator |
| ... | ... | @@ -133,7 +115,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>, |
| 133 | 115 | // Formatter std::string_view. |
| 134 | 116 | template <__fmt_char_type _CharT, class _Traits> |
| 135 | 117 | struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT> : public __formatter_string<_CharT> { |
| 136 | using _Base = __formatter_string<_CharT>; | |
| 118 | using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>; | |
| 137 | 119 | |
| 138 | 120 | template <class _FormatContext> |
| 139 | 121 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator |
| ... | ... | @@ -143,7 +125,32 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT |
| 143 | 125 | } |
| 144 | 126 | }; |
| 145 | 127 | |
| 146 | #endif //_LIBCPP_STD_VER >= 20 | |
| 128 | # if _LIBCPP_STD_VER >= 23 | |
| 129 | template <> | |
| 130 | inline constexpr bool enable_nonlocking_formatter_optimization<char*> = true; | |
| 131 | template <> | |
| 132 | inline constexpr bool enable_nonlocking_formatter_optimization<const char*> = true; | |
| 133 | template <size_t _Size> | |
| 134 | inline constexpr bool enable_nonlocking_formatter_optimization<char[_Size]> = true; | |
| 135 | template <class _Traits, class _Allocator> | |
| 136 | inline constexpr bool enable_nonlocking_formatter_optimization<basic_string<char, _Traits, _Allocator>> = true; | |
| 137 | template <class _Traits> | |
| 138 | inline constexpr bool enable_nonlocking_formatter_optimization<basic_string_view<char, _Traits>> = true; | |
| 139 | ||
| 140 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 141 | template <> | |
| 142 | inline constexpr bool enable_nonlocking_formatter_optimization<wchar_t*> = true; | |
| 143 | template <> | |
| 144 | inline constexpr bool enable_nonlocking_formatter_optimization<const wchar_t*> = true; | |
| 145 | template <size_t _Size> | |
| 146 | inline constexpr bool enable_nonlocking_formatter_optimization<wchar_t[_Size]> = true; | |
| 147 | template <class _Traits, class _Allocator> | |
| 148 | inline constexpr bool enable_nonlocking_formatter_optimization<basic_string<wchar_t, _Traits, _Allocator>> = true; | |
| 149 | template <class _Traits> | |
| 150 | inline constexpr bool enable_nonlocking_formatter_optimization<basic_string_view<wchar_t, _Traits>> = true; | |
| 151 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 152 | # endif // _LIBCPP_STD_VER >= 23 | |
| 153 | #endif // _LIBCPP_STD_VER >= 20 | |
| 147 | 154 | |
| 148 | 155 | _LIBCPP_END_NAMESPACE_STD |
| 149 | 156 |
lib/libcxx/include/__format/formatter_tuple.h+1-1| ... | ... | @@ -143,7 +143,7 @@ template <__fmt_char_type _CharT, formattable<_CharT>... _Args> |
| 143 | 143 | struct _LIBCPP_TEMPLATE_VIS formatter<tuple<_Args...>, _CharT> |
| 144 | 144 | : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {}; |
| 145 | 145 | |
| 146 | #endif //_LIBCPP_STD_VER >= 23 | |
| 146 | #endif // _LIBCPP_STD_VER >= 23 | |
| 147 | 147 | |
| 148 | 148 | _LIBCPP_END_NAMESPACE_STD |
| 149 | 149 |
lib/libcxx/include/__format/indic_conjunct_break_table.h+2-2| ... | ... | @@ -63,8 +63,8 @@ |
| 63 | 63 | |
| 64 | 64 | #include <__algorithm/ranges_upper_bound.h> |
| 65 | 65 | #include <__config> |
| 66 | #include <__cstddef/ptrdiff_t.h> | |
| 66 | 67 | #include <__iterator/access.h> |
| 67 | #include <cstddef> | |
| 68 | 68 | #include <cstdint> |
| 69 | 69 | |
| 70 | 70 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -343,7 +343,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = { |
| 343 | 343 | |
| 344 | 344 | } // namespace __indic_conjunct_break |
| 345 | 345 | |
| 346 | #endif //_LIBCPP_STD_VER >= 20 | |
| 346 | #endif // _LIBCPP_STD_VER >= 20 | |
| 347 | 347 | |
| 348 | 348 | _LIBCPP_END_NAMESPACE_STD |
| 349 | 349 |
lib/libcxx/include/__format/parser_std_format_spec.h+15-15| ... | ... | @@ -52,13 +52,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 52 | 52 | |
| 53 | 53 | namespace __format_spec { |
| 54 | 54 | |
| 55 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void | |
| 55 | [[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void | |
| 56 | 56 | __throw_invalid_option_format_error(const char* __id, const char* __option) { |
| 57 | 57 | std::__throw_format_error( |
| 58 | 58 | (string("The format specifier for ") + __id + " does not allow the " + __option + " option").c_str()); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __throw_invalid_type_format_error(const char* __id) { | |
| 61 | [[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void __throw_invalid_type_format_error(const char* __id) { | |
| 62 | 62 | std::__throw_format_error( |
| 63 | 63 | (string("The type option contains an invalid value for ") + __id + " formatting argument").c_str()); |
| 64 | 64 | } |
| ... | ... | @@ -268,7 +268,7 @@ struct __code_point<char> { |
| 268 | 268 | char __data[4] = {' '}; |
| 269 | 269 | }; |
| 270 | 270 | |
| 271 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 271 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 272 | 272 | template <> |
| 273 | 273 | struct __code_point<wchar_t> { |
| 274 | 274 | wchar_t __data[4 / sizeof(wchar_t)] = {L' '}; |
| ... | ... | @@ -321,7 +321,7 @@ struct __parsed_specifications { |
| 321 | 321 | // value in formatting functions. |
| 322 | 322 | static_assert(sizeof(__parsed_specifications<char>) == 16); |
| 323 | 323 | static_assert(is_trivially_copyable_v<__parsed_specifications<char>>); |
| 324 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 324 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 325 | 325 | static_assert(sizeof(__parsed_specifications<wchar_t>) == 16); |
| 326 | 326 | static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>); |
| 327 | 327 | # endif |
| ... | ... | @@ -580,11 +580,11 @@ private: |
| 580 | 580 | std::__throw_format_error("The fill option contains an invalid value"); |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 583 | # if _LIBCPP_HAS_UNICODE | |
| 584 | 584 | // range-fill and tuple-fill are identical |
| 585 | 585 | template <contiguous_iterator _Iterator> |
| 586 | 586 | requires same_as<_CharT, char> |
| 587 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 587 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 588 | 588 | || (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) |
| 589 | 589 | # endif |
| 590 | 590 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) { |
| ... | ... | @@ -617,7 +617,7 @@ private: |
| 617 | 617 | return true; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 620 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 621 | 621 | template <contiguous_iterator _Iterator> |
| 622 | 622 | requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) |
| 623 | 623 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) { |
| ... | ... | @@ -643,9 +643,9 @@ private: |
| 643 | 643 | return true; |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 646 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 647 | 647 | |
| 648 | # else // _LIBCPP_HAS_NO_UNICODE | |
| 648 | # else // _LIBCPP_HAS_UNICODE | |
| 649 | 649 | // range-fill and tuple-fill are identical |
| 650 | 650 | template <contiguous_iterator _Iterator> |
| 651 | 651 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) { |
| ... | ... | @@ -670,7 +670,7 @@ private: |
| 670 | 670 | return true; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 673 | # endif // _LIBCPP_HAS_UNICODE | |
| 674 | 674 | |
| 675 | 675 | template <contiguous_iterator _Iterator> |
| 676 | 676 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_sign(_Iterator& __begin) { |
| ... | ... | @@ -874,7 +874,7 @@ private: |
| 874 | 874 | |
| 875 | 875 | // Validates whether the reserved bitfields don't change the size. |
| 876 | 876 | static_assert(sizeof(__parser<char>) == 16); |
| 877 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 877 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 878 | 878 | static_assert(sizeof(__parser<wchar_t>) == 16); |
| 879 | 879 | # endif |
| 880 | 880 | |
| ... | ... | @@ -1026,7 +1026,7 @@ __column_width_result(size_t, _Iterator) -> __column_width_result<_Iterator>; |
| 1026 | 1026 | /// "rounded up". |
| 1027 | 1027 | enum class __column_width_rounding { __down, __up }; |
| 1028 | 1028 | |
| 1029 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 1029 | # if _LIBCPP_HAS_UNICODE | |
| 1030 | 1030 | |
| 1031 | 1031 | namespace __detail { |
| 1032 | 1032 | template <contiguous_iterator _Iterator> |
| ... | ... | @@ -1148,7 +1148,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_Iterator> __estimate_colu |
| 1148 | 1148 | __result.__width_ += __ascii_size; |
| 1149 | 1149 | return __result; |
| 1150 | 1150 | } |
| 1151 | # else // !defined(_LIBCPP_HAS_NO_UNICODE) | |
| 1151 | # else // _LIBCPP_HAS_UNICODE | |
| 1152 | 1152 | template <class _CharT> |
| 1153 | 1153 | _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<typename basic_string_view<_CharT>::const_iterator> |
| 1154 | 1154 | __estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding) noexcept { |
| ... | ... | @@ -1159,11 +1159,11 @@ __estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __col |
| 1159 | 1159 | return {__width, __str.begin() + __width}; |
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | # endif // !defined(_LIBCPP_HAS_NO_UNICODE) | |
| 1162 | # endif // _LIBCPP_HAS_UNICODE | |
| 1163 | 1163 | |
| 1164 | 1164 | } // namespace __format_spec |
| 1165 | 1165 | |
| 1166 | #endif //_LIBCPP_STD_VER >= 20 | |
| 1166 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1167 | 1167 | |
| 1168 | 1168 | _LIBCPP_END_NAMESPACE_STD |
| 1169 | 1169 |
lib/libcxx/include/__format/range_default_formatter.h+7-7| ... | ... | @@ -40,7 +40,7 @@ concept __const_formattable_range = |
| 40 | 40 | ranges::input_range<const _Rp> && formattable<ranges::range_reference_t<const _Rp>, _CharT>; |
| 41 | 41 | |
| 42 | 42 | template <class _Rp, class _CharT> |
| 43 | using __fmt_maybe_const = conditional_t<__const_formattable_range<_Rp, _CharT>, const _Rp, _Rp>; | |
| 43 | using __fmt_maybe_const _LIBCPP_NODEBUG = conditional_t<__const_formattable_range<_Rp, _CharT>, const _Rp, _Rp>; | |
| 44 | 44 | |
| 45 | 45 | _LIBCPP_DIAGNOSTIC_PUSH |
| 46 | 46 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshadow") |
| ... | ... | @@ -95,7 +95,7 @@ struct _LIBCPP_TEMPLATE_VIS __range_default_formatter; |
| 95 | 95 | template <ranges::input_range _Rp, class _CharT> |
| 96 | 96 | struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::sequence, _Rp, _CharT> { |
| 97 | 97 | private: |
| 98 | using __maybe_const_r = __fmt_maybe_const<_Rp, _CharT>; | |
| 98 | using __maybe_const_r _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>; | |
| 99 | 99 | range_formatter<remove_cvref_t<ranges::range_reference_t<__maybe_const_r>>, _CharT> __underlying_; |
| 100 | 100 | |
| 101 | 101 | public: |
| ... | ... | @@ -122,8 +122,8 @@ public: |
| 122 | 122 | template <ranges::input_range _Rp, class _CharT> |
| 123 | 123 | struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::map, _Rp, _CharT> { |
| 124 | 124 | private: |
| 125 | using __maybe_const_map = __fmt_maybe_const<_Rp, _CharT>; | |
| 126 | using __element_type = remove_cvref_t<ranges::range_reference_t<__maybe_const_map>>; | |
| 125 | using __maybe_const_map _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>; | |
| 126 | using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_map>>; | |
| 127 | 127 | range_formatter<__element_type, _CharT> __underlying_; |
| 128 | 128 | |
| 129 | 129 | public: |
| ... | ... | @@ -150,8 +150,8 @@ public: |
| 150 | 150 | template <ranges::input_range _Rp, class _CharT> |
| 151 | 151 | struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::set, _Rp, _CharT> { |
| 152 | 152 | private: |
| 153 | using __maybe_const_set = __fmt_maybe_const<_Rp, _CharT>; | |
| 154 | using __element_type = remove_cvref_t<ranges::range_reference_t<__maybe_const_set>>; | |
| 153 | using __maybe_const_set _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>; | |
| 154 | using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_set>>; | |
| 155 | 155 | range_formatter<__element_type, _CharT> __underlying_; |
| 156 | 156 | |
| 157 | 157 | public: |
| ... | ... | @@ -207,7 +207,7 @@ template <ranges::input_range _Rp, class _CharT> |
| 207 | 207 | requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>) |
| 208 | 208 | struct _LIBCPP_TEMPLATE_VIS formatter<_Rp, _CharT> : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {}; |
| 209 | 209 | |
| 210 | #endif //_LIBCPP_STD_VER >= 23 | |
| 210 | #endif // _LIBCPP_STD_VER >= 23 | |
| 211 | 211 | |
| 212 | 212 | _LIBCPP_END_NAMESPACE_STD |
| 213 | 213 |
lib/libcxx/include/__format/range_formatter.h+1-1| ... | ... | @@ -257,7 +257,7 @@ private: |
| 257 | 257 | basic_string_view<_CharT> __closing_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "]"); |
| 258 | 258 | }; |
| 259 | 259 | |
| 260 | #endif //_LIBCPP_STD_VER >= 23 | |
| 260 | #endif // _LIBCPP_STD_VER >= 23 | |
| 261 | 261 | |
| 262 | 262 | _LIBCPP_END_NAMESPACE_STD |
| 263 | 263 |
lib/libcxx/include/__format/unicode.h+13-13| ... | ... | @@ -54,7 +54,7 @@ struct __consume_result { |
| 54 | 54 | }; |
| 55 | 55 | static_assert(sizeof(__consume_result) == sizeof(char32_t)); |
| 56 | 56 | |
| 57 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 57 | # if _LIBCPP_HAS_UNICODE | |
| 58 | 58 | |
| 59 | 59 | /// Implements the grapheme cluster boundary rules |
| 60 | 60 | /// |
| ... | ... | @@ -123,7 +123,7 @@ class __code_point_view; |
| 123 | 123 | /// UTF-8 specialization. |
| 124 | 124 | template <> |
| 125 | 125 | class __code_point_view<char> { |
| 126 | using _Iterator = basic_string_view<char>::const_iterator; | |
| 126 | using _Iterator _LIBCPP_NODEBUG = basic_string_view<char>::const_iterator; | |
| 127 | 127 | |
| 128 | 128 | public: |
| 129 | 129 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(_Iterator __first, _Iterator __last) |
| ... | ... | @@ -235,7 +235,7 @@ private: |
| 235 | 235 | _Iterator __last_; |
| 236 | 236 | }; |
| 237 | 237 | |
| 238 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 238 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 239 | 239 | _LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_high(wchar_t __value) { |
| 240 | 240 | return __value >= 0xd800 && __value <= 0xdbff; |
| 241 | 241 | } |
| ... | ... | @@ -249,7 +249,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_low(wchar_t __value) { |
| 249 | 249 | /// - 4 UTF-32 (for example Linux) |
| 250 | 250 | template <> |
| 251 | 251 | class __code_point_view<wchar_t> { |
| 252 | using _Iterator = typename basic_string_view<wchar_t>::const_iterator; | |
| 252 | using _Iterator _LIBCPP_NODEBUG = typename basic_string_view<wchar_t>::const_iterator; | |
| 253 | 253 | |
| 254 | 254 | public: |
| 255 | 255 | static_assert(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4, "sizeof(wchar_t) has a not implemented value"); |
| ... | ... | @@ -292,7 +292,7 @@ private: |
| 292 | 292 | _Iterator __first_; |
| 293 | 293 | _Iterator __last_; |
| 294 | 294 | }; |
| 295 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 295 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 296 | 296 | |
| 297 | 297 | // State machine to implement the Extended Grapheme Cluster Boundary |
| 298 | 298 | // |
| ... | ... | @@ -300,8 +300,8 @@ private: |
| 300 | 300 | // This implements the extended rules see |
| 301 | 301 | // https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries |
| 302 | 302 | class __extended_grapheme_cluster_break { |
| 303 | using __EGC_property = __extended_grapheme_custer_property_boundary::__property; | |
| 304 | using __inCB_property = __indic_conjunct_break::__property; | |
| 303 | using __EGC_property _LIBCPP_NODEBUG = __extended_grapheme_custer_property_boundary::__property; | |
| 304 | using __inCB_property _LIBCPP_NODEBUG = __indic_conjunct_break::__property; | |
| 305 | 305 | |
| 306 | 306 | public: |
| 307 | 307 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_break(char32_t __first_code_point) |
| ... | ... | @@ -527,7 +527,7 @@ private: |
| 527 | 527 | /// Therefore only this code point is extracted. |
| 528 | 528 | template <class _CharT> |
| 529 | 529 | class __extended_grapheme_cluster_view { |
| 530 | using _Iterator = typename basic_string_view<_CharT>::const_iterator; | |
| 530 | using _Iterator _LIBCPP_NODEBUG = typename basic_string_view<_CharT>::const_iterator; | |
| 531 | 531 | |
| 532 | 532 | public: |
| 533 | 533 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_view(_Iterator __first, _Iterator __last) |
| ... | ... | @@ -566,13 +566,13 @@ private: |
| 566 | 566 | template <contiguous_iterator _Iterator> |
| 567 | 567 | __extended_grapheme_cluster_view(_Iterator, _Iterator) -> __extended_grapheme_cluster_view<iter_value_t<_Iterator>>; |
| 568 | 568 | |
| 569 | # else // _LIBCPP_HAS_NO_UNICODE | |
| 569 | # else // _LIBCPP_HAS_UNICODE | |
| 570 | 570 | |
| 571 | 571 | // For ASCII every character is a "code point". |
| 572 | // This makes it easier to write code agnostic of the _LIBCPP_HAS_NO_UNICODE define. | |
| 572 | // This makes it easier to write code agnostic of the _LIBCPP_HAS_UNICODE define. | |
| 573 | 573 | template <class _CharT> |
| 574 | 574 | class __code_point_view { |
| 575 | using _Iterator = typename basic_string_view<_CharT>::const_iterator; | |
| 575 | using _Iterator _LIBCPP_NODEBUG = typename basic_string_view<_CharT>::const_iterator; | |
| 576 | 576 | |
| 577 | 577 | public: |
| 578 | 578 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(_Iterator __first, _Iterator __last) |
| ... | ... | @@ -591,11 +591,11 @@ private: |
| 591 | 591 | _Iterator __last_; |
| 592 | 592 | }; |
| 593 | 593 | |
| 594 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 594 | # endif // _LIBCPP_HAS_UNICODE | |
| 595 | 595 | |
| 596 | 596 | } // namespace __unicode |
| 597 | 597 | |
| 598 | #endif //_LIBCPP_STD_VER >= 20 | |
| 598 | #endif // _LIBCPP_STD_VER >= 20 | |
| 599 | 599 | |
| 600 | 600 | _LIBCPP_END_NAMESPACE_STD |
| 601 | 601 |
lib/libcxx/include/__format/width_estimation_table.h+2-2| ... | ... | @@ -63,7 +63,7 @@ |
| 63 | 63 | |
| 64 | 64 | #include <__algorithm/ranges_upper_bound.h> |
| 65 | 65 | #include <__config> |
| 66 | #include <cstddef> | |
| 66 | #include <__cstddef/ptrdiff_t.h> | |
| 67 | 67 | #include <cstdint> |
| 68 | 68 | |
| 69 | 69 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -263,7 +263,7 @@ inline constexpr uint32_t __table_upper_bound = 0x0003fffd; |
| 263 | 263 | |
| 264 | 264 | } // namespace __width_estimation_table |
| 265 | 265 | |
| 266 | #endif //_LIBCPP_STD_VER >= 20 | |
| 266 | #endif // _LIBCPP_STD_VER >= 20 | |
| 267 | 267 | |
| 268 | 268 | _LIBCPP_END_NAMESPACE_STD |
| 269 | 269 |
lib/libcxx/include/__format/write_escaped.h+3-3| ... | ... | @@ -16,6 +16,7 @@ |
| 16 | 16 | #include <__charconv/to_chars_result.h> |
| 17 | 17 | #include <__chrono/statically_widen.h> |
| 18 | 18 | #include <__format/escaped_output_table.h> |
| 19 | #include <__format/extended_grapheme_cluster_table.h> | |
| 19 | 20 | #include <__format/formatter_output.h> |
| 20 | 21 | #include <__format/parser_std_format_spec.h> |
| 21 | 22 | #include <__format/unicode.h> |
| ... | ... | @@ -41,8 +42,7 @@ namespace __formatter { |
| 41 | 42 | |
| 42 | 43 | /// Writes a string using format's width estimation algorithm. |
| 43 | 44 | /// |
| 44 | /// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the | |
| 45 | /// input is ASCII. | |
| 45 | /// \note When \c _LIBCPP_HAS_UNICODE is false the function assumes the input is ASCII. | |
| 46 | 46 | template <class _CharT> |
| 47 | 47 | _LIBCPP_HIDE_FROM_ABI auto |
| 48 | 48 | __write_string(basic_string_view<_CharT> __str, |
| ... | ... | @@ -103,7 +103,7 @@ _LIBCPP_HIDE_FROM_ABI void __write_escape_ill_formed_code_unit(basic_string<_Cha |
| 103 | 103 | template <class _CharT> |
| 104 | 104 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool |
| 105 | 105 | __is_escaped_sequence_written(basic_string<_CharT>& __str, bool __last_escaped, char32_t __value) { |
| 106 | # ifdef _LIBCPP_HAS_NO_UNICODE | |
| 106 | # if !_LIBCPP_HAS_UNICODE | |
| 107 | 107 | // For ASCII assume everything above 127 is printable. |
| 108 | 108 | if (__value > 127) |
| 109 | 109 | return false; |
lib/libcxx/include/__functional/binary_function.h+2-2| ... | ... | @@ -42,11 +42,11 @@ struct __binary_function_keep_layout_base { |
| 42 | 42 | _LIBCPP_DIAGNOSTIC_PUSH |
| 43 | 43 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") |
| 44 | 44 | template <class _Arg1, class _Arg2, class _Result> |
| 45 | using __binary_function = binary_function<_Arg1, _Arg2, _Result>; | |
| 45 | using __binary_function _LIBCPP_NODEBUG = binary_function<_Arg1, _Arg2, _Result>; | |
| 46 | 46 | _LIBCPP_DIAGNOSTIC_POP |
| 47 | 47 | #else |
| 48 | 48 | template <class _Arg1, class _Arg2, class _Result> |
| 49 | using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; | |
| 49 | using __binary_function _LIBCPP_NODEBUG = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; | |
| 50 | 50 | #endif |
| 51 | 51 | |
| 52 | 52 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__functional/bind.h+12-15| ... | ... | @@ -11,13 +11,12 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_BIND_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/invoke.h> | |
| 15 | 14 | #include <__functional/weak_result_type.h> |
| 16 | 15 | #include <__fwd/functional.h> |
| 17 | 16 | #include <__type_traits/decay.h> |
| 17 | #include <__type_traits/invoke.h> | |
| 18 | 18 | #include <__type_traits/is_reference_wrapper.h> |
| 19 | 19 | #include <__type_traits/is_void.h> |
| 20 | #include <cstddef> | |
| 21 | 20 | #include <tuple> |
| 22 | 21 | |
| 23 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -83,13 +82,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_w |
| 83 | 82 | } |
| 84 | 83 | |
| 85 | 84 | template <class _Ti, class... _Uj, size_t... _Indx> |
| 86 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type | |
| 85 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...> | |
| 87 | 86 | __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) { |
| 88 | 87 | return __ti(std::forward<_Uj>(std::get<_Indx>(__uj))...); |
| 89 | 88 | } |
| 90 | 89 | |
| 91 | 90 | template <class _Ti, class... _Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0> |
| 92 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type | |
| 91 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...> | |
| 93 | 92 | __mu(_Ti& __ti, tuple<_Uj...>& __uj) { |
| 94 | 93 | typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; |
| 95 | 94 | return std::__mu_expand(__ti, __uj, __indices()); |
| ... | ... | @@ -131,12 +130,12 @@ struct __mu_return_invokable // false |
| 131 | 130 | |
| 132 | 131 | template <class _Ti, class... _Uj> |
| 133 | 132 | struct __mu_return_invokable<true, _Ti, _Uj...> { |
| 134 | typedef typename __invoke_of<_Ti&, _Uj...>::type type; | |
| 133 | using type = __invoke_result_t<_Ti&, _Uj...>; | |
| 135 | 134 | }; |
| 136 | 135 | |
| 137 | 136 | template <class _Ti, class... _Uj> |
| 138 | 137 | struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> > |
| 139 | : public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> {}; | |
| 138 | : public __mu_return_invokable<__is_invocable_v<_Ti&, _Uj...>, _Ti, _Uj...> {}; | |
| 140 | 139 | |
| 141 | 140 | template <class _Ti, class _TupleUj> |
| 142 | 141 | struct __mu_return_impl<_Ti, false, false, true, _TupleUj> { |
| ... | ... | @@ -169,12 +168,12 @@ struct __is_valid_bind_return { |
| 169 | 168 | |
| 170 | 169 | template <class _Fp, class... _BoundArgs, class _TupleUj> |
| 171 | 170 | struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> { |
| 172 | static const bool value = __invokable<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; | |
| 171 | static const bool value = __is_invocable_v<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>; | |
| 173 | 172 | }; |
| 174 | 173 | |
| 175 | 174 | template <class _Fp, class... _BoundArgs, class _TupleUj> |
| 176 | 175 | struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> { |
| 177 | static const bool value = __invokable<_Fp, typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value; | |
| 176 | static const bool value = __is_invocable_v<_Fp, typename __mu_return<const _BoundArgs, _TupleUj>::type...>; | |
| 178 | 177 | }; |
| 179 | 178 | |
| 180 | 179 | template <class _Fp, class _BoundArgs, class _TupleUj, bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value> |
| ... | ... | @@ -182,12 +181,12 @@ struct __bind_return; |
| 182 | 181 | |
| 183 | 182 | template <class _Fp, class... _BoundArgs, class _TupleUj> |
| 184 | 183 | struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> { |
| 185 | typedef typename __invoke_of< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >::type type; | |
| 184 | using type = __invoke_result_t< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >; | |
| 186 | 185 | }; |
| 187 | 186 | |
| 188 | 187 | template <class _Fp, class... _BoundArgs, class _TupleUj> |
| 189 | 188 | struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> { |
| 190 | typedef typename __invoke_of< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >::type type; | |
| 189 | using type = __invoke_result_t< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >; | |
| 191 | 190 | }; |
| 192 | 191 | |
| 193 | 192 | template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args> |
| ... | ... | @@ -199,7 +198,7 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, _ |
| 199 | 198 | template <class _Fp, class... _BoundArgs> |
| 200 | 199 | class __bind : public __weak_result_type<__decay_t<_Fp> > { |
| 201 | 200 | protected: |
| 202 | using _Fd = __decay_t<_Fp>; | |
| 201 | using _Fd _LIBCPP_NODEBUG = __decay_t<_Fp>; | |
| 203 | 202 | typedef tuple<__decay_t<_BoundArgs>...> _Td; |
| 204 | 203 | |
| 205 | 204 | private: |
| ... | ... | @@ -257,8 +256,7 @@ public: |
| 257 | 256 | is_void<_Rp>::value, |
| 258 | 257 | int> = 0> |
| 259 | 258 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) { |
| 260 | typedef __invoke_void_return_wrapper<_Rp> _Invoker; | |
| 261 | return _Invoker::__call(static_cast<base&>(*this), std::forward<_Args>(__args)...); | |
| 259 | return std::__invoke_r<_Rp>(static_cast<base&>(*this), std::forward<_Args>(__args)...); | |
| 262 | 260 | } |
| 263 | 261 | |
| 264 | 262 | template <class... _Args, |
| ... | ... | @@ -267,8 +265,7 @@ public: |
| 267 | 265 | is_void<_Rp>::value, |
| 268 | 266 | int> = 0> |
| 269 | 267 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) const { |
| 270 | typedef __invoke_void_return_wrapper<_Rp> _Invoker; | |
| 271 | return _Invoker::__call(static_cast<base const&>(*this), std::forward<_Args>(__args)...); | |
| 268 | return std::__invoke_r<_Rp>(static_cast<base const&>(*this), std::forward<_Args>(__args)...); | |
| 272 | 269 | } |
| 273 | 270 | }; |
| 274 | 271 |
lib/libcxx/include/__functional/boyer_moore_searcher.h+4-3| ... | ... | @@ -22,9 +22,10 @@ |
| 22 | 22 | #include <__memory/shared_ptr.h> |
| 23 | 23 | #include <__type_traits/make_unsigned.h> |
| 24 | 24 | #include <__utility/pair.h> |
| 25 | #include <__vector/vector.h> | |
| 25 | 26 | #include <array> |
| 27 | #include <limits> | |
| 26 | 28 | #include <unordered_map> |
| 27 | #include <vector> | |
| 28 | 29 | |
| 29 | 30 | #if _LIBCPP_STD_VER >= 17 |
| 30 | 31 | |
| ... | ... | @@ -91,7 +92,7 @@ class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher { |
| 91 | 92 | private: |
| 92 | 93 | using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type; |
| 93 | 94 | using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type; |
| 94 | using __skip_table_type = | |
| 95 | using __skip_table_type _LIBCPP_NODEBUG = | |
| 95 | 96 | _BMSkipTable<value_type, |
| 96 | 97 | difference_type, |
| 97 | 98 | _Hash, |
| ... | ... | @@ -222,7 +223,7 @@ class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher { |
| 222 | 223 | private: |
| 223 | 224 | using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type; |
| 224 | 225 | using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type; |
| 225 | using __skip_table_type = | |
| 226 | using __skip_table_type _LIBCPP_NODEBUG = | |
| 226 | 227 | _BMSkipTable<value_type, |
| 227 | 228 | difference_type, |
| 228 | 229 | _Hash, |
lib/libcxx/include/__functional/function.h+63-57| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__assert> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/nullptr_t.h> | |
| 15 | 16 | #include <__exception/exception.h> |
| 16 | 17 | #include <__functional/binary_function.h> |
| 17 | 18 | #include <__functional/invoke.h> |
| ... | ... | @@ -21,7 +22,6 @@ |
| 21 | 22 | #include <__memory/allocator.h> |
| 22 | 23 | #include <__memory/allocator_destructor.h> |
| 23 | 24 | #include <__memory/allocator_traits.h> |
| 24 | #include <__memory/builtin_new_allocator.h> | |
| 25 | 25 | #include <__memory/compressed_pair.h> |
| 26 | 26 | #include <__memory/unique_ptr.h> |
| 27 | 27 | #include <__type_traits/aligned_storage.h> |
| ... | ... | @@ -37,7 +37,6 @@ |
| 37 | 37 | #include <__utility/piecewise_construct.h> |
| 38 | 38 | #include <__utility/swap.h> |
| 39 | 39 | #include <__verbose_abort> |
| 40 | #include <new> | |
| 41 | 40 | #include <tuple> |
| 42 | 41 | #include <typeinfo> |
| 43 | 42 | |
| ... | ... | @@ -78,8 +77,8 @@ public: |
| 78 | 77 | }; |
| 79 | 78 | _LIBCPP_DIAGNOSTIC_POP |
| 80 | 79 | |
| 81 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_function_call() { | |
| 82 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 80 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_function_call() { | |
| 81 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 83 | 82 | throw bad_function_call(); |
| 84 | 83 | # else |
| 85 | 84 | _LIBCPP_VERBOSE_ABORT("bad_function_call was thrown in -fno-exceptions mode"); |
| ... | ... | @@ -123,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(function<_Fp> const& __f) { |
| 123 | 122 | return !!__f; |
| 124 | 123 | } |
| 125 | 124 | |
| 126 | # ifdef _LIBCPP_HAS_EXTENSION_BLOCKS | |
| 125 | # if _LIBCPP_HAS_EXTENSION_BLOCKS | |
| 127 | 126 | template <class _Rp, class... _Args> |
| 128 | 127 | _LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) { |
| 129 | 128 | return __p; |
| ... | ... | @@ -143,45 +142,45 @@ class __default_alloc_func; |
| 143 | 142 | |
| 144 | 143 | template <class _Fp, class _Ap, class _Rp, class... _ArgTypes> |
| 145 | 144 | class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> { |
| 146 | __compressed_pair<_Fp, _Ap> __f_; | |
| 145 | _LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Ap, __alloc_); | |
| 147 | 146 | |
| 148 | 147 | public: |
| 149 | typedef _LIBCPP_NODEBUG _Fp _Target; | |
| 150 | typedef _LIBCPP_NODEBUG _Ap _Alloc; | |
| 148 | using _Target _LIBCPP_NODEBUG = _Fp; | |
| 149 | using _Alloc _LIBCPP_NODEBUG = _Ap; | |
| 151 | 150 | |
| 152 | _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __f_.first(); } | |
| 151 | _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __func_; } | |
| 153 | 152 | |
| 154 | 153 | // WIN32 APIs may define __allocator, so use __get_allocator instead. |
| 155 | _LIBCPP_HIDE_FROM_ABI const _Alloc& __get_allocator() const { return __f_.second(); } | |
| 154 | _LIBCPP_HIDE_FROM_ABI const _Alloc& __get_allocator() const { return __alloc_; } | |
| 156 | 155 | |
| 157 | _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f) | |
| 158 | : __f_(piecewise_construct, std::forward_as_tuple(std::move(__f)), std::forward_as_tuple()) {} | |
| 156 | _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f) : __func_(std::move(__f)), __alloc_() {} | |
| 159 | 157 | |
| 160 | _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, const _Alloc& __a) | |
| 161 | : __f_(piecewise_construct, std::forward_as_tuple(__f), std::forward_as_tuple(__a)) {} | |
| 158 | _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, const _Alloc& __a) : __func_(__f), __alloc_(__a) {} | |
| 162 | 159 | |
| 163 | 160 | _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, _Alloc&& __a) |
| 164 | : __f_(piecewise_construct, std::forward_as_tuple(__f), std::forward_as_tuple(std::move(__a))) {} | |
| 161 | : __func_(__f), __alloc_(std::move(__a)) {} | |
| 165 | 162 | |
| 166 | 163 | _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f, _Alloc&& __a) |
| 167 | : __f_(piecewise_construct, std::forward_as_tuple(std::move(__f)), std::forward_as_tuple(std::move(__a))) {} | |
| 164 | : __func_(std::move(__f)), __alloc_(std::move(__a)) {} | |
| 168 | 165 | |
| 169 | 166 | _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) { |
| 170 | typedef __invoke_void_return_wrapper<_Rp> _Invoker; | |
| 171 | return _Invoker::__call(__f_.first(), std::forward<_ArgTypes>(__arg)...); | |
| 167 | return std::__invoke_r<_Rp>(__func_, std::forward<_ArgTypes>(__arg)...); | |
| 172 | 168 | } |
| 173 | 169 | |
| 174 | 170 | _LIBCPP_HIDE_FROM_ABI __alloc_func* __clone() const { |
| 175 | 171 | typedef allocator_traits<_Alloc> __alloc_traits; |
| 176 | 172 | typedef __rebind_alloc<__alloc_traits, __alloc_func> _AA; |
| 177 | _AA __a(__f_.second()); | |
| 173 | _AA __a(__alloc_); | |
| 178 | 174 | typedef __allocator_destructor<_AA> _Dp; |
| 179 | 175 | unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); |
| 180 | ::new ((void*)__hold.get()) __alloc_func(__f_.first(), _Alloc(__a)); | |
| 176 | ::new ((void*)__hold.get()) __alloc_func(__func_, _Alloc(__a)); | |
| 181 | 177 | return __hold.release(); |
| 182 | 178 | } |
| 183 | 179 | |
| 184 | _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT { __f_.~__compressed_pair<_Target, _Alloc>(); } | |
| 180 | _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT { | |
| 181 | __func_.~_Fp(); | |
| 182 | __alloc_.~_Alloc(); | |
| 183 | } | |
| 185 | 184 | |
| 186 | 185 | _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__alloc_func* __f) { |
| 187 | 186 | typedef allocator_traits<_Alloc> __alloc_traits; |
| ... | ... | @@ -192,12 +191,19 @@ public: |
| 192 | 191 | } |
| 193 | 192 | }; |
| 194 | 193 | |
| 194 | template <class _Tp> | |
| 195 | struct __deallocating_deleter { | |
| 196 | _LIBCPP_HIDE_FROM_ABI void operator()(void* __p) const { | |
| 197 | std::__libcpp_deallocate<_Tp>(static_cast<_Tp*>(__p), __element_count(1)); | |
| 198 | } | |
| 199 | }; | |
| 200 | ||
| 195 | 201 | template <class _Fp, class _Rp, class... _ArgTypes> |
| 196 | 202 | class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> { |
| 197 | 203 | _Fp __f_; |
| 198 | 204 | |
| 199 | 205 | public: |
| 200 | typedef _LIBCPP_NODEBUG _Fp _Target; | |
| 206 | using _Target _LIBCPP_NODEBUG = _Fp; | |
| 201 | 207 | |
| 202 | 208 | _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __f_; } |
| 203 | 209 | |
| ... | ... | @@ -206,13 +212,13 @@ public: |
| 206 | 212 | _LIBCPP_HIDE_FROM_ABI explicit __default_alloc_func(const _Target& __f) : __f_(__f) {} |
| 207 | 213 | |
| 208 | 214 | _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) { |
| 209 | typedef __invoke_void_return_wrapper<_Rp> _Invoker; | |
| 210 | return _Invoker::__call(__f_, std::forward<_ArgTypes>(__arg)...); | |
| 215 | return std::__invoke_r<_Rp>(__f_, std::forward<_ArgTypes>(__arg)...); | |
| 211 | 216 | } |
| 212 | 217 | |
| 213 | 218 | _LIBCPP_HIDE_FROM_ABI __default_alloc_func* __clone() const { |
| 214 | __builtin_new_allocator::__holder_t __hold = __builtin_new_allocator::__allocate_type<__default_alloc_func>(1); | |
| 215 | __default_alloc_func* __res = ::new ((void*)__hold.get()) __default_alloc_func(__f_); | |
| 219 | using _Self = __default_alloc_func; | |
| 220 | unique_ptr<_Self, __deallocating_deleter<_Self>> __hold(std::__libcpp_allocate<_Self>(__element_count(1))); | |
| 221 | _Self* __res = ::new ((void*)__hold.get()) _Self(__f_); | |
| 216 | 222 | (void)__hold.release(); |
| 217 | 223 | return __res; |
| 218 | 224 | } |
| ... | ... | @@ -221,7 +227,7 @@ public: |
| 221 | 227 | |
| 222 | 228 | _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__default_alloc_func* __f) { |
| 223 | 229 | __f->destroy(); |
| 224 | __builtin_new_allocator::__deallocate_type<__default_alloc_func>(__f, 1); | |
| 230 | std::__libcpp_deallocate<__default_alloc_func>(__f, __element_count(1)); | |
| 225 | 231 | } |
| 226 | 232 | }; |
| 227 | 233 | |
| ... | ... | @@ -243,10 +249,10 @@ public: |
| 243 | 249 | virtual void destroy() _NOEXCEPT = 0; |
| 244 | 250 | virtual void destroy_deallocate() _NOEXCEPT = 0; |
| 245 | 251 | virtual _Rp operator()(_ArgTypes&&...) = 0; |
| 246 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 252 | # if _LIBCPP_HAS_RTTI | |
| 247 | 253 | virtual const void* target(const type_info&) const _NOEXCEPT = 0; |
| 248 | 254 | virtual const std::type_info& target_type() const _NOEXCEPT = 0; |
| 249 | # endif // _LIBCPP_HAS_NO_RTTI | |
| 255 | # endif // _LIBCPP_HAS_RTTI | |
| 250 | 256 | }; |
| 251 | 257 | |
| 252 | 258 | // __func implements __base for a given functor type. |
| ... | ... | @@ -272,10 +278,10 @@ public: |
| 272 | 278 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT; |
| 273 | 279 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT; |
| 274 | 280 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg); |
| 275 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 281 | # if _LIBCPP_HAS_RTTI | |
| 276 | 282 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(const type_info&) const _NOEXCEPT; |
| 277 | 283 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT; |
| 278 | # endif // _LIBCPP_HAS_NO_RTTI | |
| 284 | # endif // _LIBCPP_HAS_RTTI | |
| 279 | 285 | }; |
| 280 | 286 | |
| 281 | 287 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> |
| ... | ... | @@ -313,7 +319,7 @@ _Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) { |
| 313 | 319 | return __f_(std::forward<_ArgTypes>(__arg)...); |
| 314 | 320 | } |
| 315 | 321 | |
| 316 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 322 | # if _LIBCPP_HAS_RTTI | |
| 317 | 323 | |
| 318 | 324 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> |
| 319 | 325 | const void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT { |
| ... | ... | @@ -327,7 +333,7 @@ const std::type_info& __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() cons |
| 327 | 333 | return typeid(_Fp); |
| 328 | 334 | } |
| 329 | 335 | |
| 330 | # endif // _LIBCPP_HAS_NO_RTTI | |
| 336 | # endif // _LIBCPP_HAS_RTTI | |
| 331 | 337 | |
| 332 | 338 | // __value_func creates a value-type from a __func. |
| 333 | 339 | |
| ... | ... | @@ -464,7 +470,7 @@ public: |
| 464 | 470 | |
| 465 | 471 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __f_ != nullptr; } |
| 466 | 472 | |
| 467 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 473 | # if _LIBCPP_HAS_RTTI | |
| 468 | 474 | _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT { |
| 469 | 475 | if (__f_ == nullptr) |
| 470 | 476 | return typeid(void); |
| ... | ... | @@ -477,7 +483,7 @@ public: |
| 477 | 483 | return nullptr; |
| 478 | 484 | return (const _Tp*)__f_->target(typeid(_Tp)); |
| 479 | 485 | } |
| 480 | # endif // _LIBCPP_HAS_NO_RTTI | |
| 486 | # endif // _LIBCPP_HAS_RTTI | |
| 481 | 487 | }; |
| 482 | 488 | |
| 483 | 489 | // Storage for a functor object, to be used with __policy to manage copy and |
| ... | ... | @@ -520,7 +526,7 @@ struct __policy { |
| 520 | 526 | nullptr, |
| 521 | 527 | nullptr, |
| 522 | 528 | true, |
| 523 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 529 | # if _LIBCPP_HAS_RTTI | |
| 524 | 530 | &typeid(void) |
| 525 | 531 | # else |
| 526 | 532 | nullptr |
| ... | ... | @@ -547,7 +553,7 @@ private: |
| 547 | 553 | &__large_clone<_Fun>, |
| 548 | 554 | &__large_destroy<_Fun>, |
| 549 | 555 | false, |
| 550 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 556 | # if _LIBCPP_HAS_RTTI | |
| 551 | 557 | &typeid(typename _Fun::_Target) |
| 552 | 558 | # else |
| 553 | 559 | nullptr |
| ... | ... | @@ -562,7 +568,7 @@ private: |
| 562 | 568 | nullptr, |
| 563 | 569 | nullptr, |
| 564 | 570 | false, |
| 565 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 571 | # if _LIBCPP_HAS_RTTI | |
| 566 | 572 | &typeid(typename _Fun::_Target) |
| 567 | 573 | # else |
| 568 | 574 | nullptr |
| ... | ... | @@ -575,7 +581,7 @@ private: |
| 575 | 581 | // Used to choose between perfect forwarding or pass-by-value. Pass-by-value is |
| 576 | 582 | // faster for types that can be passed in registers. |
| 577 | 583 | template <typename _Tp> |
| 578 | using __fast_forward = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>; | |
| 584 | using __fast_forward _LIBCPP_NODEBUG = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>; | |
| 579 | 585 | |
| 580 | 586 | // __policy_invoker calls an instance of __alloc_func held in __policy_storage. |
| 581 | 587 | |
| ... | ... | @@ -667,8 +673,8 @@ public: |
| 667 | 673 | if (__use_small_storage<_Fun>()) { |
| 668 | 674 | ::new ((void*)&__buf_.__small) _Fun(std::move(__f)); |
| 669 | 675 | } else { |
| 670 | __builtin_new_allocator::__holder_t __hold = __builtin_new_allocator::__allocate_type<_Fun>(1); | |
| 671 | __buf_.__large = ::new ((void*)__hold.get()) _Fun(std::move(__f)); | |
| 676 | unique_ptr<_Fun, __deallocating_deleter<_Fun>> __hold(std::__libcpp_allocate<_Fun>(__element_count(1))); | |
| 677 | __buf_.__large = ::new ((void*)__hold.get()) _Fun(std::move(__f)); | |
| 672 | 678 | (void)__hold.release(); |
| 673 | 679 | } |
| 674 | 680 | } |
| ... | ... | @@ -724,7 +730,7 @@ public: |
| 724 | 730 | |
| 725 | 731 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return !__policy_->__is_null; } |
| 726 | 732 | |
| 727 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 733 | # if _LIBCPP_HAS_RTTI | |
| 728 | 734 | _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT { return *__policy_->__type_info; } |
| 729 | 735 | |
| 730 | 736 | template <typename _Tp> |
| ... | ... | @@ -736,10 +742,10 @@ public: |
| 736 | 742 | else |
| 737 | 743 | return reinterpret_cast<const _Tp*>(&__buf_.__small); |
| 738 | 744 | } |
| 739 | # endif // _LIBCPP_HAS_NO_RTTI | |
| 745 | # endif // _LIBCPP_HAS_RTTI | |
| 740 | 746 | }; |
| 741 | 747 | |
| 742 | # if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) | |
| 748 | # if _LIBCPP_HAS_BLOCKS_RUNTIME | |
| 743 | 749 | |
| 744 | 750 | extern "C" void* _Block_copy(const void*); |
| 745 | 751 | extern "C" void _Block_release(const void*); |
| ... | ... | @@ -751,7 +757,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base |
| 751 | 757 | |
| 752 | 758 | public: |
| 753 | 759 | _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type const& __f) |
| 754 | # ifdef _LIBCPP_HAS_OBJC_ARC | |
| 760 | # if _LIBCPP_HAS_OBJC_ARC | |
| 755 | 761 | : __f_(__f) |
| 756 | 762 | # else |
| 757 | 763 | : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) |
| ... | ... | @@ -762,7 +768,7 @@ public: |
| 762 | 768 | // [TODO] add && to save on a retain |
| 763 | 769 | |
| 764 | 770 | _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type __f, const _Alloc& /* unused */) |
| 765 | # ifdef _LIBCPP_HAS_OBJC_ARC | |
| 771 | # if _LIBCPP_HAS_OBJC_ARC | |
| 766 | 772 | : __f_(__f) |
| 767 | 773 | # else |
| 768 | 774 | : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) |
| ... | ... | @@ -784,7 +790,7 @@ public: |
| 784 | 790 | } |
| 785 | 791 | |
| 786 | 792 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT { |
| 787 | # ifndef _LIBCPP_HAS_OBJC_ARC | |
| 793 | # if !_LIBCPP_HAS_OBJC_ARC | |
| 788 | 794 | if (__f_) |
| 789 | 795 | _Block_release(__f_); |
| 790 | 796 | # endif |
| ... | ... | @@ -803,7 +809,7 @@ public: |
| 803 | 809 | return std::__invoke(__f_, std::forward<_ArgTypes>(__arg)...); |
| 804 | 810 | } |
| 805 | 811 | |
| 806 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 812 | # if _LIBCPP_HAS_RTTI | |
| 807 | 813 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(type_info const& __ti) const _NOEXCEPT { |
| 808 | 814 | if (__ti == typeid(__func::__block_type)) |
| 809 | 815 | return &__f_; |
| ... | ... | @@ -813,7 +819,7 @@ public: |
| 813 | 819 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT { |
| 814 | 820 | return typeid(__func::__block_type); |
| 815 | 821 | } |
| 816 | # endif // _LIBCPP_HAS_NO_RTTI | |
| 822 | # endif // _LIBCPP_HAS_RTTI | |
| 817 | 823 | }; |
| 818 | 824 | |
| 819 | 825 | # endif // _LIBCPP_HAS_EXTENSION_BLOCKS |
| ... | ... | @@ -833,12 +839,12 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> |
| 833 | 839 | __func __f_; |
| 834 | 840 | |
| 835 | 841 | template <class _Fp, |
| 836 | bool = _And< _IsNotSame<__remove_cvref_t<_Fp>, function>, __invokable<_Fp, _ArgTypes...> >::value> | |
| 842 | bool = _And<_IsNotSame<__remove_cvref_t<_Fp>, function>, __is_invocable<_Fp, _ArgTypes...> >::value> | |
| 837 | 843 | struct __callable; |
| 838 | 844 | template <class _Fp> |
| 839 | 845 | struct __callable<_Fp, true> { |
| 840 | 846 | static const bool value = |
| 841 | is_void<_Rp>::value || __is_core_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type, _Rp>::value; | |
| 847 | is_void<_Rp>::value || __is_core_convertible<__invoke_result_t<_Fp, _ArgTypes...>, _Rp>::value; | |
| 842 | 848 | }; |
| 843 | 849 | template <class _Fp> |
| 844 | 850 | struct __callable<_Fp, false> { |
| ... | ... | @@ -846,14 +852,14 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> |
| 846 | 852 | }; |
| 847 | 853 | |
| 848 | 854 | template <class _Fp> |
| 849 | using _EnableIfLValueCallable = __enable_if_t<__callable<_Fp&>::value>; | |
| 855 | using _EnableIfLValueCallable _LIBCPP_NODEBUG = __enable_if_t<__callable<_Fp&>::value>; | |
| 850 | 856 | |
| 851 | 857 | public: |
| 852 | 858 | typedef _Rp result_type; |
| 853 | 859 | |
| 854 | 860 | // construct/copy/destroy: |
| 855 | 861 | _LIBCPP_HIDE_FROM_ABI function() _NOEXCEPT {} |
| 856 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI function(nullptr_t) _NOEXCEPT {} | |
| 862 | _LIBCPP_HIDE_FROM_ABI function(nullptr_t) _NOEXCEPT {} | |
| 857 | 863 | _LIBCPP_HIDE_FROM_ABI function(const function&); |
| 858 | 864 | _LIBCPP_HIDE_FROM_ABI function(function&&) _NOEXCEPT; |
| 859 | 865 | template <class _Fp, class = _EnableIfLValueCallable<_Fp>> |
| ... | ... | @@ -905,14 +911,14 @@ public: |
| 905 | 911 | // function invocation: |
| 906 | 912 | _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes...) const; |
| 907 | 913 | |
| 908 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 914 | # if _LIBCPP_HAS_RTTI | |
| 909 | 915 | // function target access: |
| 910 | 916 | _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT; |
| 911 | 917 | template <typename _Tp> |
| 912 | 918 | _LIBCPP_HIDE_FROM_ABI _Tp* target() _NOEXCEPT; |
| 913 | 919 | template <typename _Tp> |
| 914 | 920 | _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT; |
| 915 | # endif // _LIBCPP_HAS_NO_RTTI | |
| 921 | # endif // _LIBCPP_HAS_RTTI | |
| 916 | 922 | }; |
| 917 | 923 | |
| 918 | 924 | # if _LIBCPP_STD_VER >= 17 |
| ... | ... | @@ -989,7 +995,7 @@ _Rp function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const { |
| 989 | 995 | return __f_(std::forward<_ArgTypes>(__arg)...); |
| 990 | 996 | } |
| 991 | 997 | |
| 992 | # ifndef _LIBCPP_HAS_NO_RTTI | |
| 998 | # if _LIBCPP_HAS_RTTI | |
| 993 | 999 | |
| 994 | 1000 | template <class _Rp, class... _ArgTypes> |
| 995 | 1001 | const std::type_info& function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT { |
| ... | ... | @@ -1008,7 +1014,7 @@ const _Tp* function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT { |
| 1008 | 1014 | return __f_.template target<_Tp>(); |
| 1009 | 1015 | } |
| 1010 | 1016 | |
| 1011 | # endif // _LIBCPP_HAS_NO_RTTI | |
| 1017 | # endif // _LIBCPP_HAS_RTTI | |
| 1012 | 1018 | |
| 1013 | 1019 | template <class _Rp, class... _ArgTypes> |
| 1014 | 1020 | inline _LIBCPP_HIDE_FROM_ABI bool operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT { |
lib/libcxx/include/__functional/hash.h+13-8| ... | ... | @@ -10,16 +10,17 @@ |
| 10 | 10 | #define _LIBCPP___FUNCTIONAL_HASH_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/nullptr_t.h> | |
| 13 | 14 | #include <__functional/unary_function.h> |
| 14 | 15 | #include <__fwd/functional.h> |
| 15 | 16 | #include <__type_traits/conjunction.h> |
| 17 | #include <__type_traits/enable_if.h> | |
| 16 | 18 | #include <__type_traits/invoke.h> |
| 17 | 19 | #include <__type_traits/is_constructible.h> |
| 18 | 20 | #include <__type_traits/is_enum.h> |
| 19 | 21 | #include <__type_traits/underlying_type.h> |
| 20 | 22 | #include <__utility/pair.h> |
| 21 | 23 | #include <__utility/swap.h> |
| 22 | #include <cstddef> | |
| 23 | 24 | #include <cstdint> |
| 24 | 25 | #include <cstring> |
| 25 | 26 | |
| ... | ... | @@ -355,12 +356,12 @@ struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> : public __unary_function<unsign |
| 355 | 356 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __v) const _NOEXCEPT { return static_cast<size_t>(__v); } |
| 356 | 357 | }; |
| 357 | 358 | |
| 358 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 359 | #if _LIBCPP_HAS_CHAR8_T | |
| 359 | 360 | template <> |
| 360 | 361 | struct _LIBCPP_TEMPLATE_VIS hash<char8_t> : public __unary_function<char8_t, size_t> { |
| 361 | 362 | _LIBCPP_HIDE_FROM_ABI size_t operator()(char8_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); } |
| 362 | 363 | }; |
| 363 | #endif // !_LIBCPP_HAS_NO_CHAR8_T | |
| 364 | #endif // _LIBCPP_HAS_CHAR8_T | |
| 364 | 365 | |
| 365 | 366 | template <> |
| 366 | 367 | struct _LIBCPP_TEMPLATE_VIS hash<char16_t> : public __unary_function<char16_t, size_t> { |
| ... | ... | @@ -372,12 +373,12 @@ struct _LIBCPP_TEMPLATE_VIS hash<char32_t> : public __unary_function<char32_t, s |
| 372 | 373 | _LIBCPP_HIDE_FROM_ABI size_t operator()(char32_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); } |
| 373 | 374 | }; |
| 374 | 375 | |
| 375 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 376 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 376 | 377 | template <> |
| 377 | 378 | struct _LIBCPP_TEMPLATE_VIS hash<wchar_t> : public __unary_function<wchar_t, size_t> { |
| 378 | 379 | _LIBCPP_HIDE_FROM_ABI size_t operator()(wchar_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); } |
| 379 | 380 | }; |
| 380 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 381 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 381 | 382 | |
| 382 | 383 | template <> |
| 383 | 384 | struct _LIBCPP_TEMPLATE_VIS hash<short> : public __unary_function<short, size_t> { |
| ... | ... | @@ -406,7 +407,11 @@ struct _LIBCPP_TEMPLATE_VIS hash<long> : public __unary_function<long, size_t> { |
| 406 | 407 | |
| 407 | 408 | template <> |
| 408 | 409 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> : public __unary_function<unsigned long, size_t> { |
| 409 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __v) const _NOEXCEPT { return static_cast<size_t>(__v); } | |
| 410 | _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __v) const _NOEXCEPT { | |
| 411 | static_assert(sizeof(size_t) >= sizeof(unsigned long), | |
| 412 | "This would be a terrible hash function on a platform where size_t is smaller than unsigned long"); | |
| 413 | return static_cast<size_t>(__v); | |
| 414 | } | |
| 410 | 415 | }; |
| 411 | 416 | |
| 412 | 417 | template <> |
| ... | ... | @@ -415,7 +420,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<long long> : public __scalar_hash<long long> {} |
| 415 | 420 | template <> |
| 416 | 421 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long> : public __scalar_hash<unsigned long long> {}; |
| 417 | 422 | |
| 418 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 423 | #if _LIBCPP_HAS_INT128 | |
| 419 | 424 | |
| 420 | 425 | template <> |
| 421 | 426 | struct _LIBCPP_TEMPLATE_VIS hash<__int128_t> : public __scalar_hash<__int128_t> {}; |
| ... | ... | @@ -517,7 +522,7 @@ template <class _Key, class _Hash> |
| 517 | 522 | using __check_hash_requirements _LIBCPP_NODEBUG = |
| 518 | 523 | integral_constant<bool, |
| 519 | 524 | is_copy_constructible<_Hash>::value && is_move_constructible<_Hash>::value && |
| 520 | __invokable_r<size_t, _Hash, _Key const&>::value >; | |
| 525 | __is_invocable_r_v<size_t, _Hash, _Key const&> >; | |
| 521 | 526 | |
| 522 | 527 | template <class _Key, class _Hash = hash<_Key> > |
| 523 | 528 | using __has_enabled_hash _LIBCPP_NODEBUG = |
lib/libcxx/include/__functional/identity.h+1-1| ... | ... | @@ -26,7 +26,7 @@ struct __is_identity : false_type {}; |
| 26 | 26 | |
| 27 | 27 | struct __identity { |
| 28 | 28 | template <class _Tp> |
| 29 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT { | |
| 29 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT { | |
| 30 | 30 | return std::forward<_Tp>(__t); |
| 31 | 31 | } |
| 32 | 32 |
lib/libcxx/include/__functional/invoke.h+1| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__type_traits/invoke.h> |
| 15 | #include <__type_traits/is_void.h> | |
| 15 | 16 | #include <__utility/forward.h> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__functional/is_transparent.h+3-3| ... | ... | @@ -21,11 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | 22 | #if _LIBCPP_STD_VER >= 14 |
| 23 | 23 | |
| 24 | template <class _Tp, class, class = void> | |
| 24 | template <class _Tp, class _Key = void, class = void> | |
| 25 | 25 | inline const bool __is_transparent_v = false; |
| 26 | 26 | |
| 27 | template <class _Tp, class _Up> | |
| 28 | inline const bool __is_transparent_v<_Tp, _Up, __void_t<typename _Tp::is_transparent> > = true; | |
| 27 | template <class _Tp, class _Key> | |
| 28 | inline const bool __is_transparent_v<_Tp, _Key, __void_t<typename _Tp::is_transparent> > = true; | |
| 29 | 29 | |
| 30 | 30 | #endif |
| 31 | 31 |
lib/libcxx/include/__functional/mem_fn.h+3-5| ... | ... | @@ -12,8 +12,8 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__functional/binary_function.h> |
| 15 | #include <__functional/invoke.h> | |
| 16 | 15 | #include <__functional/weak_result_type.h> |
| 16 | #include <__type_traits/invoke.h> | |
| 17 | 17 | #include <__utility/forward.h> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -36,10 +36,8 @@ public: |
| 36 | 36 | |
| 37 | 37 | // invoke |
| 38 | 38 | template <class... _ArgTypes> |
| 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 40 | ||
| 41 | typename __invoke_return<type, _ArgTypes...>::type | |
| 42 | operator()(_ArgTypes&&... __args) const { | |
| 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<const _Tp&, _ArgTypes...> | |
| 40 | operator()(_ArgTypes&&... __args) const _NOEXCEPT_(__is_nothrow_invocable_v<const _Tp&, _ArgTypes...>) { | |
| 43 | 41 | return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...); |
| 44 | 42 | } |
| 45 | 43 | }; |
lib/libcxx/include/__functional/not_fn.h+23| ... | ... | @@ -16,6 +16,8 @@ |
| 16 | 16 | #include <__type_traits/decay.h> |
| 17 | 17 | #include <__type_traits/enable_if.h> |
| 18 | 18 | #include <__type_traits/is_constructible.h> |
| 19 | #include <__type_traits/is_member_pointer.h> | |
| 20 | #include <__type_traits/is_pointer.h> | |
| 19 | 21 | #include <__utility/forward.h> |
| 20 | 22 | |
| 21 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -48,6 +50,27 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto not_fn(_Fn&& __f) { |
| 48 | 50 | |
| 49 | 51 | #endif // _LIBCPP_STD_VER >= 17 |
| 50 | 52 | |
| 53 | #if _LIBCPP_STD_VER >= 26 | |
| 54 | ||
| 55 | template <auto _Fn> | |
| 56 | struct __nttp_not_fn_t { | |
| 57 | template <class... _Args> | |
| 58 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const | |
| 59 | noexcept(noexcept(!std::invoke(_Fn, std::forward<_Args>(__args)...))) | |
| 60 | -> decltype(!std::invoke(_Fn, std::forward<_Args>(__args)...)) { | |
| 61 | return !std::invoke(_Fn, std::forward<_Args>(__args)...); | |
| 62 | } | |
| 63 | }; | |
| 64 | ||
| 65 | template <auto _Fn> | |
| 66 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr auto not_fn() noexcept { | |
| 67 | if constexpr (using _Ty = decltype(_Fn); is_pointer_v<_Ty> || is_member_pointer_v<_Ty>) | |
| 68 | static_assert(_Fn != nullptr, "f cannot be equal to nullptr"); | |
| 69 | return __nttp_not_fn_t<_Fn>(); | |
| 70 | } | |
| 71 | ||
| 72 | #endif // _LIBCPP_STD_VER >= 26 | |
| 73 | ||
| 51 | 74 | _LIBCPP_END_NAMESPACE_STD |
| 52 | 75 | |
| 53 | 76 | #endif // _LIBCPP___FUNCTIONAL_NOT_FN_H |
lib/libcxx/include/__functional/operations.h+14-1| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | #include <__functional/binary_function.h> |
| 15 | 15 | #include <__functional/unary_function.h> |
| 16 | 16 | #include <__type_traits/desugars_to.h> |
| 17 | #include <__type_traits/is_integral.h> | |
| 17 | 18 | #include <__utility/forward.h> |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -364,6 +365,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less); |
| 364 | 365 | template <class _Tp> |
| 365 | 366 | inline const bool __desugars_to_v<__less_tag, less<_Tp>, _Tp, _Tp> = true; |
| 366 | 367 | |
| 368 | template <class _Tp> | |
| 369 | inline const bool __desugars_to_v<__totally_ordered_less_tag, less<_Tp>, _Tp, _Tp> = is_integral<_Tp>::value; | |
| 370 | ||
| 367 | 371 | #if _LIBCPP_STD_VER >= 14 |
| 368 | 372 | template <> |
| 369 | 373 | struct _LIBCPP_TEMPLATE_VIS less<void> { |
| ... | ... | @@ -376,8 +380,11 @@ struct _LIBCPP_TEMPLATE_VIS less<void> { |
| 376 | 380 | typedef void is_transparent; |
| 377 | 381 | }; |
| 378 | 382 | |
| 383 | template <class _Tp, class _Up> | |
| 384 | inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Up> = true; | |
| 385 | ||
| 379 | 386 | template <class _Tp> |
| 380 | inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Tp> = true; | |
| 387 | inline const bool __desugars_to_v<__totally_ordered_less_tag, less<>, _Tp, _Tp> = is_integral<_Tp>::value; | |
| 381 | 388 | #endif |
| 382 | 389 | |
| 383 | 390 | #if _LIBCPP_STD_VER >= 14 |
| ... | ... | @@ -445,6 +452,9 @@ struct _LIBCPP_TEMPLATE_VIS greater : __binary_function<_Tp, _Tp, bool> { |
| 445 | 452 | }; |
| 446 | 453 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater); |
| 447 | 454 | |
| 455 | template <class _Tp> | |
| 456 | inline const bool __desugars_to_v<__greater_tag, greater<_Tp>, _Tp, _Tp> = true; | |
| 457 | ||
| 448 | 458 | #if _LIBCPP_STD_VER >= 14 |
| 449 | 459 | template <> |
| 450 | 460 | struct _LIBCPP_TEMPLATE_VIS greater<void> { |
| ... | ... | @@ -456,6 +466,9 @@ struct _LIBCPP_TEMPLATE_VIS greater<void> { |
| 456 | 466 | } |
| 457 | 467 | typedef void is_transparent; |
| 458 | 468 | }; |
| 469 | ||
| 470 | template <class _Tp, class _Up> | |
| 471 | inline const bool __desugars_to_v<__greater_tag, greater<>, _Tp, _Up> = true; | |
| 459 | 472 | #endif |
| 460 | 473 | |
| 461 | 474 | // Logical operations |
lib/libcxx/include/__functional/perfect_forward.h+2-1| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/size_t.h> | |
| 14 | 15 | #include <__type_traits/enable_if.h> |
| 15 | 16 | #include <__type_traits/invoke.h> |
| 16 | 17 | #include <__type_traits/is_constructible.h> |
| ... | ... | @@ -93,7 +94,7 @@ public: |
| 93 | 94 | |
| 94 | 95 | // __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require]. |
| 95 | 96 | template <class _Op, class... _Args> |
| 96 | using __perfect_forward = __perfect_forward_impl<_Op, index_sequence_for<_Args...>, _Args...>; | |
| 97 | using __perfect_forward _LIBCPP_NODEBUG = __perfect_forward_impl<_Op, index_sequence_for<_Args...>, _Args...>; | |
| 97 | 98 | |
| 98 | 99 | #endif // _LIBCPP_STD_VER >= 17 |
| 99 | 100 |
lib/libcxx/include/__functional/ranges_operations.h+6| ... | ... | @@ -99,9 +99,15 @@ struct greater_equal { |
| 99 | 99 | template <class _Tp, class _Up> |
| 100 | 100 | inline const bool __desugars_to_v<__equal_tag, ranges::equal_to, _Tp, _Up> = true; |
| 101 | 101 | |
| 102 | template <class _Tp, class _Up> | |
| 103 | inline const bool __desugars_to_v<__totally_ordered_less_tag, ranges::less, _Tp, _Up> = true; | |
| 104 | ||
| 102 | 105 | template <class _Tp, class _Up> |
| 103 | 106 | inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true; |
| 104 | 107 | |
| 108 | template <class _Tp, class _Up> | |
| 109 | inline const bool __desugars_to_v<__greater_tag, ranges::greater, _Tp, _Up> = true; | |
| 110 | ||
| 105 | 111 | #endif // _LIBCPP_STD_VER >= 20 |
| 106 | 112 | |
| 107 | 113 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__functional/reference_wrapper.h+2-2| ... | ... | @@ -13,10 +13,10 @@ |
| 13 | 13 | #include <__compare/synth_three_way.h> |
| 14 | 14 | #include <__concepts/boolean_testable.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__functional/invoke.h> | |
| 17 | 16 | #include <__functional/weak_result_type.h> |
| 18 | 17 | #include <__memory/addressof.h> |
| 19 | 18 | #include <__type_traits/enable_if.h> |
| 19 | #include <__type_traits/invoke.h> | |
| 20 | 20 | #include <__type_traits/is_const.h> |
| 21 | 21 | #include <__type_traits/remove_cvref.h> |
| 22 | 22 | #include <__type_traits/void_t.h> |
| ... | ... | @@ -57,7 +57,7 @@ public: |
| 57 | 57 | |
| 58 | 58 | // invoke |
| 59 | 59 | template <class... _ArgTypes> |
| 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<type&, _ArgTypes...>::type | |
| 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<type&, _ArgTypes...> | |
| 61 | 61 | operator()(_ArgTypes&&... __args) const |
| 62 | 62 | #if _LIBCPP_STD_VER >= 17 |
| 63 | 63 | // Since is_nothrow_invocable requires C++17 LWG3764 is not backported |
lib/libcxx/include/__functional/unary_function.h+2-2| ... | ... | @@ -39,11 +39,11 @@ struct __unary_function_keep_layout_base { |
| 39 | 39 | _LIBCPP_DIAGNOSTIC_PUSH |
| 40 | 40 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") |
| 41 | 41 | template <class _Arg, class _Result> |
| 42 | using __unary_function = unary_function<_Arg, _Result>; | |
| 42 | using __unary_function _LIBCPP_NODEBUG = unary_function<_Arg, _Result>; | |
| 43 | 43 | _LIBCPP_DIAGNOSTIC_POP |
| 44 | 44 | #else |
| 45 | 45 | template <class _Arg, class _Result> |
| 46 | using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>; | |
| 46 | using __unary_function _LIBCPP_NODEBUG = __unary_function_keep_layout_base<_Arg, _Result>; | |
| 47 | 47 | #endif |
| 48 | 48 | |
| 49 | 49 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__functional/weak_result_type.h+1-6| ... | ... | @@ -12,9 +12,9 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__functional/binary_function.h> |
| 15 | #include <__functional/invoke.h> | |
| 16 | 15 | #include <__functional/unary_function.h> |
| 17 | 16 | #include <__type_traits/integral_constant.h> |
| 17 | #include <__type_traits/invoke.h> | |
| 18 | 18 | #include <__type_traits/is_same.h> |
| 19 | 19 | #include <__utility/declval.h> |
| 20 | 20 | |
| ... | ... | @@ -221,11 +221,6 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> { |
| 221 | 221 | #endif |
| 222 | 222 | }; |
| 223 | 223 | |
| 224 | template <class _Tp, class... _Args> | |
| 225 | struct __invoke_return { | |
| 226 | typedef decltype(std::__invoke(std::declval<_Tp>(), std::declval<_Args>()...)) type; | |
| 227 | }; | |
| 228 | ||
| 229 | 224 | _LIBCPP_END_NAMESPACE_STD |
| 230 | 225 | |
| 231 | 226 | #endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H |
lib/libcxx/include/__fwd/array.h+5-4| ... | ... | @@ -10,7 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___FWD_ARRAY_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 14 | 15 | |
| 15 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 17 | # pragma GCC system_header |
| ... | ... | @@ -35,11 +36,11 @@ template <size_t _Ip, class _Tp, size_t _Size> |
| 35 | 36 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT; |
| 36 | 37 | #endif |
| 37 | 38 | |
| 38 | template <class> | |
| 39 | struct __is_std_array : false_type {}; | |
| 39 | template <class _Tp> | |
| 40 | inline const bool __is_std_array_v = false; | |
| 40 | 41 | |
| 41 | 42 | template <class _Tp, size_t _Size> |
| 42 | struct __is_std_array<array<_Tp, _Size> > : true_type {}; | |
| 43 | inline const bool __is_std_array_v<array<_Tp, _Size> > = true; | |
| 43 | 44 | |
| 44 | 45 | _LIBCPP_END_NAMESPACE_STD |
| 45 | 46 |
lib/libcxx/include/__fwd/bit_reference.h+3| ... | ... | @@ -20,6 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> |
| 21 | 21 | class __bit_iterator; |
| 22 | 22 | |
| 23 | template <class, class = void> | |
| 24 | struct __size_difference_type_traits; | |
| 25 | ||
| 23 | 26 | _LIBCPP_END_NAMESPACE_STD |
| 24 | 27 | |
| 25 | 28 | #endif // _LIBCPP___FWD_BIT_REFERENCE_H |
lib/libcxx/include/__fwd/byte.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_BYTE_H | |
| 10 | #define _LIBCPP___FWD_BYTE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | #if _LIBCPP_STD_VER >= 17 | |
| 19 | namespace std { // purposefully not versioned | |
| 20 | ||
| 21 | enum class byte : unsigned char; | |
| 22 | ||
| 23 | } // namespace std | |
| 24 | #endif // _LIBCPP_STD_VER >= 17 | |
| 25 | ||
| 26 | #endif // _LIBCPP___FWD_BYTE_H |
lib/libcxx/include/__fwd/complex.h+1-1| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___FWD_COMPLEX_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 16 | # pragma GCC system_header |
lib/libcxx/include/__fwd/format.h+1-1| ... | ... | @@ -31,7 +31,7 @@ class _LIBCPP_TEMPLATE_VIS basic_format_context; |
| 31 | 31 | template <class _Tp, class _CharT = char> |
| 32 | 32 | struct _LIBCPP_TEMPLATE_VIS formatter; |
| 33 | 33 | |
| 34 | #endif //_LIBCPP_STD_VER >= 20 | |
| 34 | #endif // _LIBCPP_STD_VER >= 20 | |
| 35 | 35 | |
| 36 | 36 | _LIBCPP_END_NAMESPACE_STD |
| 37 | 37 |
lib/libcxx/include/__fwd/fstream.h+1-1| ... | ... | @@ -32,7 +32,7 @@ using ifstream = basic_ifstream<char>; |
| 32 | 32 | using ofstream = basic_ofstream<char>; |
| 33 | 33 | using fstream = basic_fstream<char>; |
| 34 | 34 | |
| 35 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 35 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 36 | 36 | using wfilebuf = basic_filebuf<wchar_t>; |
| 37 | 37 | using wifstream = basic_ifstream<wchar_t>; |
| 38 | 38 | using wofstream = basic_ofstream<wchar_t>; |
lib/libcxx/include/__fwd/get.h created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | //===---------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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 <__config> | |
| 13 | #include <__fwd/array.h> | |
| 14 | #include <__fwd/complex.h> | |
| 15 | #include <__fwd/pair.h> | |
| 16 | #include <__fwd/subrange.h> | |
| 17 | #include <__fwd/tuple.h> | |
| 18 | #include <__fwd/variant.h> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | #endif // _LIBCPP___FWD_GET_H |
lib/libcxx/include/__fwd/ios.h+1-1| ... | ... | @@ -24,7 +24,7 @@ template <class _CharT, class _Traits = char_traits<_CharT> > |
| 24 | 24 | class _LIBCPP_TEMPLATE_VIS basic_ios; |
| 25 | 25 | |
| 26 | 26 | using ios = basic_ios<char>; |
| 27 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 27 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 28 | 28 | using wios = basic_ios<wchar_t>; |
| 29 | 29 | #endif |
| 30 | 30 |
lib/libcxx/include/__fwd/istream.h+1-1| ... | ... | @@ -27,7 +27,7 @@ class _LIBCPP_TEMPLATE_VIS basic_iostream; |
| 27 | 27 | using istream = basic_istream<char>; |
| 28 | 28 | using iostream = basic_iostream<char>; |
| 29 | 29 | |
| 30 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 30 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 31 | 31 | using wistream = basic_istream<wchar_t>; |
| 32 | 32 | using wiostream = basic_iostream<wchar_t>; |
| 33 | 33 | #endif |
lib/libcxx/include/__fwd/memory.h+3| ... | ... | @@ -20,6 +20,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | template <class _Tp> |
| 21 | 21 | class _LIBCPP_TEMPLATE_VIS allocator; |
| 22 | 22 | |
| 23 | template <class _Tp> | |
| 24 | class _LIBCPP_TEMPLATE_VIS shared_ptr; | |
| 25 | ||
| 23 | 26 | _LIBCPP_END_NAMESPACE_STD |
| 24 | 27 | |
| 25 | 28 | #endif // _LIBCPP___FWD_MEMORY_H |
lib/libcxx/include/__fwd/memory_resource.h+4| ... | ... | @@ -15,6 +15,8 @@ |
| 15 | 15 | # pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | #if _LIBCPP_STD_VER >= 17 | |
| 19 | ||
| 18 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 21 | |
| 20 | 22 | namespace pmr { |
| ... | ... | @@ -24,4 +26,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator; |
| 24 | 26 | |
| 25 | 27 | _LIBCPP_END_NAMESPACE_STD |
| 26 | 28 | |
| 29 | #endif // _LIBCPP_STD_VER >= 17 | |
| 30 | ||
| 27 | 31 | #endif // _LIBCPP___FWD_MEMORY_RESOURCE_H |
lib/libcxx/include/__fwd/ostream.h+1-1| ... | ... | @@ -23,7 +23,7 @@ class _LIBCPP_TEMPLATE_VIS basic_ostream; |
| 23 | 23 | |
| 24 | 24 | using ostream = basic_ostream<char>; |
| 25 | 25 | |
| 26 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 26 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 27 | 27 | using wostream = basic_ostream<wchar_t>; |
| 28 | 28 | #endif |
| 29 | 29 |
lib/libcxx/include/__fwd/pair.h+1-1| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___FWD_PAIR_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__fwd/tuple.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
lib/libcxx/include/__fwd/span.h+1-1| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | #define _LIBCPP___FWD_SPAN_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <cstddef> | |
| 14 | #include <__cstddef/size_t.h> | |
| 15 | 15 | #include <limits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__fwd/sstream.h+1-1| ... | ... | @@ -34,7 +34,7 @@ using istringstream = basic_istringstream<char>; |
| 34 | 34 | using ostringstream = basic_ostringstream<char>; |
| 35 | 35 | using stringstream = basic_stringstream<char>; |
| 36 | 36 | |
| 37 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 37 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 38 | 38 | using wstringbuf = basic_stringbuf<wchar_t>; |
| 39 | 39 | using wistringstream = basic_istringstream<wchar_t>; |
| 40 | 40 | using wostringstream = basic_ostringstream<wchar_t>; |
lib/libcxx/include/__fwd/streambuf.h+1-1| ... | ... | @@ -23,7 +23,7 @@ class _LIBCPP_TEMPLATE_VIS basic_streambuf; |
| 23 | 23 | |
| 24 | 24 | using streambuf = basic_streambuf<char>; |
| 25 | 25 | |
| 26 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 26 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 27 | 27 | using wstreambuf = basic_streambuf<wchar_t>; |
| 28 | 28 | #endif |
| 29 | 29 |
lib/libcxx/include/__fwd/string.h+10-10| ... | ... | @@ -24,7 +24,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits; |
| 24 | 24 | template <> |
| 25 | 25 | struct char_traits<char>; |
| 26 | 26 | |
| 27 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 27 | #if _LIBCPP_HAS_CHAR8_T | |
| 28 | 28 | template <> |
| 29 | 29 | struct char_traits<char8_t>; |
| 30 | 30 | #endif |
| ... | ... | @@ -34,7 +34,7 @@ struct char_traits<char16_t>; |
| 34 | 34 | template <> |
| 35 | 35 | struct char_traits<char32_t>; |
| 36 | 36 | |
| 37 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 37 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 38 | 38 | template <> |
| 39 | 39 | struct char_traits<wchar_t>; |
| 40 | 40 | #endif |
| ... | ... | @@ -44,11 +44,11 @@ class _LIBCPP_TEMPLATE_VIS basic_string; |
| 44 | 44 | |
| 45 | 45 | using string = basic_string<char>; |
| 46 | 46 | |
| 47 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 47 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 48 | 48 | using wstring = basic_string<wchar_t>; |
| 49 | 49 | #endif |
| 50 | 50 | |
| 51 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 51 | #if _LIBCPP_HAS_CHAR8_T | |
| 52 | 52 | using u8string = basic_string<char8_t>; |
| 53 | 53 | #endif |
| 54 | 54 | |
| ... | ... | @@ -63,11 +63,11 @@ using basic_string _LIBCPP_AVAILABILITY_PMR = std::basic_string<_CharT, _Traits, |
| 63 | 63 | |
| 64 | 64 | using string _LIBCPP_AVAILABILITY_PMR = basic_string<char>; |
| 65 | 65 | |
| 66 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 66 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 67 | 67 | using wstring _LIBCPP_AVAILABILITY_PMR = basic_string<wchar_t>; |
| 68 | 68 | # endif |
| 69 | 69 | |
| 70 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 70 | # if _LIBCPP_HAS_CHAR8_T | |
| 71 | 71 | using u8string _LIBCPP_AVAILABILITY_PMR = basic_string<char8_t>; |
| 72 | 72 | # endif |
| 73 | 73 | |
| ... | ... | @@ -80,20 +80,20 @@ using u32string _LIBCPP_AVAILABILITY_PMR = basic_string<char32_t>; |
| 80 | 80 | // clang-format off |
| 81 | 81 | template <class _CharT, class _Traits, class _Allocator> |
| 82 | 82 | class _LIBCPP_PREFERRED_NAME(string) |
| 83 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 83 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 84 | 84 | _LIBCPP_PREFERRED_NAME(wstring) |
| 85 | 85 | #endif |
| 86 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 86 | #if _LIBCPP_HAS_CHAR8_T | |
| 87 | 87 | _LIBCPP_PREFERRED_NAME(u8string) |
| 88 | 88 | #endif |
| 89 | 89 | _LIBCPP_PREFERRED_NAME(u16string) |
| 90 | 90 | _LIBCPP_PREFERRED_NAME(u32string) |
| 91 | 91 | #if _LIBCPP_STD_VER >= 17 |
| 92 | 92 | _LIBCPP_PREFERRED_NAME(pmr::string) |
| 93 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 93 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 94 | 94 | _LIBCPP_PREFERRED_NAME(pmr::wstring) |
| 95 | 95 | # endif |
| 96 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 96 | # if _LIBCPP_HAS_CHAR8_T | |
| 97 | 97 | _LIBCPP_PREFERRED_NAME(pmr::u8string) |
| 98 | 98 | # endif |
| 99 | 99 | _LIBCPP_PREFERRED_NAME(pmr::u16string) |
lib/libcxx/include/__fwd/string_view.h+4-4| ... | ... | @@ -23,22 +23,22 @@ template <class _CharT, class _Traits = char_traits<_CharT> > |
| 23 | 23 | class _LIBCPP_TEMPLATE_VIS basic_string_view; |
| 24 | 24 | |
| 25 | 25 | typedef basic_string_view<char> string_view; |
| 26 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 26 | #if _LIBCPP_HAS_CHAR8_T | |
| 27 | 27 | typedef basic_string_view<char8_t> u8string_view; |
| 28 | 28 | #endif |
| 29 | 29 | typedef basic_string_view<char16_t> u16string_view; |
| 30 | 30 | typedef basic_string_view<char32_t> u32string_view; |
| 31 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 31 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 32 | 32 | typedef basic_string_view<wchar_t> wstring_view; |
| 33 | 33 | #endif |
| 34 | 34 | |
| 35 | 35 | // clang-format off |
| 36 | 36 | template <class _CharT, class _Traits> |
| 37 | 37 | class _LIBCPP_PREFERRED_NAME(string_view) |
| 38 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 38 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 39 | 39 | _LIBCPP_PREFERRED_NAME(wstring_view) |
| 40 | 40 | #endif |
| 41 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 41 | #if _LIBCPP_HAS_CHAR8_T | |
| 42 | 42 | _LIBCPP_PREFERRED_NAME(u8string_view) |
| 43 | 43 | #endif |
| 44 | 44 | _LIBCPP_PREFERRED_NAME(u16string_view) |
lib/libcxx/include/__fwd/subrange.h+1-1| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__concepts/copyable.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/size_t.h> | |
| 14 | 15 | #include <__iterator/concepts.h> |
| 15 | #include <cstddef> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | # pragma GCC system_header |
lib/libcxx/include/__fwd/tuple.h+1-1| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___FWD_TUPLE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 16 | # pragma GCC system_header |
lib/libcxx/include/__fwd/variant.h created+77| ... | ... | @@ -0,0 +1,77 @@ |
| 1 | //===---------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_VARIANT_H | |
| 10 | #define _LIBCPP___FWD_VARIANT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER >= 17 | |
| 22 | ||
| 23 | template <class... _Types> | |
| 24 | class _LIBCPP_TEMPLATE_VIS variant; | |
| 25 | ||
| 26 | template <class _Tp> | |
| 27 | struct _LIBCPP_TEMPLATE_VIS variant_size; | |
| 28 | ||
| 29 | template <class _Tp> | |
| 30 | inline constexpr size_t variant_size_v = variant_size<_Tp>::value; | |
| 31 | ||
| 32 | template <size_t _Ip, class _Tp> | |
| 33 | struct _LIBCPP_TEMPLATE_VIS variant_alternative; | |
| 34 | ||
| 35 | template <size_t _Ip, class _Tp> | |
| 36 | using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type; | |
| 37 | ||
| 38 | inline constexpr size_t variant_npos = static_cast<size_t>(-1); | |
| 39 | ||
| 40 | template <size_t _Ip, class... _Types> | |
| 41 | _LIBCPP_HIDE_FROM_ABI | |
| 42 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>& | |
| 43 | get(variant<_Types...>&); | |
| 44 | ||
| 45 | template <size_t _Ip, class... _Types> | |
| 46 | _LIBCPP_HIDE_FROM_ABI | |
| 47 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&& | |
| 48 | get(variant<_Types...>&&); | |
| 49 | ||
| 50 | template <size_t _Ip, class... _Types> | |
| 51 | _LIBCPP_HIDE_FROM_ABI | |
| 52 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>& | |
| 53 | get(const variant<_Types...>&); | |
| 54 | ||
| 55 | template <size_t _Ip, class... _Types> | |
| 56 | _LIBCPP_HIDE_FROM_ABI | |
| 57 | _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& | |
| 58 | get(const variant<_Types...>&&); | |
| 59 | ||
| 60 | template <class _Tp, class... _Types> | |
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp& get(variant<_Types...>&); | |
| 62 | ||
| 63 | template <class _Tp, class... _Types> | |
| 64 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp&& get(variant<_Types...>&&); | |
| 65 | ||
| 66 | template <class _Tp, class... _Types> | |
| 67 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp& get(const variant<_Types...>&); | |
| 68 | ||
| 69 | template <class _Tp, class... _Types> | |
| 70 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&& | |
| 71 | get(const variant<_Types...>&&); | |
| 72 | ||
| 73 | #endif // _LIBCPP_STD_VER >= 17 | |
| 74 | ||
| 75 | _LIBCPP_END_NAMESPACE_STD | |
| 76 | ||
| 77 | #endif // _LIBCPP___FWD_VARIANT_H |
lib/libcxx/include/__fwd/vector.h+3| ... | ... | @@ -21,6 +21,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | template <class _Tp, class _Alloc = allocator<_Tp> > |
| 22 | 22 | class _LIBCPP_TEMPLATE_VIS vector; |
| 23 | 23 | |
| 24 | template <class _Allocator> | |
| 25 | class vector<bool, _Allocator>; | |
| 26 | ||
| 24 | 27 | _LIBCPP_END_NAMESPACE_STD |
| 25 | 28 | |
| 26 | 29 | #endif // _LIBCPP___FWD_VECTOR_H |
lib/libcxx/include/__hash_table+130-103| ... | ... | @@ -15,9 +15,11 @@ |
| 15 | 15 | #include <__assert> |
| 16 | 16 | #include <__bit/countl.h> |
| 17 | 17 | #include <__config> |
| 18 | #include <__cstddef/ptrdiff_t.h> | |
| 19 | #include <__cstddef/size_t.h> | |
| 18 | 20 | #include <__functional/hash.h> |
| 19 | #include <__functional/invoke.h> | |
| 20 | 21 | #include <__iterator/iterator_traits.h> |
| 22 | #include <__math/rounding_functions.h> | |
| 21 | 23 | #include <__memory/addressof.h> |
| 22 | 24 | #include <__memory/allocator_traits.h> |
| 23 | 25 | #include <__memory/compressed_pair.h> |
| ... | ... | @@ -25,14 +27,16 @@ |
| 25 | 27 | #include <__memory/pointer_traits.h> |
| 26 | 28 | #include <__memory/swap_allocator.h> |
| 27 | 29 | #include <__memory/unique_ptr.h> |
| 30 | #include <__new/launder.h> | |
| 28 | 31 | #include <__type_traits/can_extract_key.h> |
| 29 | #include <__type_traits/conditional.h> | |
| 32 | #include <__type_traits/enable_if.h> | |
| 33 | #include <__type_traits/invoke.h> | |
| 30 | 34 | #include <__type_traits/is_const.h> |
| 31 | 35 | #include <__type_traits/is_constructible.h> |
| 32 | 36 | #include <__type_traits/is_nothrow_assignable.h> |
| 33 | 37 | #include <__type_traits/is_nothrow_constructible.h> |
| 34 | #include <__type_traits/is_pointer.h> | |
| 35 | 38 | #include <__type_traits/is_reference.h> |
| 39 | #include <__type_traits/is_same.h> | |
| 36 | 40 | #include <__type_traits/is_swappable.h> |
| 37 | 41 | #include <__type_traits/remove_const.h> |
| 38 | 42 | #include <__type_traits/remove_cvref.h> |
| ... | ... | @@ -40,10 +44,7 @@ |
| 40 | 44 | #include <__utility/move.h> |
| 41 | 45 | #include <__utility/pair.h> |
| 42 | 46 | #include <__utility/swap.h> |
| 43 | #include <cmath> | |
| 44 | #include <cstring> | |
| 45 | #include <initializer_list> | |
| 46 | #include <new> // __launder | |
| 47 | #include <limits> | |
| 47 | 48 | |
| 48 | 49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 49 | 50 | # pragma GCC system_header |
| ... | ... | @@ -77,11 +78,18 @@ struct __hash_node_base { |
| 77 | 78 | typedef __hash_node_base __first_node; |
| 78 | 79 | typedef __rebind_pointer_t<_NodePtr, __first_node> __node_base_pointer; |
| 79 | 80 | typedef _NodePtr __node_pointer; |
| 80 | ||
| 81 | #if defined(_LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB) | |
| 82 | 81 | typedef __node_base_pointer __next_pointer; |
| 83 | #else | |
| 84 | typedef __conditional_t<is_pointer<__node_pointer>::value, __node_base_pointer, __node_pointer> __next_pointer; | |
| 82 | ||
| 83 | // TODO(LLVM 22): Remove this check | |
| 84 | #ifndef _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB | |
| 85 | static_assert(sizeof(__node_base_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) == | |
| 86 | _LIBCPP_ALIGNOF(__node_pointer), | |
| 87 | "It looks like you are using std::__hash_table (an implementation detail for the unordered containers) " | |
| 88 | "with a fancy pointer type that thas a different representation depending on whether it points to a " | |
| 89 | "__hash_table base pointer or a __hash_table node pointer (both of which are implementation details of " | |
| 90 | "the standard library). This means that your ABI is being broken between LLVM 19 and LLVM 20. If you " | |
| 91 | "don't care about your ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to " | |
| 92 | "silence this diagnostic."); | |
| 85 | 93 | #endif |
| 86 | 94 | |
| 87 | 95 | __next_pointer __next_; |
| ... | ... | @@ -103,8 +111,8 @@ struct __hash_node_base { |
| 103 | 111 | template <class _Tp, class _VoidPtr> |
| 104 | 112 | struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > > { |
| 105 | 113 | typedef _Tp __node_value_type; |
| 106 | using _Base = __hash_node_base<__rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > >; | |
| 107 | using __next_pointer = typename _Base::__next_pointer; | |
| 114 | using _Base _LIBCPP_NODEBUG = __hash_node_base<__rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > >; | |
| 115 | using __next_pointer _LIBCPP_NODEBUG = typename _Base::__next_pointer; | |
| 108 | 116 | |
| 109 | 117 | size_t __hash_; |
| 110 | 118 | |
| ... | ... | @@ -554,29 +562,29 @@ class __bucket_list_deallocator { |
| 554 | 562 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 555 | 563 | typedef typename __alloc_traits::size_type size_type; |
| 556 | 564 | |
| 557 | __compressed_pair<size_type, allocator_type> __data_; | |
| 565 | _LIBCPP_COMPRESSED_PAIR(size_type, __size_, allocator_type, __alloc_); | |
| 558 | 566 | |
| 559 | 567 | public: |
| 560 | 568 | typedef typename __alloc_traits::pointer pointer; |
| 561 | 569 | |
| 562 | 570 | _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| 563 | : __data_(0, __default_init_tag()) {} | |
| 571 | : __size_(0) {} | |
| 564 | 572 | |
| 565 | 573 | _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(const allocator_type& __a, size_type __size) |
| 566 | 574 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) |
| 567 | : __data_(__size, __a) {} | |
| 575 | : __size_(__size), __alloc_(__a) {} | |
| 568 | 576 | |
| 569 | 577 | _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(__bucket_list_deallocator&& __x) |
| 570 | 578 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) |
| 571 | : __data_(std::move(__x.__data_)) { | |
| 579 | : __size_(std::move(__x.__size_)), __alloc_(std::move(__x.__alloc_)) { | |
| 572 | 580 | __x.size() = 0; |
| 573 | 581 | } |
| 574 | 582 | |
| 575 | _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __data_.first(); } | |
| 576 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __data_.first(); } | |
| 583 | _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; } | |
| 584 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; } | |
| 577 | 585 | |
| 578 | _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __data_.second(); } | |
| 579 | _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __data_.second(); } | |
| 586 | _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __alloc_; } | |
| 587 | _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __alloc_; } | |
| 580 | 588 | |
| 581 | 589 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { __alloc_traits::deallocate(__alloc(), __p, size()); } |
| 582 | 590 | }; |
| ... | ... | @@ -642,9 +650,9 @@ struct __enforce_unordered_container_requirements { |
| 642 | 650 | |
| 643 | 651 | template <class _Key, class _Hash, class _Equal> |
| 644 | 652 | #ifndef _LIBCPP_CXX03_LANG |
| 645 | _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value, | |
| 653 | _LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Equal const&, _Key const&, _Key const&>, | |
| 646 | 654 | "the specified comparator type does not provide a viable const call operator") |
| 647 | _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value, | |
| 655 | _LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Hash const&, _Key const&>, | |
| 648 | 656 | "the specified hash functor does not provide a viable const call operator") |
| 649 | 657 | #endif |
| 650 | 658 | typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type |
| ... | ... | @@ -716,27 +724,27 @@ private: |
| 716 | 724 | |
| 717 | 725 | // --- Member data begin --- |
| 718 | 726 | __bucket_list __bucket_list_; |
| 719 | __compressed_pair<__first_node, __node_allocator> __p1_; | |
| 720 | __compressed_pair<size_type, hasher> __p2_; | |
| 721 | __compressed_pair<float, key_equal> __p3_; | |
| 727 | _LIBCPP_COMPRESSED_PAIR(__first_node, __first_node_, __node_allocator, __node_alloc_); | |
| 728 | _LIBCPP_COMPRESSED_PAIR(size_type, __size_, hasher, __hasher_); | |
| 729 | _LIBCPP_COMPRESSED_PAIR(float, __max_load_factor_, key_equal, __key_eq_); | |
| 722 | 730 | // --- Member data end --- |
| 723 | 731 | |
| 724 | _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __p2_.first(); } | |
| 732 | _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; } | |
| 725 | 733 | |
| 726 | 734 | public: |
| 727 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __p2_.first(); } | |
| 735 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; } | |
| 728 | 736 | |
| 729 | _LIBCPP_HIDE_FROM_ABI hasher& hash_function() _NOEXCEPT { return __p2_.second(); } | |
| 730 | _LIBCPP_HIDE_FROM_ABI const hasher& hash_function() const _NOEXCEPT { return __p2_.second(); } | |
| 737 | _LIBCPP_HIDE_FROM_ABI hasher& hash_function() _NOEXCEPT { return __hasher_; } | |
| 738 | _LIBCPP_HIDE_FROM_ABI const hasher& hash_function() const _NOEXCEPT { return __hasher_; } | |
| 731 | 739 | |
| 732 | _LIBCPP_HIDE_FROM_ABI float& max_load_factor() _NOEXCEPT { return __p3_.first(); } | |
| 733 | _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __p3_.first(); } | |
| 740 | _LIBCPP_HIDE_FROM_ABI float& max_load_factor() _NOEXCEPT { return __max_load_factor_; } | |
| 741 | _LIBCPP_HIDE_FROM_ABI float max_load_factor() const _NOEXCEPT { return __max_load_factor_; } | |
| 734 | 742 | |
| 735 | _LIBCPP_HIDE_FROM_ABI key_equal& key_eq() _NOEXCEPT { return __p3_.second(); } | |
| 736 | _LIBCPP_HIDE_FROM_ABI const key_equal& key_eq() const _NOEXCEPT { return __p3_.second(); } | |
| 743 | _LIBCPP_HIDE_FROM_ABI key_equal& key_eq() _NOEXCEPT { return __key_eq_; } | |
| 744 | _LIBCPP_HIDE_FROM_ABI const key_equal& key_eq() const _NOEXCEPT { return __key_eq_; } | |
| 737 | 745 | |
| 738 | _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __p1_.second(); } | |
| 739 | _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __p1_.second(); } | |
| 746 | _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; } | |
| 747 | _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; } | |
| 740 | 748 | |
| 741 | 749 | public: |
| 742 | 750 | typedef __hash_iterator<__node_pointer> iterator; |
| ... | ... | @@ -875,10 +883,10 @@ public: |
| 875 | 883 | _LIBCPP_HIDE_FROM_ABI void __rehash_unique(size_type __n) { __rehash<true>(__n); } |
| 876 | 884 | _LIBCPP_HIDE_FROM_ABI void __rehash_multi(size_type __n) { __rehash<false>(__n); } |
| 877 | 885 | _LIBCPP_HIDE_FROM_ABI void __reserve_unique(size_type __n) { |
| 878 | __rehash_unique(static_cast<size_type>(std::ceil(__n / max_load_factor()))); | |
| 886 | __rehash_unique(static_cast<size_type>(__math::ceil(__n / max_load_factor()))); | |
| 879 | 887 | } |
| 880 | 888 | _LIBCPP_HIDE_FROM_ABI void __reserve_multi(size_type __n) { |
| 881 | __rehash_multi(static_cast<size_type>(std::ceil(__n / max_load_factor()))); | |
| 889 | __rehash_multi(static_cast<size_type>(__math::ceil(__n / max_load_factor()))); | |
| 882 | 890 | } |
| 883 | 891 | |
| 884 | 892 | _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __bucket_list_.get_deleter().size(); } |
| ... | ... | @@ -1022,26 +1030,34 @@ inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() _NOEXCEPT_( |
| 1022 | 1030 | is_nothrow_default_constructible<__bucket_list>::value&& is_nothrow_default_constructible<__first_node>::value&& |
| 1023 | 1031 | is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_default_constructible<hasher>::value&& |
| 1024 | 1032 | is_nothrow_default_constructible<key_equal>::value) |
| 1025 | : __p2_(0, __default_init_tag()), __p3_(1.0f, __default_init_tag()) {} | |
| 1033 | : __size_(0), __max_load_factor_(1.0f) {} | |
| 1026 | 1034 | |
| 1027 | 1035 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1028 | 1036 | inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, const key_equal& __eql) |
| 1029 | : __bucket_list_(nullptr, __bucket_list_deleter()), __p1_(), __p2_(0, __hf), __p3_(1.0f, __eql) {} | |
| 1037 | : __bucket_list_(nullptr, __bucket_list_deleter()), | |
| 1038 | __first_node_(), | |
| 1039 | __node_alloc_(), | |
| 1040 | __size_(0), | |
| 1041 | __hasher_(__hf), | |
| 1042 | __max_load_factor_(1.0f), | |
| 1043 | __key_eq_(__eql) {} | |
| 1030 | 1044 | |
| 1031 | 1045 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1032 | 1046 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table( |
| 1033 | 1047 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 1034 | 1048 | : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), |
| 1035 | __p1_(__default_init_tag(), __node_allocator(__a)), | |
| 1036 | __p2_(0, __hf), | |
| 1037 | __p3_(1.0f, __eql) {} | |
| 1049 | __node_alloc_(__node_allocator(__a)), | |
| 1050 | __size_(0), | |
| 1051 | __hasher_(__hf), | |
| 1052 | __max_load_factor_(1.0f), | |
| 1053 | __key_eq_(__eql) {} | |
| 1038 | 1054 | |
| 1039 | 1055 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1040 | 1056 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a) |
| 1041 | 1057 | : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), |
| 1042 | __p1_(__default_init_tag(), __node_allocator(__a)), | |
| 1043 | __p2_(0, __default_init_tag()), | |
| 1044 | __p3_(1.0f, __default_init_tag()) {} | |
| 1058 | __node_alloc_(__node_allocator(__a)), | |
| 1059 | __size_(0), | |
| 1060 | __max_load_factor_(1.0f) {} | |
| 1045 | 1061 | |
| 1046 | 1062 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1047 | 1063 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u) |
| ... | ... | @@ -1049,17 +1065,20 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u) |
| 1049 | 1065 | __bucket_list_deleter(allocator_traits<__pointer_allocator>::select_on_container_copy_construction( |
| 1050 | 1066 | __u.__bucket_list_.get_deleter().__alloc()), |
| 1051 | 1067 | 0)), |
| 1052 | __p1_(__default_init_tag(), | |
| 1053 | allocator_traits<__node_allocator>::select_on_container_copy_construction(__u.__node_alloc())), | |
| 1054 | __p2_(0, __u.hash_function()), | |
| 1055 | __p3_(__u.__p3_) {} | |
| 1068 | __node_alloc_(allocator_traits<__node_allocator>::select_on_container_copy_construction(__u.__node_alloc())), | |
| 1069 | __size_(0), | |
| 1070 | __hasher_(__u.hash_function()), | |
| 1071 | __max_load_factor_(__u.__max_load_factor_), | |
| 1072 | __key_eq_(__u.__key_eq_) {} | |
| 1056 | 1073 | |
| 1057 | 1074 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1058 | 1075 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, const allocator_type& __a) |
| 1059 | 1076 | : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), |
| 1060 | __p1_(__default_init_tag(), __node_allocator(__a)), | |
| 1061 | __p2_(0, __u.hash_function()), | |
| 1062 | __p3_(__u.__p3_) {} | |
| 1077 | __node_alloc_(__node_allocator(__a)), | |
| 1078 | __size_(0), | |
| 1079 | __hasher_(__u.hash_function()), | |
| 1080 | __max_load_factor_(__u.__max_load_factor_), | |
| 1081 | __key_eq_(__u.__key_eq_) {} | |
| 1063 | 1082 | |
| 1064 | 1083 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1065 | 1084 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEXCEPT_( |
| ... | ... | @@ -1067,12 +1086,15 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEX |
| 1067 | 1086 | is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<hasher>::value&& |
| 1068 | 1087 | is_nothrow_move_constructible<key_equal>::value) |
| 1069 | 1088 | : __bucket_list_(std::move(__u.__bucket_list_)), |
| 1070 | __p1_(std::move(__u.__p1_)), | |
| 1071 | __p2_(std::move(__u.__p2_)), | |
| 1072 | __p3_(std::move(__u.__p3_)) { | |
| 1089 | __first_node_(std::move(__u.__first_node_)), | |
| 1090 | __node_alloc_(std::move(__u.__node_alloc_)), | |
| 1091 | __size_(std::move(__u.__size_)), | |
| 1092 | __hasher_(std::move(__u.__hasher_)), | |
| 1093 | __max_load_factor_(__u.__max_load_factor_), | |
| 1094 | __key_eq_(std::move(__u.__key_eq_)) { | |
| 1073 | 1095 | if (size() > 0) { |
| 1074 | __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr(); | |
| 1075 | __u.__p1_.first().__next_ = nullptr; | |
| 1096 | __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr(); | |
| 1097 | __u.__first_node_.__next_ = nullptr; | |
| 1076 | 1098 | __u.size() = 0; |
| 1077 | 1099 | } |
| 1078 | 1100 | } |
| ... | ... | @@ -1080,17 +1102,19 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEX |
| 1080 | 1102 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1081 | 1103 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, const allocator_type& __a) |
| 1082 | 1104 | : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), |
| 1083 | __p1_(__default_init_tag(), __node_allocator(__a)), | |
| 1084 | __p2_(0, std::move(__u.hash_function())), | |
| 1085 | __p3_(std::move(__u.__p3_)) { | |
| 1105 | __node_alloc_(__node_allocator(__a)), | |
| 1106 | __size_(0), | |
| 1107 | __hasher_(std::move(__u.__hasher_)), | |
| 1108 | __max_load_factor_(__u.__max_load_factor_), | |
| 1109 | __key_eq_(std::move(__u.__key_eq_)) { | |
| 1086 | 1110 | if (__a == allocator_type(__u.__node_alloc())) { |
| 1087 | 1111 | __bucket_list_.reset(__u.__bucket_list_.release()); |
| 1088 | 1112 | __bucket_list_.get_deleter().size() = __u.__bucket_list_.get_deleter().size(); |
| 1089 | 1113 | __u.__bucket_list_.get_deleter().size() = 0; |
| 1090 | 1114 | if (__u.size() > 0) { |
| 1091 | __p1_.first().__next_ = __u.__p1_.first().__next_; | |
| 1092 | __u.__p1_.first().__next_ = nullptr; | |
| 1093 | __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr(); | |
| 1115 | __first_node_.__next_ = __u.__first_node_.__next_; | |
| 1116 | __u.__first_node_.__next_ = nullptr; | |
| 1117 | __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr(); | |
| 1094 | 1118 | size() = __u.size(); |
| 1095 | 1119 | __u.size() = 0; |
| 1096 | 1120 | } |
| ... | ... | @@ -1104,7 +1128,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() { |
| 1104 | 1128 | static_assert(is_copy_constructible<hasher>::value, "Hasher must be copy-constructible."); |
| 1105 | 1129 | #endif |
| 1106 | 1130 | |
| 1107 | __deallocate_node(__p1_.first().__next_); | |
| 1131 | __deallocate_node(__first_node_.__next_); | |
| 1108 | 1132 | } |
| 1109 | 1133 | |
| 1110 | 1134 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -1150,8 +1174,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT { |
| 1150 | 1174 | for (size_type __i = 0; __i < __bc; ++__i) |
| 1151 | 1175 | __bucket_list_[__i] = nullptr; |
| 1152 | 1176 | size() = 0; |
| 1153 | __next_pointer __cache = __p1_.first().__next_; | |
| 1154 | __p1_.first().__next_ = nullptr; | |
| 1177 | __next_pointer __cache = __first_node_.__next_; | |
| 1178 | __first_node_.__next_ = nullptr; | |
| 1155 | 1179 | return __cache; |
| 1156 | 1180 | } |
| 1157 | 1181 | |
| ... | ... | @@ -1168,10 +1192,10 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, |
| 1168 | 1192 | hash_function() = std::move(__u.hash_function()); |
| 1169 | 1193 | max_load_factor() = __u.max_load_factor(); |
| 1170 | 1194 | key_eq() = std::move(__u.key_eq()); |
| 1171 | __p1_.first().__next_ = __u.__p1_.first().__next_; | |
| 1195 | __first_node_.__next_ = __u.__first_node_.__next_; | |
| 1172 | 1196 | if (size() > 0) { |
| 1173 | __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr(); | |
| 1174 | __u.__p1_.first().__next_ = nullptr; | |
| 1197 | __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr(); | |
| 1198 | __u.__first_node_.__next_ = nullptr; | |
| 1175 | 1199 | __u.size() = 0; |
| 1176 | 1200 | } |
| 1177 | 1201 | } |
| ... | ... | @@ -1186,9 +1210,9 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, |
| 1186 | 1210 | max_load_factor() = __u.max_load_factor(); |
| 1187 | 1211 | if (bucket_count() != 0) { |
| 1188 | 1212 | __next_pointer __cache = __detach(); |
| 1189 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1213 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 1190 | 1214 | try { |
| 1191 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1215 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1192 | 1216 | const_iterator __i = __u.begin(); |
| 1193 | 1217 | while (__cache != nullptr && __u.size() != 0) { |
| 1194 | 1218 | __cache->__upcast()->__get_value() = std::move(__u.remove(__i++)->__get_value()); |
| ... | ... | @@ -1196,12 +1220,12 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, |
| 1196 | 1220 | __node_insert_multi(__cache->__upcast()); |
| 1197 | 1221 | __cache = __next; |
| 1198 | 1222 | } |
| 1199 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1223 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 1200 | 1224 | } catch (...) { |
| 1201 | 1225 | __deallocate_node(__cache); |
| 1202 | 1226 | throw; |
| 1203 | 1227 | } |
| 1204 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1228 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1205 | 1229 | __deallocate_node(__cache); |
| 1206 | 1230 | } |
| 1207 | 1231 | const_iterator __i = __u.begin(); |
| ... | ... | @@ -1232,21 +1256,21 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __ |
| 1232 | 1256 | |
| 1233 | 1257 | if (bucket_count() != 0) { |
| 1234 | 1258 | __next_pointer __cache = __detach(); |
| 1235 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1259 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 1236 | 1260 | try { |
| 1237 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1261 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1238 | 1262 | for (; __cache != nullptr && __first != __last; ++__first) { |
| 1239 | 1263 | __cache->__upcast()->__get_value() = *__first; |
| 1240 | 1264 | __next_pointer __next = __cache->__next_; |
| 1241 | 1265 | __node_insert_unique(__cache->__upcast()); |
| 1242 | 1266 | __cache = __next; |
| 1243 | 1267 | } |
| 1244 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1268 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 1245 | 1269 | } catch (...) { |
| 1246 | 1270 | __deallocate_node(__cache); |
| 1247 | 1271 | throw; |
| 1248 | 1272 | } |
| 1249 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1273 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1250 | 1274 | __deallocate_node(__cache); |
| 1251 | 1275 | } |
| 1252 | 1276 | for (; __first != __last; ++__first) |
| ... | ... | @@ -1264,21 +1288,21 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f |
| 1264 | 1288 | " or the nodes value type"); |
| 1265 | 1289 | if (bucket_count() != 0) { |
| 1266 | 1290 | __next_pointer __cache = __detach(); |
| 1267 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1291 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 1268 | 1292 | try { |
| 1269 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1293 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1270 | 1294 | for (; __cache != nullptr && __first != __last; ++__first) { |
| 1271 | 1295 | __cache->__upcast()->__get_value() = *__first; |
| 1272 | 1296 | __next_pointer __next = __cache->__next_; |
| 1273 | 1297 | __node_insert_multi(__cache->__upcast()); |
| 1274 | 1298 | __cache = __next; |
| 1275 | 1299 | } |
| 1276 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1300 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 1277 | 1301 | } catch (...) { |
| 1278 | 1302 | __deallocate_node(__cache); |
| 1279 | 1303 | throw; |
| 1280 | 1304 | } |
| 1281 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1305 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1282 | 1306 | __deallocate_node(__cache); |
| 1283 | 1307 | } |
| 1284 | 1308 | for (; __first != __last; ++__first) |
| ... | ... | @@ -1288,7 +1312,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f |
| 1288 | 1312 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1289 | 1313 | inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator |
| 1290 | 1314 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT { |
| 1291 | return iterator(__p1_.first().__next_); | |
| 1315 | return iterator(__first_node_.__next_); | |
| 1292 | 1316 | } |
| 1293 | 1317 | |
| 1294 | 1318 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -1300,7 +1324,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT { |
| 1300 | 1324 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1301 | 1325 | inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator |
| 1302 | 1326 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT { |
| 1303 | return const_iterator(__p1_.first().__next_); | |
| 1327 | return const_iterator(__first_node_.__next_); | |
| 1304 | 1328 | } |
| 1305 | 1329 | |
| 1306 | 1330 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -1312,8 +1336,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT { |
| 1312 | 1336 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1313 | 1337 | void __hash_table<_Tp, _Hash, _Equal, _Alloc>::clear() _NOEXCEPT { |
| 1314 | 1338 | if (size() > 0) { |
| 1315 | __deallocate_node(__p1_.first().__next_); | |
| 1316 | __p1_.first().__next_ = nullptr; | |
| 1339 | __deallocate_node(__first_node_.__next_); | |
| 1340 | __first_node_.__next_ = nullptr; | |
| 1317 | 1341 | size_type __bc = bucket_count(); |
| 1318 | 1342 | for (size_type __i = 0; __i < __bc; ++__i) |
| 1319 | 1343 | __bucket_list_[__i] = nullptr; |
| ... | ... | @@ -1348,7 +1372,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(size_t __ |
| 1348 | 1372 | } |
| 1349 | 1373 | if (size() + 1 > __bc * max_load_factor() || __bc == 0) { |
| 1350 | 1374 | __rehash_unique(std::max<size_type>( |
| 1351 | 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); | |
| 1375 | 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); | |
| 1352 | 1376 | } |
| 1353 | 1377 | return nullptr; |
| 1354 | 1378 | } |
| ... | ... | @@ -1365,7 +1389,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_perform(__node_po |
| 1365 | 1389 | // insert_after __bucket_list_[__chash], or __first_node if bucket is null |
| 1366 | 1390 | __next_pointer __pn = __bucket_list_[__chash]; |
| 1367 | 1391 | if (__pn == nullptr) { |
| 1368 | __pn = __p1_.first().__ptr(); | |
| 1392 | __pn = __first_node_.__ptr(); | |
| 1369 | 1393 | __nd->__next_ = __pn->__next_; |
| 1370 | 1394 | __pn->__next_ = __nd->__ptr(); |
| 1371 | 1395 | // fix up __bucket_list_ |
| ... | ... | @@ -1408,7 +1432,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(size_t __c |
| 1408 | 1432 | size_type __bc = bucket_count(); |
| 1409 | 1433 | if (size() + 1 > __bc * max_load_factor() || __bc == 0) { |
| 1410 | 1434 | __rehash_multi(std::max<size_type>( |
| 1411 | 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); | |
| 1435 | 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); | |
| 1412 | 1436 | __bc = bucket_count(); |
| 1413 | 1437 | } |
| 1414 | 1438 | size_t __chash = std::__constrain_hash(__cp_hash, __bc); |
| ... | ... | @@ -1445,7 +1469,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_perform( |
| 1445 | 1469 | size_type __bc = bucket_count(); |
| 1446 | 1470 | size_t __chash = std::__constrain_hash(__cp->__hash_, __bc); |
| 1447 | 1471 | if (__pn == nullptr) { |
| 1448 | __pn = __p1_.first().__ptr(); | |
| 1472 | __pn = __first_node_.__ptr(); | |
| 1449 | 1473 | __cp->__next_ = __pn->__next_; |
| 1450 | 1474 | __pn->__next_ = __cp->__ptr(); |
| 1451 | 1475 | // fix up __bucket_list_ |
| ... | ... | @@ -1483,7 +1507,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(const_iterator __p |
| 1483 | 1507 | size_type __bc = bucket_count(); |
| 1484 | 1508 | if (size() + 1 > __bc * max_load_factor() || __bc == 0) { |
| 1485 | 1509 | __rehash_multi(std::max<size_type>( |
| 1486 | 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); | |
| 1510 | 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); | |
| 1487 | 1511 | __bc = bucket_count(); |
| 1488 | 1512 | } |
| 1489 | 1513 | size_t __chash = std::__constrain_hash(__cp->__hash_, __bc); |
| ... | ... | @@ -1523,14 +1547,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& |
| 1523 | 1547 | __node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args)...); |
| 1524 | 1548 | if (size() + 1 > __bc * max_load_factor() || __bc == 0) { |
| 1525 | 1549 | __rehash_unique(std::max<size_type>( |
| 1526 | 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); | |
| 1550 | 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); | |
| 1527 | 1551 | __bc = bucket_count(); |
| 1528 | 1552 | __chash = std::__constrain_hash(__hash, __bc); |
| 1529 | 1553 | } |
| 1530 | 1554 | // insert_after __bucket_list_[__chash], or __first_node if bucket is null |
| 1531 | 1555 | __next_pointer __pn = __bucket_list_[__chash]; |
| 1532 | 1556 | if (__pn == nullptr) { |
| 1533 | __pn = __p1_.first().__ptr(); | |
| 1557 | __pn = __first_node_.__ptr(); | |
| 1534 | 1558 | __h->__next_ = __pn->__next_; |
| 1535 | 1559 | __pn->__next_ = __h.get()->__ptr(); |
| 1536 | 1560 | // fix up __bucket_list_ |
| ... | ... | @@ -1692,8 +1716,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_D |
| 1692 | 1716 | else if (__n < __bc) { |
| 1693 | 1717 | __n = std::max<size_type>( |
| 1694 | 1718 | __n, |
| 1695 | std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(std::ceil(float(size()) / max_load_factor()))) | |
| 1696 | : std::__next_prime(size_t(std::ceil(float(size()) / max_load_factor())))); | |
| 1719 | std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(__math::ceil(float(size()) / max_load_factor()))) | |
| 1720 | : std::__next_prime(size_t(__math::ceil(float(size()) / max_load_factor())))); | |
| 1697 | 1721 | if (__n < __bc) |
| 1698 | 1722 | __do_rehash<_UniqueKeys>(__n); |
| 1699 | 1723 | } |
| ... | ... | @@ -1708,7 +1732,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc) { |
| 1708 | 1732 | if (__nbc > 0) { |
| 1709 | 1733 | for (size_type __i = 0; __i < __nbc; ++__i) |
| 1710 | 1734 | __bucket_list_[__i] = nullptr; |
| 1711 | __next_pointer __pp = __p1_.first().__ptr(); | |
| 1735 | __next_pointer __pp = __first_node_.__ptr(); | |
| 1712 | 1736 | __next_pointer __cp = __pp->__next_; |
| 1713 | 1737 | if (__cp != nullptr) { |
| 1714 | 1738 | size_type __chash = std::__constrain_hash(__cp->__hash(), __nbc); |
| ... | ... | @@ -1885,7 +1909,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT { |
| 1885 | 1909 | // Fix up __bucket_list_ |
| 1886 | 1910 | // if __pn is not in same bucket (before begin is not in same bucket) && |
| 1887 | 1911 | // if __cn->__next_ is not in same bucket (nullptr is not in same bucket) |
| 1888 | if (__pn == __p1_.first().__ptr() || std::__constrain_hash(__pn->__hash(), __bc) != __chash) { | |
| 1912 | if (__pn == __first_node_.__ptr() || std::__constrain_hash(__pn->__hash(), __bc) != __chash) { | |
| 1889 | 1913 | if (__cn->__next_ == nullptr || std::__constrain_hash(__cn->__next_->__hash(), __bc) != __chash) |
| 1890 | 1914 | __bucket_list_[__chash] = nullptr; |
| 1891 | 1915 | } |
| ... | ... | @@ -2004,14 +2028,17 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) |
| 2004 | 2028 | std::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size()); |
| 2005 | 2029 | std::__swap_allocator(__bucket_list_.get_deleter().__alloc(), __u.__bucket_list_.get_deleter().__alloc()); |
| 2006 | 2030 | std::__swap_allocator(__node_alloc(), __u.__node_alloc()); |
| 2007 | std::swap(__p1_.first().__next_, __u.__p1_.first().__next_); | |
| 2008 | __p2_.swap(__u.__p2_); | |
| 2009 | __p3_.swap(__u.__p3_); | |
| 2031 | std::swap(__first_node_.__next_, __u.__first_node_.__next_); | |
| 2032 | using std::swap; | |
| 2033 | swap(__size_, __u.__size_); | |
| 2034 | swap(__hasher_, __u.__hasher_); | |
| 2035 | swap(__max_load_factor_, __u.__max_load_factor_); | |
| 2036 | swap(__key_eq_, __u.__key_eq_); | |
| 2010 | 2037 | if (size() > 0) |
| 2011 | __bucket_list_[std::__constrain_hash(__p1_.first().__next_->__hash(), bucket_count())] = __p1_.first().__ptr(); | |
| 2038 | __bucket_list_[std::__constrain_hash(__first_node_.__next_->__hash(), bucket_count())] = __first_node_.__ptr(); | |
| 2012 | 2039 | if (__u.size() > 0) |
| 2013 | __u.__bucket_list_[std::__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] = | |
| 2014 | __u.__p1_.first().__ptr(); | |
| 2040 | __u.__bucket_list_[std::__constrain_hash(__u.__first_node_.__next_->__hash(), __u.bucket_count())] = | |
| 2041 | __u.__first_node_.__ptr(); | |
| 2015 | 2042 | } |
| 2016 | 2043 | |
| 2017 | 2044 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
lib/libcxx/include/__iterator/access.h+1-1| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_ACCESS_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <cstddef> | |
| 14 | #include <__cstddef/size_t.h> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
lib/libcxx/include/__iterator/advance.h+2-6| ... | ... | @@ -76,9 +76,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i |
| 76 | 76 | // [range.iter.op.advance] |
| 77 | 77 | |
| 78 | 78 | namespace ranges { |
| 79 | namespace __advance { | |
| 80 | ||
| 81 | struct __fn { | |
| 79 | struct __advance { | |
| 82 | 80 | private: |
| 83 | 81 | template <class _Ip> |
| 84 | 82 | _LIBCPP_HIDE_FROM_ABI static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) { |
| ... | ... | @@ -189,10 +187,8 @@ public: |
| 189 | 187 | } |
| 190 | 188 | }; |
| 191 | 189 | |
| 192 | } // namespace __advance | |
| 193 | ||
| 194 | 190 | inline namespace __cpo { |
| 195 | inline constexpr auto advance = __advance::__fn{}; | |
| 191 | inline constexpr auto advance = __advance{}; | |
| 196 | 192 | } // namespace __cpo |
| 197 | 193 | } // namespace ranges |
| 198 | 194 |
lib/libcxx/include/__iterator/aliasing_iterator.h+4-4| ... | ... | @@ -10,10 +10,10 @@ |
| 10 | 10 | #define _LIBCPP___ITERATOR_ALIASING_ITERATOR_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/ptrdiff_t.h> | |
| 13 | 14 | #include <__iterator/iterator_traits.h> |
| 14 | 15 | #include <__memory/pointer_traits.h> |
| 15 | 16 | #include <__type_traits/is_trivial.h> |
| 16 | #include <cstddef> | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | # pragma GCC system_header |
| ... | ... | @@ -31,8 +31,8 @@ struct __aliasing_iterator_wrapper { |
| 31 | 31 | class __iterator { |
| 32 | 32 | _BaseIter __base_ = nullptr; |
| 33 | 33 | |
| 34 | using __iter_traits = iterator_traits<_BaseIter>; | |
| 35 | using __base_value_type = typename __iter_traits::value_type; | |
| 34 | using __iter_traits _LIBCPP_NODEBUG = iterator_traits<_BaseIter>; | |
| 35 | using __base_value_type _LIBCPP_NODEBUG = typename __iter_traits::value_type; | |
| 36 | 36 | |
| 37 | 37 | static_assert(__has_random_access_iterator_category<_BaseIter>::value, |
| 38 | 38 | "The base iterator has to be a random access iterator!"); |
| ... | ... | @@ -120,7 +120,7 @@ struct __aliasing_iterator_wrapper { |
| 120 | 120 | |
| 121 | 121 | // This is required to avoid ADL instantiations on _BaseT |
| 122 | 122 | template <class _BaseT, class _Alias> |
| 123 | using __aliasing_iterator = typename __aliasing_iterator_wrapper<_BaseT, _Alias>::__iterator; | |
| 123 | using __aliasing_iterator _LIBCPP_NODEBUG = typename __aliasing_iterator_wrapper<_BaseT, _Alias>::__iterator; | |
| 124 | 124 | |
| 125 | 125 | _LIBCPP_END_NAMESPACE_STD |
| 126 | 126 |
lib/libcxx/include/__iterator/back_insert_iterator.h+1-1| ... | ... | @@ -11,11 +11,11 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__iterator/iterator.h> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | 17 | #include <__memory/addressof.h> |
| 17 | 18 | #include <__utility/move.h> |
| 18 | #include <cstddef> | |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | 21 | # pragma GCC system_header |
lib/libcxx/include/__iterator/bounded_iter.h+18-8| ... | ... | @@ -16,9 +16,13 @@ |
| 16 | 16 | #include <__config> |
| 17 | 17 | #include <__iterator/iterator_traits.h> |
| 18 | 18 | #include <__memory/pointer_traits.h> |
| 19 | #include <__type_traits/conjunction.h> | |
| 20 | #include <__type_traits/disjunction.h> | |
| 19 | 21 | #include <__type_traits/enable_if.h> |
| 20 | 22 | #include <__type_traits/integral_constant.h> |
| 21 | 23 | #include <__type_traits/is_convertible.h> |
| 24 | #include <__type_traits/is_same.h> | |
| 25 | #include <__type_traits/make_const_lvalue_ref.h> | |
| 22 | 26 | #include <__utility/move.h> |
| 23 | 27 | |
| 24 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -47,8 +51,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 47 | 51 | // pointer, it is undefined at the language level (see [expr.add]). If |
| 48 | 52 | // bounded iterators exhibited this undefined behavior, we risk compiler |
| 49 | 53 | // optimizations deleting non-redundant bounds checks. |
| 50 | template <class _Iterator, class = __enable_if_t< __libcpp_is_contiguous_iterator<_Iterator>::value > > | |
| 54 | template <class _Iterator> | |
| 51 | 55 | struct __bounded_iter { |
| 56 | static_assert(__libcpp_is_contiguous_iterator<_Iterator>::value, | |
| 57 | "Only contiguous iterators can be adapted by __bounded_iter."); | |
| 58 | ||
| 52 | 59 | using value_type = typename iterator_traits<_Iterator>::value_type; |
| 53 | 60 | using difference_type = typename iterator_traits<_Iterator>::difference_type; |
| 54 | 61 | using pointer = typename iterator_traits<_Iterator>::pointer; |
| ... | ... | @@ -60,14 +67,19 @@ struct __bounded_iter { |
| 60 | 67 | |
| 61 | 68 | // Create a singular iterator. |
| 62 | 69 | // |
| 63 | // Such an iterator points past the end of an empty span, so it is not dereferenceable. | |
| 64 | // Observing operations like comparison and assignment are valid. | |
| 70 | // Such an iterator points past the end of an empty range, so it is not dereferenceable. | |
| 71 | // Operations like comparison and assignment are valid. | |
| 65 | 72 | _LIBCPP_HIDE_FROM_ABI __bounded_iter() = default; |
| 66 | 73 | |
| 67 | 74 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default; |
| 68 | 75 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default; |
| 69 | 76 | |
| 70 | template <class _OtherIterator, __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value, int> = 0> | |
| 77 | template < class _OtherIterator, | |
| 78 | __enable_if_t< | |
| 79 | _And< is_convertible<const _OtherIterator&, _Iterator>, | |
| 80 | _Or<is_same<reference, __iter_reference<_OtherIterator> >, | |
| 81 | is_same<reference, __make_const_lvalue_ref<__iter_reference<_OtherIterator> > > > >::value, | |
| 82 | int> = 0> | |
| 71 | 83 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT |
| 72 | 84 | : __current_(__other.__current_), |
| 73 | 85 | __begin_(__other.__begin_), |
| ... | ... | @@ -209,9 +221,7 @@ public: |
| 209 | 221 | operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { |
| 210 | 222 | return __x.__current_ != __y.__current_; |
| 211 | 223 | } |
| 212 | #endif | |
| 213 | 224 | |
| 214 | // TODO(mordante) disable these overloads in the LLVM 20 release. | |
| 215 | 225 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool |
| 216 | 226 | operator<(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { |
| 217 | 227 | return __x.__current_ < __y.__current_; |
| ... | ... | @@ -229,7 +239,7 @@ public: |
| 229 | 239 | return __x.__current_ >= __y.__current_; |
| 230 | 240 | } |
| 231 | 241 | |
| 232 | #if _LIBCPP_STD_VER >= 20 | |
| 242 | #else | |
| 233 | 243 | _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering |
| 234 | 244 | operator<=>(__bounded_iter const& __x, __bounded_iter const& __y) noexcept { |
| 235 | 245 | if constexpr (three_way_comparable<_Iterator, strong_ordering>) { |
| ... | ... | @@ -249,7 +259,7 @@ public: |
| 249 | 259 | private: |
| 250 | 260 | template <class> |
| 251 | 261 | friend struct pointer_traits; |
| 252 | template <class, class> | |
| 262 | template <class> | |
| 253 | 263 | friend struct __bounded_iter; |
| 254 | 264 | _Iterator __current_; // current iterator |
| 255 | 265 | _Iterator __begin_, __end_; // valid range represented as [begin, end] |
lib/libcxx/include/__iterator/common_iterator.h+2-1| ... | ... | @@ -26,6 +26,7 @@ |
| 26 | 26 | #include <__iterator/iterator_traits.h> |
| 27 | 27 | #include <__iterator/readable_traits.h> |
| 28 | 28 | #include <__memory/addressof.h> |
| 29 | #include <__type_traits/conditional.h> | |
| 29 | 30 | #include <__type_traits/is_pointer.h> |
| 30 | 31 | #include <__utility/declval.h> |
| 31 | 32 | #include <variant> |
| ... | ... | @@ -235,7 +236,7 @@ public: |
| 235 | 236 | return std::__unchecked_get<_Sent>(__x.__hold_) - std::__unchecked_get<_I2>(__y.__hold_); |
| 236 | 237 | } |
| 237 | 238 | |
| 238 | _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> | |
| 239 | _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) | |
| 239 | 240 | iter_move(const common_iterator& __i) noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>()))) |
| 240 | 241 | requires input_iterator<_Iter> |
| 241 | 242 | { |
lib/libcxx/include/__iterator/concepts.h+46-17| ... | ... | @@ -26,7 +26,6 @@ |
| 26 | 26 | #include <__concepts/semiregular.h> |
| 27 | 27 | #include <__concepts/totally_ordered.h> |
| 28 | 28 | #include <__config> |
| 29 | #include <__functional/invoke.h> | |
| 30 | 29 | #include <__iterator/incrementable_traits.h> |
| 31 | 30 | #include <__iterator/iter_move.h> |
| 32 | 31 | #include <__iterator/iterator_traits.h> |
| ... | ... | @@ -34,7 +33,10 @@ |
| 34 | 33 | #include <__memory/pointer_traits.h> |
| 35 | 34 | #include <__type_traits/add_pointer.h> |
| 36 | 35 | #include <__type_traits/common_reference.h> |
| 36 | #include <__type_traits/integral_constant.h> | |
| 37 | #include <__type_traits/invoke.h> | |
| 37 | 38 | #include <__type_traits/is_pointer.h> |
| 39 | #include <__type_traits/is_primary_template.h> | |
| 38 | 40 | #include <__type_traits/is_reference.h> |
| 39 | 41 | #include <__type_traits/remove_cv.h> |
| 40 | 42 | #include <__type_traits/remove_cvref.h> |
| ... | ... | @@ -64,8 +66,33 @@ concept __indirectly_readable_impl = |
| 64 | 66 | template <class _In> |
| 65 | 67 | concept indirectly_readable = __indirectly_readable_impl<remove_cvref_t<_In>>; |
| 66 | 68 | |
| 69 | template <class _Tp> | |
| 70 | using __projected_iterator_t _LIBCPP_NODEBUG = typename _Tp::__projected_iterator; | |
| 71 | ||
| 72 | template <class _Tp> | |
| 73 | using __projected_projection_t _LIBCPP_NODEBUG = typename _Tp::__projected_projection; | |
| 74 | ||
| 75 | template <class _Tp> | |
| 76 | concept __specialization_of_projected = requires { | |
| 77 | typename __projected_iterator_t<_Tp>; | |
| 78 | typename __projected_projection_t<_Tp>; | |
| 79 | } && __is_primary_template<_Tp>::value; | |
| 80 | ||
| 81 | template <class _Tp> | |
| 82 | struct __indirect_value_t_impl { | |
| 83 | using type = iter_value_t<_Tp>&; | |
| 84 | }; | |
| 85 | template <__specialization_of_projected _Tp> | |
| 86 | struct __indirect_value_t_impl<_Tp> { | |
| 87 | using type = invoke_result_t<__projected_projection_t<_Tp>&, | |
| 88 | typename __indirect_value_t_impl<__projected_iterator_t<_Tp>>::type>; | |
| 89 | }; | |
| 90 | ||
| 91 | template <indirectly_readable _Tp> | |
| 92 | using __indirect_value_t _LIBCPP_NODEBUG = typename __indirect_value_t_impl<_Tp>::type; | |
| 93 | ||
| 67 | 94 | template <indirectly_readable _Tp> |
| 68 | using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, iter_value_t<_Tp>&>; | |
| 95 | using iter_common_reference_t = common_reference_t<iter_reference_t<_Tp>, __indirect_value_t<_Tp>>; | |
| 69 | 96 | |
| 70 | 97 | // [iterator.concept.writable] |
| 71 | 98 | template <class _Out, class _Tp> |
| ... | ... | @@ -176,43 +203,45 @@ concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip |
| 176 | 203 | // [indirectcallable.indirectinvocable] |
| 177 | 204 | template <class _Fp, class _It> |
| 178 | 205 | concept indirectly_unary_invocable = |
| 179 | indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, iter_value_t<_It>&> && | |
| 206 | indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, __indirect_value_t<_It>> && | |
| 180 | 207 | 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>>>; | |
| 208 | common_reference_with< invoke_result_t<_Fp&, __indirect_value_t<_It>>, | |
| 209 | invoke_result_t<_Fp&, iter_reference_t<_It>>>; | |
| 182 | 210 | |
| 183 | 211 | template <class _Fp, class _It> |
| 184 | 212 | concept indirectly_regular_unary_invocable = |
| 185 | indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, iter_value_t<_It>&> && | |
| 213 | indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, __indirect_value_t<_It>> && | |
| 186 | 214 | 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>>>; | |
| 215 | common_reference_with< invoke_result_t<_Fp&, __indirect_value_t<_It>>, | |
| 216 | invoke_result_t<_Fp&, iter_reference_t<_It>>>; | |
| 188 | 217 | |
| 189 | 218 | template <class _Fp, class _It> |
| 190 | 219 | concept indirect_unary_predicate = |
| 191 | indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, iter_value_t<_It>&> && | |
| 220 | indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, __indirect_value_t<_It>> && | |
| 192 | 221 | predicate<_Fp&, iter_reference_t<_It>>; |
| 193 | 222 | |
| 194 | 223 | template <class _Fp, class _It1, class _It2> |
| 195 | 224 | concept indirect_binary_predicate = |
| 196 | 225 | indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> && |
| 197 | predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && | |
| 198 | predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && | |
| 199 | predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && | |
| 226 | predicate<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> && | |
| 227 | predicate<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> && | |
| 228 | predicate<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> && | |
| 200 | 229 | predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>; |
| 201 | 230 | |
| 202 | 231 | template <class _Fp, class _It1, class _It2 = _It1> |
| 203 | 232 | concept indirect_equivalence_relation = |
| 204 | 233 | indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> && |
| 205 | equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && | |
| 206 | equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && | |
| 207 | equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && | |
| 234 | equivalence_relation<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> && | |
| 235 | equivalence_relation<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> && | |
| 236 | equivalence_relation<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> && | |
| 208 | 237 | equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>; |
| 209 | 238 | |
| 210 | 239 | template <class _Fp, class _It1, class _It2 = _It1> |
| 211 | 240 | concept indirect_strict_weak_order = |
| 212 | 241 | indirectly_readable<_It1> && indirectly_readable<_It2> && copy_constructible<_Fp> && |
| 213 | strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && | |
| 214 | strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && | |
| 215 | strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && | |
| 242 | strict_weak_order<_Fp&, __indirect_value_t<_It1>, __indirect_value_t<_It2>> && | |
| 243 | strict_weak_order<_Fp&, __indirect_value_t<_It1>, iter_reference_t<_It2>> && | |
| 244 | strict_weak_order<_Fp&, iter_reference_t<_It1>, __indirect_value_t<_It2>> && | |
| 216 | 245 | strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>; |
| 217 | 246 | |
| 218 | 247 | template <class _Fp, class... _Its> |
| ... | ... | @@ -245,7 +274,7 @@ concept indirectly_copyable_storable = |
| 245 | 274 | #endif // _LIBCPP_STD_VER >= 20 |
| 246 | 275 | |
| 247 | 276 | template <class _Tp> |
| 248 | using __has_random_access_iterator_category_or_concept | |
| 277 | using __has_random_access_iterator_category_or_concept _LIBCPP_NODEBUG | |
| 249 | 278 | #if _LIBCPP_STD_VER >= 20 |
| 250 | 279 | = integral_constant<bool, random_access_iterator<_Tp>>; |
| 251 | 280 | #else // _LIBCPP_STD_VER < 20 |
lib/libcxx/include/__iterator/counted_iterator.h+4-4| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__assert> |
| 14 | #include <__compare/ordering.h> | |
| 14 | 15 | #include <__concepts/assignable.h> |
| 15 | 16 | #include <__concepts/common_with.h> |
| 16 | 17 | #include <__concepts/constructible.h> |
| ... | ... | @@ -28,7 +29,6 @@ |
| 28 | 29 | #include <__type_traits/add_pointer.h> |
| 29 | 30 | #include <__type_traits/conditional.h> |
| 30 | 31 | #include <__utility/move.h> |
| 31 | #include <compare> | |
| 32 | 32 | |
| 33 | 33 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 34 | 34 | # pragma GCC system_header |
| ... | ... | @@ -132,7 +132,7 @@ public: |
| 132 | 132 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator++(int) { |
| 133 | 133 | _LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator already at or past end."); |
| 134 | 134 | --__count_; |
| 135 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 135 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 136 | 136 | try { |
| 137 | 137 | return __current_++; |
| 138 | 138 | } catch (...) { |
| ... | ... | @@ -141,7 +141,7 @@ public: |
| 141 | 141 | } |
| 142 | 142 | # else |
| 143 | 143 | return __current_++; |
| 144 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 144 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | _LIBCPP_HIDE_FROM_ABI constexpr counted_iterator operator++(int) |
| ... | ... | @@ -249,7 +249,7 @@ public: |
| 249 | 249 | return __rhs.__count_ <=> __lhs.__count_; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> | |
| 252 | _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) | |
| 253 | 253 | iter_move(const counted_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__current_))) |
| 254 | 254 | requires input_iterator<_Iter> |
| 255 | 255 | { |
lib/libcxx/include/__iterator/data.h-1| ... | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_DATA_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <cstddef> | |
| 15 | 14 | #include <initializer_list> |
| 16 | 15 | |
| 17 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__iterator/distance.h+2-6| ... | ... | @@ -52,9 +52,7 @@ distance(_InputIter __first, _InputIter __last) { |
| 52 | 52 | // [range.iter.op.distance] |
| 53 | 53 | |
| 54 | 54 | namespace ranges { |
| 55 | namespace __distance { | |
| 56 | ||
| 57 | struct __fn { | |
| 55 | struct __distance { | |
| 58 | 56 | template <class _Ip, sentinel_for<_Ip> _Sp> |
| 59 | 57 | requires(!sized_sentinel_for<_Sp, _Ip>) |
| 60 | 58 | _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const { |
| ... | ... | @@ -85,10 +83,8 @@ struct __fn { |
| 85 | 83 | } |
| 86 | 84 | }; |
| 87 | 85 | |
| 88 | } // namespace __distance | |
| 89 | ||
| 90 | 86 | inline namespace __cpo { |
| 91 | inline constexpr auto distance = __distance::__fn{}; | |
| 87 | inline constexpr auto distance = __distance{}; | |
| 92 | 88 | } // namespace __cpo |
| 93 | 89 | } // namespace ranges |
| 94 | 90 |
lib/libcxx/include/__iterator/empty.h-1| ... | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_EMPTY_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <cstddef> | |
| 15 | 14 | #include <initializer_list> |
| 16 | 15 | |
| 17 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__iterator/front_insert_iterator.h+1-1| ... | ... | @@ -11,11 +11,11 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__iterator/iterator.h> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | 17 | #include <__memory/addressof.h> |
| 17 | 18 | #include <__utility/move.h> |
| 18 | #include <cstddef> | |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | 21 | # pragma GCC system_header |
lib/libcxx/include/__iterator/incrementable_traits.h+1-1| ... | ... | @@ -12,13 +12,13 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__concepts/arithmetic.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/ptrdiff_t.h> | |
| 15 | 16 | #include <__type_traits/conditional.h> |
| 16 | 17 | #include <__type_traits/is_object.h> |
| 17 | 18 | #include <__type_traits/is_primary_template.h> |
| 18 | 19 | #include <__type_traits/make_signed.h> |
| 19 | 20 | #include <__type_traits/remove_cvref.h> |
| 20 | 21 | #include <__utility/declval.h> |
| 21 | #include <cstddef> | |
| 22 | 22 | |
| 23 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | 24 | # pragma GCC system_header |
lib/libcxx/include/__iterator/insert_iterator.h+3-3| ... | ... | @@ -11,12 +11,12 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_INSERT_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__iterator/iterator.h> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | 17 | #include <__memory/addressof.h> |
| 17 | 18 | #include <__ranges/access.h> |
| 18 | 19 | #include <__utility/move.h> |
| 19 | #include <cstddef> | |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 22 | # pragma GCC system_header |
| ... | ... | @@ -29,10 +29,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | |
| 30 | 30 | #if _LIBCPP_STD_VER >= 20 |
| 31 | 31 | template <class _Container> |
| 32 | using __insert_iterator_iter_t = ranges::iterator_t<_Container>; | |
| 32 | using __insert_iterator_iter_t _LIBCPP_NODEBUG = ranges::iterator_t<_Container>; | |
| 33 | 33 | #else |
| 34 | 34 | template <class _Container> |
| 35 | using __insert_iterator_iter_t = typename _Container::iterator; | |
| 35 | using __insert_iterator_iter_t _LIBCPP_NODEBUG = typename _Container::iterator; | |
| 36 | 36 | #endif |
| 37 | 37 | |
| 38 | 38 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
lib/libcxx/include/__iterator/istream_iterator.h+1-1| ... | ... | @@ -11,13 +11,13 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__fwd/istream.h> |
| 15 | 16 | #include <__fwd/string.h> |
| 16 | 17 | #include <__iterator/default_sentinel.h> |
| 17 | 18 | #include <__iterator/iterator.h> |
| 18 | 19 | #include <__iterator/iterator_traits.h> |
| 19 | 20 | #include <__memory/addressof.h> |
| 20 | #include <cstddef> | |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | 23 | # pragma GCC system_header |
lib/libcxx/include/__iterator/istreambuf_iterator.h+2| ... | ... | @@ -16,6 +16,8 @@ |
| 16 | 16 | #include <__iterator/default_sentinel.h> |
| 17 | 17 | #include <__iterator/iterator.h> |
| 18 | 18 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__string/char_traits.h> | |
| 20 | #include <iosfwd> | |
| 19 | 21 | |
| 20 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | 23 | # pragma GCC system_header |
lib/libcxx/include/__iterator/iterator.h+1-1| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <cstddef> | |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
lib/libcxx/include/__iterator/iterator_traits.h+31-24| ... | ... | @@ -18,12 +18,15 @@ |
| 18 | 18 | #include <__concepts/same_as.h> |
| 19 | 19 | #include <__concepts/totally_ordered.h> |
| 20 | 20 | #include <__config> |
| 21 | #include <__cstddef/ptrdiff_t.h> | |
| 21 | 22 | #include <__fwd/pair.h> |
| 22 | 23 | #include <__iterator/incrementable_traits.h> |
| 23 | 24 | #include <__iterator/readable_traits.h> |
| 24 | 25 | #include <__type_traits/common_reference.h> |
| 25 | 26 | #include <__type_traits/conditional.h> |
| 26 | 27 | #include <__type_traits/disjunction.h> |
| 28 | #include <__type_traits/enable_if.h> | |
| 29 | #include <__type_traits/integral_constant.h> | |
| 27 | 30 | #include <__type_traits/is_convertible.h> |
| 28 | 31 | #include <__type_traits/is_object.h> |
| 29 | 32 | #include <__type_traits/is_primary_template.h> |
| ... | ... | @@ -34,7 +37,6 @@ |
| 34 | 37 | #include <__type_traits/remove_cvref.h> |
| 35 | 38 | #include <__type_traits/void_t.h> |
| 36 | 39 | #include <__utility/declval.h> |
| 37 | #include <cstddef> | |
| 38 | 40 | |
| 39 | 41 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 40 | 42 | # pragma GCC system_header |
| ... | ... | @@ -45,7 +47,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 45 | 47 | #if _LIBCPP_STD_VER >= 20 |
| 46 | 48 | |
| 47 | 49 | template <class _Tp> |
| 48 | using __with_reference = _Tp&; | |
| 50 | using __with_reference _LIBCPP_NODEBUG = _Tp&; | |
| 49 | 51 | |
| 50 | 52 | template <class _Tp> |
| 51 | 53 | concept __can_reference = requires { typename __with_reference<_Tp>; }; |
| ... | ... | @@ -78,19 +80,20 @@ struct __iter_traits_cache { |
| 78 | 80 | using type = _If< __is_primary_template<iterator_traits<_Iter> >::value, _Iter, iterator_traits<_Iter> >; |
| 79 | 81 | }; |
| 80 | 82 | template <class _Iter> |
| 81 | using _ITER_TRAITS = typename __iter_traits_cache<_Iter>::type; | |
| 83 | using _ITER_TRAITS _LIBCPP_NODEBUG = typename __iter_traits_cache<_Iter>::type; | |
| 82 | 84 | |
| 83 | 85 | struct __iter_concept_concept_test { |
| 84 | 86 | template <class _Iter> |
| 85 | using _Apply = typename _ITER_TRAITS<_Iter>::iterator_concept; | |
| 87 | using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_concept; | |
| 86 | 88 | }; |
| 87 | 89 | struct __iter_concept_category_test { |
| 88 | 90 | template <class _Iter> |
| 89 | using _Apply = typename _ITER_TRAITS<_Iter>::iterator_category; | |
| 91 | using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_category; | |
| 90 | 92 | }; |
| 91 | 93 | struct __iter_concept_random_fallback { |
| 92 | 94 | template <class _Iter> |
| 93 | using _Apply = __enable_if_t< __is_primary_template<iterator_traits<_Iter> >::value, random_access_iterator_tag >; | |
| 95 | using _Apply _LIBCPP_NODEBUG = | |
| 96 | __enable_if_t<__is_primary_template<iterator_traits<_Iter> >::value, random_access_iterator_tag>; | |
| 94 | 97 | }; |
| 95 | 98 | |
| 96 | 99 | template <class _Iter, class _Tester> |
| ... | ... | @@ -104,7 +107,7 @@ struct __iter_concept_cache { |
| 104 | 107 | }; |
| 105 | 108 | |
| 106 | 109 | template <class _Iter> |
| 107 | using _ITER_CONCEPT = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>; | |
| 110 | using _ITER_CONCEPT _LIBCPP_NODEBUG = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>; | |
| 108 | 111 | |
| 109 | 112 | template <class _Tp> |
| 110 | 113 | struct __has_iterator_typedefs { |
| ... | ... | @@ -362,7 +365,7 @@ struct __iterator_traits<_Ip> { |
| 362 | 365 | |
| 363 | 366 | template <class _Ip> |
| 364 | 367 | struct iterator_traits : __iterator_traits<_Ip> { |
| 365 | using __primary_template = iterator_traits; | |
| 368 | using __primary_template _LIBCPP_NODEBUG = iterator_traits; | |
| 366 | 369 | }; |
| 367 | 370 | |
| 368 | 371 | #else // _LIBCPP_STD_VER >= 20 |
| ... | ... | @@ -395,7 +398,7 @@ struct __iterator_traits<_Iter, true> |
| 395 | 398 | |
| 396 | 399 | template <class _Iter> |
| 397 | 400 | struct _LIBCPP_TEMPLATE_VIS iterator_traits : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> { |
| 398 | using __primary_template = iterator_traits; | |
| 401 | using __primary_template _LIBCPP_NODEBUG = iterator_traits; | |
| 399 | 402 | }; |
| 400 | 403 | #endif // _LIBCPP_STD_VER >= 20 |
| 401 | 404 | |
| ... | ... | @@ -428,16 +431,19 @@ template <class _Tp, class _Up> |
| 428 | 431 | struct __has_iterator_concept_convertible_to<_Tp, _Up, false> : false_type {}; |
| 429 | 432 | |
| 430 | 433 | template <class _Tp> |
| 431 | using __has_input_iterator_category = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>; | |
| 434 | using __has_input_iterator_category _LIBCPP_NODEBUG = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>; | |
| 432 | 435 | |
| 433 | 436 | template <class _Tp> |
| 434 | using __has_forward_iterator_category = __has_iterator_category_convertible_to<_Tp, forward_iterator_tag>; | |
| 437 | using __has_forward_iterator_category _LIBCPP_NODEBUG = | |
| 438 | __has_iterator_category_convertible_to<_Tp, forward_iterator_tag>; | |
| 435 | 439 | |
| 436 | 440 | template <class _Tp> |
| 437 | using __has_bidirectional_iterator_category = __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>; | |
| 441 | using __has_bidirectional_iterator_category _LIBCPP_NODEBUG = | |
| 442 | __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>; | |
| 438 | 443 | |
| 439 | 444 | template <class _Tp> |
| 440 | using __has_random_access_iterator_category = __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>; | |
| 445 | using __has_random_access_iterator_category _LIBCPP_NODEBUG = | |
| 446 | __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>; | |
| 441 | 447 | |
| 442 | 448 | // __libcpp_is_contiguous_iterator determines if an iterator is known by |
| 443 | 449 | // libc++ to be contiguous, either because it advertises itself as such |
| ... | ... | @@ -464,48 +470,49 @@ template <class _Iter> |
| 464 | 470 | class __wrap_iter; |
| 465 | 471 | |
| 466 | 472 | template <class _Tp> |
| 467 | using __has_exactly_input_iterator_category = | |
| 473 | using __has_exactly_input_iterator_category _LIBCPP_NODEBUG = | |
| 468 | 474 | integral_constant<bool, |
| 469 | 475 | __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value && |
| 470 | 476 | !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value>; |
| 471 | 477 | |
| 472 | 478 | template <class _Tp> |
| 473 | using __has_exactly_forward_iterator_category = | |
| 479 | using __has_exactly_forward_iterator_category _LIBCPP_NODEBUG = | |
| 474 | 480 | integral_constant<bool, |
| 475 | 481 | __has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value && |
| 476 | 482 | !__has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value>; |
| 477 | 483 | |
| 478 | 484 | template <class _Tp> |
| 479 | using __has_exactly_bidirectional_iterator_category = | |
| 485 | using __has_exactly_bidirectional_iterator_category _LIBCPP_NODEBUG = | |
| 480 | 486 | integral_constant<bool, |
| 481 | 487 | __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value && |
| 482 | 488 | !__has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>::value>; |
| 483 | 489 | |
| 484 | 490 | template <class _InputIterator> |
| 485 | using __iter_value_type = typename iterator_traits<_InputIterator>::value_type; | |
| 491 | using __iter_value_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type; | |
| 486 | 492 | |
| 487 | 493 | template <class _InputIterator> |
| 488 | using __iter_key_type = __remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>; | |
| 494 | using __iter_key_type _LIBCPP_NODEBUG = | |
| 495 | __remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>; | |
| 489 | 496 | |
| 490 | 497 | template <class _InputIterator> |
| 491 | using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type; | |
| 498 | using __iter_mapped_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type::second_type; | |
| 492 | 499 | |
| 493 | 500 | template <class _InputIterator> |
| 494 | using __iter_to_alloc_type = | |
| 501 | using __iter_to_alloc_type _LIBCPP_NODEBUG = | |
| 495 | 502 | pair<const typename iterator_traits<_InputIterator>::value_type::first_type, |
| 496 | 503 | typename iterator_traits<_InputIterator>::value_type::second_type>; |
| 497 | 504 | |
| 498 | 505 | template <class _Iter> |
| 499 | using __iterator_category_type = typename iterator_traits<_Iter>::iterator_category; | |
| 506 | using __iterator_category_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category; | |
| 500 | 507 | |
| 501 | 508 | template <class _Iter> |
| 502 | using __iterator_pointer_type = typename iterator_traits<_Iter>::pointer; | |
| 509 | using __iterator_pointer_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::pointer; | |
| 503 | 510 | |
| 504 | 511 | template <class _Iter> |
| 505 | using __iter_diff_t = typename iterator_traits<_Iter>::difference_type; | |
| 512 | using __iter_diff_t _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::difference_type; | |
| 506 | 513 | |
| 507 | 514 | template <class _Iter> |
| 508 | using __iter_reference = typename iterator_traits<_Iter>::reference; | |
| 515 | using __iter_reference _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::reference; | |
| 509 | 516 | |
| 510 | 517 | #if _LIBCPP_STD_VER >= 20 |
| 511 | 518 |
lib/libcxx/include/__iterator/next.h+8-11| ... | ... | @@ -25,7 +25,7 @@ |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | 27 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 28 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter | |
| 28 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter | |
| 29 | 29 | next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { |
| 30 | 30 | // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation. |
| 31 | 31 | // Note that this check duplicates the similar check in `std::advance`. |
| ... | ... | @@ -41,38 +41,35 @@ next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = |
| 41 | 41 | // [range.iter.op.next] |
| 42 | 42 | |
| 43 | 43 | namespace ranges { |
| 44 | namespace __next { | |
| 45 | ||
| 46 | struct __fn { | |
| 44 | struct __next { | |
| 47 | 45 | template <input_or_output_iterator _Ip> |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const { | |
| 46 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const { | |
| 49 | 47 | ++__x; |
| 50 | 48 | return __x; |
| 51 | 49 | } |
| 52 | 50 | |
| 53 | 51 | template <input_or_output_iterator _Ip> |
| 54 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const { | |
| 52 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const { | |
| 55 | 53 | ranges::advance(__x, __n); |
| 56 | 54 | return __x; |
| 57 | 55 | } |
| 58 | 56 | |
| 59 | 57 | template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const { | |
| 58 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const { | |
| 61 | 59 | ranges::advance(__x, __bound_sentinel); |
| 62 | 60 | return __x; |
| 63 | 61 | } |
| 64 | 62 | |
| 65 | 63 | template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> |
| 66 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const { | |
| 64 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip | |
| 65 | operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const { | |
| 67 | 66 | ranges::advance(__x, __n, __bound_sentinel); |
| 68 | 67 | return __x; |
| 69 | 68 | } |
| 70 | 69 | }; |
| 71 | 70 | |
| 72 | } // namespace __next | |
| 73 | ||
| 74 | 71 | inline namespace __cpo { |
| 75 | inline constexpr auto next = __next::__fn{}; | |
| 72 | inline constexpr auto next = __next{}; | |
| 76 | 73 | } // namespace __cpo |
| 77 | 74 | } // namespace ranges |
| 78 | 75 |
lib/libcxx/include/__iterator/ostream_iterator.h+1-1| ... | ... | @@ -11,12 +11,12 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__fwd/ostream.h> |
| 15 | 16 | #include <__fwd/string.h> |
| 16 | 17 | #include <__iterator/iterator.h> |
| 17 | 18 | #include <__iterator/iterator_traits.h> |
| 18 | 19 | #include <__memory/addressof.h> |
| 19 | #include <cstddef> | |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 22 | # pragma GCC system_header |
lib/libcxx/include/__iterator/ostreambuf_iterator.h+7-2| ... | ... | @@ -11,10 +11,13 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 15 | #include <__fwd/ios.h> | |
| 16 | #include <__fwd/ostream.h> | |
| 17 | #include <__fwd/streambuf.h> | |
| 14 | 18 | #include <__iterator/iterator.h> |
| 15 | 19 | #include <__iterator/iterator_traits.h> |
| 16 | #include <cstddef> | |
| 17 | #include <iosfwd> // for forward declaration of basic_streambuf | |
| 20 | #include <iosfwd> // for forward declaration of ostreambuf_iterator | |
| 18 | 21 | |
| 19 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 23 | # pragma GCC system_header |
| ... | ... | @@ -62,9 +65,11 @@ public: |
| 62 | 65 | _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++(int) { return *this; } |
| 63 | 66 | _LIBCPP_HIDE_FROM_ABI bool failed() const _NOEXCEPT { return __sbuf_ == nullptr; } |
| 64 | 67 | |
| 68 | #if _LIBCPP_HAS_LOCALIZATION | |
| 65 | 69 | template <class _Ch, class _Tr> |
| 66 | 70 | friend _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_Ch, _Tr> __pad_and_output( |
| 67 | 71 | ostreambuf_iterator<_Ch, _Tr> __s, const _Ch* __ob, const _Ch* __op, const _Ch* __oe, ios_base& __iob, _Ch __fl); |
| 72 | #endif // _LIBCPP_HAS_LOCALIZATION | |
| 68 | 73 | }; |
| 69 | 74 | |
| 70 | 75 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__iterator/prev.h+24-11| ... | ... | @@ -17,16 +17,20 @@ |
| 17 | 17 | #include <__iterator/incrementable_traits.h> |
| 18 | 18 | #include <__iterator/iterator_traits.h> |
| 19 | 19 | #include <__type_traits/enable_if.h> |
| 20 | #include <__utility/move.h> | |
| 20 | 21 | |
| 21 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 23 | # pragma GCC system_header |
| 23 | 24 | #endif |
| 24 | 25 | |
| 26 | _LIBCPP_PUSH_MACROS | |
| 27 | #include <__undef_macros> | |
| 28 | ||
| 25 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 30 | |
| 27 | 31 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 28 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter | |
| 29 | prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { | |
| 32 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter | |
| 33 | prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n) { | |
| 30 | 34 | // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation. |
| 31 | 35 | // Note that this check duplicates the similar check in `std::advance`. |
| 32 | 36 | _LIBCPP_ASSERT_PEDANTIC(__n <= 0 || __has_bidirectional_iterator_category<_InputIter>::value, |
| ... | ... | @@ -35,37 +39,44 @@ prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = |
| 35 | 39 | return __x; |
| 36 | 40 | } |
| 37 | 41 | |
| 42 | // LWG 3197 | |
| 43 | // It is unclear what the implications of "BidirectionalIterator" in the standard are. | |
| 44 | // However, calling std::prev(non-bidi-iterator) is obviously an error and we should catch it at compile time. | |
| 45 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> | |
| 46 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter prev(_InputIter __it) { | |
| 47 | static_assert(__has_bidirectional_iterator_category<_InputIter>::value, | |
| 48 | "Attempt to prev(it) with a non-bidirectional iterator"); | |
| 49 | return std::prev(std::move(__it), 1); | |
| 50 | } | |
| 51 | ||
| 38 | 52 | #if _LIBCPP_STD_VER >= 20 |
| 39 | 53 | |
| 40 | 54 | // [range.iter.op.prev] |
| 41 | 55 | |
| 42 | 56 | namespace ranges { |
| 43 | namespace __prev { | |
| 44 | ||
| 45 | struct __fn { | |
| 57 | struct __prev { | |
| 46 | 58 | template <bidirectional_iterator _Ip> |
| 47 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const { | |
| 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x) const { | |
| 48 | 60 | --__x; |
| 49 | 61 | return __x; |
| 50 | 62 | } |
| 51 | 63 | |
| 52 | 64 | template <bidirectional_iterator _Ip> |
| 53 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const { | |
| 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const { | |
| 54 | 66 | ranges::advance(__x, -__n); |
| 55 | 67 | return __x; |
| 56 | 68 | } |
| 57 | 69 | |
| 58 | 70 | template <bidirectional_iterator _Ip> |
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound_iter) const { | |
| 71 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip | |
| 72 | operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound_iter) const { | |
| 60 | 73 | ranges::advance(__x, -__n, __bound_iter); |
| 61 | 74 | return __x; |
| 62 | 75 | } |
| 63 | 76 | }; |
| 64 | 77 | |
| 65 | } // namespace __prev | |
| 66 | ||
| 67 | 78 | inline namespace __cpo { |
| 68 | inline constexpr auto prev = __prev::__fn{}; | |
| 79 | inline constexpr auto prev = __prev{}; | |
| 69 | 80 | } // namespace __cpo |
| 70 | 81 | } // namespace ranges |
| 71 | 82 | |
| ... | ... | @@ -73,4 +84,6 @@ inline constexpr auto prev = __prev::__fn{}; |
| 73 | 84 | |
| 74 | 85 | _LIBCPP_END_NAMESPACE_STD |
| 75 | 86 | |
| 87 | _LIBCPP_POP_MACROS | |
| 88 | ||
| 76 | 89 | #endif // _LIBCPP___ITERATOR_PREV_H |
lib/libcxx/include/__iterator/projected.h+8| ... | ... | @@ -26,6 +26,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | template <class _It, class _Proj> |
| 27 | 27 | struct __projected_impl { |
| 28 | 28 | struct __type { |
| 29 | using __primary_template _LIBCPP_NODEBUG = __type; | |
| 30 | using __projected_iterator _LIBCPP_NODEBUG = _It; | |
| 31 | using __projected_projection _LIBCPP_NODEBUG = _Proj; | |
| 32 | ||
| 29 | 33 | using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>; |
| 30 | 34 | indirect_result_t<_Proj&, _It> operator*() const; // not defined |
| 31 | 35 | }; |
| ... | ... | @@ -34,6 +38,10 @@ struct __projected_impl { |
| 34 | 38 | template <weakly_incrementable _It, class _Proj> |
| 35 | 39 | struct __projected_impl<_It, _Proj> { |
| 36 | 40 | struct __type { |
| 41 | using __primary_template _LIBCPP_NODEBUG = __type; | |
| 42 | using __projected_iterator _LIBCPP_NODEBUG = _It; | |
| 43 | using __projected_projection _LIBCPP_NODEBUG = _Proj; | |
| 44 | ||
| 37 | 45 | using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>; |
| 38 | 46 | using difference_type = iter_difference_t<_It>; |
| 39 | 47 | indirect_result_t<_Proj&, _It> operator*() const; // not defined |
lib/libcxx/include/__iterator/ranges_iterator_traits.h+3-3| ... | ... | @@ -24,13 +24,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | #if _LIBCPP_STD_VER >= 23 |
| 25 | 25 | |
| 26 | 26 | template <ranges::input_range _Range> |
| 27 | using __range_key_type = __remove_const_t<typename ranges::range_value_t<_Range>::first_type>; | |
| 27 | using __range_key_type _LIBCPP_NODEBUG = __remove_const_t<typename ranges::range_value_t<_Range>::first_type>; | |
| 28 | 28 | |
| 29 | 29 | template <ranges::input_range _Range> |
| 30 | using __range_mapped_type = typename ranges::range_value_t<_Range>::second_type; | |
| 30 | using __range_mapped_type _LIBCPP_NODEBUG = typename ranges::range_value_t<_Range>::second_type; | |
| 31 | 31 | |
| 32 | 32 | template <ranges::input_range _Range> |
| 33 | using __range_to_alloc_type = | |
| 33 | using __range_to_alloc_type _LIBCPP_NODEBUG = | |
| 34 | 34 | pair<const typename ranges::range_value_t<_Range>::first_type, typename ranges::range_value_t<_Range>::second_type>; |
| 35 | 35 | |
| 36 | 36 | #endif |
lib/libcxx/include/__iterator/reverse_access.h-1| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__iterator/reverse_iterator.h> |
| 15 | #include <cstddef> | |
| 16 | 15 | #include <initializer_list> |
| 17 | 16 | |
| 18 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__iterator/reverse_iterator.h+6-4| ... | ... | @@ -136,10 +136,12 @@ public: |
| 136 | 136 | _LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const |
| 137 | 137 | requires is_pointer_v<_Iter> || requires(const _Iter __i) { __i.operator->(); } |
| 138 | 138 | { |
| 139 | _Iter __tmp = current; | |
| 140 | --__tmp; | |
| 139 | 141 | if constexpr (is_pointer_v<_Iter>) { |
| 140 | return std::prev(current); | |
| 142 | return __tmp; | |
| 141 | 143 | } else { |
| 142 | return std::prev(current).operator->(); | |
| 144 | return __tmp.operator->(); | |
| 143 | 145 | } |
| 144 | 146 | } |
| 145 | 147 | #else |
| ... | ... | @@ -327,8 +329,8 @@ __reverse_range(_Range&& __range) { |
| 327 | 329 | |
| 328 | 330 | template <class _Iter, bool __b> |
| 329 | 331 | struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b> { |
| 330 | using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>())); | |
| 331 | using _ReverseWrapper = reverse_iterator<reverse_iterator<_Iter> >; | |
| 332 | using _UnwrappedIter _LIBCPP_NODEBUG = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>())); | |
| 333 | using _ReverseWrapper _LIBCPP_NODEBUG = reverse_iterator<reverse_iterator<_Iter> >; | |
| 332 | 334 | |
| 333 | 335 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper |
| 334 | 336 | __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) { |
lib/libcxx/include/__iterator/segmented_iterator.h+2-2| ... | ... | @@ -41,8 +41,8 @@ |
| 41 | 41 | // Returns the iterator composed of the segment iterator and local iterator. |
| 42 | 42 | |
| 43 | 43 | #include <__config> |
| 44 | #include <__cstddef/size_t.h> | |
| 44 | 45 | #include <__type_traits/integral_constant.h> |
| 45 | #include <cstddef> | |
| 46 | 46 | |
| 47 | 47 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 48 | 48 | # pragma GCC system_header |
| ... | ... | @@ -72,7 +72,7 @@ template <class _Tp> |
| 72 | 72 | struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {}; |
| 73 | 73 | |
| 74 | 74 | template <class _Iterator> |
| 75 | using __is_segmented_iterator = __has_specialization<__segmented_iterator_traits<_Iterator> >; | |
| 75 | using __is_segmented_iterator _LIBCPP_NODEBUG = __has_specialization<__segmented_iterator_traits<_Iterator> >; | |
| 76 | 76 | |
| 77 | 77 | _LIBCPP_END_NAMESPACE_STD |
| 78 | 78 |
lib/libcxx/include/__iterator/size.h+2-1| ... | ... | @@ -11,9 +11,10 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_SIZE_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 15 | #include <__cstddef/size_t.h> | |
| 14 | 16 | #include <__type_traits/common_type.h> |
| 15 | 17 | #include <__type_traits/make_signed.h> |
| 16 | #include <cstddef> | |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 20 | # pragma GCC system_header |
lib/libcxx/include/__iterator/static_bounded_iter.h created+318| ... | ... | @@ -0,0 +1,318 @@ |
| 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___ITERATOR_STATIC_BOUNDED_ITER_H | |
| 11 | #define _LIBCPP___ITERATOR_STATIC_BOUNDED_ITER_H | |
| 12 | ||
| 13 | #include <__assert> | |
| 14 | #include <__compare/ordering.h> | |
| 15 | #include <__compare/three_way_comparable.h> | |
| 16 | #include <__config> | |
| 17 | #include <__cstddef/size_t.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__memory/pointer_traits.h> | |
| 20 | #include <__type_traits/conjunction.h> | |
| 21 | #include <__type_traits/disjunction.h> | |
| 22 | #include <__type_traits/enable_if.h> | |
| 23 | #include <__type_traits/integral_constant.h> | |
| 24 | #include <__type_traits/is_convertible.h> | |
| 25 | #include <__type_traits/is_same.h> | |
| 26 | #include <__type_traits/make_const_lvalue_ref.h> | |
| 27 | #include <__utility/move.h> | |
| 28 | ||
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 30 | # pragma GCC system_header | |
| 31 | #endif | |
| 32 | ||
| 33 | _LIBCPP_PUSH_MACROS | |
| 34 | #include <__undef_macros> | |
| 35 | ||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 37 | ||
| 38 | template <class _Iterator, size_t _Size> | |
| 39 | struct __static_bounded_iter_storage { | |
| 40 | _LIBCPP_HIDE_FROM_ABI __static_bounded_iter_storage() = default; | |
| 41 | _LIBCPP_HIDE_FROM_ABI | |
| 42 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __static_bounded_iter_storage(_Iterator __current, _Iterator __begin) | |
| 43 | : __current_(__current), __begin_(__begin) {} | |
| 44 | ||
| 45 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator& __current() _NOEXCEPT { return __current_; } | |
| 46 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __current() const _NOEXCEPT { return __current_; } | |
| 47 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __begin() const _NOEXCEPT { return __begin_; } | |
| 48 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __end() const _NOEXCEPT { return __begin_ + _Size; } | |
| 49 | ||
| 50 | private: | |
| 51 | _Iterator __current_; // current iterator | |
| 52 | _Iterator __begin_; // start of the valid range, which is [__begin_, __begin_ + _Size) | |
| 53 | }; | |
| 54 | ||
| 55 | template <class _Iterator> | |
| 56 | struct __static_bounded_iter_storage<_Iterator, 0> { | |
| 57 | _LIBCPP_HIDE_FROM_ABI __static_bounded_iter_storage() = default; | |
| 58 | _LIBCPP_HIDE_FROM_ABI | |
| 59 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __static_bounded_iter_storage(_Iterator __current, _Iterator /* __begin */) | |
| 60 | : __current_(__current) {} | |
| 61 | ||
| 62 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator& __current() _NOEXCEPT { return __current_; } | |
| 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __current() const _NOEXCEPT { return __current_; } | |
| 64 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __begin() const _NOEXCEPT { return __current_; } | |
| 65 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __end() const _NOEXCEPT { return __current_; } | |
| 66 | ||
| 67 | private: | |
| 68 | _Iterator __current_; // current iterator | |
| 69 | }; | |
| 70 | ||
| 71 | // This is an iterator wrapper for contiguous iterators that points within a range | |
| 72 | // whose size is known at compile-time. This is very similar to `__bounded_iter`, | |
| 73 | // except that we don't have to store the end of the range in physical memory since | |
| 74 | // it can be computed from the start of the range. | |
| 75 | // | |
| 76 | // The operations on which this iterator wrapper traps are the same as `__bounded_iter`. | |
| 77 | template <class _Iterator, size_t _Size> | |
| 78 | struct __static_bounded_iter { | |
| 79 | static_assert(__libcpp_is_contiguous_iterator<_Iterator>::value, | |
| 80 | "Only contiguous iterators can be adapted by __static_bounded_iter."); | |
| 81 | ||
| 82 | using value_type = typename iterator_traits<_Iterator>::value_type; | |
| 83 | using difference_type = typename iterator_traits<_Iterator>::difference_type; | |
| 84 | using pointer = typename iterator_traits<_Iterator>::pointer; | |
| 85 | using reference = typename iterator_traits<_Iterator>::reference; | |
| 86 | using iterator_category = typename iterator_traits<_Iterator>::iterator_category; | |
| 87 | #if _LIBCPP_STD_VER >= 20 | |
| 88 | using iterator_concept = contiguous_iterator_tag; | |
| 89 | #endif | |
| 90 | ||
| 91 | // Create a singular iterator. | |
| 92 | // | |
| 93 | // Such an iterator points past the end of an empty range, so it is not dereferenceable. | |
| 94 | // Operations like comparison and assignment are valid. | |
| 95 | _LIBCPP_HIDE_FROM_ABI __static_bounded_iter() = default; | |
| 96 | ||
| 97 | _LIBCPP_HIDE_FROM_ABI __static_bounded_iter(__static_bounded_iter const&) = default; | |
| 98 | _LIBCPP_HIDE_FROM_ABI __static_bounded_iter(__static_bounded_iter&&) = default; | |
| 99 | ||
| 100 | template <class _OtherIterator, | |
| 101 | __enable_if_t< | |
| 102 | _And< is_convertible<const _OtherIterator&, _Iterator>, | |
| 103 | _Or<is_same<reference, __iter_reference<_OtherIterator> >, | |
| 104 | is_same<reference, __make_const_lvalue_ref<__iter_reference<_OtherIterator> > > > >::value, | |
| 105 | int> = 0> | |
| 106 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 107 | __static_bounded_iter(__static_bounded_iter<_OtherIterator, _Size> const& __other) _NOEXCEPT | |
| 108 | : __storage_(__other.__storage_.__current(), __other.__storage_.__begin()) {} | |
| 109 | ||
| 110 | // Assign a bounded iterator to another one, rebinding the bounds of the iterator as well. | |
| 111 | _LIBCPP_HIDE_FROM_ABI __static_bounded_iter& operator=(__static_bounded_iter const&) = default; | |
| 112 | _LIBCPP_HIDE_FROM_ABI __static_bounded_iter& operator=(__static_bounded_iter&&) = default; | |
| 113 | ||
| 114 | private: | |
| 115 | // Create an iterator wrapping the given iterator, and whose bounds are described | |
| 116 | // by the provided [begin, begin + _Size] range. | |
| 117 | _LIBCPP_HIDE_FROM_ABI | |
| 118 | _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __static_bounded_iter(_Iterator __current, _Iterator __begin) | |
| 119 | : __storage_(__current, __begin) { | |
| 120 | _LIBCPP_ASSERT_INTERNAL( | |
| 121 | __begin <= __current, "__static_bounded_iter(current, begin): current and begin are inconsistent"); | |
| 122 | _LIBCPP_ASSERT_INTERNAL( | |
| 123 | __current <= __end(), "__static_bounded_iter(current, begin): current and (begin + Size) are inconsistent"); | |
| 124 | } | |
| 125 | ||
| 126 | template <size_t _Sz, class _It> | |
| 127 | friend _LIBCPP_CONSTEXPR __static_bounded_iter<_It, _Sz> __make_static_bounded_iter(_It, _It); | |
| 128 | ||
| 129 | public: | |
| 130 | // Dereference and indexing operations. | |
| 131 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { | |
| 132 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 133 | __current() != __end(), "__static_bounded_iter::operator*: Attempt to dereference an iterator at the end"); | |
| 134 | return *__current(); | |
| 135 | } | |
| 136 | ||
| 137 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT { | |
| 138 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 139 | __current() != __end(), "__static_bounded_iter::operator->: Attempt to dereference an iterator at the end"); | |
| 140 | return std::__to_address(__current()); | |
| 141 | } | |
| 142 | ||
| 143 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT { | |
| 144 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 145 | __n >= __begin() - __current(), | |
| 146 | "__static_bounded_iter::operator[]: Attempt to index an iterator past the start"); | |
| 147 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 148 | __n < __end() - __current(), | |
| 149 | "__static_bounded_iter::operator[]: Attempt to index an iterator at or past the end"); | |
| 150 | return __current()[__n]; | |
| 151 | } | |
| 152 | ||
| 153 | // Arithmetic operations. | |
| 154 | // | |
| 155 | // These operations check that the iterator remains within `[begin, end]`. | |
| 156 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter& operator++() _NOEXCEPT { | |
| 157 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 158 | __current() != __end(), "__static_bounded_iter::operator++: Attempt to advance an iterator past the end"); | |
| 159 | ++__current(); | |
| 160 | return *this; | |
| 161 | } | |
| 162 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter operator++(int) _NOEXCEPT { | |
| 163 | __static_bounded_iter __tmp(*this); | |
| 164 | ++*this; | |
| 165 | return __tmp; | |
| 166 | } | |
| 167 | ||
| 168 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter& operator--() _NOEXCEPT { | |
| 169 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 170 | __current() != __begin(), "__static_bounded_iter::operator--: Attempt to rewind an iterator past the start"); | |
| 171 | --__current(); | |
| 172 | return *this; | |
| 173 | } | |
| 174 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter operator--(int) _NOEXCEPT { | |
| 175 | __static_bounded_iter __tmp(*this); | |
| 176 | --*this; | |
| 177 | return __tmp; | |
| 178 | } | |
| 179 | ||
| 180 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter& operator+=(difference_type __n) _NOEXCEPT { | |
| 181 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 182 | __n >= __begin() - __current(), | |
| 183 | "__static_bounded_iter::operator+=: Attempt to rewind an iterator past the start"); | |
| 184 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 185 | __n <= __end() - __current(), "__static_bounded_iter::operator+=: Attempt to advance an iterator past the end"); | |
| 186 | __current() += __n; | |
| 187 | return *this; | |
| 188 | } | |
| 189 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter | |
| 190 | operator+(__static_bounded_iter const& __self, difference_type __n) _NOEXCEPT { | |
| 191 | __static_bounded_iter __tmp(__self); | |
| 192 | __tmp += __n; | |
| 193 | return __tmp; | |
| 194 | } | |
| 195 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter | |
| 196 | operator+(difference_type __n, __static_bounded_iter const& __self) _NOEXCEPT { | |
| 197 | __static_bounded_iter __tmp(__self); | |
| 198 | __tmp += __n; | |
| 199 | return __tmp; | |
| 200 | } | |
| 201 | ||
| 202 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __static_bounded_iter& operator-=(difference_type __n) _NOEXCEPT { | |
| 203 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 204 | __n <= __current() - __begin(), | |
| 205 | "__static_bounded_iter::operator-=: Attempt to rewind an iterator past the start"); | |
| 206 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 207 | __n >= __current() - __end(), "__static_bounded_iter::operator-=: Attempt to advance an iterator past the end"); | |
| 208 | __current() -= __n; | |
| 209 | return *this; | |
| 210 | } | |
| 211 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter | |
| 212 | operator-(__static_bounded_iter const& __self, difference_type __n) _NOEXCEPT { | |
| 213 | __static_bounded_iter __tmp(__self); | |
| 214 | __tmp -= __n; | |
| 215 | return __tmp; | |
| 216 | } | |
| 217 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend difference_type | |
| 218 | operator-(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT { | |
| 219 | return __x.__current() - __y.__current(); | |
| 220 | } | |
| 221 | ||
| 222 | // Comparison operations. | |
| 223 | // | |
| 224 | // These operations do not check whether the iterators are within their bounds. | |
| 225 | // The valid range for each iterator is also not considered as part of the comparison, | |
| 226 | // i.e. two iterators pointing to the same location will be considered equal even | |
| 227 | // if they have different validity ranges. | |
| 228 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 229 | operator==(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT { | |
| 230 | return __x.__current() == __y.__current(); | |
| 231 | } | |
| 232 | ||
| 233 | #if _LIBCPP_STD_VER <= 17 | |
| 234 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 235 | operator!=(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT { | |
| 236 | return __x.__current() != __y.__current(); | |
| 237 | } | |
| 238 | ||
| 239 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 240 | operator<(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT { | |
| 241 | return __x.__current() < __y.__current(); | |
| 242 | } | |
| 243 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 244 | operator>(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT { | |
| 245 | return __x.__current() > __y.__current(); | |
| 246 | } | |
| 247 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 248 | operator<=(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT { | |
| 249 | return __x.__current() <= __y.__current(); | |
| 250 | } | |
| 251 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 252 | operator>=(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT { | |
| 253 | return __x.__current() >= __y.__current(); | |
| 254 | } | |
| 255 | ||
| 256 | #else | |
| 257 | _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering | |
| 258 | operator<=>(__static_bounded_iter const& __x, __static_bounded_iter const& __y) noexcept { | |
| 259 | if constexpr (three_way_comparable<_Iterator, strong_ordering>) { | |
| 260 | return __x.__current() <=> __y.__current(); | |
| 261 | } else { | |
| 262 | if (__x.__current() < __y.__current()) | |
| 263 | return strong_ordering::less; | |
| 264 | ||
| 265 | if (__x.__current() == __y.__current()) | |
| 266 | return strong_ordering::equal; | |
| 267 | ||
| 268 | return strong_ordering::greater; | |
| 269 | } | |
| 270 | } | |
| 271 | #endif // _LIBCPP_STD_VER >= 20 | |
| 272 | ||
| 273 | private: | |
| 274 | template <class> | |
| 275 | friend struct pointer_traits; | |
| 276 | template <class, size_t> | |
| 277 | friend struct __static_bounded_iter; | |
| 278 | __static_bounded_iter_storage<_Iterator, _Size> __storage_; | |
| 279 | ||
| 280 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator& __current() _NOEXCEPT { | |
| 281 | return __storage_.__current(); | |
| 282 | } | |
| 283 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __current() const _NOEXCEPT { | |
| 284 | return __storage_.__current(); | |
| 285 | } | |
| 286 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __begin() const _NOEXCEPT { | |
| 287 | return __storage_.__begin(); | |
| 288 | } | |
| 289 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iterator __end() const _NOEXCEPT { return __storage_.__end(); } | |
| 290 | }; | |
| 291 | ||
| 292 | template <size_t _Size, class _It> | |
| 293 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __static_bounded_iter<_It, _Size> | |
| 294 | __make_static_bounded_iter(_It __it, _It __begin) { | |
| 295 | return __static_bounded_iter<_It, _Size>(std::move(__it), std::move(__begin)); | |
| 296 | } | |
| 297 | ||
| 298 | #if _LIBCPP_STD_VER <= 17 | |
| 299 | template <class _Iterator, size_t _Size> | |
| 300 | struct __libcpp_is_contiguous_iterator<__static_bounded_iter<_Iterator, _Size> > : true_type {}; | |
| 301 | #endif | |
| 302 | ||
| 303 | template <class _Iterator, size_t _Size> | |
| 304 | struct pointer_traits<__static_bounded_iter<_Iterator, _Size> > { | |
| 305 | using pointer = __static_bounded_iter<_Iterator, _Size>; | |
| 306 | using element_type = typename pointer_traits<_Iterator>::element_type; | |
| 307 | using difference_type = typename pointer_traits<_Iterator>::difference_type; | |
| 308 | ||
| 309 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static element_type* to_address(pointer __it) _NOEXCEPT { | |
| 310 | return std::__to_address(__it.__current()); | |
| 311 | } | |
| 312 | }; | |
| 313 | ||
| 314 | _LIBCPP_END_NAMESPACE_STD | |
| 315 | ||
| 316 | _LIBCPP_POP_MACROS | |
| 317 | ||
| 318 | #endif // _LIBCPP___ITERATOR_STATIC_BOUNDED_ITER_H |
lib/libcxx/include/__iterator/wrap_iter.h+15-8| ... | ... | @@ -13,12 +13,17 @@ |
| 13 | 13 | #include <__compare/ordering.h> |
| 14 | 14 | #include <__compare/three_way_comparable.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__cstddef/size_t.h> | |
| 16 | 17 | #include <__iterator/iterator_traits.h> |
| 17 | 18 | #include <__memory/addressof.h> |
| 18 | 19 | #include <__memory/pointer_traits.h> |
| 20 | #include <__type_traits/conjunction.h> | |
| 21 | #include <__type_traits/disjunction.h> | |
| 19 | 22 | #include <__type_traits/enable_if.h> |
| 23 | #include <__type_traits/integral_constant.h> | |
| 20 | 24 | #include <__type_traits/is_convertible.h> |
| 21 | #include <cstddef> | |
| 25 | #include <__type_traits/is_same.h> | |
| 26 | #include <__type_traits/make_const_lvalue_ref.h> | |
| 22 | 27 | |
| 23 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | 29 | # pragma GCC system_header |
| ... | ... | @@ -44,9 +49,14 @@ private: |
| 44 | 49 | |
| 45 | 50 | public: |
| 46 | 51 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT : __i_() {} |
| 47 | template <class _Up, __enable_if_t<is_convertible<_Up, iterator_type>::value, int> = 0> | |
| 48 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter(const __wrap_iter<_Up>& __u) _NOEXCEPT | |
| 49 | : __i_(__u.base()) {} | |
| 52 | template < | |
| 53 | class _OtherIter, | |
| 54 | __enable_if_t< _And< is_convertible<const _OtherIter&, _Iter>, | |
| 55 | _Or<is_same<reference, __iter_reference<_OtherIter> >, | |
| 56 | is_same<reference, __make_const_lvalue_ref<__iter_reference<_OtherIter> > > > >::value, | |
| 57 | int> = 0> | |
| 58 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter(const __wrap_iter<_OtherIter>& __u) _NOEXCEPT | |
| 59 | : __i_(__u.__i_) {} | |
| 50 | 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { return *__i_; } |
| 51 | 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT { |
| 52 | 62 | return std::__to_address(__i_); |
| ... | ... | @@ -145,9 +155,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool |
| 145 | 155 | operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT { |
| 146 | 156 | return !(__x == __y); |
| 147 | 157 | } |
| 148 | #endif | |
| 149 | ||
| 150 | // TODO(mordante) disable these overloads in the LLVM 20 release. | |
| 151 | 158 | template <class _Iter1> |
| 152 | 159 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool |
| 153 | 160 | operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { |
| ... | ... | @@ -184,7 +191,7 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX |
| 184 | 191 | return !(__y < __x); |
| 185 | 192 | } |
| 186 | 193 | |
| 187 | #if _LIBCPP_STD_VER >= 20 | |
| 194 | #else | |
| 188 | 195 | template <class _Iter1, class _Iter2> |
| 189 | 196 | _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering |
| 190 | 197 | operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept { |
lib/libcxx/include/__locale+34-31| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__locale_dir/locale_base_api.h> |
| 15 | #include <__memory/shared_ptr.h> // __shared_count | |
| 15 | #include <__memory/shared_count.h> | |
| 16 | 16 | #include <__mutex/once_flag.h> |
| 17 | 17 | #include <__type_traits/make_unsigned.h> |
| 18 | 18 | #include <__utility/no_destroy.h> |
| ... | ... | @@ -27,7 +27,7 @@ |
| 27 | 27 | #include <cstddef> |
| 28 | 28 | #include <cstring> |
| 29 | 29 | |
| 30 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 30 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 31 | 31 | # include <cwchar> |
| 32 | 32 | #else |
| 33 | 33 | # include <__std_mbstate_t.h> |
| ... | ... | @@ -50,7 +50,7 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&); |
| 50 | 50 | class _LIBCPP_EXPORTED_FROM_ABI locale { |
| 51 | 51 | public: |
| 52 | 52 | // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor. |
| 53 | using __trivially_relocatable = locale; | |
| 53 | using __trivially_relocatable _LIBCPP_NODEBUG = locale; | |
| 54 | 54 | |
| 55 | 55 | // types: |
| 56 | 56 | class _LIBCPP_EXPORTED_FROM_ABI facet; |
| ... | ... | @@ -60,8 +60,9 @@ public: |
| 60 | 60 | |
| 61 | 61 | static const category // values assigned here are for exposition only |
| 62 | 62 | none = 0, |
| 63 | collate = LC_COLLATE_MASK, ctype = LC_CTYPE_MASK, monetary = LC_MONETARY_MASK, numeric = LC_NUMERIC_MASK, | |
| 64 | time = LC_TIME_MASK, messages = LC_MESSAGES_MASK, all = collate | ctype | monetary | numeric | time | messages; | |
| 63 | collate = _LIBCPP_COLLATE_MASK, ctype = _LIBCPP_CTYPE_MASK, monetary = _LIBCPP_MONETARY_MASK, | |
| 64 | numeric = _LIBCPP_NUMERIC_MASK, time = _LIBCPP_TIME_MASK, messages = _LIBCPP_MESSAGES_MASK, | |
| 65 | all = collate | ctype | monetary | numeric | time | messages; | |
| 65 | 66 | |
| 66 | 67 | // construct/copy/destroy: |
| 67 | 68 | locale() _NOEXCEPT; |
| ... | ... | @@ -236,7 +237,7 @@ long collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) cons |
| 236 | 237 | } |
| 237 | 238 | |
| 238 | 239 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>; |
| 239 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 240 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 240 | 241 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>; |
| 241 | 242 | #endif |
| 242 | 243 | |
| ... | ... | @@ -247,7 +248,7 @@ class _LIBCPP_TEMPLATE_VIS collate_byname; |
| 247 | 248 | |
| 248 | 249 | template <> |
| 249 | 250 | class _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> : public collate<char> { |
| 250 | locale_t __l_; | |
| 251 | __locale::__locale_t __l_; | |
| 251 | 252 | |
| 252 | 253 | public: |
| 253 | 254 | typedef char char_type; |
| ... | ... | @@ -263,10 +264,10 @@ protected: |
| 263 | 264 | string_type do_transform(const char_type* __lo, const char_type* __hi) const override; |
| 264 | 265 | }; |
| 265 | 266 | |
| 266 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 267 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 267 | 268 | template <> |
| 268 | 269 | class _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> : public collate<wchar_t> { |
| 269 | locale_t __l_; | |
| 270 | __locale::__locale_t __l_; | |
| 270 | 271 | |
| 271 | 272 | public: |
| 272 | 273 | typedef wchar_t char_type; |
| ... | ... | @@ -348,7 +349,7 @@ public: |
| 348 | 349 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA |
| 349 | 350 | #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) |
| 350 | 351 | # ifdef __APPLE__ |
| 351 | typedef __uint32_t mask; | |
| 352 | typedef uint32_t mask; | |
| 352 | 353 | # elif defined(__FreeBSD__) |
| 353 | 354 | typedef unsigned long mask; |
| 354 | 355 | # elif defined(__NetBSD__) |
| ... | ... | @@ -449,7 +450,7 @@ public: |
| 449 | 450 | template <class _CharT> |
| 450 | 451 | class _LIBCPP_TEMPLATE_VIS ctype; |
| 451 | 452 | |
| 452 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 453 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 453 | 454 | template <> |
| 454 | 455 | class _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t> : public locale::facet, public ctype_base { |
| 455 | 456 | public: |
| ... | ... | @@ -514,7 +515,9 @@ protected: |
| 514 | 515 | virtual const char_type* |
| 515 | 516 | do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; |
| 516 | 517 | }; |
| 517 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 518 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 519 | ||
| 520 | inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_isascii(int __c) { return (__c & ~0x7F) == 0; } | |
| 518 | 521 | |
| 519 | 522 | template <> |
| 520 | 523 | class _LIBCPP_EXPORTED_FROM_ABI ctype<char> : public locale::facet, public ctype_base { |
| ... | ... | @@ -527,25 +530,25 @@ public: |
| 527 | 530 | explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0); |
| 528 | 531 | |
| 529 | 532 | _LIBCPP_HIDE_FROM_ABI bool is(mask __m, char_type __c) const { |
| 530 | return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) != 0 : false; | |
| 533 | return std::__libcpp_isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) != 0 : false; | |
| 531 | 534 | } |
| 532 | 535 | |
| 533 | 536 | _LIBCPP_HIDE_FROM_ABI const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const { |
| 534 | 537 | for (; __low != __high; ++__low, ++__vec) |
| 535 | *__vec = isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0; | |
| 538 | *__vec = std::__libcpp_isascii(*__low) ? __tab_[static_cast<int>(*__low)] : 0; | |
| 536 | 539 | return __low; |
| 537 | 540 | } |
| 538 | 541 | |
| 539 | 542 | _LIBCPP_HIDE_FROM_ABI const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const { |
| 540 | 543 | for (; __low != __high; ++__low) |
| 541 | if (isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)) | |
| 544 | if (std::__libcpp_isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m)) | |
| 542 | 545 | break; |
| 543 | 546 | return __low; |
| 544 | 547 | } |
| 545 | 548 | |
| 546 | 549 | _LIBCPP_HIDE_FROM_ABI const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const { |
| 547 | 550 | for (; __low != __high; ++__low) |
| 548 | if (!isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m)) | |
| 551 | if (!std::__libcpp_isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m)) | |
| 549 | 552 | break; |
| 550 | 553 | return __low; |
| 551 | 554 | } |
| ... | ... | @@ -616,7 +619,7 @@ class _LIBCPP_TEMPLATE_VIS ctype_byname; |
| 616 | 619 | |
| 617 | 620 | template <> |
| 618 | 621 | class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> : public ctype<char> { |
| 619 | locale_t __l_; | |
| 622 | __locale::__locale_t __l_; | |
| 620 | 623 | |
| 621 | 624 | public: |
| 622 | 625 | explicit ctype_byname(const char*, size_t = 0); |
| ... | ... | @@ -630,10 +633,10 @@ protected: |
| 630 | 633 | const char_type* do_tolower(char_type* __low, const char_type* __high) const override; |
| 631 | 634 | }; |
| 632 | 635 | |
| 633 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 636 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 634 | 637 | template <> |
| 635 | 638 | class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> : public ctype<wchar_t> { |
| 636 | locale_t __l_; | |
| 639 | __locale::__locale_t __l_; | |
| 637 | 640 | |
| 638 | 641 | public: |
| 639 | 642 | explicit ctype_byname(const char*, size_t = 0); |
| ... | ... | @@ -655,7 +658,7 @@ protected: |
| 655 | 658 | const char_type* |
| 656 | 659 | do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override; |
| 657 | 660 | }; |
| 658 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 661 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 659 | 662 | |
| 660 | 663 | template <class _CharT> |
| 661 | 664 | inline _LIBCPP_HIDE_FROM_ABI bool isspace(_CharT __c, const locale& __loc) { |
| ... | ... | @@ -821,10 +824,10 @@ protected: |
| 821 | 824 | |
| 822 | 825 | // template <> class codecvt<wchar_t, char, mbstate_t> |
| 823 | 826 | |
| 824 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 827 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 825 | 828 | template <> |
| 826 | 829 | class _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> : public locale::facet, public codecvt_base { |
| 827 | locale_t __l_; | |
| 830 | __locale::__locale_t __l_; | |
| 828 | 831 | |
| 829 | 832 | public: |
| 830 | 833 | typedef wchar_t intern_type; |
| ... | ... | @@ -900,7 +903,7 @@ protected: |
| 900 | 903 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; |
| 901 | 904 | virtual int do_max_length() const _NOEXCEPT; |
| 902 | 905 | }; |
| 903 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 906 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 904 | 907 | |
| 905 | 908 | // template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20 |
| 906 | 909 | |
| ... | ... | @@ -982,7 +985,7 @@ protected: |
| 982 | 985 | virtual int do_max_length() const _NOEXCEPT; |
| 983 | 986 | }; |
| 984 | 987 | |
| 985 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 988 | #if _LIBCPP_HAS_CHAR8_T | |
| 986 | 989 | |
| 987 | 990 | // template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20 |
| 988 | 991 | |
| ... | ... | @@ -1145,7 +1148,7 @@ protected: |
| 1145 | 1148 | virtual int do_max_length() const _NOEXCEPT; |
| 1146 | 1149 | }; |
| 1147 | 1150 | |
| 1148 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 1151 | #if _LIBCPP_HAS_CHAR8_T | |
| 1149 | 1152 | |
| 1150 | 1153 | // template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20 |
| 1151 | 1154 | |
| ... | ... | @@ -1248,14 +1251,14 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() {} |
| 1248 | 1251 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 1249 | 1252 | |
| 1250 | 1253 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>; |
| 1251 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1254 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1252 | 1255 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>; |
| 1253 | 1256 | #endif |
| 1254 | 1257 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 |
| 1255 | 1258 | _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20 |
| 1256 | 1259 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 |
| 1257 | 1260 | _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20 |
| 1258 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 1261 | #if _LIBCPP_HAS_CHAR8_T | |
| 1259 | 1262 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20 |
| 1260 | 1263 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20 |
| 1261 | 1264 | #endif |
| ... | ... | @@ -1438,7 +1441,7 @@ protected: |
| 1438 | 1441 | string __grouping_; |
| 1439 | 1442 | }; |
| 1440 | 1443 | |
| 1441 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1444 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1442 | 1445 | template <> |
| 1443 | 1446 | class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> : public locale::facet { |
| 1444 | 1447 | public: |
| ... | ... | @@ -1467,7 +1470,7 @@ protected: |
| 1467 | 1470 | char_type __thousands_sep_; |
| 1468 | 1471 | string __grouping_; |
| 1469 | 1472 | }; |
| 1470 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1473 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1471 | 1474 | |
| 1472 | 1475 | // template <class charT> class numpunct_byname |
| 1473 | 1476 | |
| ... | ... | @@ -1490,7 +1493,7 @@ private: |
| 1490 | 1493 | void __init(const char*); |
| 1491 | 1494 | }; |
| 1492 | 1495 | |
| 1493 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1496 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1494 | 1497 | template <> |
| 1495 | 1498 | class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> : public numpunct<wchar_t> { |
| 1496 | 1499 | public: |
| ... | ... | @@ -1506,7 +1509,7 @@ protected: |
| 1506 | 1509 | private: |
| 1507 | 1510 | void __init(const char*); |
| 1508 | 1511 | }; |
| 1509 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1512 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1510 | 1513 | |
| 1511 | 1514 | _LIBCPP_END_NAMESPACE_STD |
| 1512 | 1515 |
lib/libcxx/include/__locale_dir/locale_base_api.h+305-80| ... | ... | @@ -9,90 +9,315 @@ |
| 9 | 9 | #ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H |
| 10 | 10 | #define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H |
| 11 | 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 | |
| 12 | #include <__config> | |
| 31 | 13 | |
| 32 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 33 | 15 | # pragma GCC system_header |
| 34 | 16 | #endif |
| 35 | 17 | |
| 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 | */ | |
| 18 | // The platform-specific headers have to provide the following interface. | |
| 19 | // | |
| 20 | // These functions are equivalent to their C counterparts, except that __locale::__locale_t | |
| 21 | // is used instead of the current global locale. | |
| 22 | // | |
| 23 | // Variadic functions may be implemented as templates with a parameter pack instead | |
| 24 | // of C-style variadic functions. | |
| 25 | // | |
| 26 | // Most of these functions are only required when building the library. Functions that are also | |
| 27 | // required when merely using the headers are marked as such below. | |
| 28 | // | |
| 29 | // TODO: __localeconv shouldn't take a reference, but the Windows implementation doesn't allow copying __locale_t | |
| 30 | // TODO: Eliminate the need for any of these functions from the headers. | |
| 31 | // | |
| 32 | // Locale management | |
| 33 | // ----------------- | |
| 34 | // namespace __locale { | |
| 35 | // using __locale_t = implementation-defined; // required by the headers | |
| 36 | // using __lconv_t = implementation-defined; | |
| 37 | // __locale_t __newlocale(int, const char*, __locale_t); | |
| 38 | // void __freelocale(__locale_t); | |
| 39 | // char* __setlocale(int, const char*); | |
| 40 | // __lconv_t* __localeconv(__locale_t&); | |
| 41 | // } | |
| 42 | // | |
| 43 | // // required by the headers | |
| 44 | // #define _LIBCPP_COLLATE_MASK /* implementation-defined */ | |
| 45 | // #define _LIBCPP_CTYPE_MASK /* implementation-defined */ | |
| 46 | // #define _LIBCPP_MONETARY_MASK /* implementation-defined */ | |
| 47 | // #define _LIBCPP_NUMERIC_MASK /* implementation-defined */ | |
| 48 | // #define _LIBCPP_TIME_MASK /* implementation-defined */ | |
| 49 | // #define _LIBCPP_MESSAGES_MASK /* implementation-defined */ | |
| 50 | // #define _LIBCPP_ALL_MASK /* implementation-defined */ | |
| 51 | // #define _LIBCPP_LC_ALL /* implementation-defined */ | |
| 52 | // | |
| 53 | // Strtonum functions | |
| 54 | // ------------------ | |
| 55 | // namespace __locale { | |
| 56 | // // required by the headers | |
| 57 | // float __strtof(const char*, char**, __locale_t); | |
| 58 | // double __strtod(const char*, char**, __locale_t); | |
| 59 | // long double __strtold(const char*, char**, __locale_t); | |
| 60 | // long long __strtoll(const char*, char**, __locale_t); | |
| 61 | // unsigned long long __strtoull(const char*, char**, __locale_t); | |
| 62 | // } | |
| 63 | // | |
| 64 | // Character manipulation functions | |
| 65 | // -------------------------------- | |
| 66 | // namespace __locale { | |
| 67 | // int __islower(int, __locale_t); | |
| 68 | // int __isupper(int, __locale_t); | |
| 69 | // int __isdigit(int, __locale_t); // required by the headers | |
| 70 | // int __isxdigit(int, __locale_t); // required by the headers | |
| 71 | // int __toupper(int, __locale_t); | |
| 72 | // int __tolower(int, __locale_t); | |
| 73 | // int __strcoll(const char*, const char*, __locale_t); | |
| 74 | // size_t __strxfrm(char*, const char*, size_t, __locale_t); | |
| 75 | // | |
| 76 | // int __iswctype(wint_t, wctype_t, __locale_t); | |
| 77 | // int __iswspace(wint_t, __locale_t); | |
| 78 | // int __iswprint(wint_t, __locale_t); | |
| 79 | // int __iswcntrl(wint_t, __locale_t); | |
| 80 | // int __iswupper(wint_t, __locale_t); | |
| 81 | // int __iswlower(wint_t, __locale_t); | |
| 82 | // int __iswalpha(wint_t, __locale_t); | |
| 83 | // int __iswblank(wint_t, __locale_t); | |
| 84 | // int __iswdigit(wint_t, __locale_t); | |
| 85 | // int __iswpunct(wint_t, __locale_t); | |
| 86 | // int __iswxdigit(wint_t, __locale_t); | |
| 87 | // wint_t __towupper(wint_t, __locale_t); | |
| 88 | // wint_t __towlower(wint_t, __locale_t); | |
| 89 | // int __wcscoll(const wchar_t*, const wchar_t*, __locale_t); | |
| 90 | // size_t __wcsxfrm(wchar_t*, const wchar_t*, size_t, __locale_t); | |
| 91 | // | |
| 92 | // size_t __strftime(char*, size_t, const char*, const tm*, __locale_t); | |
| 93 | // } | |
| 94 | // | |
| 95 | // Other functions | |
| 96 | // --------------- | |
| 97 | // namespace __locale { | |
| 98 | // implementation-defined __mb_len_max(__locale_t); | |
| 99 | // wint_t __btowc(int, __locale_t); | |
| 100 | // int __wctob(wint_t, __locale_t); | |
| 101 | // size_t __wcsnrtombs(char*, const wchar_t**, size_t, size_t, mbstate_t*, __locale_t); | |
| 102 | // size_t __wcrtomb(char*, wchar_t, mbstate_t*, __locale_t); | |
| 103 | // size_t __mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*, __locale_t); | |
| 104 | // size_t __mbrtowc(wchar_t*, const char*, size_t, mbstate_t*, __locale_t); | |
| 105 | // int __mbtowc(wchar_t*, const char*, size_t, __locale_t); | |
| 106 | // size_t __mbrlen(const char*, size_t, mbstate_t*, __locale_t); | |
| 107 | // size_t __mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*, __locale_t); | |
| 108 | // | |
| 109 | // int __snprintf(char*, size_t, __locale_t, const char*, ...); // required by the headers | |
| 110 | // int __asprintf(char**, __locale_t, const char*, ...); // required by the headers | |
| 111 | // int __sscanf(const char*, __locale_t, const char*, ...); // required by the headers | |
| 112 | // } | |
| 113 | ||
| 114 | #if defined(__APPLE__) | |
| 115 | # include <__locale_dir/support/apple.h> | |
| 116 | #elif defined(__FreeBSD__) | |
| 117 | # include <__locale_dir/support/freebsd.h> | |
| 118 | #elif defined(_LIBCPP_MSVCRT_LIKE) | |
| 119 | # include <__locale_dir/support/windows.h> | |
| 120 | #elif defined(__Fuchsia__) | |
| 121 | # include <__locale_dir/support/fuchsia.h> | |
| 122 | #else | |
| 123 | ||
| 124 | // TODO: This is a temporary definition to bridge between the old way we defined the locale base API | |
| 125 | // (by providing global non-reserved names) and the new API. As we move individual platforms | |
| 126 | // towards the new way of defining the locale base API, this should disappear since each platform | |
| 127 | // will define those directly. | |
| 128 | # if defined(_AIX) || defined(__MVS__) | |
| 129 | # include <__locale_dir/locale_base_api/ibm.h> | |
| 130 | # elif defined(__ANDROID__) | |
| 131 | # include <__locale_dir/locale_base_api/android.h> | |
| 132 | # elif defined(__OpenBSD__) | |
| 133 | # include <__locale_dir/locale_base_api/openbsd.h> | |
| 134 | # elif defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC | |
| 135 | # include <__locale_dir/locale_base_api/musl.h> | |
| 136 | # endif | |
| 137 | ||
| 138 | # include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> | |
| 139 | ||
| 140 | # include <__cstddef/size_t.h> | |
| 141 | # include <__utility/forward.h> | |
| 142 | # include <ctype.h> | |
| 143 | # include <string.h> | |
| 144 | # include <time.h> | |
| 145 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 146 | # include <wctype.h> | |
| 147 | # endif | |
| 148 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 149 | namespace __locale { | |
| 150 | // | |
| 151 | // Locale management | |
| 152 | // | |
| 153 | # define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK | |
| 154 | # define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK | |
| 155 | # define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK | |
| 156 | # define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK | |
| 157 | # define _LIBCPP_TIME_MASK LC_TIME_MASK | |
| 158 | # define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK | |
| 159 | # define _LIBCPP_ALL_MASK LC_ALL_MASK | |
| 160 | # define _LIBCPP_LC_ALL LC_ALL | |
| 161 | ||
| 162 | using __locale_t _LIBCPP_NODEBUG = locale_t; | |
| 163 | ||
| 164 | # if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 165 | using __lconv_t _LIBCPP_NODEBUG = lconv; | |
| 166 | ||
| 167 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) { | |
| 168 | return newlocale(__category_mask, __name, __loc); | |
| 169 | } | |
| 170 | ||
| 171 | inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __locale) { | |
| 172 | return ::setlocale(__category, __locale); | |
| 173 | } | |
| 174 | ||
| 175 | inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { freelocale(__loc); } | |
| 176 | ||
| 177 | inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return __libcpp_localeconv_l(__loc); } | |
| 178 | # endif // _LIBCPP_BUILDING_LIBRARY | |
| 179 | ||
| 180 | // | |
| 181 | // Strtonum functions | |
| 182 | // | |
| 183 | inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) { | |
| 184 | return strtof_l(__nptr, __endptr, __loc); | |
| 185 | } | |
| 186 | ||
| 187 | inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) { | |
| 188 | return strtod_l(__nptr, __endptr, __loc); | |
| 189 | } | |
| 190 | ||
| 191 | inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) { | |
| 192 | return strtold_l(__nptr, __endptr, __loc); | |
| 193 | } | |
| 194 | ||
| 195 | inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | |
| 196 | return strtoll_l(__nptr, __endptr, __base, __loc); | |
| 197 | } | |
| 198 | ||
| 199 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | |
| 200 | __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | |
| 201 | return strtoull_l(__nptr, __endptr, __base, __loc); | |
| 202 | } | |
| 203 | ||
| 204 | // | |
| 205 | // Character manipulation functions | |
| 206 | // | |
| 207 | # if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 208 | inline _LIBCPP_HIDE_FROM_ABI int __islower(int __ch, __locale_t __loc) { return islower_l(__ch, __loc); } | |
| 209 | inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __ch, __locale_t __loc) { return isupper_l(__ch, __loc); } | |
| 210 | # endif | |
| 211 | ||
| 212 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __ch, __locale_t __loc) { return isdigit_l(__ch, __loc); } | |
| 213 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __ch, __locale_t __loc) { return isxdigit_l(__ch, __loc); } | |
| 214 | ||
| 215 | # if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 216 | inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) { | |
| 217 | return strcoll_l(__s1, __s2, __loc); | |
| 218 | } | |
| 219 | inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) { | |
| 220 | return strxfrm_l(__dest, __src, __n, __loc); | |
| 221 | } | |
| 222 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __ch, __locale_t __loc) { return toupper_l(__ch, __loc); } | |
| 223 | inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __ch, __locale_t __loc) { return tolower_l(__ch, __loc); } | |
| 224 | ||
| 225 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 226 | inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __s1, const wchar_t* __s2, __locale_t __loc) { | |
| 227 | return wcscoll_l(__s1, __s2, __loc); | |
| 228 | } | |
| 229 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) { | |
| 230 | return wcsxfrm_l(__dest, __src, __n, __loc); | |
| 231 | } | |
| 232 | inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __ch, wctype_t __type, __locale_t __loc) { | |
| 233 | return iswctype_l(__ch, __type, __loc); | |
| 234 | } | |
| 235 | inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __ch, __locale_t __loc) { return iswspace_l(__ch, __loc); } | |
| 236 | inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __ch, __locale_t __loc) { return iswprint_l(__ch, __loc); } | |
| 237 | inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __ch, __locale_t __loc) { return iswcntrl_l(__ch, __loc); } | |
| 238 | inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __ch, __locale_t __loc) { return iswupper_l(__ch, __loc); } | |
| 239 | inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __ch, __locale_t __loc) { return iswlower_l(__ch, __loc); } | |
| 240 | inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __ch, __locale_t __loc) { return iswalpha_l(__ch, __loc); } | |
| 241 | inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __ch, __locale_t __loc) { return iswblank_l(__ch, __loc); } | |
| 242 | inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __ch, __locale_t __loc) { return iswdigit_l(__ch, __loc); } | |
| 243 | inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __ch, __locale_t __loc) { return iswpunct_l(__ch, __loc); } | |
| 244 | inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __ch, __locale_t __loc) { return iswxdigit_l(__ch, __loc); } | |
| 245 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __ch, __locale_t __loc) { return towupper_l(__ch, __loc); } | |
| 246 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __ch, __locale_t __loc) { return towlower_l(__ch, __loc); } | |
| 247 | # endif | |
| 248 | ||
| 249 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 250 | __strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __locale_t __loc) { | |
| 251 | return strftime_l(__s, __max, __format, __tm, __loc); | |
| 252 | } | |
| 253 | ||
| 254 | // | |
| 255 | // Other functions | |
| 256 | // | |
| 257 | inline _LIBCPP_HIDE_FROM_ABI decltype(__libcpp_mb_cur_max_l(__locale_t())) __mb_len_max(__locale_t __loc) { | |
| 258 | return __libcpp_mb_cur_max_l(__loc); | |
| 259 | } | |
| 260 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 261 | inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __ch, __locale_t __loc) { return __libcpp_btowc_l(__ch, __loc); } | |
| 262 | inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __ch, __locale_t __loc) { return __libcpp_wctob_l(__ch, __loc); } | |
| 263 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 264 | __wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) { | |
| 265 | return __libcpp_wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __loc); | |
| 266 | } | |
| 267 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __ch, mbstate_t* __ps, __locale_t __loc) { | |
| 268 | return __libcpp_wcrtomb_l(__s, __ch, __ps, __loc); | |
| 269 | } | |
| 270 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 271 | __mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) { | |
| 272 | return __libcpp_mbsnrtowcs_l(__dest, __src, __nms, __len, __ps, __loc); | |
| 273 | } | |
| 274 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 275 | __mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) { | |
| 276 | return __libcpp_mbrtowc_l(__pwc, __s, __n, __ps, __loc); | |
| 277 | } | |
| 278 | inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) { | |
| 279 | return __libcpp_mbtowc_l(__pwc, __pmb, __max, __loc); | |
| 280 | } | |
| 281 | inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) { | |
| 282 | return __libcpp_mbrlen_l(__s, __n, __ps, __loc); | |
| 283 | } | |
| 284 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 285 | __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) { | |
| 286 | return __libcpp_mbsrtowcs_l(__dest, __src, __len, __ps, __loc); | |
| 287 | } | |
| 288 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 289 | # endif // _LIBCPP_BUILDING_LIBRARY | |
| 290 | ||
| 291 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 292 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat") | |
| 293 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates | |
| 294 | # ifdef _LIBCPP_COMPILER_CLANG_BASED | |
| 295 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__) | |
| 296 | # else | |
| 297 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */ | |
| 298 | # endif | |
| 299 | ||
| 300 | template <class... _Args> | |
| 301 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf( | |
| 302 | char* __s, size_t __n, __locale_t __loc, const char* __format, _Args&&... __args) { | |
| 303 | return std::__libcpp_snprintf_l(__s, __n, __loc, __format, std::forward<_Args>(__args)...); | |
| 304 | } | |
| 305 | template <class... _Args> | |
| 306 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf( | |
| 307 | char** __s, __locale_t __loc, const char* __format, _Args&&... __args) { | |
| 308 | return std::__libcpp_asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...); | |
| 309 | } | |
| 310 | template <class... _Args> | |
| 311 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf( | |
| 312 | const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) { | |
| 313 | return std::__libcpp_sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...); | |
| 314 | } | |
| 315 | _LIBCPP_DIAGNOSTIC_POP | |
| 316 | # undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT | |
| 317 | ||
| 318 | } // namespace __locale | |
| 319 | _LIBCPP_END_NAMESPACE_STD | |
| 320 | ||
| 321 | #endif // Compatibility definition of locale base APIs | |
| 97 | 322 | |
| 98 | 323 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H |
lib/libcxx/include/__locale_dir/locale_base_api/android.h+4-9| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H | |
| 11 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H | |
| 10 | #ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H | |
| 11 | #define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H | |
| 12 | 12 | |
| 13 | 13 | #include <stdlib.h> |
| 14 | 14 | |
| ... | ... | @@ -18,9 +18,6 @@ extern "C" { |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | #include <android/api-level.h> |
| 21 | #if __ANDROID_API__ < 21 | |
| 22 | # include <__support/xlocale/__posix_l_fallback.h> | |
| 23 | #endif | |
| 24 | 21 | |
| 25 | 22 | // If we do not have this header, we are in a platform build rather than an NDK |
| 26 | 23 | // build, which will always be at least as new as the ToT NDK, in which case we |
| ... | ... | @@ -30,9 +27,7 @@ extern "C" { |
| 30 | 27 | // In NDK versions later than 16, locale-aware functions are provided by |
| 31 | 28 | // legacy_stdlib_inlines.h |
| 32 | 29 | # if __NDK_MAJOR__ <= 16 |
| 33 | # if __ANDROID_API__ < 21 | |
| 34 | # include <__support/xlocale/__strtonum_fallback.h> | |
| 35 | # elif __ANDROID_API__ < 26 | |
| 30 | # if __ANDROID_API__ < 26 | |
| 36 | 31 | |
| 37 | 32 | inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) { |
| 38 | 33 | return ::strtof(__nptr, __endptr); |
| ... | ... | @@ -47,4 +42,4 @@ inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr |
| 47 | 42 | # endif // __NDK_MAJOR__ <= 16 |
| 48 | 43 | #endif // __has_include(<android/ndk-version.h>) |
| 49 | 44 | |
| 50 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H | |
| 45 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H |
lib/libcxx/include/__locale_dir/locale_base_api/bsd_locale_defaults.h deleted-36| ... | ... | @@ -1,36 +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 | // The BSDs have lots of *_l functions. We don't want to define those symbols | |
| 10 | // on other platforms though, for fear of conflicts with user code. So here, | |
| 11 | // we will define the mapping from an internal macro to the real BSD symbol. | |
| 12 | //===----------------------------------------------------------------------===// | |
| 13 | ||
| 14 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_DEFAULTS_H | |
| 15 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_DEFAULTS_H | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | #define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc) | |
| 22 | #define __libcpp_btowc_l(ch, loc) btowc_l(ch, loc) | |
| 23 | #define __libcpp_wctob_l(wch, loc) wctob_l(wch, loc) | |
| 24 | #define __libcpp_wcsnrtombs_l(dst, src, nwc, len, ps, loc) wcsnrtombs_l(dst, src, nwc, len, ps, loc) | |
| 25 | #define __libcpp_wcrtomb_l(src, wc, ps, loc) wcrtomb_l(src, wc, ps, loc) | |
| 26 | #define __libcpp_mbsnrtowcs_l(dst, src, nms, len, ps, loc) mbsnrtowcs_l(dst, src, nms, len, ps, loc) | |
| 27 | #define __libcpp_mbrtowc_l(pwc, s, n, ps, l) mbrtowc_l(pwc, s, n, ps, l) | |
| 28 | #define __libcpp_mbtowc_l(pwc, pmb, max, l) mbtowc_l(pwc, pmb, max, l) | |
| 29 | #define __libcpp_mbrlen_l(s, n, ps, l) mbrlen_l(s, n, ps, l) | |
| 30 | #define __libcpp_localeconv_l(l) localeconv_l(l) | |
| 31 | #define __libcpp_mbsrtowcs_l(dest, src, len, ps, l) mbsrtowcs_l(dest, src, len, ps, l) | |
| 32 | #define __libcpp_snprintf_l(...) snprintf_l(__VA_ARGS__) | |
| 33 | #define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__) | |
| 34 | #define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__) | |
| 35 | ||
| 36 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_DEFAULTS_H |
lib/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h+38-24| ... | ... | @@ -10,15 +10,15 @@ |
| 10 | 10 | // of those functions for non-BSD platforms. |
| 11 | 11 | //===----------------------------------------------------------------------===// |
| 12 | 12 | |
| 13 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H | |
| 14 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H | |
| 13 | #ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H | |
| 14 | #define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H | |
| 15 | 15 | |
| 16 | #include <__locale_dir/locale_base_api/locale_guard.h> | |
| 17 | #include <cstdio> | |
| 16 | #include <locale.h> | |
| 18 | 17 | #include <stdarg.h> |
| 18 | #include <stdio.h> | |
| 19 | 19 | #include <stdlib.h> |
| 20 | 20 | |
| 21 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 21 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 22 | 22 | # include <cwchar> |
| 23 | 23 | #endif |
| 24 | 24 | |
| ... | ... | @@ -28,65 +28,79 @@ |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 30 | |
| 31 | struct __locale_guard { | |
| 32 | _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {} | |
| 33 | ||
| 34 | _LIBCPP_HIDE_FROM_ABI ~__locale_guard() { | |
| 35 | if (__old_loc_) | |
| 36 | ::uselocale(__old_loc_); | |
| 37 | } | |
| 38 | ||
| 39 | locale_t __old_loc_; | |
| 40 | ||
| 41 | __locale_guard(__locale_guard const&) = delete; | |
| 42 | __locale_guard& operator=(__locale_guard const&) = delete; | |
| 43 | }; | |
| 44 | ||
| 31 | 45 | inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l) { |
| 32 | __libcpp_locale_guard __current(__l); | |
| 46 | __locale_guard __current(__l); | |
| 33 | 47 | return MB_CUR_MAX; |
| 34 | 48 | } |
| 35 | 49 | |
| 36 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 50 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 37 | 51 | inline _LIBCPP_HIDE_FROM_ABI wint_t __libcpp_btowc_l(int __c, locale_t __l) { |
| 38 | __libcpp_locale_guard __current(__l); | |
| 52 | __locale_guard __current(__l); | |
| 39 | 53 | return btowc(__c); |
| 40 | 54 | } |
| 41 | 55 | |
| 42 | 56 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_wctob_l(wint_t __c, locale_t __l) { |
| 43 | __libcpp_locale_guard __current(__l); | |
| 57 | __locale_guard __current(__l); | |
| 44 | 58 | return wctob(__c); |
| 45 | 59 | } |
| 46 | 60 | |
| 47 | 61 | inline _LIBCPP_HIDE_FROM_ABI size_t |
| 48 | 62 | __libcpp_wcsnrtombs_l(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, locale_t __l) { |
| 49 | __libcpp_locale_guard __current(__l); | |
| 63 | __locale_guard __current(__l); | |
| 50 | 64 | return wcsnrtombs(__dest, __src, __nwc, __len, __ps); |
| 51 | 65 | } |
| 52 | 66 | |
| 53 | 67 | inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_wcrtomb_l(char* __s, wchar_t __wc, mbstate_t* __ps, locale_t __l) { |
| 54 | __libcpp_locale_guard __current(__l); | |
| 68 | __locale_guard __current(__l); | |
| 55 | 69 | return wcrtomb(__s, __wc, __ps); |
| 56 | 70 | } |
| 57 | 71 | |
| 58 | 72 | inline _LIBCPP_HIDE_FROM_ABI size_t |
| 59 | 73 | __libcpp_mbsnrtowcs_l(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, locale_t __l) { |
| 60 | __libcpp_locale_guard __current(__l); | |
| 74 | __locale_guard __current(__l); | |
| 61 | 75 | return mbsnrtowcs(__dest, __src, __nms, __len, __ps); |
| 62 | 76 | } |
| 63 | 77 | |
| 64 | 78 | inline _LIBCPP_HIDE_FROM_ABI size_t |
| 65 | 79 | __libcpp_mbrtowc_l(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, locale_t __l) { |
| 66 | __libcpp_locale_guard __current(__l); | |
| 80 | __locale_guard __current(__l); | |
| 67 | 81 | return mbrtowc(__pwc, __s, __n, __ps); |
| 68 | 82 | } |
| 69 | 83 | |
| 70 | 84 | inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mbtowc_l(wchar_t* __pwc, const char* __pmb, size_t __max, locale_t __l) { |
| 71 | __libcpp_locale_guard __current(__l); | |
| 85 | __locale_guard __current(__l); | |
| 72 | 86 | return mbtowc(__pwc, __pmb, __max); |
| 73 | 87 | } |
| 74 | 88 | |
| 75 | 89 | inline _LIBCPP_HIDE_FROM_ABI size_t __libcpp_mbrlen_l(const char* __s, size_t __n, mbstate_t* __ps, locale_t __l) { |
| 76 | __libcpp_locale_guard __current(__l); | |
| 90 | __locale_guard __current(__l); | |
| 77 | 91 | return mbrlen(__s, __n, __ps); |
| 78 | 92 | } |
| 79 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 93 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 80 | 94 | |
| 81 | inline _LIBCPP_HIDE_FROM_ABI lconv* __libcpp_localeconv_l(locale_t __l) { | |
| 82 | __libcpp_locale_guard __current(__l); | |
| 95 | inline _LIBCPP_HIDE_FROM_ABI lconv* __libcpp_localeconv_l(locale_t& __l) { | |
| 96 | __locale_guard __current(__l); | |
| 83 | 97 | return localeconv(); |
| 84 | 98 | } |
| 85 | 99 | |
| 86 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 100 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 87 | 101 | inline _LIBCPP_HIDE_FROM_ABI size_t |
| 88 | 102 | __libcpp_mbsrtowcs_l(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, locale_t __l) { |
| 89 | __libcpp_locale_guard __current(__l); | |
| 103 | __locale_guard __current(__l); | |
| 90 | 104 | return mbsrtowcs(__dest, __src, __len, __ps); |
| 91 | 105 | } |
| 92 | 106 | #endif |
| ... | ... | @@ -95,7 +109,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __libcpp_snprintf_l( |
| 95 | 109 | char* __s, size_t __n, locale_t __l, const char* __format, ...) { |
| 96 | 110 | va_list __va; |
| 97 | 111 | va_start(__va, __format); |
| 98 | __libcpp_locale_guard __current(__l); | |
| 112 | __locale_guard __current(__l); | |
| 99 | 113 | int __res = vsnprintf(__s, __n, __format, __va); |
| 100 | 114 | va_end(__va); |
| 101 | 115 | return __res; |
| ... | ... | @@ -105,7 +119,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __libcpp_asprintf_l( |
| 105 | 119 | char** __s, locale_t __l, const char* __format, ...) { |
| 106 | 120 | va_list __va; |
| 107 | 121 | va_start(__va, __format); |
| 108 | __libcpp_locale_guard __current(__l); | |
| 122 | __locale_guard __current(__l); | |
| 109 | 123 | int __res = vasprintf(__s, __format, __va); |
| 110 | 124 | va_end(__va); |
| 111 | 125 | return __res; |
| ... | ... | @@ -115,7 +129,7 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __libcpp_sscanf_l( |
| 115 | 129 | const char* __s, locale_t __l, const char* __format, ...) { |
| 116 | 130 | va_list __va; |
| 117 | 131 | va_start(__va, __format); |
| 118 | __libcpp_locale_guard __current(__l); | |
| 132 | __locale_guard __current(__l); | |
| 119 | 133 | int __res = vsscanf(__s, __format, __va); |
| 120 | 134 | va_end(__va); |
| 121 | 135 | return __res; |
| ... | ... | @@ -123,4 +137,4 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __libcpp_sscanf_l( |
| 123 | 137 | |
| 124 | 138 | _LIBCPP_END_NAMESPACE_STD |
| 125 | 139 | |
| 126 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H | |
| 140 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H |
lib/libcxx/include/__locale_dir/locale_base_api/fuchsia.h deleted-18| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===-----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___LOCALE_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+5-5| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H | |
| 11 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H | |
| 10 | #ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_IBM_H | |
| 11 | #define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_IBM_H | |
| 12 | 12 | |
| 13 | 13 | #if defined(__MVS__) |
| 14 | 14 | # include <__support/ibm/locale_mgmt_zos.h> |
| ... | ... | @@ -82,7 +82,7 @@ strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) { |
| 82 | 82 | inline _LIBCPP_HIDE_FROM_ABI |
| 83 | 83 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) { |
| 84 | 84 | const size_t buff_size = 256; |
| 85 | if ((*strp = (char*)malloc(buff_size)) == NULL) { | |
| 85 | if ((*strp = (char*)malloc(buff_size)) == nullptr) { | |
| 86 | 86 | return -1; |
| 87 | 87 | } |
| 88 | 88 | |
| ... | ... | @@ -97,7 +97,7 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char |
| 97 | 97 | va_end(ap_copy); |
| 98 | 98 | |
| 99 | 99 | if ((size_t)str_size >= buff_size) { |
| 100 | if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) { | |
| 100 | if ((*strp = (char*)realloc(*strp, str_size + 1)) == nullptr) { | |
| 101 | 101 | return -1; |
| 102 | 102 | } |
| 103 | 103 | str_size = vsnprintf(*strp, str_size + 1, fmt, ap); |
| ... | ... | @@ -105,4 +105,4 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char |
| 105 | 105 | return str_size; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H | |
| 108 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_IBM_H |
lib/libcxx/include/__locale_dir/locale_base_api/locale_guard.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___LOCALE_LOCALE_BASE_API_LOCALE_GUARD_H | |
| 10 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_LOCALE_GUARD_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__locale> // for locale_t | |
| 14 | #include <clocale> | |
| 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 !defined(_LIBCPP_LOCALE__L_EXTENSIONS) | |
| 23 | struct __libcpp_locale_guard { | |
| 24 | _LIBCPP_HIDE_FROM_ABI __libcpp_locale_guard(locale_t& __loc) : __old_loc_(uselocale(__loc)) {} | |
| 25 | ||
| 26 | _LIBCPP_HIDE_FROM_ABI ~__libcpp_locale_guard() { | |
| 27 | if (__old_loc_) | |
| 28 | uselocale(__old_loc_); | |
| 29 | } | |
| 30 | ||
| 31 | locale_t __old_loc_; | |
| 32 | ||
| 33 | __libcpp_locale_guard(__libcpp_locale_guard const&) = delete; | |
| 34 | __libcpp_locale_guard& operator=(__libcpp_locale_guard const&) = delete; | |
| 35 | }; | |
| 36 | #elif defined(_LIBCPP_MSVCRT_LIKE) | |
| 37 | struct __libcpp_locale_guard { | |
| 38 | __libcpp_locale_guard(locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) { | |
| 39 | // Setting the locale can be expensive even when the locale given is | |
| 40 | // already the current locale, so do an explicit check to see if the | |
| 41 | // current locale is already the one we want. | |
| 42 | const char* __lc = __setlocale(nullptr); | |
| 43 | // If every category is the same, the locale string will simply be the | |
| 44 | // locale name, otherwise it will be a semicolon-separated string listing | |
| 45 | // each category. In the second case, we know at least one category won't | |
| 46 | // be what we want, so we only have to check the first case. | |
| 47 | if (std::strcmp(__l.__get_locale(), __lc) != 0) { | |
| 48 | __locale_all = _strdup(__lc); | |
| 49 | if (__locale_all == nullptr) | |
| 50 | __throw_bad_alloc(); | |
| 51 | __setlocale(__l.__get_locale()); | |
| 52 | } | |
| 53 | } | |
| 54 | ~__libcpp_locale_guard() { | |
| 55 | // The CRT documentation doesn't explicitly say, but setlocale() does the | |
| 56 | // right thing when given a semicolon-separated list of locale settings | |
| 57 | // for the different categories in the same format as returned by | |
| 58 | // setlocale(LC_ALL, nullptr). | |
| 59 | if (__locale_all != nullptr) { | |
| 60 | __setlocale(__locale_all); | |
| 61 | free(__locale_all); | |
| 62 | } | |
| 63 | _configthreadlocale(__status); | |
| 64 | } | |
| 65 | static const char* __setlocale(const char* __locale) { | |
| 66 | const char* __new_locale = setlocale(LC_ALL, __locale); | |
| 67 | if (__new_locale == nullptr) | |
| 68 | __throw_bad_alloc(); | |
| 69 | return __new_locale; | |
| 70 | } | |
| 71 | int __status; | |
| 72 | char* __locale_all = nullptr; | |
| 73 | }; | |
| 74 | #endif | |
| 75 | ||
| 76 | _LIBCPP_END_NAMESPACE_STD | |
| 77 | ||
| 78 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_LOCALE_GUARD_H |
lib/libcxx/include/__locale_dir/locale_base_api/musl.h+3-3| ... | ... | @@ -14,8 +14,8 @@ |
| 14 | 14 | // in Musl. |
| 15 | 15 | //===----------------------------------------------------------------------===// |
| 16 | 16 | |
| 17 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H | |
| 18 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H | |
| 17 | #ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_MUSL_H | |
| 18 | #define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_MUSL_H | |
| 19 | 19 | |
| 20 | 20 | #include <cstdlib> |
| 21 | 21 | #include <cwchar> |
| ... | ... | @@ -28,4 +28,4 @@ inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, c |
| 28 | 28 | return ::strtoull(__nptr, __endptr, __base); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_MUSL_H | |
| 31 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_MUSL_H |
lib/libcxx/include/__locale_dir/locale_base_api/newlib.h deleted-12| ... | ... | @@ -1,12 +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___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+3-3| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H | |
| 11 | #define _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H | |
| 10 | #ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H | |
| 11 | #define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H | |
| 12 | 12 | |
| 13 | 13 | #include <__support/xlocale/__strtonum_fallback.h> |
| 14 | 14 | #include <clocale> |
| ... | ... | @@ -16,4 +16,4 @@ |
| 16 | 16 | #include <ctype.h> |
| 17 | 17 | #include <cwctype> |
| 18 | 18 | |
| 19 | #endif // _LIBCPP___LOCALE_LOCALE_BASE_API_OPENBSD_H | |
| 19 | #endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H |
lib/libcxx/include/__locale_dir/locale_base_api/win32.h deleted-235| ... | ... | @@ -1,235 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===-----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___LOCALE_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/__locale_dir/pad_and_output.h created+88| ... | ... | @@ -0,0 +1,88 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_PAD_AND_OUTPUT_H | |
| 10 | #define _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if _LIBCPP_HAS_LOCALIZATION | |
| 15 | ||
| 16 | # include <ios> | |
| 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 _CharT, class _OutputIterator> | |
| 25 | _LIBCPP_HIDE_FROM_ABI _OutputIterator __pad_and_output( | |
| 26 | _OutputIterator __s, const _CharT* __ob, const _CharT* __op, const _CharT* __oe, ios_base& __iob, _CharT __fl) { | |
| 27 | streamsize __sz = __oe - __ob; | |
| 28 | streamsize __ns = __iob.width(); | |
| 29 | if (__ns > __sz) | |
| 30 | __ns -= __sz; | |
| 31 | else | |
| 32 | __ns = 0; | |
| 33 | for (; __ob < __op; ++__ob, ++__s) | |
| 34 | *__s = *__ob; | |
| 35 | for (; __ns; --__ns, ++__s) | |
| 36 | *__s = __fl; | |
| 37 | for (; __ob < __oe; ++__ob, ++__s) | |
| 38 | *__s = *__ob; | |
| 39 | __iob.width(0); | |
| 40 | return __s; | |
| 41 | } | |
| 42 | ||
| 43 | template <class _CharT, class _Traits> | |
| 44 | _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_CharT, _Traits> __pad_and_output( | |
| 45 | ostreambuf_iterator<_CharT, _Traits> __s, | |
| 46 | const _CharT* __ob, | |
| 47 | const _CharT* __op, | |
| 48 | const _CharT* __oe, | |
| 49 | ios_base& __iob, | |
| 50 | _CharT __fl) { | |
| 51 | if (__s.__sbuf_ == nullptr) | |
| 52 | return __s; | |
| 53 | streamsize __sz = __oe - __ob; | |
| 54 | streamsize __ns = __iob.width(); | |
| 55 | if (__ns > __sz) | |
| 56 | __ns -= __sz; | |
| 57 | else | |
| 58 | __ns = 0; | |
| 59 | streamsize __np = __op - __ob; | |
| 60 | if (__np > 0) { | |
| 61 | if (__s.__sbuf_->sputn(__ob, __np) != __np) { | |
| 62 | __s.__sbuf_ = nullptr; | |
| 63 | return __s; | |
| 64 | } | |
| 65 | } | |
| 66 | if (__ns > 0) { | |
| 67 | basic_string<_CharT, _Traits> __sp(__ns, __fl); | |
| 68 | if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns) { | |
| 69 | __s.__sbuf_ = nullptr; | |
| 70 | return __s; | |
| 71 | } | |
| 72 | } | |
| 73 | __np = __oe - __op; | |
| 74 | if (__np > 0) { | |
| 75 | if (__s.__sbuf_->sputn(__op, __np) != __np) { | |
| 76 | __s.__sbuf_ = nullptr; | |
| 77 | return __s; | |
| 78 | } | |
| 79 | } | |
| 80 | __iob.width(0); | |
| 81 | return __s; | |
| 82 | } | |
| 83 | ||
| 84 | _LIBCPP_END_NAMESPACE_STD | |
| 85 | ||
| 86 | #endif // _LIBCPP_HAS_LOCALIZATION | |
| 87 | ||
| 88 | #endif // _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H |
lib/libcxx/include/__locale_dir/support/apple.h created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | //===-----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H | |
| 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | #include <__locale_dir/support/bsd_like.h> | |
| 19 | ||
| 20 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H |
lib/libcxx/include/__locale_dir/support/bsd_like.h created+234| ... | ... | @@ -0,0 +1,234 @@ |
| 1 | //===-----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_BSD_LIKE_H | |
| 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_BSD_LIKE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | #include <__std_mbstate_t.h> | |
| 15 | #include <__utility/forward.h> | |
| 16 | #include <clocale> // std::lconv | |
| 17 | #include <ctype.h> | |
| 18 | #include <stdio.h> | |
| 19 | #include <stdlib.h> | |
| 20 | #include <string.h> | |
| 21 | #include <time.h> | |
| 22 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 23 | # include <wchar.h> | |
| 24 | # include <wctype.h> | |
| 25 | #endif | |
| 26 | ||
| 27 | #include <xlocale.h> | |
| 28 | ||
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 30 | # pragma GCC system_header | |
| 31 | #endif | |
| 32 | ||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 34 | namespace __locale { | |
| 35 | ||
| 36 | // | |
| 37 | // Locale management | |
| 38 | // | |
| 39 | #define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK | |
| 40 | #define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK | |
| 41 | #define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK | |
| 42 | #define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK | |
| 43 | #define _LIBCPP_TIME_MASK LC_TIME_MASK | |
| 44 | #define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK | |
| 45 | #define _LIBCPP_ALL_MASK LC_ALL_MASK | |
| 46 | #define _LIBCPP_LC_ALL LC_ALL | |
| 47 | ||
| 48 | using __locale_t = ::locale_t; | |
| 49 | #if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 50 | using __lconv_t = std::lconv; | |
| 51 | ||
| 52 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) { | |
| 53 | return ::newlocale(__category_mask, __locale, __base); | |
| 54 | } | |
| 55 | ||
| 56 | inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::freelocale(__loc); } | |
| 57 | ||
| 58 | inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __locale) { | |
| 59 | return ::setlocale(__category, __locale); | |
| 60 | } | |
| 61 | ||
| 62 | inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return ::localeconv_l(__loc); } | |
| 63 | #endif // _LIBCPP_BUILDING_LIBRARY | |
| 64 | ||
| 65 | // | |
| 66 | // Strtonum functions | |
| 67 | // | |
| 68 | inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) { | |
| 69 | return ::strtof_l(__nptr, __endptr, __loc); | |
| 70 | } | |
| 71 | ||
| 72 | inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) { | |
| 73 | return ::strtod_l(__nptr, __endptr, __loc); | |
| 74 | } | |
| 75 | ||
| 76 | inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) { | |
| 77 | return ::strtold_l(__nptr, __endptr, __loc); | |
| 78 | } | |
| 79 | ||
| 80 | inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | |
| 81 | return ::strtoll_l(__nptr, __endptr, __base, __loc); | |
| 82 | } | |
| 83 | ||
| 84 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | |
| 85 | __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | |
| 86 | return ::strtoull_l(__nptr, __endptr, __base, __loc); | |
| 87 | } | |
| 88 | ||
| 89 | // | |
| 90 | // Character manipulation functions | |
| 91 | // | |
| 92 | #if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 93 | inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t __loc) { return ::islower_l(__c, __loc); } | |
| 94 | ||
| 95 | inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t __loc) { return ::isupper_l(__c, __loc); } | |
| 96 | #endif | |
| 97 | ||
| 98 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return ::isdigit_l(__c, __loc); } | |
| 99 | ||
| 100 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return ::isxdigit_l(__c, __loc); } | |
| 101 | ||
| 102 | #if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 103 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return ::toupper_l(__c, __loc); } | |
| 104 | ||
| 105 | inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t __loc) { return ::tolower_l(__c, __loc); } | |
| 106 | ||
| 107 | inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) { | |
| 108 | return ::strcoll_l(__s1, __s2, __loc); | |
| 109 | } | |
| 110 | ||
| 111 | inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) { | |
| 112 | return ::strxfrm_l(__dest, __src, __n, __loc); | |
| 113 | } | |
| 114 | ||
| 115 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 116 | inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) { | |
| 117 | return ::iswctype_l(__c, __type, __loc); | |
| 118 | } | |
| 119 | ||
| 120 | inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::iswspace_l(__c, __loc); } | |
| 121 | ||
| 122 | inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::iswprint_l(__c, __loc); } | |
| 123 | ||
| 124 | inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return ::iswcntrl_l(__c, __loc); } | |
| 125 | ||
| 126 | inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __c, __locale_t __loc) { return ::iswupper_l(__c, __loc); } | |
| 127 | ||
| 128 | inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __c, __locale_t __loc) { return ::iswlower_l(__c, __loc); } | |
| 129 | ||
| 130 | inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __c, __locale_t __loc) { return ::iswalpha_l(__c, __loc); } | |
| 131 | ||
| 132 | inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __c, __locale_t __loc) { return ::iswblank_l(__c, __loc); } | |
| 133 | ||
| 134 | inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __c, __locale_t __loc) { return ::iswdigit_l(__c, __loc); } | |
| 135 | ||
| 136 | inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __c, __locale_t __loc) { return ::iswpunct_l(__c, __loc); } | |
| 137 | ||
| 138 | inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __c, __locale_t __loc) { return ::iswxdigit_l(__c, __loc); } | |
| 139 | ||
| 140 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __c, __locale_t __loc) { return ::towupper_l(__c, __loc); } | |
| 141 | ||
| 142 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __c, __locale_t __loc) { return ::towlower_l(__c, __loc); } | |
| 143 | ||
| 144 | inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t __loc) { | |
| 145 | return ::wcscoll_l(__ws1, __ws2, __loc); | |
| 146 | } | |
| 147 | ||
| 148 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) { | |
| 149 | return ::wcsxfrm_l(__dest, __src, __n, __loc); | |
| 150 | } | |
| 151 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 152 | ||
| 153 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 154 | __strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) { | |
| 155 | return ::strftime_l(__s, __max, __format, __tm, __loc); | |
| 156 | } | |
| 157 | ||
| 158 | // | |
| 159 | // Other functions | |
| 160 | // | |
| 161 | inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t __loc) { return MB_CUR_MAX_L(__loc); } | |
| 162 | ||
| 163 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 164 | inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __c, __locale_t __loc) { return ::btowc_l(__c, __loc); } | |
| 165 | ||
| 166 | inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __c, __locale_t __loc) { return ::wctob_l(__c, __loc); } | |
| 167 | ||
| 168 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 169 | __wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) { | |
| 170 | return ::wcsnrtombs_l(__dest, __src, __nwc, __len, __ps, __loc); // wcsnrtombs is a POSIX extension | |
| 171 | } | |
| 172 | ||
| 173 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __wc, mbstate_t* __ps, __locale_t __loc) { | |
| 174 | return ::wcrtomb_l(__s, __wc, __ps, __loc); | |
| 175 | } | |
| 176 | ||
| 177 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 178 | __mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) { | |
| 179 | return ::mbsnrtowcs_l(__dest, __src, __nms, __len, __ps, __loc); // mbsnrtowcs is a POSIX extension | |
| 180 | } | |
| 181 | ||
| 182 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 183 | __mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) { | |
| 184 | return ::mbrtowc_l(__pwc, __s, __n, __ps, __loc); | |
| 185 | } | |
| 186 | ||
| 187 | inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) { | |
| 188 | return ::mbtowc_l(__pwc, __pmb, __max, __loc); | |
| 189 | } | |
| 190 | ||
| 191 | inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) { | |
| 192 | return ::mbrlen_l(__s, __n, __ps, __loc); | |
| 193 | } | |
| 194 | ||
| 195 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 196 | __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) { | |
| 197 | return ::mbsrtowcs_l(__dest, __src, __len, __ps, __loc); | |
| 198 | } | |
| 199 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 200 | #endif // _LIBCPP_BUILDING_LIBRARY | |
| 201 | ||
| 202 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 203 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat") | |
| 204 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates | |
| 205 | #ifdef _LIBCPP_COMPILER_CLANG_BASED | |
| 206 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__) | |
| 207 | #else | |
| 208 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */ | |
| 209 | #endif | |
| 210 | ||
| 211 | template <class... _Args> | |
| 212 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf( | |
| 213 | char* __s, size_t __n, __locale_t __loc, const char* __format, _Args&&... __args) { | |
| 214 | return ::snprintf_l(__s, __n, __loc, __format, std::forward<_Args>(__args)...); | |
| 215 | } | |
| 216 | ||
| 217 | template <class... _Args> | |
| 218 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf( | |
| 219 | char** __s, __locale_t __loc, const char* __format, _Args&&... __args) { | |
| 220 | return ::asprintf_l(__s, __loc, __format, std::forward<_Args>(__args)...); // non-standard | |
| 221 | } | |
| 222 | ||
| 223 | template <class... _Args> | |
| 224 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf( | |
| 225 | const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) { | |
| 226 | return ::sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...); | |
| 227 | } | |
| 228 | _LIBCPP_DIAGNOSTIC_POP | |
| 229 | #undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT | |
| 230 | ||
| 231 | } // namespace __locale | |
| 232 | _LIBCPP_END_NAMESPACE_STD | |
| 233 | ||
| 234 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_BSD_LIKE_H |
lib/libcxx/include/__locale_dir/support/freebsd.h created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | //===-----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H | |
| 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | #include <__locale_dir/support/bsd_like.h> | |
| 19 | ||
| 20 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H |
lib/libcxx/include/__locale_dir/support/fuchsia.h created+160| ... | ... | @@ -0,0 +1,160 @@ |
| 1 | //===-----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_FUCHSIA_H | |
| 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_FUCHSIA_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__utility/forward.h> | |
| 14 | #include <clocale> // uselocale & friends | |
| 15 | #include <cstdio> | |
| 16 | #include <cstdlib> | |
| 17 | #include <cwchar> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | namespace __locale { | |
| 25 | ||
| 26 | struct __locale_guard { | |
| 27 | _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {} | |
| 28 | ||
| 29 | _LIBCPP_HIDE_FROM_ABI ~__locale_guard() { | |
| 30 | if (__old_loc_) | |
| 31 | ::uselocale(__old_loc_); | |
| 32 | } | |
| 33 | ||
| 34 | locale_t __old_loc_; | |
| 35 | ||
| 36 | __locale_guard(__locale_guard const&) = delete; | |
| 37 | __locale_guard& operator=(__locale_guard const&) = delete; | |
| 38 | }; | |
| 39 | ||
| 40 | // | |
| 41 | // Locale management | |
| 42 | // | |
| 43 | #define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK | |
| 44 | #define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK | |
| 45 | #define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK | |
| 46 | #define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK | |
| 47 | #define _LIBCPP_TIME_MASK LC_TIME_MASK | |
| 48 | #define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK | |
| 49 | #define _LIBCPP_ALL_MASK LC_ALL_MASK | |
| 50 | #define _LIBCPP_LC_ALL LC_ALL | |
| 51 | ||
| 52 | using __locale_t = locale_t; | |
| 53 | ||
| 54 | #if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 55 | using __lconv_t = std::lconv; | |
| 56 | ||
| 57 | inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) { | |
| 58 | return ::newlocale(__category_mask, __name, __loc); | |
| 59 | } | |
| 60 | ||
| 61 | inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::freelocale(__loc); } | |
| 62 | ||
| 63 | inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __locale) { | |
| 64 | return ::setlocale(__category, __locale); | |
| 65 | } | |
| 66 | ||
| 67 | inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { | |
| 68 | __locale_guard __current(__loc); | |
| 69 | return std::localeconv(); | |
| 70 | } | |
| 71 | ||
| 72 | // | |
| 73 | // Other functions | |
| 74 | // | |
| 75 | inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t __loc) { | |
| 76 | __locale_guard __current(__loc); | |
| 77 | return MB_CUR_MAX; | |
| 78 | } | |
| 79 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 80 | inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __ch, __locale_t __loc) { | |
| 81 | __locale_guard __current(__loc); | |
| 82 | return std::btowc(__ch); | |
| 83 | } | |
| 84 | inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __ch, __locale_t __loc) { | |
| 85 | __locale_guard __current(__loc); | |
| 86 | return std::wctob(__ch); | |
| 87 | } | |
| 88 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 89 | __wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) { | |
| 90 | __locale_guard __current(__loc); | |
| 91 | return ::wcsnrtombs(__dest, __src, __nwc, __len, __ps); // non-standard | |
| 92 | } | |
| 93 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __ch, mbstate_t* __ps, __locale_t __loc) { | |
| 94 | __locale_guard __current(__loc); | |
| 95 | return std::wcrtomb(__s, __ch, __ps); | |
| 96 | } | |
| 97 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 98 | __mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) { | |
| 99 | __locale_guard __current(__loc); | |
| 100 | return ::mbsnrtowcs(__dest, __src, __nms, __len, __ps); // non-standard | |
| 101 | } | |
| 102 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 103 | __mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) { | |
| 104 | __locale_guard __current(__loc); | |
| 105 | return std::mbrtowc(__pwc, __s, __n, __ps); | |
| 106 | } | |
| 107 | inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) { | |
| 108 | __locale_guard __current(__loc); | |
| 109 | return std::mbtowc(__pwc, __pmb, __max); | |
| 110 | } | |
| 111 | inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) { | |
| 112 | __locale_guard __current(__loc); | |
| 113 | return std::mbrlen(__s, __n, __ps); | |
| 114 | } | |
| 115 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 116 | __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) { | |
| 117 | __locale_guard __current(__loc); | |
| 118 | return ::mbsrtowcs(__dest, __src, __len, __ps); | |
| 119 | } | |
| 120 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 121 | #endif // _LIBCPP_BUILDING_LIBRARY | |
| 122 | ||
| 123 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 124 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat") | |
| 125 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates | |
| 126 | #ifdef _LIBCPP_COMPILER_CLANG_BASED | |
| 127 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__) | |
| 128 | #else | |
| 129 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */ | |
| 130 | #endif | |
| 131 | ||
| 132 | template <class... _Args> | |
| 133 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf( | |
| 134 | char* __s, size_t __n, __locale_t __loc, const char* __format, _Args&&... __args) { | |
| 135 | __locale_guard __current(__loc); | |
| 136 | return std::snprintf(__s, __n, __format, std::forward<_Args>(__args)...); | |
| 137 | } | |
| 138 | template <class... _Args> | |
| 139 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf( | |
| 140 | char** __s, __locale_t __loc, const char* __format, _Args&&... __args) { | |
| 141 | __locale_guard __current(__loc); | |
| 142 | return ::asprintf(__s, __format, std::forward<_Args>(__args)...); // non-standard | |
| 143 | } | |
| 144 | template <class... _Args> | |
| 145 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf( | |
| 146 | const char* __s, __locale_t __loc, const char* __format, _Args&&... __args) { | |
| 147 | __locale_guard __current(__loc); | |
| 148 | return std::sscanf(__s, __format, std::forward<_Args>(__args)...); | |
| 149 | } | |
| 150 | ||
| 151 | _LIBCPP_DIAGNOSTIC_POP | |
| 152 | #undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT | |
| 153 | ||
| 154 | } // namespace __locale | |
| 155 | _LIBCPP_END_NAMESPACE_STD | |
| 156 | ||
| 157 | #include <__locale_dir/support/no_locale/characters.h> | |
| 158 | #include <__locale_dir/support/no_locale/strtonum.h> | |
| 159 | ||
| 160 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_FUCHSIA_H |
lib/libcxx/include/__locale_dir/support/no_locale/characters.h created+102| ... | ... | @@ -0,0 +1,102 @@ |
| 1 | //===-----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CHARACTERS_H | |
| 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CHARACTERS_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | #include <cctype> | |
| 15 | #include <cstdlib> | |
| 16 | #include <cstring> | |
| 17 | #include <ctime> | |
| 18 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 19 | # include <cwctype> | |
| 20 | #endif | |
| 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 __locale { | |
| 28 | ||
| 29 | // | |
| 30 | // Character manipulation functions | |
| 31 | // | |
| 32 | #if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 33 | inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t) { return std::islower(__c); } | |
| 34 | ||
| 35 | inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t) { return std::isupper(__c); } | |
| 36 | #endif | |
| 37 | ||
| 38 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t) { return std::isdigit(__c); } | |
| 39 | ||
| 40 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t) { return std::isxdigit(__c); } | |
| 41 | ||
| 42 | #if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 43 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t) { return std::toupper(__c); } | |
| 44 | ||
| 45 | inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t) { return std::tolower(__c); } | |
| 46 | ||
| 47 | inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t) { | |
| 48 | return std::strcoll(__s1, __s2); | |
| 49 | } | |
| 50 | ||
| 51 | inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t) { | |
| 52 | return std::strxfrm(__dest, __src, __n); | |
| 53 | } | |
| 54 | ||
| 55 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 56 | inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t) { | |
| 57 | return std::iswctype(__c, __type); | |
| 58 | } | |
| 59 | ||
| 60 | inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t) { return std::iswspace(__c); } | |
| 61 | ||
| 62 | inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t) { return std::iswprint(__c); } | |
| 63 | ||
| 64 | inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t) { return std::iswcntrl(__c); } | |
| 65 | ||
| 66 | inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __c, __locale_t) { return std::iswupper(__c); } | |
| 67 | ||
| 68 | inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __c, __locale_t) { return std::iswlower(__c); } | |
| 69 | ||
| 70 | inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __c, __locale_t) { return std::iswalpha(__c); } | |
| 71 | ||
| 72 | inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __c, __locale_t) { return std::iswblank(__c); } | |
| 73 | ||
| 74 | inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __c, __locale_t) { return std::iswdigit(__c); } | |
| 75 | ||
| 76 | inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __c, __locale_t) { return std::iswpunct(__c); } | |
| 77 | ||
| 78 | inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __c, __locale_t) { return std::iswxdigit(__c); } | |
| 79 | ||
| 80 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __c, __locale_t) { return std::towupper(__c); } | |
| 81 | ||
| 82 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __c, __locale_t) { return std::towlower(__c); } | |
| 83 | ||
| 84 | inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t) { | |
| 85 | return std::wcscoll(__ws1, __ws2); | |
| 86 | } | |
| 87 | ||
| 88 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t) { | |
| 89 | return std::wcsxfrm(__dest, __src, __n); | |
| 90 | } | |
| 91 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 92 | ||
| 93 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 94 | __strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t) { | |
| 95 | return std::strftime(__s, __max, __format, __tm); | |
| 96 | } | |
| 97 | #endif // _LIBCPP_BUILDING_LIBRARY | |
| 98 | ||
| 99 | } // namespace __locale | |
| 100 | _LIBCPP_END_NAMESPACE_STD | |
| 101 | ||
| 102 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CHARACTERS_H |
lib/libcxx/include/__locale_dir/support/no_locale/strtonum.h created+49| ... | ... | @@ -0,0 +1,49 @@ |
| 1 | //===-----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_STRTONUM_H | |
| 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_STRTONUM_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <cstdlib> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | namespace __locale { | |
| 21 | ||
| 22 | // | |
| 23 | // Strtonum functions | |
| 24 | // | |
| 25 | inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t) { | |
| 26 | return std::strtof(__nptr, __endptr); | |
| 27 | } | |
| 28 | ||
| 29 | inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t) { | |
| 30 | return std::strtod(__nptr, __endptr); | |
| 31 | } | |
| 32 | ||
| 33 | inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t) { | |
| 34 | return std::strtold(__nptr, __endptr); | |
| 35 | } | |
| 36 | ||
| 37 | inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t) { | |
| 38 | return std::strtoll(__nptr, __endptr, __base); | |
| 39 | } | |
| 40 | ||
| 41 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | |
| 42 | __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t) { | |
| 43 | return std::strtoull(__nptr, __endptr, __base); | |
| 44 | } | |
| 45 | ||
| 46 | } // namespace __locale | |
| 47 | _LIBCPP_END_NAMESPACE_STD | |
| 48 | ||
| 49 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_STRTONUM_H |
lib/libcxx/include/__locale_dir/support/windows.h created+343| ... | ... | @@ -0,0 +1,343 @@ |
| 1 | //===-----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___LOCALE_DIR_SUPPORT_WINDOWS_H | |
| 10 | #define _LIBCPP___LOCALE_DIR_SUPPORT_WINDOWS_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__cstddef/nullptr_t.h> | |
| 14 | #include <__utility/forward.h> | |
| 15 | #include <clocale> // std::lconv & friends | |
| 16 | #include <cstddef> | |
| 17 | #include <ctype.h> // ::_isupper_l & friends | |
| 18 | #include <locale.h> // ::_locale_t | |
| 19 | #include <stdio.h> // ::_sscanf_l | |
| 20 | #include <stdlib.h> // ::_strtod_l & friends | |
| 21 | #include <string.h> // ::_strcoll_l | |
| 22 | #include <string> | |
| 23 | #include <time.h> // ::_strftime_l | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | #endif | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | namespace __locale { | |
| 31 | ||
| 32 | using __lconv_t = std::lconv; | |
| 33 | ||
| 34 | class __lconv_storage { | |
| 35 | public: | |
| 36 | __lconv_storage(const __lconv_t* __lc_input) { | |
| 37 | __lc_ = *__lc_input; | |
| 38 | ||
| 39 | __decimal_point_ = __lc_input->decimal_point; | |
| 40 | __thousands_sep_ = __lc_input->thousands_sep; | |
| 41 | __grouping_ = __lc_input->grouping; | |
| 42 | __int_curr_symbol_ = __lc_input->int_curr_symbol; | |
| 43 | __currency_symbol_ = __lc_input->currency_symbol; | |
| 44 | __mon_decimal_point_ = __lc_input->mon_decimal_point; | |
| 45 | __mon_thousands_sep_ = __lc_input->mon_thousands_sep; | |
| 46 | __mon_grouping_ = __lc_input->mon_grouping; | |
| 47 | __positive_sign_ = __lc_input->positive_sign; | |
| 48 | __negative_sign_ = __lc_input->negative_sign; | |
| 49 | ||
| 50 | __lc_.decimal_point = const_cast<char*>(__decimal_point_.c_str()); | |
| 51 | __lc_.thousands_sep = const_cast<char*>(__thousands_sep_.c_str()); | |
| 52 | __lc_.grouping = const_cast<char*>(__grouping_.c_str()); | |
| 53 | __lc_.int_curr_symbol = const_cast<char*>(__int_curr_symbol_.c_str()); | |
| 54 | __lc_.currency_symbol = const_cast<char*>(__currency_symbol_.c_str()); | |
| 55 | __lc_.mon_decimal_point = const_cast<char*>(__mon_decimal_point_.c_str()); | |
| 56 | __lc_.mon_thousands_sep = const_cast<char*>(__mon_thousands_sep_.c_str()); | |
| 57 | __lc_.mon_grouping = const_cast<char*>(__mon_grouping_.c_str()); | |
| 58 | __lc_.positive_sign = const_cast<char*>(__positive_sign_.c_str()); | |
| 59 | __lc_.negative_sign = const_cast<char*>(__negative_sign_.c_str()); | |
| 60 | } | |
| 61 | ||
| 62 | __lconv_t* __get() { return &__lc_; } | |
| 63 | ||
| 64 | private: | |
| 65 | __lconv_t __lc_; | |
| 66 | std::string __decimal_point_; | |
| 67 | std::string __thousands_sep_; | |
| 68 | std::string __grouping_; | |
| 69 | std::string __int_curr_symbol_; | |
| 70 | std::string __currency_symbol_; | |
| 71 | std::string __mon_decimal_point_; | |
| 72 | std::string __mon_thousands_sep_; | |
| 73 | std::string __mon_grouping_; | |
| 74 | std::string __positive_sign_; | |
| 75 | std::string __negative_sign_; | |
| 76 | }; | |
| 77 | ||
| 78 | // | |
| 79 | // Locale management | |
| 80 | // | |
| 81 | #define _CATMASK(n) ((1 << (n)) >> 1) | |
| 82 | #define _LIBCPP_COLLATE_MASK _CATMASK(LC_COLLATE) | |
| 83 | #define _LIBCPP_CTYPE_MASK _CATMASK(LC_CTYPE) | |
| 84 | #define _LIBCPP_MONETARY_MASK _CATMASK(LC_MONETARY) | |
| 85 | #define _LIBCPP_NUMERIC_MASK _CATMASK(LC_NUMERIC) | |
| 86 | #define _LIBCPP_TIME_MASK _CATMASK(LC_TIME) | |
| 87 | #define _LIBCPP_MESSAGES_MASK _CATMASK(6) | |
| 88 | #define _LIBCPP_ALL_MASK \ | |
| 89 | (_LIBCPP_COLLATE_MASK | _LIBCPP_CTYPE_MASK | _LIBCPP_MESSAGES_MASK | _LIBCPP_MONETARY_MASK | _LIBCPP_NUMERIC_MASK | \ | |
| 90 | _LIBCPP_TIME_MASK) | |
| 91 | #define _LIBCPP_LC_ALL LC_ALL | |
| 92 | ||
| 93 | class __locale_t { | |
| 94 | public: | |
| 95 | __locale_t() : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {} | |
| 96 | __locale_t(std::nullptr_t) : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {} | |
| 97 | __locale_t(::_locale_t __loc, const char* __loc_str) : __locale_(__loc), __locale_str_(__loc_str), __lc_(nullptr) {} | |
| 98 | __locale_t(const __locale_t& __loc) | |
| 99 | : __locale_(__loc.__locale_), __locale_str_(__loc.__locale_str_), __lc_(nullptr) {} | |
| 100 | ||
| 101 | ~__locale_t() { delete __lc_; } | |
| 102 | ||
| 103 | __locale_t& operator=(const __locale_t& __loc) { | |
| 104 | __locale_ = __loc.__locale_; | |
| 105 | __locale_str_ = __loc.__locale_str_; | |
| 106 | // __lc_ not copied | |
| 107 | return *this; | |
| 108 | } | |
| 109 | ||
| 110 | friend bool operator==(const __locale_t& __left, const __locale_t& __right) { | |
| 111 | return __left.__locale_ == __right.__locale_; | |
| 112 | } | |
| 113 | ||
| 114 | friend bool operator==(const __locale_t& __left, int __right) { return __left.__locale_ == nullptr && __right == 0; } | |
| 115 | ||
| 116 | friend bool operator==(const __locale_t& __left, long long __right) { | |
| 117 | return __left.__locale_ == nullptr && __right == 0; | |
| 118 | } | |
| 119 | ||
| 120 | friend bool operator==(const __locale_t& __left, std::nullptr_t) { return __left.__locale_ == nullptr; } | |
| 121 | ||
| 122 | friend bool operator==(int __left, const __locale_t& __right) { return __left == 0 && nullptr == __right.__locale_; } | |
| 123 | ||
| 124 | friend bool operator==(std::nullptr_t, const __locale_t& __right) { return nullptr == __right.__locale_; } | |
| 125 | ||
| 126 | friend bool operator!=(const __locale_t& __left, const __locale_t& __right) { return !(__left == __right); } | |
| 127 | ||
| 128 | friend bool operator!=(const __locale_t& __left, int __right) { return !(__left == __right); } | |
| 129 | ||
| 130 | friend bool operator!=(const __locale_t& __left, long long __right) { return !(__left == __right); } | |
| 131 | ||
| 132 | friend bool operator!=(const __locale_t& __left, std::nullptr_t __right) { return !(__left == __right); } | |
| 133 | ||
| 134 | friend bool operator!=(int __left, const __locale_t& __right) { return !(__left == __right); } | |
| 135 | ||
| 136 | friend bool operator!=(std::nullptr_t __left, const __locale_t& __right) { return !(__left == __right); } | |
| 137 | ||
| 138 | operator bool() const { return __locale_ != nullptr; } | |
| 139 | ||
| 140 | const char* __get_locale() const { return __locale_str_; } | |
| 141 | ||
| 142 | operator ::_locale_t() const { return __locale_; } | |
| 143 | ||
| 144 | __lconv_t* __store_lconv(const __lconv_t* __input_lc) { | |
| 145 | delete __lc_; | |
| 146 | __lc_ = new __lconv_storage(__input_lc); | |
| 147 | return __lc_->__get(); | |
| 148 | } | |
| 149 | ||
| 150 | private: | |
| 151 | ::_locale_t __locale_; | |
| 152 | const char* __locale_str_; | |
| 153 | __lconv_storage* __lc_ = nullptr; | |
| 154 | }; | |
| 155 | ||
| 156 | #if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 157 | _LIBCPP_EXPORTED_FROM_ABI __locale_t __newlocale(int __mask, const char* __locale, __locale_t __base); | |
| 158 | inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::_free_locale(__loc); } | |
| 159 | inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, const char* __locale) { | |
| 160 | char* __new_locale = ::setlocale(__category, __locale); | |
| 161 | if (__new_locale == nullptr) | |
| 162 | std::__throw_bad_alloc(); | |
| 163 | return __new_locale; | |
| 164 | } | |
| 165 | _LIBCPP_EXPORTED_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc); | |
| 166 | #endif // _LIBCPP_BUILDING_LIBRARY | |
| 167 | ||
| 168 | // | |
| 169 | // Strtonum functions | |
| 170 | // | |
| 171 | ||
| 172 | // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+ | |
| 173 | #if defined(_LIBCPP_MSVCRT) | |
| 174 | inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) { | |
| 175 | return ::_strtof_l(__nptr, __endptr, __loc); | |
| 176 | } | |
| 177 | inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) { | |
| 178 | return ::_strtold_l(__nptr, __endptr, __loc); | |
| 179 | } | |
| 180 | #else | |
| 181 | _LIBCPP_EXPORTED_FROM_ABI float __strtof(const char*, char**, __locale_t); | |
| 182 | _LIBCPP_EXPORTED_FROM_ABI long double __strtold(const char*, char**, __locale_t); | |
| 183 | #endif | |
| 184 | ||
| 185 | inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) { | |
| 186 | return ::_strtod_l(__nptr, __endptr, __loc); | |
| 187 | } | |
| 188 | ||
| 189 | inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | |
| 190 | return ::_strtoi64_l(__nptr, __endptr, __base, __loc); | |
| 191 | } | |
| 192 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | |
| 193 | __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) { | |
| 194 | return ::_strtoui64_l(__nptr, __endptr, __base, __loc); | |
| 195 | } | |
| 196 | ||
| 197 | // | |
| 198 | // Character manipulation functions | |
| 199 | // | |
| 200 | #if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 201 | inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t __loc) { return _islower_l(__c, __loc); } | |
| 202 | ||
| 203 | inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t __loc) { return _isupper_l(__c, __loc); } | |
| 204 | #endif | |
| 205 | ||
| 206 | inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return _isdigit_l(__c, __loc); } | |
| 207 | ||
| 208 | inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return _isxdigit_l(__c, __loc); } | |
| 209 | ||
| 210 | #if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 211 | inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return ::_toupper_l(__c, __loc); } | |
| 212 | ||
| 213 | inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t __loc) { return ::_tolower_l(__c, __loc); } | |
| 214 | ||
| 215 | inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) { | |
| 216 | return ::_strcoll_l(__s1, __s2, __loc); | |
| 217 | } | |
| 218 | ||
| 219 | inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) { | |
| 220 | return ::_strxfrm_l(__dest, __src, __n, __loc); | |
| 221 | } | |
| 222 | ||
| 223 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 224 | inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) { | |
| 225 | return ::_iswctype_l(__c, __type, __loc); | |
| 226 | } | |
| 227 | inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return ::_iswspace_l(__c, __loc); } | |
| 228 | inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return ::_iswprint_l(__c, __loc); } | |
| 229 | inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return ::_iswcntrl_l(__c, __loc); } | |
| 230 | inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __c, __locale_t __loc) { return ::_iswupper_l(__c, __loc); } | |
| 231 | inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __c, __locale_t __loc) { return ::_iswlower_l(__c, __loc); } | |
| 232 | inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __c, __locale_t __loc) { return ::_iswalpha_l(__c, __loc); } | |
| 233 | // TODO: use locale to determine blank characters | |
| 234 | inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __c, __locale_t /*loc*/) { return (__c == L' ' || __c == L'\t'); } | |
| 235 | inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __c, __locale_t __loc) { return ::_iswdigit_l(__c, __loc); } | |
| 236 | inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __c, __locale_t __loc) { return ::_iswpunct_l(__c, __loc); } | |
| 237 | inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __c, __locale_t __loc) { return ::_iswxdigit_l(__c, __loc); } | |
| 238 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __c, __locale_t __loc) { return ::_towupper_l(__c, __loc); } | |
| 239 | inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __c, __locale_t __loc) { return ::_towlower_l(__c, __loc); } | |
| 240 | ||
| 241 | inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t __loc) { | |
| 242 | return ::_wcscoll_l(__ws1, __ws2, __loc); | |
| 243 | } | |
| 244 | ||
| 245 | inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) { | |
| 246 | return ::_wcsxfrm_l(__dest, __src, __n, __loc); | |
| 247 | } | |
| 248 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 249 | ||
| 250 | # if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800 | |
| 251 | _LIBCPP_EXPORTED_FROM_ABI size_t __strftime(char*, size_t, const char*, const struct tm*, __locale_t); | |
| 252 | # else | |
| 253 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 254 | __strftime(char* __ret, size_t __n, const char* __format, const struct tm* __tm, __locale_t __loc) { | |
| 255 | return ::_strftime_l(__ret, __n, __format, __tm, __loc); | |
| 256 | } | |
| 257 | # endif | |
| 258 | ||
| 259 | // | |
| 260 | // Other functions | |
| 261 | // | |
| 262 | _LIBCPP_EXPORTED_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t); | |
| 263 | _LIBCPP_EXPORTED_FROM_ABI wint_t __btowc(int, __locale_t); | |
| 264 | _LIBCPP_EXPORTED_FROM_ABI int __wctob(wint_t, __locale_t); | |
| 265 | _LIBCPP_EXPORTED_FROM_ABI size_t | |
| 266 | __wcsnrtombs(char* __restrict, const wchar_t** __restrict, size_t, size_t, mbstate_t* __restrict, __locale_t); | |
| 267 | _LIBCPP_EXPORTED_FROM_ABI size_t __wcrtomb(char* __restrict, wchar_t, mbstate_t* __restrict, __locale_t); | |
| 268 | _LIBCPP_EXPORTED_FROM_ABI size_t | |
| 269 | __mbsnrtowcs(wchar_t* __restrict, const char** __restrict, size_t, size_t, mbstate_t* __restrict, __locale_t); | |
| 270 | _LIBCPP_EXPORTED_FROM_ABI size_t | |
| 271 | __mbrtowc(wchar_t* __restrict, const char* __restrict, size_t, mbstate_t* __restrict, __locale_t); | |
| 272 | ||
| 273 | inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) { | |
| 274 | return ::_mbtowc_l(__pwc, __pmb, __max, __loc); | |
| 275 | } | |
| 276 | ||
| 277 | _LIBCPP_EXPORTED_FROM_ABI size_t __mbrlen(const char* __restrict, size_t, mbstate_t* __restrict, __locale_t); | |
| 278 | ||
| 279 | _LIBCPP_EXPORTED_FROM_ABI size_t | |
| 280 | __mbsrtowcs(wchar_t* __restrict, const char** __restrict, size_t, mbstate_t* __restrict, __locale_t); | |
| 281 | #endif // _LIBCPP_BUILDING_LIBRARY | |
| 282 | ||
| 283 | _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf( | |
| 284 | char* __ret, size_t __n, __locale_t __loc, const char* __format, ...); | |
| 285 | ||
| 286 | _LIBCPP_EXPORTED_FROM_ABI | |
| 287 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(char** __ret, __locale_t __loc, const char* __format, ...); | |
| 288 | ||
| 289 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 290 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat") | |
| 291 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates | |
| 292 | #ifdef _LIBCPP_COMPILER_CLANG_BASED | |
| 293 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__) | |
| 294 | #else | |
| 295 | # define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */ | |
| 296 | #endif | |
| 297 | ||
| 298 | template <class... _Args> | |
| 299 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf( | |
| 300 | const char* __dest, __locale_t __loc, const char* __format, _Args&&... __args) { | |
| 301 | return ::_sscanf_l(__dest, __format, __loc, std::forward<_Args>(__args)...); | |
| 302 | } | |
| 303 | _LIBCPP_DIAGNOSTIC_POP | |
| 304 | #undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT | |
| 305 | ||
| 306 | #if defined(_LIBCPP_BUILDING_LIBRARY) | |
| 307 | struct __locale_guard { | |
| 308 | _LIBCPP_HIDE_FROM_ABI __locale_guard(__locale_t __l) : __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) { | |
| 309 | // Setting the locale can be expensive even when the locale given is | |
| 310 | // already the current locale, so do an explicit check to see if the | |
| 311 | // current locale is already the one we want. | |
| 312 | const char* __lc = __locale::__setlocale(LC_ALL, nullptr); | |
| 313 | // If every category is the same, the locale string will simply be the | |
| 314 | // locale name, otherwise it will be a semicolon-separated string listing | |
| 315 | // each category. In the second case, we know at least one category won't | |
| 316 | // be what we want, so we only have to check the first case. | |
| 317 | if (std::strcmp(__l.__get_locale(), __lc) != 0) { | |
| 318 | __locale_all = _strdup(__lc); | |
| 319 | if (__locale_all == nullptr) | |
| 320 | __throw_bad_alloc(); | |
| 321 | __locale::__setlocale(LC_ALL, __l.__get_locale()); | |
| 322 | } | |
| 323 | } | |
| 324 | _LIBCPP_HIDE_FROM_ABI ~__locale_guard() { | |
| 325 | // The CRT documentation doesn't explicitly say, but setlocale() does the | |
| 326 | // right thing when given a semicolon-separated list of locale settings | |
| 327 | // for the different categories in the same format as returned by | |
| 328 | // setlocale(LC_ALL, nullptr). | |
| 329 | if (__locale_all != nullptr) { | |
| 330 | __locale::__setlocale(LC_ALL, __locale_all); | |
| 331 | free(__locale_all); | |
| 332 | } | |
| 333 | _configthreadlocale(__status); | |
| 334 | } | |
| 335 | int __status; | |
| 336 | char* __locale_all = nullptr; | |
| 337 | }; | |
| 338 | #endif // _LIBCPP_BUILDING_LIBRARY | |
| 339 | ||
| 340 | } // namespace __locale | |
| 341 | _LIBCPP_END_NAMESPACE_STD | |
| 342 | ||
| 343 | #endif // _LIBCPP___LOCALE_DIR_SUPPORT_WINDOWS_H |
lib/libcxx/include/__math/abs.h+4-4| ... | ... | @@ -23,19 +23,19 @@ namespace __math { |
| 23 | 23 | |
| 24 | 24 | // fabs |
| 25 | 25 | |
| 26 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); } | |
| 26 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); } | |
| 27 | 27 | |
| 28 | 28 | template <class = int> |
| 29 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { | |
| 29 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { | |
| 30 | 30 | return __builtin_fabs(__x); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT { | |
| 33 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT { | |
| 34 | 34 | return __builtin_fabsl(__x); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 38 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT { | |
| 38 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT { | |
| 39 | 39 | return __builtin_fabs((double)__x); |
| 40 | 40 | } |
| 41 | 41 |
lib/libcxx/include/__math/copysign.h+3-4| ... | ... | @@ -13,7 +13,6 @@ |
| 13 | 13 | #include <__type_traits/enable_if.h> |
| 14 | 14 | #include <__type_traits/is_arithmetic.h> |
| 15 | 15 | #include <__type_traits/promote.h> |
| 16 | #include <limits> | |
| 17 | 16 | |
| 18 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 18 | # pragma GCC system_header |
| ... | ... | @@ -25,16 +24,16 @@ namespace __math { |
| 25 | 24 | |
| 26 | 25 | // copysign |
| 27 | 26 | |
| 28 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { | |
| 27 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { | |
| 29 | 28 | return ::__builtin_copysignf(__x, __y); |
| 30 | 29 | } |
| 31 | 30 | |
| 32 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { | |
| 31 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { | |
| 33 | 32 | return ::__builtin_copysignl(__x, __y); |
| 34 | 33 | } |
| 35 | 34 | |
| 36 | 35 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 37 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type copysign(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 36 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type copysign(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 38 | 37 | return ::__builtin_copysign(__x, __y); |
| 39 | 38 | } |
| 40 | 39 |
lib/libcxx/include/__math/hypot.h+2-3| ... | ... | @@ -9,16 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___MATH_HYPOT_H |
| 10 | 10 | #define _LIBCPP___MATH_HYPOT_H |
| 11 | 11 | |
| 12 | #include <__algorithm/max.h> | |
| 13 | 12 | #include <__config> |
| 14 | 13 | #include <__math/abs.h> |
| 15 | 14 | #include <__math/exponential_functions.h> |
| 15 | #include <__math/min_max.h> | |
| 16 | 16 | #include <__math/roots.h> |
| 17 | 17 | #include <__type_traits/enable_if.h> |
| 18 | 18 | #include <__type_traits/is_arithmetic.h> |
| 19 | 19 | #include <__type_traits/is_same.h> |
| 20 | 20 | #include <__type_traits/promote.h> |
| 21 | #include <__utility/pair.h> | |
| 22 | 21 | #include <limits> |
| 23 | 22 | |
| 24 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -63,7 +62,7 @@ _LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) { |
| 63 | 62 | const _Real __overflow_scale = __math::ldexp(_Real(1), -(__exp + 20)); |
| 64 | 63 | |
| 65 | 64 | // Scale arguments depending on their size |
| 66 | const _Real __max_abs = std::max(__math::fabs(__x), std::max(__math::fabs(__y), __math::fabs(__z))); | |
| 65 | const _Real __max_abs = __math::fmax(__math::fabs(__x), __math::fmax(__math::fabs(__y), __math::fabs(__z))); | |
| 67 | 66 | _Real __scale; |
| 68 | 67 | if (__max_abs > __overflow_threshold) { // x*x + y*y + z*z might overflow |
| 69 | 68 | __scale = __overflow_scale; |
lib/libcxx/include/__math/min_max.h+8-8| ... | ... | @@ -25,21 +25,21 @@ namespace __math { |
| 25 | 25 | |
| 26 | 26 | // fmax |
| 27 | 27 | |
| 28 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { | |
| 28 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { | |
| 29 | 29 | return __builtin_fmaxf(__x, __y); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | template <class = int> |
| 33 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { | |
| 33 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { | |
| 34 | 34 | return __builtin_fmax(__x, __y); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT { | |
| 37 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT { | |
| 38 | 38 | return __builtin_fmaxl(__x, __y); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 42 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 42 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 43 | 43 | using __result_type = typename __promote<_A1, _A2>::type; |
| 44 | 44 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 45 | 45 | return __math::fmax((__result_type)__x, (__result_type)__y); |
| ... | ... | @@ -47,21 +47,21 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::typ |
| 47 | 47 | |
| 48 | 48 | // fmin |
| 49 | 49 | |
| 50 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT { | |
| 50 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT { | |
| 51 | 51 | return __builtin_fminf(__x, __y); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | template <class = int> |
| 55 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { | |
| 55 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { | |
| 56 | 56 | return __builtin_fmin(__x, __y); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT { | |
| 59 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT { | |
| 60 | 60 | return __builtin_fminl(__x, __y); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 64 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 64 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 65 | 65 | using __result_type = typename __promote<_A1, _A2>::type; |
| 66 | 66 | static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), ""); |
| 67 | 67 | return __math::fmin((__result_type)__x, (__result_type)__y); |
lib/libcxx/include/__math/remainder.h-1| ... | ... | @@ -14,7 +14,6 @@ |
| 14 | 14 | #include <__type_traits/is_arithmetic.h> |
| 15 | 15 | #include <__type_traits/is_same.h> |
| 16 | 16 | #include <__type_traits/promote.h> |
| 17 | #include <limits> | |
| 18 | 17 | |
| 19 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 19 | # pragma GCC system_header |
lib/libcxx/include/__math/roots.h+4-4| ... | ... | @@ -39,19 +39,19 @@ inline _LIBCPP_HIDE_FROM_ABI double sqrt(_A1 __x) _NOEXCEPT { |
| 39 | 39 | |
| 40 | 40 | // cbrt |
| 41 | 41 | |
| 42 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); } | |
| 42 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); } | |
| 43 | 43 | |
| 44 | 44 | template <class = int> |
| 45 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { | |
| 45 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { | |
| 46 | 46 | return __builtin_cbrt(__x); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT { | |
| 49 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT { | |
| 50 | 50 | return __builtin_cbrtl(__x); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 54 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT { | |
| 54 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT { | |
| 55 | 55 | return __builtin_cbrt((double)__x); |
| 56 | 56 | } |
| 57 | 57 |
lib/libcxx/include/__math/rounding_functions.h+24-24| ... | ... | @@ -26,37 +26,37 @@ namespace __math { |
| 26 | 26 | |
| 27 | 27 | // ceil |
| 28 | 28 | |
| 29 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); } | |
| 29 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); } | |
| 30 | 30 | |
| 31 | 31 | template <class = int> |
| 32 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { | |
| 32 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { | |
| 33 | 33 | return __builtin_ceil(__x); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT { | |
| 36 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT { | |
| 37 | 37 | return __builtin_ceill(__x); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 41 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT { | |
| 41 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT { | |
| 42 | 42 | return __builtin_ceil((double)__x); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // floor |
| 46 | 46 | |
| 47 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); } | |
| 47 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); } | |
| 48 | 48 | |
| 49 | 49 | template <class = int> |
| 50 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { | |
| 50 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { | |
| 51 | 51 | return __builtin_floor(__x); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT { | |
| 54 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT { | |
| 55 | 55 | return __builtin_floorl(__x); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 59 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT { | |
| 59 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT { | |
| 60 | 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 | 126 | |
| 127 | 127 | // nearbyint |
| 128 | 128 | |
| 129 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT { | |
| 129 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT { | |
| 130 | 130 | return __builtin_nearbyintf(__x); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | template <class = int> |
| 134 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { | |
| 134 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { | |
| 135 | 135 | return __builtin_nearbyint(__x); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT { | |
| 138 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT { | |
| 139 | 139 | return __builtin_nearbyintl(__x); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 143 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT { | |
| 143 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT { | |
| 144 | 144 | return __builtin_nearbyint((double)__x); |
| 145 | 145 | } |
| 146 | 146 | |
| ... | ... | @@ -186,55 +186,55 @@ inline _LIBCPP_HIDE_FROM_ABI double nexttoward(_A1 __x, long double __y) _NOEXCE |
| 186 | 186 | |
| 187 | 187 | // rint |
| 188 | 188 | |
| 189 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); } | |
| 189 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); } | |
| 190 | 190 | |
| 191 | 191 | template <class = int> |
| 192 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { | |
| 192 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { | |
| 193 | 193 | return __builtin_rint(__x); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT { | |
| 196 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT { | |
| 197 | 197 | return __builtin_rintl(__x); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 201 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT { | |
| 201 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT { | |
| 202 | 202 | return __builtin_rint((double)__x); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // round |
| 206 | 206 | |
| 207 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); } | |
| 207 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); } | |
| 208 | 208 | |
| 209 | 209 | template <class = int> |
| 210 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { | |
| 210 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { | |
| 211 | 211 | return __builtin_round(__x); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT { | |
| 214 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT { | |
| 215 | 215 | return __builtin_roundl(__x); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 219 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT { | |
| 219 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT { | |
| 220 | 220 | return __builtin_round((double)__x); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // trunc |
| 224 | 224 | |
| 225 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_trunc(__x); } | |
| 225 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_trunc(__x); } | |
| 226 | 226 | |
| 227 | 227 | template <class = int> |
| 228 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { | |
| 228 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { | |
| 229 | 229 | return __builtin_trunc(__x); |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT { | |
| 232 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT { | |
| 233 | 233 | return __builtin_truncl(__x); |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 237 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT { | |
| 237 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT { | |
| 238 | 238 | return __builtin_trunc((double)__x); |
| 239 | 239 | } |
| 240 | 240 |
lib/libcxx/include/__math/traits.h+66-52| ... | ... | @@ -12,11 +12,9 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__type_traits/enable_if.h> |
| 14 | 14 | #include <__type_traits/is_arithmetic.h> |
| 15 | #include <__type_traits/is_floating_point.h> | |
| 16 | 15 | #include <__type_traits/is_integral.h> |
| 17 | 16 | #include <__type_traits/is_signed.h> |
| 18 | 17 | #include <__type_traits/promote.h> |
| 19 | #include <limits> | |
| 20 | 18 | |
| 21 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 20 | # pragma GCC system_header |
| ... | ... | @@ -28,115 +26,131 @@ namespace __math { |
| 28 | 26 | |
| 29 | 27 | // signbit |
| 30 | 28 | |
| 31 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> | |
| 32 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { | |
| 29 | // TODO(LLVM 22): Remove conditional once support for Clang 19 is dropped. | |
| 30 | #if defined(_LIBCPP_COMPILER_GCC) || __has_constexpr_builtin(__builtin_signbit) | |
| 31 | # define _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_CONSTEXPR_SINCE_CXX23 | |
| 32 | #else | |
| 33 | # define _LIBCPP_SIGNBIT_CONSTEXPR | |
| 34 | #endif | |
| 35 | ||
| 36 | // The universal C runtime (UCRT) in the WinSDK provides floating point overloads | |
| 37 | // for std::signbit(). By defining our overloads as templates, we can work around | |
| 38 | // this issue as templates are less preferred than non-template functions. | |
| 39 | template <class = void> | |
| 40 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(float __x) _NOEXCEPT { | |
| 41 | return __builtin_signbit(__x); | |
| 42 | } | |
| 43 | ||
| 44 | template <class = void> | |
| 45 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(double __x) _NOEXCEPT { | |
| 46 | return __builtin_signbit(__x); | |
| 47 | } | |
| 48 | ||
| 49 | template <class = void> | |
| 50 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(long double __x) _NOEXCEPT { | |
| 33 | 51 | return __builtin_signbit(__x); |
| 34 | 52 | } |
| 35 | 53 | |
| 36 | 54 | template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0> |
| 37 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { | |
| 55 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { | |
| 38 | 56 | return __x < 0; |
| 39 | 57 | } |
| 40 | 58 | |
| 41 | 59 | template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0> |
| 42 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { | |
| 60 | [[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { | |
| 43 | 61 | return false; |
| 44 | 62 | } |
| 45 | 63 | |
| 46 | 64 | // isfinite |
| 47 | 65 | |
| 48 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0> | |
| 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); | |
| 51 | } | |
| 52 | ||
| 53 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0> | |
| 54 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { | |
| 66 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | |
| 67 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { | |
| 55 | 68 | return true; |
| 56 | 69 | } |
| 57 | 70 | |
| 58 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(float __x) _NOEXCEPT { | |
| 71 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(float __x) _NOEXCEPT { | |
| 59 | 72 | return __builtin_isfinite(__x); |
| 60 | 73 | } |
| 61 | 74 | |
| 62 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(double __x) _NOEXCEPT { | |
| 75 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(double __x) _NOEXCEPT { | |
| 63 | 76 | return __builtin_isfinite(__x); |
| 64 | 77 | } |
| 65 | 78 | |
| 66 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(long double __x) _NOEXCEPT { | |
| 79 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(long double __x) _NOEXCEPT { | |
| 67 | 80 | return __builtin_isfinite(__x); |
| 68 | 81 | } |
| 69 | 82 | |
| 70 | 83 | // isinf |
| 71 | 84 | |
| 72 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0> | |
| 73 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT { | |
| 74 | return __builtin_isinf((typename __promote<_A1>::type)__x); | |
| 75 | } | |
| 76 | ||
| 77 | template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0> | |
| 78 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT { | |
| 85 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | |
| 86 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT { | |
| 79 | 87 | return false; |
| 80 | 88 | } |
| 81 | 89 | |
| 82 | #ifdef _LIBCPP_PREFERRED_OVERLOAD | |
| 83 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { | |
| 90 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { | |
| 84 | 91 | return __builtin_isinf(__x); |
| 85 | 92 | } |
| 86 | 93 | |
| 87 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool | |
| 88 | isinf(double __x) _NOEXCEPT { | |
| 94 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI | |
| 95 | #ifdef _LIBCPP_PREFERRED_OVERLOAD | |
| 96 | _LIBCPP_PREFERRED_OVERLOAD | |
| 97 | #endif | |
| 98 | bool | |
| 99 | isinf(double __x) _NOEXCEPT { | |
| 89 | 100 | return __builtin_isinf(__x); |
| 90 | 101 | } |
| 91 | 102 | |
| 92 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { | |
| 103 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { | |
| 93 | 104 | return __builtin_isinf(__x); |
| 94 | 105 | } |
| 95 | #endif | |
| 96 | 106 | |
| 97 | 107 | // isnan |
| 98 | 108 | |
| 99 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> | |
| 100 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT { | |
| 101 | return __builtin_isnan(__x); | |
| 102 | } | |
| 103 | ||
| 104 | 109 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> |
| 105 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { | |
| 110 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { | |
| 106 | 111 | return false; |
| 107 | 112 | } |
| 108 | 113 | |
| 109 | #ifdef _LIBCPP_PREFERRED_OVERLOAD | |
| 110 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { | |
| 114 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { | |
| 111 | 115 | return __builtin_isnan(__x); |
| 112 | 116 | } |
| 113 | 117 | |
| 114 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool | |
| 115 | isnan(double __x) _NOEXCEPT { | |
| 118 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI | |
| 119 | #ifdef _LIBCPP_PREFERRED_OVERLOAD | |
| 120 | _LIBCPP_PREFERRED_OVERLOAD | |
| 121 | #endif | |
| 122 | bool | |
| 123 | isnan(double __x) _NOEXCEPT { | |
| 116 | 124 | return __builtin_isnan(__x); |
| 117 | 125 | } |
| 118 | 126 | |
| 119 | _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { | |
| 127 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { | |
| 120 | 128 | return __builtin_isnan(__x); |
| 121 | 129 | } |
| 122 | #endif | |
| 123 | 130 | |
| 124 | 131 | // isnormal |
| 125 | 132 | |
| 126 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> | |
| 127 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { | |
| 133 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | |
| 134 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { | |
| 135 | return __x != 0; | |
| 136 | } | |
| 137 | ||
| 138 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(float __x) _NOEXCEPT { | |
| 128 | 139 | return __builtin_isnormal(__x); |
| 129 | 140 | } |
| 130 | 141 | |
| 131 | template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> | |
| 132 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { | |
| 133 | return __x != 0; | |
| 142 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(double __x) _NOEXCEPT { | |
| 143 | return __builtin_isnormal(__x); | |
| 144 | } | |
| 145 | ||
| 146 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(long double __x) _NOEXCEPT { | |
| 147 | return __builtin_isnormal(__x); | |
| 134 | 148 | } |
| 135 | 149 | |
| 136 | 150 | // isgreater |
| 137 | 151 | |
| 138 | 152 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 139 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 153 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 140 | 154 | using type = typename __promote<_A1, _A2>::type; |
| 141 | 155 | return __builtin_isgreater((type)__x, (type)__y); |
| 142 | 156 | } |
| ... | ... | @@ -144,7 +158,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) |
| 144 | 158 | // isgreaterequal |
| 145 | 159 | |
| 146 | 160 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 147 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 161 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 148 | 162 | using type = typename __promote<_A1, _A2>::type; |
| 149 | 163 | return __builtin_isgreaterequal((type)__x, (type)__y); |
| 150 | 164 | } |
| ... | ... | @@ -152,7 +166,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 |
| 152 | 166 | // isless |
| 153 | 167 | |
| 154 | 168 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 155 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 169 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 156 | 170 | using type = typename __promote<_A1, _A2>::type; |
| 157 | 171 | return __builtin_isless((type)__x, (type)__y); |
| 158 | 172 | } |
| ... | ... | @@ -160,7 +174,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NO |
| 160 | 174 | // islessequal |
| 161 | 175 | |
| 162 | 176 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 163 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 177 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 164 | 178 | using type = typename __promote<_A1, _A2>::type; |
| 165 | 179 | return __builtin_islessequal((type)__x, (type)__y); |
| 166 | 180 | } |
| ... | ... | @@ -168,7 +182,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y |
| 168 | 182 | // islessgreater |
| 169 | 183 | |
| 170 | 184 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 171 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 185 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 172 | 186 | using type = typename __promote<_A1, _A2>::type; |
| 173 | 187 | return __builtin_islessgreater((type)__x, (type)__y); |
| 174 | 188 | } |
| ... | ... | @@ -176,7 +190,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 _ |
| 176 | 190 | // isunordered |
| 177 | 191 | |
| 178 | 192 | template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> |
| 179 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 193 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { | |
| 180 | 194 | using type = typename __promote<_A1, _A2>::type; |
| 181 | 195 | return __builtin_isunordered((type)__x, (type)__y); |
| 182 | 196 | } |
lib/libcxx/include/__mbstate_t.h+2-2| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | # define __CORRECT_ISO_CPP_WCHAR_H_PROTO |
| 36 | 36 | #endif |
| 37 | 37 | |
| 38 | #if defined(_LIBCPP_HAS_MUSL_LIBC) | |
| 38 | #if _LIBCPP_HAS_MUSL_LIBC | |
| 39 | 39 | # define __NEED_mbstate_t |
| 40 | 40 | # include <bits/alltypes.h> |
| 41 | 41 | # undef __NEED_mbstate_t |
| ... | ... | @@ -43,7 +43,7 @@ |
| 43 | 43 | # include <bits/types/mbstate_t.h> // works on most Unixes |
| 44 | 44 | #elif __has_include(<sys/_types/_mbstate_t.h>) |
| 45 | 45 | # include <sys/_types/_mbstate_t.h> // works on Darwin |
| 46 | #elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && __has_include_next(<wchar.h>) | |
| 46 | #elif _LIBCPP_HAS_WIDE_CHARACTERS && __has_include_next(<wchar.h>) | |
| 47 | 47 | # include_next <wchar.h> // fall back to the C standard provider of mbstate_t |
| 48 | 48 | #elif __has_include_next(<uchar.h>) |
| 49 | 49 | # include_next <uchar.h> // <uchar.h> is also required to make mbstate_t visible |
lib/libcxx/include/__mdspan/default_accessor.h+1-2| ... | ... | @@ -18,12 +18,11 @@ |
| 18 | 18 | #define _LIBCPP___MDSPAN_DEFAULT_ACCESSOR_H |
| 19 | 19 | |
| 20 | 20 | #include <__config> |
| 21 | #include <__cstddef/size_t.h> | |
| 21 | 22 | #include <__type_traits/is_abstract.h> |
| 22 | 23 | #include <__type_traits/is_array.h> |
| 23 | 24 | #include <__type_traits/is_convertible.h> |
| 24 | 25 | #include <__type_traits/remove_const.h> |
| 25 | #include <cinttypes> | |
| 26 | #include <cstddef> | |
| 27 | 26 | |
| 28 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | 28 | # pragma GCC system_header |
lib/libcxx/include/__mdspan/extents.h+10-9| ... | ... | @@ -19,6 +19,9 @@ |
| 19 | 19 | |
| 20 | 20 | #include <__assert> |
| 21 | 21 | #include <__config> |
| 22 | ||
| 23 | #include <__concepts/arithmetic.h> | |
| 24 | #include <__cstddef/byte.h> | |
| 22 | 25 | #include <__type_traits/common_type.h> |
| 23 | 26 | #include <__type_traits/is_convertible.h> |
| 24 | 27 | #include <__type_traits/is_nothrow_constructible.h> |
| ... | ... | @@ -27,9 +30,7 @@ |
| 27 | 30 | #include <__utility/integer_sequence.h> |
| 28 | 31 | #include <__utility/unreachable.h> |
| 29 | 32 | #include <array> |
| 30 | #include <cinttypes> | |
| 31 | 33 | #include <concepts> |
| 32 | #include <cstddef> | |
| 33 | 34 | #include <limits> |
| 34 | 35 | #include <span> |
| 35 | 36 | |
| ... | ... | @@ -128,14 +129,14 @@ private: |
| 128 | 129 | // Static values member |
| 129 | 130 | static constexpr size_t __size_ = sizeof...(_Values); |
| 130 | 131 | static constexpr size_t __size_dynamic_ = ((_Values == _DynTag) + ... + 0); |
| 131 | using _StaticValues = __static_array<_TStatic, _Values...>; | |
| 132 | using _DynamicValues = __possibly_empty_array<_TDynamic, __size_dynamic_>; | |
| 132 | using _StaticValues _LIBCPP_NODEBUG = __static_array<_TStatic, _Values...>; | |
| 133 | using _DynamicValues _LIBCPP_NODEBUG = __possibly_empty_array<_TDynamic, __size_dynamic_>; | |
| 133 | 134 | |
| 134 | 135 | // Dynamic values member |
| 135 | 136 | _LIBCPP_NO_UNIQUE_ADDRESS _DynamicValues __dyn_vals_; |
| 136 | 137 | |
| 137 | 138 | // static mapping of indices to the position in the dynamic values array |
| 138 | using _DynamicIdxMap = __static_partial_sums<static_cast<size_t>(_Values == _DynTag)...>; | |
| 139 | using _DynamicIdxMap _LIBCPP_NODEBUG = __static_partial_sums<static_cast<size_t>(_Values == _DynTag)...>; | |
| 139 | 140 | |
| 140 | 141 | template <size_t... _Indices> |
| 141 | 142 | _LIBCPP_HIDE_FROM_ABI static constexpr _DynamicValues __zeros(index_sequence<_Indices...>) noexcept { |
| ... | ... | @@ -282,8 +283,7 @@ public: |
| 282 | 283 | using size_type = make_unsigned_t<index_type>; |
| 283 | 284 | using rank_type = size_t; |
| 284 | 285 | |
| 285 | static_assert(is_integral<index_type>::value && !is_same<index_type, bool>::value, | |
| 286 | "extents::index_type must be a signed or unsigned integer type"); | |
| 286 | static_assert(__libcpp_integer<index_type>, "extents::index_type must be a signed or unsigned integer type"); | |
| 287 | 287 | static_assert(((__mdspan_detail::__is_representable_as<index_type>(_Extents) || (_Extents == dynamic_extent)) && ...), |
| 288 | 288 | "extents ctor: arguments must be representable as index_type and nonnegative"); |
| 289 | 289 | |
| ... | ... | @@ -292,7 +292,8 @@ private: |
| 292 | 292 | static constexpr rank_type __rank_dynamic_ = ((_Extents == dynamic_extent) + ... + 0); |
| 293 | 293 | |
| 294 | 294 | // internal storage type using __maybe_static_array |
| 295 | using _Values = __mdspan_detail::__maybe_static_array<_IndexType, size_t, dynamic_extent, _Extents...>; | |
| 295 | using _Values _LIBCPP_NODEBUG = | |
| 296 | __mdspan_detail::__maybe_static_array<_IndexType, size_t, dynamic_extent, _Extents...>; | |
| 296 | 297 | [[no_unique_address]] _Values __vals_; |
| 297 | 298 | |
| 298 | 299 | public: |
| ... | ... | @@ -448,7 +449,7 @@ struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> { |
| 448 | 449 | using type = extents<_IndexType, _ExtentsPack...>; |
| 449 | 450 | }; |
| 450 | 451 | |
| 451 | } // end namespace __mdspan_detail | |
| 452 | } // namespace __mdspan_detail | |
| 452 | 453 | |
| 453 | 454 | // [mdspan.extents.dextents], alias template |
| 454 | 455 | template <class _IndexType, size_t _Rank> |
lib/libcxx/include/__mdspan/layout_left.h+1-3| ... | ... | @@ -21,14 +21,12 @@ |
| 21 | 21 | #include <__config> |
| 22 | 22 | #include <__fwd/mdspan.h> |
| 23 | 23 | #include <__mdspan/extents.h> |
| 24 | #include <__type_traits/common_type.h> | |
| 24 | 25 | #include <__type_traits/is_constructible.h> |
| 25 | 26 | #include <__type_traits/is_convertible.h> |
| 26 | 27 | #include <__type_traits/is_nothrow_constructible.h> |
| 27 | 28 | #include <__utility/integer_sequence.h> |
| 28 | 29 | #include <array> |
| 29 | #include <cinttypes> | |
| 30 | #include <cstddef> | |
| 31 | #include <limits> | |
| 32 | 30 | |
| 33 | 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 34 | 32 | # pragma GCC system_header |
lib/libcxx/include/__mdspan/layout_right.h+2-3| ... | ... | @@ -19,15 +19,14 @@ |
| 19 | 19 | |
| 20 | 20 | #include <__assert> |
| 21 | 21 | #include <__config> |
| 22 | #include <__cstddef/size_t.h> | |
| 22 | 23 | #include <__fwd/mdspan.h> |
| 23 | 24 | #include <__mdspan/extents.h> |
| 25 | #include <__type_traits/common_type.h> | |
| 24 | 26 | #include <__type_traits/is_constructible.h> |
| 25 | 27 | #include <__type_traits/is_convertible.h> |
| 26 | 28 | #include <__type_traits/is_nothrow_constructible.h> |
| 27 | 29 | #include <__utility/integer_sequence.h> |
| 28 | #include <cinttypes> | |
| 29 | #include <cstddef> | |
| 30 | #include <limits> | |
| 31 | 30 | |
| 32 | 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 33 | 32 | # pragma GCC system_header |
lib/libcxx/include/__mdspan/layout_stride.h+5-2| ... | ... | @@ -18,19 +18,22 @@ |
| 18 | 18 | #define _LIBCPP___MDSPAN_LAYOUT_STRIDE_H |
| 19 | 19 | |
| 20 | 20 | #include <__assert> |
| 21 | #include <__concepts/same_as.h> | |
| 21 | 22 | #include <__config> |
| 22 | 23 | #include <__fwd/mdspan.h> |
| 23 | 24 | #include <__mdspan/extents.h> |
| 25 | #include <__type_traits/common_type.h> | |
| 24 | 26 | #include <__type_traits/is_constructible.h> |
| 25 | 27 | #include <__type_traits/is_convertible.h> |
| 28 | #include <__type_traits/is_integral.h> | |
| 26 | 29 | #include <__type_traits/is_nothrow_constructible.h> |
| 30 | #include <__type_traits/is_same.h> | |
| 27 | 31 | #include <__utility/as_const.h> |
| 28 | 32 | #include <__utility/integer_sequence.h> |
| 29 | 33 | #include <__utility/swap.h> |
| 30 | 34 | #include <array> |
| 31 | #include <cinttypes> | |
| 32 | #include <cstddef> | |
| 33 | 35 | #include <limits> |
| 36 | #include <span> | |
| 34 | 37 | |
| 35 | 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 36 | 39 | # pragma GCC system_header |
lib/libcxx/include/__mdspan/mdspan.h-3| ... | ... | @@ -37,9 +37,6 @@ |
| 37 | 37 | #include <__type_traits/remove_reference.h> |
| 38 | 38 | #include <__utility/integer_sequence.h> |
| 39 | 39 | #include <array> |
| 40 | #include <cinttypes> | |
| 41 | #include <cstddef> | |
| 42 | #include <limits> | |
| 43 | 40 | #include <span> |
| 44 | 41 | |
| 45 | 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__memory/addressof.h+3-5| ... | ... | @@ -23,17 +23,15 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* a |
| 23 | 23 | return __builtin_addressof(__x); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) | |
| 26 | #if _LIBCPP_HAS_OBJC_ARC | |
| 27 | 27 | // Objective-C++ Automatic Reference Counting uses qualified pointers |
| 28 | // that require special addressof() signatures. When | |
| 29 | // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler | |
| 30 | // itself is providing these definitions. Otherwise, we provide them. | |
| 28 | // that require special addressof() signatures. | |
| 31 | 29 | template <class _Tp> |
| 32 | 30 | inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEPT { |
| 33 | 31 | return &__x; |
| 34 | 32 | } |
| 35 | 33 | |
| 36 | # ifdef _LIBCPP_HAS_OBJC_ARC_WEAK | |
| 34 | # if _LIBCPP_HAS_OBJC_ARC_WEAK | |
| 37 | 35 | template <class _Tp> |
| 38 | 36 | inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT { |
| 39 | 37 | return &__x; |
lib/libcxx/include/__memory/align.h+1-1| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___MEMORY_ALIGN_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 16 | # pragma GCC system_header |
lib/libcxx/include/__memory/aligned_alloc.h+3-4| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #define _LIBCPP___MEMORY_ALIGNED_ALLOC_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 14 | 13 | #include <cstdlib> |
| 15 | 14 | |
| 16 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -19,7 +18,7 @@ |
| 19 | 18 | |
| 20 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 20 | |
| 22 | #ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 21 | #if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION | |
| 23 | 22 | |
| 24 | 23 | // Low-level helpers to call the aligned allocation and deallocation functions |
| 25 | 24 | // on the target platform. This is used to implement libc++'s own memory |
| ... | ... | @@ -30,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 29 | inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) { |
| 31 | 30 | # if defined(_LIBCPP_MSVCRT_LIKE) |
| 32 | 31 | return ::_aligned_malloc(__size, __alignment); |
| 33 | # elif _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC) | |
| 32 | # elif _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_C11_ALIGNED_ALLOC | |
| 34 | 33 | // aligned_alloc() requires that __size is a multiple of __alignment, |
| 35 | 34 | // but for C++ [new.delete.general], only states "if the value of an |
| 36 | 35 | // alignment argument passed to any of these functions is not a valid |
| ... | ... | @@ -57,7 +56,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_aligned_free(void* __ptr) { |
| 57 | 56 | # endif |
| 58 | 57 | } |
| 59 | 58 | |
| 60 | #endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 59 | #endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION | |
| 61 | 60 | |
| 62 | 61 | _LIBCPP_END_NAMESPACE_STD |
| 63 | 62 |
lib/libcxx/include/__memory/allocate_at_least.h+2-2| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__memory/allocator_traits.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
| ... | ... | @@ -35,7 +35,7 @@ struct __allocation_result { |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | template <class _Alloc> |
| 38 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI | |
| 38 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI | |
| 39 | 39 | _LIBCPP_CONSTEXPR __allocation_result<typename allocator_traits<_Alloc>::pointer> |
| 40 | 40 | __allocate_at_least(_Alloc& __alloc, size_t __n) { |
| 41 | 41 | return {__alloc.allocate(__n), __n}; |
lib/libcxx/include/__memory/allocation_guard.h+2-3| ... | ... | @@ -14,7 +14,6 @@ |
| 14 | 14 | #include <__memory/addressof.h> |
| 15 | 15 | #include <__memory/allocator_traits.h> |
| 16 | 16 | #include <__utility/move.h> |
| 17 | #include <cstddef> | |
| 18 | 17 | |
| 19 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 19 | # pragma GCC system_header |
| ... | ... | @@ -46,8 +45,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 46 | 45 | // custom allocator. |
| 47 | 46 | template <class _Alloc> |
| 48 | 47 | struct __allocation_guard { |
| 49 | using _Pointer = typename allocator_traits<_Alloc>::pointer; | |
| 50 | using _Size = typename allocator_traits<_Alloc>::size_type; | |
| 48 | using _Pointer _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::pointer; | |
| 49 | using _Size _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::size_type; | |
| 51 | 50 | |
| 52 | 51 | template <class _AllocT> // we perform the allocator conversion inside the constructor |
| 53 | 52 | _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n) |
lib/libcxx/include/__memory/allocator.h+11-102| ... | ... | @@ -11,17 +11,19 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_ALLOCATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 15 | #include <__cstddef/size_t.h> | |
| 14 | 16 | #include <__memory/addressof.h> |
| 15 | 17 | #include <__memory/allocate_at_least.h> |
| 16 | 18 | #include <__memory/allocator_traits.h> |
| 19 | #include <__new/allocate.h> | |
| 20 | #include <__new/exceptions.h> | |
| 17 | 21 | #include <__type_traits/is_const.h> |
| 18 | 22 | #include <__type_traits/is_constant_evaluated.h> |
| 19 | 23 | #include <__type_traits/is_same.h> |
| 20 | 24 | #include <__type_traits/is_void.h> |
| 21 | 25 | #include <__type_traits/is_volatile.h> |
| 22 | 26 | #include <__utility/forward.h> |
| 23 | #include <cstddef> | |
| 24 | #include <new> | |
| 25 | 27 | |
| 26 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | 29 | # pragma GCC system_header |
| ... | ... | @@ -47,23 +49,7 @@ public: |
| 47 | 49 | typedef allocator<_Up> other; |
| 48 | 50 | }; |
| 49 | 51 | }; |
| 50 | ||
| 51 | // TODO(LLVM 20): Remove the escape hatch | |
| 52 | # ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST | |
| 53 | template <> | |
| 54 | class _LIBCPP_TEMPLATE_VIS allocator<const void> { | |
| 55 | public: | |
| 56 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer; | |
| 57 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; | |
| 58 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type; | |
| 59 | ||
| 60 | template <class _Up> | |
| 61 | struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { | |
| 62 | typedef allocator<_Up> other; | |
| 63 | }; | |
| 64 | }; | |
| 65 | # endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST | |
| 66 | #endif // _LIBCPP_STD_VER <= 17 | |
| 52 | #endif // _LIBCPP_STD_VER <= 17 | |
| 67 | 53 | |
| 68 | 54 | // This class provides a non-trivial default constructor to the class that derives from it |
| 69 | 55 | // if the condition is satisfied. |
| ... | ... | @@ -109,18 +95,20 @@ public: |
| 109 | 95 | template <class _Up> |
| 110 | 96 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {} |
| 111 | 97 | |
| 112 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) { | |
| 98 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) { | |
| 99 | static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type"); | |
| 113 | 100 | if (__n > allocator_traits<allocator>::max_size(*this)) |
| 114 | 101 | __throw_bad_array_new_length(); |
| 115 | 102 | if (__libcpp_is_constant_evaluated()) { |
| 116 | 103 | return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); |
| 117 | 104 | } else { |
| 118 | return static_cast<_Tp*>(std::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); | |
| 105 | return std::__libcpp_allocate<_Tp>(__element_count(__n)); | |
| 119 | 106 | } |
| 120 | 107 | } |
| 121 | 108 | |
| 122 | 109 | #if _LIBCPP_STD_VER >= 23 |
| 123 | 110 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<_Tp*> allocate_at_least(size_t __n) { |
| 111 | static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type"); | |
| 124 | 112 | return {allocate(__n), __n}; |
| 125 | 113 | } |
| 126 | 114 | #endif |
| ... | ... | @@ -129,7 +117,7 @@ public: |
| 129 | 117 | if (__libcpp_is_constant_evaluated()) { |
| 130 | 118 | ::operator delete(__p); |
| 131 | 119 | } else { |
| 132 | std::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); | |
| 120 | std::__libcpp_deallocate<_Tp>(__p, __element_count(__n)); | |
| 133 | 121 | } |
| 134 | 122 | } |
| 135 | 123 | |
| ... | ... | @@ -152,7 +140,7 @@ public: |
| 152 | 140 | return std::addressof(__x); |
| 153 | 141 | } |
| 154 | 142 | |
| 155 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 _Tp* allocate(size_t __n, const void*) { | |
| 143 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 _Tp* allocate(size_t __n, const void*) { | |
| 156 | 144 | return allocate(__n); |
| 157 | 145 | } |
| 158 | 146 | |
| ... | ... | @@ -169,85 +157,6 @@ public: |
| 169 | 157 | #endif |
| 170 | 158 | }; |
| 171 | 159 | |
| 172 | // TODO(LLVM 20): Remove the escape hatch | |
| 173 | #ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST | |
| 174 | template <class _Tp> | |
| 175 | class _LIBCPP_TEMPLATE_VIS allocator<const _Tp> | |
| 176 | : private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> > { | |
| 177 | static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); | |
| 178 | ||
| 179 | public: | |
| 180 | typedef size_t size_type; | |
| 181 | typedef ptrdiff_t difference_type; | |
| 182 | typedef const _Tp value_type; | |
| 183 | typedef true_type propagate_on_container_move_assignment; | |
| 184 | # if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS) | |
| 185 | _LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal; | |
| 186 | # endif | |
| 187 | ||
| 188 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default; | |
| 189 | ||
| 190 | template <class _Up> | |
| 191 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {} | |
| 192 | ||
| 193 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const _Tp* allocate(size_t __n) { | |
| 194 | if (__n > allocator_traits<allocator>::max_size(*this)) | |
| 195 | __throw_bad_array_new_length(); | |
| 196 | if (__libcpp_is_constant_evaluated()) { | |
| 197 | return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp))); | |
| 198 | } else { | |
| 199 | return static_cast<const _Tp*>(std::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); | |
| 200 | } | |
| 201 | } | |
| 202 | ||
| 203 | # if _LIBCPP_STD_VER >= 23 | |
| 204 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<const _Tp*> allocate_at_least(size_t __n) { | |
| 205 | return {allocate(__n), __n}; | |
| 206 | } | |
| 207 | # endif | |
| 208 | ||
| 209 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void deallocate(const _Tp* __p, size_t __n) { | |
| 210 | if (__libcpp_is_constant_evaluated()) { | |
| 211 | ::operator delete(const_cast<_Tp*>(__p)); | |
| 212 | } else { | |
| 213 | std::__libcpp_deallocate((void*)const_cast<_Tp*>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); | |
| 214 | } | |
| 215 | } | |
| 216 | ||
| 217 | // C++20 Removed members | |
| 218 | # if _LIBCPP_STD_VER <= 17 | |
| 219 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer; | |
| 220 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; | |
| 221 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference; | |
| 222 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference; | |
| 223 | ||
| 224 | template <class _Up> | |
| 225 | struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { | |
| 226 | typedef allocator<_Up> other; | |
| 227 | }; | |
| 228 | ||
| 229 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI const_pointer address(const_reference __x) const _NOEXCEPT { | |
| 230 | return std::addressof(__x); | |
| 231 | } | |
| 232 | ||
| 233 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 const _Tp* allocate(size_t __n, const void*) { | |
| 234 | return allocate(__n); | |
| 235 | } | |
| 236 | ||
| 237 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | |
| 238 | return size_type(~0) / sizeof(_Tp); | |
| 239 | } | |
| 240 | ||
| 241 | template <class _Up, class... _Args> | |
| 242 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void construct(_Up* __p, _Args&&... __args) { | |
| 243 | ::new ((void*)__p) _Up(std::forward<_Args>(__args)...); | |
| 244 | } | |
| 245 | ||
| 246 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void destroy(pointer __p) { __p->~_Tp(); } | |
| 247 | # endif | |
| 248 | }; | |
| 249 | #endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST | |
| 250 | ||
| 251 | 160 | template <class _Tp, class _Up> |
| 252 | 161 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| 253 | 162 | operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT { |
lib/libcxx/include/__memory/allocator_arg_t.h+7-7| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #ifndef _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H | |
| 11 | #define _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H | |
| 10 | #ifndef _LIBCPP___MEMORY_ALLOCATOR_ARG_T_H | |
| 11 | #define _LIBCPP___MEMORY_ALLOCATOR_ARG_T_H | |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__memory/uses_allocator.h> |
| ... | ... | @@ -39,10 +39,10 @@ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); |
| 39 | 39 | |
| 40 | 40 | template <class _Tp, class _Alloc, class... _Args> |
| 41 | 41 | struct __uses_alloc_ctor_imp { |
| 42 | typedef _LIBCPP_NODEBUG __remove_cvref_t<_Alloc> _RawAlloc; | |
| 43 | static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value; | |
| 44 | static const bool __ic = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; | |
| 45 | static const int value = __ua ? 2 - __ic : 0; | |
| 42 | using _RawAlloc _LIBCPP_NODEBUG = __remove_cvref_t<_Alloc>; | |
| 43 | static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value; | |
| 44 | static const bool __ic = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; | |
| 45 | static const int value = __ua ? 2 - __ic : 0; | |
| 46 | 46 | }; |
| 47 | 47 | |
| 48 | 48 | template <class _Tp, class _Alloc, class... _Args> |
| ... | ... | @@ -72,4 +72,4 @@ __user_alloc_construct_impl(integral_constant<int, 2>, _Tp* __storage, const _Al |
| 72 | 72 | |
| 73 | 73 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 74 | |
| 75 | #endif // _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H | |
| 75 | #endif // _LIBCPP___MEMORY_ALLOCATOR_ARG_T_H |
lib/libcxx/include/__memory/allocator_destructor.h+3-3| ... | ... | @@ -20,11 +20,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Alloc> |
| 22 | 22 | class __allocator_destructor { |
| 23 | typedef _LIBCPP_NODEBUG allocator_traits<_Alloc> __alloc_traits; | |
| 23 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<_Alloc>; | |
| 24 | 24 | |
| 25 | 25 | public: |
| 26 | typedef _LIBCPP_NODEBUG typename __alloc_traits::pointer pointer; | |
| 27 | typedef _LIBCPP_NODEBUG typename __alloc_traits::size_type size_type; | |
| 26 | using pointer _LIBCPP_NODEBUG = typename __alloc_traits::pointer; | |
| 27 | using size_type _LIBCPP_NODEBUG = typename __alloc_traits::size_type; | |
| 28 | 28 | |
| 29 | 29 | private: |
| 30 | 30 | _Alloc& __alloc_; |
lib/libcxx/include/__memory/allocator_traits.h+53-63| ... | ... | @@ -11,8 +11,11 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/size_t.h> | |
| 15 | #include <__fwd/memory.h> | |
| 14 | 16 | #include <__memory/construct_at.h> |
| 15 | 17 | #include <__memory/pointer_traits.h> |
| 18 | #include <__type_traits/detected_or.h> | |
| 16 | 19 | #include <__type_traits/enable_if.h> |
| 17 | 20 | #include <__type_traits/is_constructible.h> |
| 18 | 21 | #include <__type_traits/is_empty.h> |
| ... | ... | @@ -22,7 +25,6 @@ |
| 22 | 25 | #include <__type_traits/void_t.h> |
| 23 | 26 | #include <__utility/declval.h> |
| 24 | 27 | #include <__utility/forward.h> |
| 25 | #include <cstddef> | |
| 26 | 28 | #include <limits> |
| 27 | 29 | |
| 28 | 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -41,17 +43,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 43 | struct NAME<_Tp, __void_t<typename _Tp::PROPERTY > > : true_type {} |
| 42 | 44 | |
| 43 | 45 | // __pointer |
| 44 | template <class _Tp, | |
| 45 | class _Alloc, | |
| 46 | class _RawAlloc = __libcpp_remove_reference_t<_Alloc>, | |
| 47 | bool = __has_pointer<_RawAlloc>::value> | |
| 48 | struct __pointer { | |
| 49 | using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer; | |
| 50 | }; | |
| 51 | template <class _Tp, class _Alloc, class _RawAlloc> | |
| 52 | struct __pointer<_Tp, _Alloc, _RawAlloc, false> { | |
| 53 | using type _LIBCPP_NODEBUG = _Tp*; | |
| 54 | }; | |
| 46 | template <class _Tp> | |
| 47 | using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer; | |
| 48 | ||
| 49 | template <class _Tp, class _Alloc> | |
| 50 | using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >; | |
| 55 | 51 | |
| 56 | 52 | // __const_pointer |
| 57 | 53 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer); |
| ... | ... | @@ -62,7 +58,7 @@ struct __const_pointer { |
| 62 | 58 | template <class _Tp, class _Ptr, class _Alloc> |
| 63 | 59 | struct __const_pointer<_Tp, _Ptr, _Alloc, false> { |
| 64 | 60 | #ifdef _LIBCPP_CXX03_LANG |
| 65 | using type = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other; | |
| 61 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other; | |
| 66 | 62 | #else |
| 67 | 63 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>; |
| 68 | 64 | #endif |
| ... | ... | @@ -99,13 +95,11 @@ struct __const_void_pointer<_Ptr, _Alloc, false> { |
| 99 | 95 | }; |
| 100 | 96 | |
| 101 | 97 | // __size_type |
| 102 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_size_type, size_type); | |
| 103 | template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value> | |
| 104 | struct __size_type : make_unsigned<_DiffType> {}; | |
| 98 | template <class _Tp> | |
| 99 | using __size_type_member _LIBCPP_NODEBUG = typename _Tp::size_type; | |
| 100 | ||
| 105 | 101 | template <class _Alloc, class _DiffType> |
| 106 | struct __size_type<_Alloc, _DiffType, true> { | |
| 107 | using type _LIBCPP_NODEBUG = typename _Alloc::size_type; | |
| 108 | }; | |
| 102 | using __size_type _LIBCPP_NODEBUG = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>; | |
| 109 | 103 | |
| 110 | 104 | // __alloc_traits_difference_type |
| 111 | 105 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type); |
| ... | ... | @@ -119,40 +113,38 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> { |
| 119 | 113 | }; |
| 120 | 114 | |
| 121 | 115 | // __propagate_on_container_copy_assignment |
| 122 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_copy_assignment, propagate_on_container_copy_assignment); | |
| 123 | template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value> | |
| 124 | struct __propagate_on_container_copy_assignment : false_type {}; | |
| 116 | template <class _Tp> | |
| 117 | using __propagate_on_container_copy_assignment_member _LIBCPP_NODEBUG = | |
| 118 | typename _Tp::propagate_on_container_copy_assignment; | |
| 119 | ||
| 125 | 120 | template <class _Alloc> |
| 126 | struct __propagate_on_container_copy_assignment<_Alloc, true> { | |
| 127 | using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_copy_assignment; | |
| 128 | }; | |
| 121 | using __propagate_on_container_copy_assignment _LIBCPP_NODEBUG = | |
| 122 | __detected_or_t<false_type, __propagate_on_container_copy_assignment_member, _Alloc>; | |
| 129 | 123 | |
| 130 | 124 | // __propagate_on_container_move_assignment |
| 131 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_move_assignment, propagate_on_container_move_assignment); | |
| 132 | template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_Alloc>::value> | |
| 133 | struct __propagate_on_container_move_assignment : false_type {}; | |
| 125 | template <class _Tp> | |
| 126 | using __propagate_on_container_move_assignment_member _LIBCPP_NODEBUG = | |
| 127 | typename _Tp::propagate_on_container_move_assignment; | |
| 128 | ||
| 134 | 129 | template <class _Alloc> |
| 135 | struct __propagate_on_container_move_assignment<_Alloc, true> { | |
| 136 | using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_move_assignment; | |
| 137 | }; | |
| 130 | using __propagate_on_container_move_assignment _LIBCPP_NODEBUG = | |
| 131 | __detected_or_t<false_type, __propagate_on_container_move_assignment_member, _Alloc>; | |
| 138 | 132 | |
| 139 | 133 | // __propagate_on_container_swap |
| 140 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_swap, propagate_on_container_swap); | |
| 141 | template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value> | |
| 142 | struct __propagate_on_container_swap : false_type {}; | |
| 134 | template <class _Tp> | |
| 135 | using __propagate_on_container_swap_member _LIBCPP_NODEBUG = typename _Tp::propagate_on_container_swap; | |
| 136 | ||
| 143 | 137 | template <class _Alloc> |
| 144 | struct __propagate_on_container_swap<_Alloc, true> { | |
| 145 | using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_swap; | |
| 146 | }; | |
| 138 | using __propagate_on_container_swap _LIBCPP_NODEBUG = | |
| 139 | __detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>; | |
| 147 | 140 | |
| 148 | 141 | // __is_always_equal |
| 149 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_is_always_equal, is_always_equal); | |
| 150 | template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value> | |
| 151 | struct __is_always_equal : is_empty<_Alloc> {}; | |
| 142 | template <class _Tp> | |
| 143 | using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal; | |
| 144 | ||
| 152 | 145 | template <class _Alloc> |
| 153 | struct __is_always_equal<_Alloc, true> { | |
| 154 | using type _LIBCPP_NODEBUG = typename _Alloc::is_always_equal; | |
| 155 | }; | |
| 146 | using __is_always_equal _LIBCPP_NODEBUG = | |
| 147 | __detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>; | |
| 156 | 148 | |
| 157 | 149 | // __allocator_traits_rebind |
| 158 | 150 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -177,7 +169,7 @@ struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> { |
| 177 | 169 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 178 | 170 | |
| 179 | 171 | template <class _Alloc, class _Tp> |
| 180 | using __allocator_traits_rebind_t = typename __allocator_traits_rebind<_Alloc, _Tp>::type; | |
| 172 | using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_rebind<_Alloc, _Tp>::type; | |
| 181 | 173 | |
| 182 | 174 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 183 | 175 | |
| ... | ... | @@ -244,20 +236,18 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result); |
| 244 | 236 | |
| 245 | 237 | template <class _Alloc> |
| 246 | 238 | struct _LIBCPP_TEMPLATE_VIS allocator_traits { |
| 247 | using allocator_type = _Alloc; | |
| 248 | using value_type = typename allocator_type::value_type; | |
| 249 | using pointer = typename __pointer<value_type, allocator_type>::type; | |
| 250 | using const_pointer = typename __const_pointer<value_type, pointer, allocator_type>::type; | |
| 251 | using void_pointer = typename __void_pointer<pointer, allocator_type>::type; | |
| 252 | using const_void_pointer = typename __const_void_pointer<pointer, allocator_type>::type; | |
| 253 | using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type; | |
| 254 | using size_type = typename __size_type<allocator_type, difference_type>::type; | |
| 255 | using propagate_on_container_copy_assignment = | |
| 256 | typename __propagate_on_container_copy_assignment<allocator_type>::type; | |
| 257 | using propagate_on_container_move_assignment = | |
| 258 | typename __propagate_on_container_move_assignment<allocator_type>::type; | |
| 259 | using propagate_on_container_swap = typename __propagate_on_container_swap<allocator_type>::type; | |
| 260 | using is_always_equal = typename __is_always_equal<allocator_type>::type; | |
| 239 | using allocator_type = _Alloc; | |
| 240 | using value_type = typename allocator_type::value_type; | |
| 241 | using pointer = __pointer<value_type, allocator_type>; | |
| 242 | using const_pointer = typename __const_pointer<value_type, pointer, allocator_type>::type; | |
| 243 | using void_pointer = typename __void_pointer<pointer, allocator_type>::type; | |
| 244 | using const_void_pointer = typename __const_void_pointer<pointer, allocator_type>::type; | |
| 245 | using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type; | |
| 246 | using size_type = __size_type<allocator_type, difference_type>; | |
| 247 | using propagate_on_container_copy_assignment = __propagate_on_container_copy_assignment<allocator_type>; | |
| 248 | using propagate_on_container_move_assignment = __propagate_on_container_move_assignment<allocator_type>; | |
| 249 | using propagate_on_container_swap = __propagate_on_container_swap<allocator_type>; | |
| 250 | using is_always_equal = __is_always_equal<allocator_type>; | |
| 261 | 251 | |
| 262 | 252 | #ifndef _LIBCPP_CXX03_LANG |
| 263 | 253 | template <class _Tp> |
| ... | ... | @@ -275,13 +265,13 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { |
| 275 | 265 | }; |
| 276 | 266 | #endif // _LIBCPP_CXX03_LANG |
| 277 | 267 | |
| 278 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | |
| 268 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | |
| 279 | 269 | allocate(allocator_type& __a, size_type __n) { |
| 280 | 270 | return __a.allocate(__n); |
| 281 | 271 | } |
| 282 | 272 | |
| 283 | 273 | template <class _Ap = _Alloc, __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0> |
| 284 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | |
| 274 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | |
| 285 | 275 | allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) { |
| 286 | 276 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 287 | 277 | return __a.allocate(__n, __hint); |
| ... | ... | @@ -290,7 +280,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits { |
| 290 | 280 | template <class _Ap = _Alloc, |
| 291 | 281 | class = void, |
| 292 | 282 | __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0> |
| 293 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | |
| 283 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer | |
| 294 | 284 | allocate(allocator_type& __a, size_type __n, const_void_pointer) { |
| 295 | 285 | return __a.allocate(__n); |
| 296 | 286 | } |
| ... | ... | @@ -369,12 +359,12 @@ template <class _Traits, class _Tp> |
| 369 | 359 | using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>; |
| 370 | 360 | #else |
| 371 | 361 | template <class _Traits, class _Tp> |
| 372 | using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other; | |
| 362 | using __rebind_alloc _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>::other; | |
| 373 | 363 | #endif |
| 374 | 364 | |
| 375 | 365 | template <class _Alloc> |
| 376 | 366 | struct __check_valid_allocator : true_type { |
| 377 | using _Traits = std::allocator_traits<_Alloc>; | |
| 367 | using _Traits _LIBCPP_NODEBUG = std::allocator_traits<_Alloc>; | |
| 378 | 368 | static_assert(is_same<_Alloc, __rebind_alloc<_Traits, typename _Traits::value_type> >::value, |
| 379 | 369 | "[allocator.requirements] states that rebinding an allocator to the same type should result in the " |
| 380 | 370 | "original allocator"); |
lib/libcxx/include/__memory/array_cookie.h created+55| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___MEMORY_ARRAY_COOKIE_H | |
| 11 | #define _LIBCPP___MEMORY_ARRAY_COOKIE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__configuration/abi.h> | |
| 15 | #include <__cstddef/size_t.h> | |
| 16 | #include <__type_traits/integral_constant.h> | |
| 17 | #include <__type_traits/is_trivially_destructible.h> | |
| 18 | #include <__type_traits/negation.h> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | // Trait representing whether a type requires an array cookie at the start of its allocation when | |
| 27 | // allocated as `new T[n]` and deallocated as `delete[] array`. | |
| 28 | // | |
| 29 | // Under the Itanium C++ ABI [1], we know that an array cookie is available unless `T` is trivially | |
| 30 | // destructible and the call to `operator delete[]` is not a sized operator delete. Under ABIs other | |
| 31 | // than the Itanium ABI, we assume there are no array cookies. | |
| 32 | // | |
| 33 | // [1]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#array-cookies | |
| 34 | #ifdef _LIBCPP_ABI_ITANIUM | |
| 35 | // TODO: Use a builtin instead | |
| 36 | // TODO: We should factor in the choice of the usual deallocation function in this determination. | |
| 37 | template <class _Tp> | |
| 38 | struct __has_array_cookie : _Not<is_trivially_destructible<_Tp> > {}; | |
| 39 | #else | |
| 40 | template <class _Tp> | |
| 41 | struct __has_array_cookie : false_type {}; | |
| 42 | #endif | |
| 43 | ||
| 44 | template <class _Tp> | |
| 45 | // Avoid failures when -fsanitize-address-poison-custom-array-cookie is enabled | |
| 46 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") size_t __get_array_cookie(_Tp const* __ptr) { | |
| 47 | static_assert( | |
| 48 | __has_array_cookie<_Tp>::value, "Trying to access the array cookie of a type that is not guaranteed to have one"); | |
| 49 | size_t const* __cookie = reinterpret_cast<size_t const*>(__ptr) - 1; // TODO: Use a builtin instead | |
| 50 | return *__cookie; | |
| 51 | } | |
| 52 | ||
| 53 | _LIBCPP_END_NAMESPACE_STD | |
| 54 | ||
| 55 | #endif // _LIBCPP___MEMORY_ARRAY_COOKIE_H |
lib/libcxx/include/__memory/assume_aligned.h+2-2| ... | ... | @@ -12,8 +12,8 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__assert> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/size_t.h> | |
| 15 | 16 | #include <__type_traits/is_constant_evaluated.h> |
| 16 | #include <cstddef> | |
| 17 | 17 | #include <cstdint> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | 25 | template <size_t _Np, class _Tp> |
| 26 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __assume_aligned(_Tp* __ptr) { | |
| 26 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __assume_aligned(_Tp* __ptr) { | |
| 27 | 27 | static_assert(_Np != 0 && (_Np & (_Np - 1)) == 0, "std::assume_aligned<N>(p) requires N to be a power of two"); |
| 28 | 28 | |
| 29 | 29 | if (__libcpp_is_constant_evaluated()) { |
lib/libcxx/include/__memory/builtin_new_allocator.h deleted-67| ... | ... | @@ -1,67 +0,0 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___MEMORY_BUILTIN_NEW_ALLOCATOR_H | |
| 10 | #define _LIBCPP___MEMORY_BUILTIN_NEW_ALLOCATOR_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__memory/unique_ptr.h> | |
| 14 | #include <cstddef> | |
| 15 | #include <new> | |
| 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 | // __builtin_new_allocator -- A non-templated helper for allocating and | |
| 24 | // deallocating memory using __builtin_operator_new and | |
| 25 | // __builtin_operator_delete. It should be used in preference to | |
| 26 | // `std::allocator<T>` to avoid additional instantiations. | |
| 27 | struct __builtin_new_allocator { | |
| 28 | struct __builtin_new_deleter { | |
| 29 | typedef void* pointer_type; | |
| 30 | ||
| 31 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align) | |
| 32 | : __size_(__size), __align_(__align) {} | |
| 33 | ||
| 34 | _LIBCPP_HIDE_FROM_ABI void operator()(void* __p) const _NOEXCEPT { | |
| 35 | std::__libcpp_deallocate(__p, __size_, __align_); | |
| 36 | } | |
| 37 | ||
| 38 | private: | |
| 39 | size_t __size_; | |
| 40 | size_t __align_; | |
| 41 | }; | |
| 42 | ||
| 43 | typedef unique_ptr<void, __builtin_new_deleter> __holder_t; | |
| 44 | ||
| 45 | _LIBCPP_HIDE_FROM_ABI static __holder_t __allocate_bytes(size_t __s, size_t __align) { | |
| 46 | return __holder_t(std::__libcpp_allocate(__s, __align), __builtin_new_deleter(__s, __align)); | |
| 47 | } | |
| 48 | ||
| 49 | _LIBCPP_HIDE_FROM_ABI static void __deallocate_bytes(void* __p, size_t __s, size_t __align) _NOEXCEPT { | |
| 50 | std::__libcpp_deallocate(__p, __s, __align); | |
| 51 | } | |
| 52 | ||
| 53 | template <class _Tp> | |
| 54 | _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI static __holder_t __allocate_type(size_t __n) { | |
| 55 | return __allocate_bytes(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); | |
| 56 | } | |
| 57 | ||
| 58 | template <class _Tp> | |
| 59 | _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI static void | |
| 60 | __deallocate_type(void* __p, size_t __n) _NOEXCEPT { | |
| 61 | __deallocate_bytes(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); | |
| 62 | } | |
| 63 | }; | |
| 64 | ||
| 65 | _LIBCPP_END_NAMESPACE_STD | |
| 66 | ||
| 67 | #endif // _LIBCPP___MEMORY_BUILTIN_NEW_ALLOCATOR_H |
lib/libcxx/include/__memory/compressed_pair.h+72-138| ... | ... | @@ -11,161 +11,95 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_COMPRESSED_PAIR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__fwd/tuple.h> | |
| 15 | #include <__tuple/tuple_indices.h> | |
| 16 | #include <__type_traits/decay.h> | |
| 17 | #include <__type_traits/dependent_type.h> | |
| 18 | #include <__type_traits/enable_if.h> | |
| 19 | #include <__type_traits/is_constructible.h> | |
| 14 | #include <__cstddef/size_t.h> | |
| 15 | #include <__type_traits/datasizeof.h> | |
| 20 | 16 | #include <__type_traits/is_empty.h> |
| 21 | 17 | #include <__type_traits/is_final.h> |
| 22 | #include <__type_traits/is_same.h> | |
| 23 | #include <__type_traits/is_swappable.h> | |
| 24 | #include <__utility/forward.h> | |
| 25 | #include <__utility/move.h> | |
| 26 | #include <__utility/piecewise_construct.h> | |
| 27 | #include <cstddef> | |
| 18 | #include <__type_traits/is_reference.h> | |
| 28 | 19 | |
| 29 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 30 | 21 | # pragma GCC system_header |
| 31 | 22 | #endif |
| 32 | 23 | |
| 33 | _LIBCPP_PUSH_MACROS | |
| 34 | #include <__undef_macros> | |
| 35 | ||
| 36 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 37 | 25 | |
| 38 | // Tag used to default initialize one or both of the pair's elements. | |
| 39 | struct __default_init_tag {}; | |
| 40 | struct __value_init_tag {}; | |
| 41 | ||
| 42 | template <class _Tp, int _Idx, bool _CanBeEmptyBase = is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value> | |
| 43 | struct __compressed_pair_elem { | |
| 44 | using _ParamT = _Tp; | |
| 45 | using reference = _Tp&; | |
| 46 | using const_reference = const _Tp&; | |
| 47 | ||
| 48 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} | |
| 49 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_() {} | |
| 50 | ||
| 51 | template <class _Up, __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value, int> = 0> | |
| 52 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) | |
| 53 | : __value_(std::forward<_Up>(__u)) {} | |
| 26 | // ================================================================================================================== // | |
| 27 | // The utilites here are for staying ABI compatible with the legacy `__compressed_pair`. They should not be used // | |
| 28 | // for new data structures. Use `_LIBCPP_NO_UNIQUE_ADDRESS` for new data structures instead (but make sure you // | |
| 29 | // understand how it works). // | |
| 30 | // ================================================================================================================== // | |
| 54 | 31 | |
| 55 | #ifndef _LIBCPP_CXX03_LANG | |
| 56 | template <class... _Args, size_t... _Indices> | |
| 57 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit __compressed_pair_elem( | |
| 58 | piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>) | |
| 59 | : __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {} | |
| 60 | #endif | |
| 61 | ||
| 62 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference __get() _NOEXCEPT { return __value_; } | |
| 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; } | |
| 64 | ||
| 65 | private: | |
| 66 | _Tp __value_; | |
| 67 | }; | |
| 32 | // The first member is aligned to the alignment of the second member to force padding in front of the compressed pair | |
| 33 | // in case there are members before it. | |
| 34 | // | |
| 35 | // For example: | |
| 36 | // (assuming x86-64 linux) | |
| 37 | // class SomeClass { | |
| 38 | // uint32_t member1; | |
| 39 | // _LIBCPP_COMPRESSED_PAIR(uint32_t, member2, uint64_t, member3); | |
| 40 | // } | |
| 41 | // | |
| 42 | // The layout with __compressed_pair is: | |
| 43 | // member1 - offset: 0, size: 4 | |
| 44 | // padding - offset: 4, size: 4 | |
| 45 | // member2 - offset: 8, size: 4 | |
| 46 | // padding - offset: 12, size: 4 | |
| 47 | // member3 - offset: 16, size: 8 | |
| 48 | // | |
| 49 | // If the [[gnu::aligned]] wasn't there, the layout would instead be: | |
| 50 | // member1 - offset: 0, size: 4 | |
| 51 | // member2 - offset: 4, size: 4 | |
| 52 | // member3 - offset: 8, size: 8 | |
| 53 | // | |
| 54 | // Furthermore, that alignment must be the same as what was used in the old __compressed_pair layout, so we must | |
| 55 | // handle reference types specially since alignof(T&) == alignof(T). | |
| 56 | // See https://github.com/llvm/llvm-project/issues/118559. | |
| 68 | 57 | |
| 69 | template <class _Tp, int _Idx> | |
| 70 | struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { | |
| 71 | using _ParamT = _Tp; | |
| 72 | using reference = _Tp&; | |
| 73 | using const_reference = const _Tp&; | |
| 74 | using __value_type = _Tp; | |
| 75 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem() = default; | |
| 77 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} | |
| 78 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_type() {} | |
| 79 | ||
| 80 | template <class _Up, __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value, int> = 0> | |
| 81 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) | |
| 82 | : __value_type(std::forward<_Up>(__u)) {} | |
| 83 | ||
| 84 | #ifndef _LIBCPP_CXX03_LANG | |
| 85 | template <class... _Args, size_t... _Indices> | |
| 86 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 | |
| 87 | __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>) | |
| 88 | : __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {} | |
| 89 | #endif | |
| 58 | #ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING | |
| 90 | 59 | |
| 91 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference __get() _NOEXCEPT { return *this; } | |
| 92 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; } | |
| 93 | }; | |
| 60 | template <class _Tp> | |
| 61 | inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp); | |
| 94 | 62 | |
| 95 | template <class _T1, class _T2> | |
| 96 | class __compressed_pair : private __compressed_pair_elem<_T1, 0>, private __compressed_pair_elem<_T2, 1> { | |
| 97 | public: | |
| 98 | // NOTE: This static assert should never fire because __compressed_pair | |
| 99 | // is *almost never* used in a scenario where it's possible for T1 == T2. | |
| 100 | // (The exception is std::function where it is possible that the function | |
| 101 | // object and the allocator have the same type). | |
| 102 | static_assert( | |
| 103 | (!is_same<_T1, _T2>::value), | |
| 104 | "__compressed_pair cannot be instantiated when T1 and T2 are the same type; " | |
| 105 | "The current implementation is NOT ABI-compatible with the previous implementation for this configuration"); | |
| 106 | ||
| 107 | using _Base1 _LIBCPP_NODEBUG = __compressed_pair_elem<_T1, 0>; | |
| 108 | using _Base2 _LIBCPP_NODEBUG = __compressed_pair_elem<_T2, 1>; | |
| 109 | ||
| 110 | template <bool _Dummy = true, | |
| 111 | __enable_if_t< __dependent_type<is_default_constructible<_T1>, _Dummy>::value && | |
| 112 | __dependent_type<is_default_constructible<_T2>, _Dummy>::value, | |
| 113 | int> = 0> | |
| 114 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair() | |
| 115 | : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} | |
| 116 | ||
| 117 | template <class _U1, class _U2> | |
| 118 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair(_U1&& __t1, _U2&& __t2) | |
| 119 | : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {} | |
| 120 | ||
| 121 | #ifndef _LIBCPP_CXX03_LANG | |
| 122 | template <class... _Args1, class... _Args2> | |
| 123 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit __compressed_pair( | |
| 124 | piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) | |
| 125 | : _Base1(__pc, std::move(__first_args), typename __make_tuple_indices<sizeof...(_Args1)>::type()), | |
| 126 | _Base2(__pc, std::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {} | |
| 127 | #endif | |
| 63 | template <class _Tp> | |
| 64 | inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void*); | |
| 128 | 65 | |
| 129 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename _Base1::reference first() _NOEXCEPT { | |
| 130 | return static_cast<_Base1&>(*this).__get(); | |
| 131 | } | |
| 132 | ||
| 133 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename _Base1::const_reference first() const _NOEXCEPT { | |
| 134 | return static_cast<_Base1 const&>(*this).__get(); | |
| 135 | } | |
| 136 | ||
| 137 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename _Base2::reference second() _NOEXCEPT { | |
| 138 | return static_cast<_Base2&>(*this).__get(); | |
| 139 | } | |
| 140 | ||
| 141 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR typename _Base2::const_reference second() const _NOEXCEPT { | |
| 142 | return static_cast<_Base2 const&>(*this).__get(); | |
| 143 | } | |
| 144 | ||
| 145 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT { | |
| 146 | return static_cast<_Base1*>(__pair); | |
| 147 | } | |
| 148 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT { | |
| 149 | return static_cast<_Base2*>(__pair); | |
| 150 | } | |
| 151 | ||
| 152 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(__compressed_pair& __x) | |
| 153 | _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) { | |
| 154 | using std::swap; | |
| 155 | swap(first(), __x.first()); | |
| 156 | swap(second(), __x.second()); | |
| 157 | } | |
| 66 | template <class _ToPad, | |
| 67 | bool _Empty = ((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || | |
| 68 | is_reference<_ToPad>::value || sizeof(_ToPad) == __datasizeof_v<_ToPad>)> | |
| 69 | class __compressed_pair_padding { | |
| 70 | char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>] = {}; | |
| 158 | 71 | }; |
| 159 | 72 | |
| 160 | template <class _T1, class _T2> | |
| 161 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void | |
| 162 | swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) | |
| 163 | _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) { | |
| 164 | __x.swap(__y); | |
| 165 | } | |
| 73 | template <class _ToPad> | |
| 74 | class __compressed_pair_padding<_ToPad, true> {}; | |
| 75 | ||
| 76 | # define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ | |
| 77 | _LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \ | |
| 78 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ | |
| 79 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ | |
| 80 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _) | |
| 81 | ||
| 82 | # define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \ | |
| 83 | _LIBCPP_NO_UNIQUE_ADDRESS \ | |
| 84 | __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \ | |
| 85 | __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \ | |
| 86 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \ | |
| 87 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \ | |
| 88 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \ | |
| 89 | _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \ | |
| 90 | _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _) | |
| 91 | ||
| 92 | #else | |
| 93 | # define _LIBCPP_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ | |
| 94 | _LIBCPP_NO_UNIQUE_ADDRESS T1 Name1; \ | |
| 95 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Name2 | |
| 96 | ||
| 97 | # define _LIBCPP_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3) \ | |
| 98 | _LIBCPP_NO_UNIQUE_ADDRESS T1 Name1; \ | |
| 99 | _LIBCPP_NO_UNIQUE_ADDRESS T2 Name2; \ | |
| 100 | _LIBCPP_NO_UNIQUE_ADDRESS T3 Name3 | |
| 101 | #endif // _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING | |
| 166 | 102 | |
| 167 | 103 | _LIBCPP_END_NAMESPACE_STD |
| 168 | 104 | |
| 169 | _LIBCPP_POP_MACROS | |
| 170 | ||
| 171 | 105 | #endif // _LIBCPP___MEMORY_COMPRESSED_PAIR_H |
lib/libcxx/include/__memory/construct_at.h+3-4| ... | ... | @@ -14,13 +14,12 @@ |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__iterator/access.h> |
| 16 | 16 | #include <__memory/addressof.h> |
| 17 | #include <__memory/voidify.h> | |
| 17 | #include <__new/placement_new_delete.h> | |
| 18 | 18 | #include <__type_traits/enable_if.h> |
| 19 | 19 | #include <__type_traits/is_array.h> |
| 20 | 20 | #include <__utility/declval.h> |
| 21 | 21 | #include <__utility/forward.h> |
| 22 | 22 | #include <__utility/move.h> |
| 23 | #include <new> | |
| 24 | 23 | |
| 25 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | 25 | # pragma GCC system_header |
| ... | ... | @@ -38,7 +37,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 38 | 37 | template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))> |
| 39 | 38 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) { |
| 40 | 39 | _LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at"); |
| 41 | return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...); | |
| 40 | return ::new (static_cast<void*>(__location)) _Tp(std::forward<_Args>(__args)...); | |
| 42 | 41 | } |
| 43 | 42 | |
| 44 | 43 | #endif |
| ... | ... | @@ -49,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l |
| 49 | 48 | return std::construct_at(__location, std::forward<_Args>(__args)...); |
| 50 | 49 | #else |
| 51 | 50 | return _LIBCPP_ASSERT_NON_NULL(__location != nullptr, "null pointer given to construct_at"), |
| 52 | ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...); | |
| 51 | ::new (static_cast<void*>(__location)) _Tp(std::forward<_Args>(__args)...); | |
| 53 | 52 | #endif |
| 54 | 53 | } |
| 55 | 54 |
lib/libcxx/include/__memory/destruct_n.h+11-11| ... | ... | @@ -10,9 +10,9 @@ |
| 10 | 10 | #define _LIBCPP___MEMORY_DESTRUCT_N_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/integral_constant.h> |
| 14 | 15 | #include <__type_traits/is_trivially_destructible.h> |
| 15 | #include <cstddef> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | # pragma GCC system_header |
| ... | ... | @@ -25,35 +25,35 @@ private: |
| 25 | 25 | size_t __size_; |
| 26 | 26 | |
| 27 | 27 | template <class _Tp> |
| 28 | _LIBCPP_HIDE_FROM_ABI void __process(_Tp* __p, false_type) _NOEXCEPT { | |
| 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __process(_Tp* __p, false_type) _NOEXCEPT { | |
| 29 | 29 | for (size_t __i = 0; __i < __size_; ++__i, ++__p) |
| 30 | 30 | __p->~_Tp(); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | template <class _Tp> |
| 34 | _LIBCPP_HIDE_FROM_ABI void __process(_Tp*, true_type) _NOEXCEPT {} | |
| 34 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __process(_Tp*, true_type) _NOEXCEPT {} | |
| 35 | 35 | |
| 36 | _LIBCPP_HIDE_FROM_ABI void __incr(false_type) _NOEXCEPT { ++__size_; } | |
| 37 | _LIBCPP_HIDE_FROM_ABI void __incr(true_type) _NOEXCEPT {} | |
| 36 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __incr(false_type) _NOEXCEPT { ++__size_; } | |
| 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __incr(true_type) _NOEXCEPT {} | |
| 38 | 38 | |
| 39 | _LIBCPP_HIDE_FROM_ABI void __set(size_t __s, false_type) _NOEXCEPT { __size_ = __s; } | |
| 40 | _LIBCPP_HIDE_FROM_ABI void __set(size_t, true_type) _NOEXCEPT {} | |
| 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __set(size_t __s, false_type) _NOEXCEPT { __size_ = __s; } | |
| 40 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __set(size_t, true_type) _NOEXCEPT {} | |
| 41 | 41 | |
| 42 | 42 | public: |
| 43 | _LIBCPP_HIDE_FROM_ABI explicit __destruct_n(size_t __s) _NOEXCEPT : __size_(__s) {} | |
| 43 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __destruct_n(size_t __s) _NOEXCEPT : __size_(__s) {} | |
| 44 | 44 | |
| 45 | 45 | template <class _Tp> |
| 46 | _LIBCPP_HIDE_FROM_ABI void __incr() _NOEXCEPT { | |
| 46 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __incr() _NOEXCEPT { | |
| 47 | 47 | __incr(integral_constant<bool, is_trivially_destructible<_Tp>::value>()); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | template <class _Tp> |
| 51 | _LIBCPP_HIDE_FROM_ABI void __set(size_t __s, _Tp*) _NOEXCEPT { | |
| 51 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __set(size_t __s, _Tp*) _NOEXCEPT { | |
| 52 | 52 | __set(__s, integral_constant<bool, is_trivially_destructible<_Tp>::value>()); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | template <class _Tp> |
| 56 | _LIBCPP_HIDE_FROM_ABI void operator()(_Tp* __p) _NOEXCEPT { | |
| 56 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void operator()(_Tp* __p) _NOEXCEPT { | |
| 57 | 57 | __process(__p, integral_constant<bool, is_trivially_destructible<_Tp>::value>()); |
| 58 | 58 | } |
| 59 | 59 | }; |
lib/libcxx/include/__memory/inout_ptr.h+1| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | #include <__memory/pointer_traits.h> |
| 16 | 16 | #include <__memory/shared_ptr.h> |
| 17 | 17 | #include <__memory/unique_ptr.h> |
| 18 | #include <__type_traits/is_pointer.h> | |
| 18 | 19 | #include <__type_traits/is_same.h> |
| 19 | 20 | #include <__type_traits/is_specialization.h> |
| 20 | 21 | #include <__type_traits/is_void.h> |
lib/libcxx/include/__memory/noexcept_move_assign_container.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___MEMORY_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H | |
| 10 | #define _LIBCPP___MEMORY_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__memory/allocator_traits.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <__type_traits/is_nothrow_assignable.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 <typename _Alloc, typename _Traits = allocator_traits<_Alloc> > | |
| 24 | struct __noexcept_move_assign_container | |
| 25 | : public integral_constant<bool, | |
| 26 | _Traits::propagate_on_container_move_assignment::value | |
| 27 | #if _LIBCPP_STD_VER >= 17 | |
| 28 | || _Traits::is_always_equal::value | |
| 29 | #else | |
| 30 | && is_nothrow_move_assignable<_Alloc>::value | |
| 31 | #endif | |
| 32 | > { | |
| 33 | }; | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP___MEMORY_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H |
lib/libcxx/include/__memory/out_ptr.h+1| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | #include <__memory/pointer_traits.h> |
| 16 | 16 | #include <__memory/shared_ptr.h> |
| 17 | 17 | #include <__memory/unique_ptr.h> |
| 18 | #include <__type_traits/is_pointer.h> | |
| 18 | 19 | #include <__type_traits/is_specialization.h> |
| 19 | 20 | #include <__type_traits/is_void.h> |
| 20 | 21 | #include <__utility/forward.h> |
lib/libcxx/include/__memory/pointer_traits.h+16-14| ... | ... | @@ -11,17 +11,19 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_POINTER_TRAITS_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__memory/addressof.h> |
| 15 | 16 | #include <__type_traits/conditional.h> |
| 16 | 17 | #include <__type_traits/conjunction.h> |
| 17 | 18 | #include <__type_traits/decay.h> |
| 19 | #include <__type_traits/enable_if.h> | |
| 20 | #include <__type_traits/integral_constant.h> | |
| 18 | 21 | #include <__type_traits/is_class.h> |
| 19 | 22 | #include <__type_traits/is_function.h> |
| 20 | 23 | #include <__type_traits/is_void.h> |
| 21 | 24 | #include <__type_traits/void_t.h> |
| 22 | 25 | #include <__utility/declval.h> |
| 23 | 26 | #include <__utility/forward.h> |
| 24 | #include <cstddef> | |
| 25 | 27 | |
| 26 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | 29 | # pragma GCC system_header |
| ... | ... | @@ -48,17 +50,17 @@ struct __pointer_traits_element_type {}; |
| 48 | 50 | |
| 49 | 51 | template <class _Ptr> |
| 50 | 52 | struct __pointer_traits_element_type<_Ptr, true> { |
| 51 | typedef _LIBCPP_NODEBUG typename _Ptr::element_type type; | |
| 53 | using type _LIBCPP_NODEBUG = typename _Ptr::element_type; | |
| 52 | 54 | }; |
| 53 | 55 | |
| 54 | 56 | template <template <class, class...> class _Sp, class _Tp, class... _Args> |
| 55 | 57 | struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> { |
| 56 | typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::element_type type; | |
| 58 | using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::element_type; | |
| 57 | 59 | }; |
| 58 | 60 | |
| 59 | 61 | template <template <class, class...> class _Sp, class _Tp, class... _Args> |
| 60 | 62 | struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> { |
| 61 | typedef _LIBCPP_NODEBUG _Tp type; | |
| 63 | using type _LIBCPP_NODEBUG = _Tp; | |
| 62 | 64 | }; |
| 63 | 65 | |
| 64 | 66 | template <class _Tp, class = void> |
| ... | ... | @@ -69,12 +71,12 @@ struct __has_difference_type<_Tp, __void_t<typename _Tp::difference_type> > : tr |
| 69 | 71 | |
| 70 | 72 | template <class _Ptr, bool = __has_difference_type<_Ptr>::value> |
| 71 | 73 | struct __pointer_traits_difference_type { |
| 72 | typedef _LIBCPP_NODEBUG ptrdiff_t type; | |
| 74 | using type _LIBCPP_NODEBUG = ptrdiff_t; | |
| 73 | 75 | }; |
| 74 | 76 | |
| 75 | 77 | template <class _Ptr> |
| 76 | 78 | struct __pointer_traits_difference_type<_Ptr, true> { |
| 77 | typedef _LIBCPP_NODEBUG typename _Ptr::difference_type type; | |
| 79 | using type _LIBCPP_NODEBUG = typename _Ptr::difference_type; | |
| 78 | 80 | }; |
| 79 | 81 | |
| 80 | 82 | template <class _Tp, class _Up> |
| ... | ... | @@ -94,18 +96,18 @@ public: |
| 94 | 96 | template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> |
| 95 | 97 | struct __pointer_traits_rebind { |
| 96 | 98 | #ifndef _LIBCPP_CXX03_LANG |
| 97 | typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up> type; | |
| 99 | using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>; | |
| 98 | 100 | #else |
| 99 | typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up>::other type; | |
| 101 | using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other; | |
| 100 | 102 | #endif |
| 101 | 103 | }; |
| 102 | 104 | |
| 103 | 105 | template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up> |
| 104 | 106 | struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> { |
| 105 | 107 | #ifndef _LIBCPP_CXX03_LANG |
| 106 | typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up> type; | |
| 108 | using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::template rebind<_Up>; | |
| 107 | 109 | #else |
| 108 | typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; | |
| 110 | using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::template rebind<_Up>::other; | |
| 109 | 111 | #endif |
| 110 | 112 | }; |
| 111 | 113 | |
| ... | ... | @@ -174,10 +176,10 @@ public: |
| 174 | 176 | |
| 175 | 177 | #ifndef _LIBCPP_CXX03_LANG |
| 176 | 178 | template <class _From, class _To> |
| 177 | using __rebind_pointer_t = typename pointer_traits<_From>::template rebind<_To>; | |
| 179 | using __rebind_pointer_t _LIBCPP_NODEBUG = typename pointer_traits<_From>::template rebind<_To>; | |
| 178 | 180 | #else |
| 179 | 181 | template <class _From, class _To> |
| 180 | using __rebind_pointer_t = typename pointer_traits<_From>::template rebind<_To>::other; | |
| 182 | using __rebind_pointer_t _LIBCPP_NODEBUG = typename pointer_traits<_From>::template rebind<_To>::other; | |
| 181 | 183 | #endif |
| 182 | 184 | |
| 183 | 185 | // to_address |
| ... | ... | @@ -274,7 +276,7 @@ struct __pointer_of<_Tp> { |
| 274 | 276 | }; |
| 275 | 277 | |
| 276 | 278 | template <typename _Tp> |
| 277 | using __pointer_of_t = typename __pointer_of<_Tp>::type; | |
| 279 | using __pointer_of_t _LIBCPP_NODEBUG = typename __pointer_of<_Tp>::type; | |
| 278 | 280 | |
| 279 | 281 | template <class _Tp, class _Up> |
| 280 | 282 | struct __pointer_of_or { |
| ... | ... | @@ -288,7 +290,7 @@ struct __pointer_of_or<_Tp, _Up> { |
| 288 | 290 | }; |
| 289 | 291 | |
| 290 | 292 | template <typename _Tp, typename _Up> |
| 291 | using __pointer_of_or_t = typename __pointer_of_or<_Tp, _Up>::type; | |
| 293 | using __pointer_of_or_t _LIBCPP_NODEBUG = typename __pointer_of_or<_Tp, _Up>::type; | |
| 292 | 294 | |
| 293 | 295 | template <class _Smart> |
| 294 | 296 | concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); }; |
lib/libcxx/include/__memory/ranges_construct_at.h+8-25| ... | ... | @@ -22,7 +22,6 @@ |
| 22 | 22 | #include <__utility/declval.h> |
| 23 | 23 | #include <__utility/forward.h> |
| 24 | 24 | #include <__utility/move.h> |
| 25 | #include <new> | |
| 26 | 25 | |
| 27 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | 27 | # pragma GCC system_header |
| ... | ... | @@ -38,43 +37,33 @@ namespace ranges { |
| 38 | 37 | |
| 39 | 38 | // construct_at |
| 40 | 39 | |
| 41 | namespace __construct_at { | |
| 42 | ||
| 43 | struct __fn { | |
| 40 | struct __construct_at { | |
| 44 | 41 | template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))> |
| 45 | 42 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* operator()(_Tp* __location, _Args&&... __args) const { |
| 46 | 43 | return std::construct_at(__location, std::forward<_Args>(__args)...); |
| 47 | 44 | } |
| 48 | 45 | }; |
| 49 | 46 | |
| 50 | } // namespace __construct_at | |
| 51 | ||
| 52 | 47 | inline namespace __cpo { |
| 53 | inline constexpr auto construct_at = __construct_at::__fn{}; | |
| 48 | inline constexpr auto construct_at = __construct_at{}; | |
| 54 | 49 | } // namespace __cpo |
| 55 | 50 | |
| 56 | 51 | // destroy_at |
| 57 | 52 | |
| 58 | namespace __destroy_at { | |
| 59 | ||
| 60 | struct __fn { | |
| 53 | struct __destroy_at { | |
| 61 | 54 | template <destructible _Tp> |
| 62 | 55 | _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Tp* __location) const noexcept { |
| 63 | 56 | std::destroy_at(__location); |
| 64 | 57 | } |
| 65 | 58 | }; |
| 66 | 59 | |
| 67 | } // namespace __destroy_at | |
| 68 | ||
| 69 | 60 | inline namespace __cpo { |
| 70 | inline constexpr auto destroy_at = __destroy_at::__fn{}; | |
| 61 | inline constexpr auto destroy_at = __destroy_at{}; | |
| 71 | 62 | } // namespace __cpo |
| 72 | 63 | |
| 73 | 64 | // destroy |
| 74 | 65 | |
| 75 | namespace __destroy { | |
| 76 | ||
| 77 | struct __fn { | |
| 66 | struct __destroy { | |
| 78 | 67 | template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel> |
| 79 | 68 | requires destructible<iter_value_t<_InputIterator>> |
| 80 | 69 | _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept { |
| ... | ... | @@ -88,17 +77,13 @@ struct __fn { |
| 88 | 77 | } |
| 89 | 78 | }; |
| 90 | 79 | |
| 91 | } // namespace __destroy | |
| 92 | ||
| 93 | 80 | inline namespace __cpo { |
| 94 | inline constexpr auto destroy = __destroy::__fn{}; | |
| 81 | inline constexpr auto destroy = __destroy{}; | |
| 95 | 82 | } // namespace __cpo |
| 96 | 83 | |
| 97 | 84 | // destroy_n |
| 98 | 85 | |
| 99 | namespace __destroy_n { | |
| 100 | ||
| 101 | struct __fn { | |
| 86 | struct __destroy_n { | |
| 102 | 87 | template <__nothrow_input_iterator _InputIterator> |
| 103 | 88 | requires destructible<iter_value_t<_InputIterator>> |
| 104 | 89 | _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator |
| ... | ... | @@ -107,10 +92,8 @@ struct __fn { |
| 107 | 92 | } |
| 108 | 93 | }; |
| 109 | 94 | |
| 110 | } // namespace __destroy_n | |
| 111 | ||
| 112 | 95 | inline namespace __cpo { |
| 113 | inline constexpr auto destroy_n = __destroy_n::__fn{}; | |
| 96 | inline constexpr auto destroy_n = __destroy_n{}; | |
| 114 | 97 | } // namespace __cpo |
| 115 | 98 | |
| 116 | 99 | } // namespace ranges |
lib/libcxx/include/__memory/ranges_uninitialized_algorithms.h+20-61| ... | ... | @@ -25,7 +25,6 @@ |
| 25 | 25 | #include <__ranges/dangling.h> |
| 26 | 26 | #include <__type_traits/remove_reference.h> |
| 27 | 27 | #include <__utility/move.h> |
| 28 | #include <new> | |
| 29 | 28 | |
| 30 | 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 31 | 30 | # pragma GCC system_header |
| ... | ... | @@ -42,9 +41,7 @@ namespace ranges { |
| 42 | 41 | |
| 43 | 42 | // uninitialized_default_construct |
| 44 | 43 | |
| 45 | namespace __uninitialized_default_construct { | |
| 46 | ||
| 47 | struct __fn { | |
| 44 | struct __uninitialized_default_construct { | |
| 48 | 45 | template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel> |
| 49 | 46 | requires default_initializable<iter_value_t<_ForwardIterator>> |
| 50 | 47 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { |
| ... | ... | @@ -59,17 +56,13 @@ struct __fn { |
| 59 | 56 | } |
| 60 | 57 | }; |
| 61 | 58 | |
| 62 | } // namespace __uninitialized_default_construct | |
| 63 | ||
| 64 | 59 | inline namespace __cpo { |
| 65 | inline constexpr auto uninitialized_default_construct = __uninitialized_default_construct::__fn{}; | |
| 60 | inline constexpr auto uninitialized_default_construct = __uninitialized_default_construct{}; | |
| 66 | 61 | } // namespace __cpo |
| 67 | 62 | |
| 68 | 63 | // uninitialized_default_construct_n |
| 69 | 64 | |
| 70 | namespace __uninitialized_default_construct_n { | |
| 71 | ||
| 72 | struct __fn { | |
| 65 | struct __uninitialized_default_construct_n { | |
| 73 | 66 | template <__nothrow_forward_iterator _ForwardIterator> |
| 74 | 67 | requires default_initializable<iter_value_t<_ForwardIterator>> |
| 75 | 68 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| ... | ... | @@ -79,17 +72,13 @@ struct __fn { |
| 79 | 72 | } |
| 80 | 73 | }; |
| 81 | 74 | |
| 82 | } // namespace __uninitialized_default_construct_n | |
| 83 | ||
| 84 | 75 | inline namespace __cpo { |
| 85 | inline constexpr auto uninitialized_default_construct_n = __uninitialized_default_construct_n::__fn{}; | |
| 76 | inline constexpr auto uninitialized_default_construct_n = __uninitialized_default_construct_n{}; | |
| 86 | 77 | } // namespace __cpo |
| 87 | 78 | |
| 88 | 79 | // uninitialized_value_construct |
| 89 | 80 | |
| 90 | namespace __uninitialized_value_construct { | |
| 91 | ||
| 92 | struct __fn { | |
| 81 | struct __uninitialized_value_construct { | |
| 93 | 82 | template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel> |
| 94 | 83 | requires default_initializable<iter_value_t<_ForwardIterator>> |
| 95 | 84 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { |
| ... | ... | @@ -104,17 +93,13 @@ struct __fn { |
| 104 | 93 | } |
| 105 | 94 | }; |
| 106 | 95 | |
| 107 | } // namespace __uninitialized_value_construct | |
| 108 | ||
| 109 | 96 | inline namespace __cpo { |
| 110 | inline constexpr auto uninitialized_value_construct = __uninitialized_value_construct::__fn{}; | |
| 97 | inline constexpr auto uninitialized_value_construct = __uninitialized_value_construct{}; | |
| 111 | 98 | } // namespace __cpo |
| 112 | 99 | |
| 113 | 100 | // uninitialized_value_construct_n |
| 114 | 101 | |
| 115 | namespace __uninitialized_value_construct_n { | |
| 116 | ||
| 117 | struct __fn { | |
| 102 | struct __uninitialized_value_construct_n { | |
| 118 | 103 | template <__nothrow_forward_iterator _ForwardIterator> |
| 119 | 104 | requires default_initializable<iter_value_t<_ForwardIterator>> |
| 120 | 105 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| ... | ... | @@ -124,17 +109,13 @@ struct __fn { |
| 124 | 109 | } |
| 125 | 110 | }; |
| 126 | 111 | |
| 127 | } // namespace __uninitialized_value_construct_n | |
| 128 | ||
| 129 | 112 | inline namespace __cpo { |
| 130 | inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_construct_n::__fn{}; | |
| 113 | inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_construct_n{}; | |
| 131 | 114 | } // namespace __cpo |
| 132 | 115 | |
| 133 | 116 | // uninitialized_fill |
| 134 | 117 | |
| 135 | namespace __uninitialized_fill { | |
| 136 | ||
| 137 | struct __fn { | |
| 118 | struct __uninitialized_fill { | |
| 138 | 119 | template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel, class _Tp> |
| 139 | 120 | requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&> |
| 140 | 121 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const { |
| ... | ... | @@ -149,17 +130,13 @@ struct __fn { |
| 149 | 130 | } |
| 150 | 131 | }; |
| 151 | 132 | |
| 152 | } // namespace __uninitialized_fill | |
| 153 | ||
| 154 | 133 | inline namespace __cpo { |
| 155 | inline constexpr auto uninitialized_fill = __uninitialized_fill::__fn{}; | |
| 134 | inline constexpr auto uninitialized_fill = __uninitialized_fill{}; | |
| 156 | 135 | } // namespace __cpo |
| 157 | 136 | |
| 158 | 137 | // uninitialized_fill_n |
| 159 | 138 | |
| 160 | namespace __uninitialized_fill_n { | |
| 161 | ||
| 162 | struct __fn { | |
| 139 | struct __uninitialized_fill_n { | |
| 163 | 140 | template <__nothrow_forward_iterator _ForwardIterator, class _Tp> |
| 164 | 141 | requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&> |
| 165 | 142 | _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| ... | ... | @@ -169,10 +146,8 @@ struct __fn { |
| 169 | 146 | } |
| 170 | 147 | }; |
| 171 | 148 | |
| 172 | } // namespace __uninitialized_fill_n | |
| 173 | ||
| 174 | 149 | inline namespace __cpo { |
| 175 | inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{}; | |
| 150 | inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n{}; | |
| 176 | 151 | } // namespace __cpo |
| 177 | 152 | |
| 178 | 153 | // uninitialized_copy |
| ... | ... | @@ -180,9 +155,7 @@ inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{}; |
| 180 | 155 | template <class _InputIterator, class _OutputIterator> |
| 181 | 156 | using uninitialized_copy_result = in_out_result<_InputIterator, _OutputIterator>; |
| 182 | 157 | |
| 183 | namespace __uninitialized_copy { | |
| 184 | ||
| 185 | struct __fn { | |
| 158 | struct __uninitialized_copy { | |
| 186 | 159 | template <input_iterator _InputIterator, |
| 187 | 160 | sentinel_for<_InputIterator> _Sentinel1, |
| 188 | 161 | __nothrow_forward_iterator _OutputIterator, |
| ... | ... | @@ -207,10 +180,8 @@ struct __fn { |
| 207 | 180 | } |
| 208 | 181 | }; |
| 209 | 182 | |
| 210 | } // namespace __uninitialized_copy | |
| 211 | ||
| 212 | 183 | inline namespace __cpo { |
| 213 | inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{}; | |
| 184 | inline constexpr auto uninitialized_copy = __uninitialized_copy{}; | |
| 214 | 185 | } // namespace __cpo |
| 215 | 186 | |
| 216 | 187 | // uninitialized_copy_n |
| ... | ... | @@ -218,9 +189,7 @@ inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{}; |
| 218 | 189 | template <class _InputIterator, class _OutputIterator> |
| 219 | 190 | using uninitialized_copy_n_result = in_out_result<_InputIterator, _OutputIterator>; |
| 220 | 191 | |
| 221 | namespace __uninitialized_copy_n { | |
| 222 | ||
| 223 | struct __fn { | |
| 192 | struct __uninitialized_copy_n { | |
| 224 | 193 | template <input_iterator _InputIterator, |
| 225 | 194 | __nothrow_forward_iterator _OutputIterator, |
| 226 | 195 | __nothrow_sentinel_for<_OutputIterator> _Sentinel> |
| ... | ... | @@ -238,10 +207,8 @@ struct __fn { |
| 238 | 207 | } |
| 239 | 208 | }; |
| 240 | 209 | |
| 241 | } // namespace __uninitialized_copy_n | |
| 242 | ||
| 243 | 210 | inline namespace __cpo { |
| 244 | inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{}; | |
| 211 | inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n{}; | |
| 245 | 212 | } // namespace __cpo |
| 246 | 213 | |
| 247 | 214 | // uninitialized_move |
| ... | ... | @@ -249,9 +216,7 @@ inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{}; |
| 249 | 216 | template <class _InputIterator, class _OutputIterator> |
| 250 | 217 | using uninitialized_move_result = in_out_result<_InputIterator, _OutputIterator>; |
| 251 | 218 | |
| 252 | namespace __uninitialized_move { | |
| 253 | ||
| 254 | struct __fn { | |
| 219 | struct __uninitialized_move { | |
| 255 | 220 | template <input_iterator _InputIterator, |
| 256 | 221 | sentinel_for<_InputIterator> _Sentinel1, |
| 257 | 222 | __nothrow_forward_iterator _OutputIterator, |
| ... | ... | @@ -276,10 +241,8 @@ struct __fn { |
| 276 | 241 | } |
| 277 | 242 | }; |
| 278 | 243 | |
| 279 | } // namespace __uninitialized_move | |
| 280 | ||
| 281 | 244 | inline namespace __cpo { |
| 282 | inline constexpr auto uninitialized_move = __uninitialized_move::__fn{}; | |
| 245 | inline constexpr auto uninitialized_move = __uninitialized_move{}; | |
| 283 | 246 | } // namespace __cpo |
| 284 | 247 | |
| 285 | 248 | // uninitialized_move_n |
| ... | ... | @@ -287,9 +250,7 @@ inline constexpr auto uninitialized_move = __uninitialized_move::__fn{}; |
| 287 | 250 | template <class _InputIterator, class _OutputIterator> |
| 288 | 251 | using uninitialized_move_n_result = in_out_result<_InputIterator, _OutputIterator>; |
| 289 | 252 | |
| 290 | namespace __uninitialized_move_n { | |
| 291 | ||
| 292 | struct __fn { | |
| 253 | struct __uninitialized_move_n { | |
| 293 | 254 | template <input_iterator _InputIterator, |
| 294 | 255 | __nothrow_forward_iterator _OutputIterator, |
| 295 | 256 | __nothrow_sentinel_for<_OutputIterator> _Sentinel> |
| ... | ... | @@ -308,10 +269,8 @@ struct __fn { |
| 308 | 269 | } |
| 309 | 270 | }; |
| 310 | 271 | |
| 311 | } // namespace __uninitialized_move_n | |
| 312 | ||
| 313 | 272 | inline namespace __cpo { |
| 314 | inline constexpr auto uninitialized_move_n = __uninitialized_move_n::__fn{}; | |
| 273 | inline constexpr auto uninitialized_move_n = __uninitialized_move_n{}; | |
| 315 | 274 | } // namespace __cpo |
| 316 | 275 | |
| 317 | 276 | } // namespace ranges |
lib/libcxx/include/__memory/raw_storage_iterator.h+1-2| ... | ... | @@ -11,12 +11,11 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__iterator/iterator.h> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | 17 | #include <__memory/addressof.h> |
| 17 | 18 | #include <__utility/move.h> |
| 18 | #include <cstddef> | |
| 19 | #include <new> | |
| 20 | 19 | |
| 21 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 21 | # pragma GCC system_header |
lib/libcxx/include/__memory/shared_count.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___MEMORY_SHARED_COUNT_H | |
| 10 | #define _LIBCPP___MEMORY_SHARED_COUNT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <typeinfo> | |
| 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 | // NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively) | |
| 22 | // should be sufficient for thread safety. | |
| 23 | // See https://llvm.org/PR22803 | |
| 24 | #if (defined(__clang__) && __has_builtin(__atomic_add_fetch) && defined(__ATOMIC_RELAXED) && \ | |
| 25 | defined(__ATOMIC_ACQ_REL)) || \ | |
| 26 | defined(_LIBCPP_COMPILER_GCC) | |
| 27 | # define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT 1 | |
| 28 | #else | |
| 29 | # define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT 0 | |
| 30 | #endif | |
| 31 | ||
| 32 | template <class _ValueType> | |
| 33 | inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_relaxed_load(_ValueType const* __value) { | |
| 34 | #if _LIBCPP_HAS_THREADS && defined(__ATOMIC_RELAXED) && \ | |
| 35 | (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC)) | |
| 36 | return __atomic_load_n(__value, __ATOMIC_RELAXED); | |
| 37 | #else | |
| 38 | return *__value; | |
| 39 | #endif | |
| 40 | } | |
| 41 | ||
| 42 | template <class _ValueType> | |
| 43 | inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const* __value) { | |
| 44 | #if _LIBCPP_HAS_THREADS && defined(__ATOMIC_ACQUIRE) && \ | |
| 45 | (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC)) | |
| 46 | return __atomic_load_n(__value, __ATOMIC_ACQUIRE); | |
| 47 | #else | |
| 48 | return *__value; | |
| 49 | #endif | |
| 50 | } | |
| 51 | ||
| 52 | template <class _Tp> | |
| 53 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT { | |
| 54 | #if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS | |
| 55 | return __atomic_add_fetch(&__t, 1, __ATOMIC_RELAXED); | |
| 56 | #else | |
| 57 | return __t += 1; | |
| 58 | #endif | |
| 59 | } | |
| 60 | ||
| 61 | template <class _Tp> | |
| 62 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT { | |
| 63 | #if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS | |
| 64 | return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL); | |
| 65 | #else | |
| 66 | return __t -= 1; | |
| 67 | #endif | |
| 68 | } | |
| 69 | ||
| 70 | class _LIBCPP_EXPORTED_FROM_ABI __shared_count { | |
| 71 | __shared_count(const __shared_count&); | |
| 72 | __shared_count& operator=(const __shared_count&); | |
| 73 | ||
| 74 | protected: | |
| 75 | long __shared_owners_; | |
| 76 | virtual ~__shared_count(); | |
| 77 | ||
| 78 | private: | |
| 79 | virtual void __on_zero_shared() _NOEXCEPT = 0; | |
| 80 | ||
| 81 | public: | |
| 82 | _LIBCPP_HIDE_FROM_ABI explicit __shared_count(long __refs = 0) _NOEXCEPT : __shared_owners_(__refs) {} | |
| 83 | ||
| 84 | #if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS) | |
| 85 | void __add_shared() noexcept; | |
| 86 | bool __release_shared() noexcept; | |
| 87 | #else | |
| 88 | _LIBCPP_HIDE_FROM_ABI void __add_shared() _NOEXCEPT { __libcpp_atomic_refcount_increment(__shared_owners_); } | |
| 89 | _LIBCPP_HIDE_FROM_ABI bool __release_shared() _NOEXCEPT { | |
| 90 | if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1) { | |
| 91 | __on_zero_shared(); | |
| 92 | return true; | |
| 93 | } | |
| 94 | return false; | |
| 95 | } | |
| 96 | #endif | |
| 97 | _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __libcpp_relaxed_load(&__shared_owners_) + 1; } | |
| 98 | }; | |
| 99 | ||
| 100 | class _LIBCPP_EXPORTED_FROM_ABI __shared_weak_count : private __shared_count { | |
| 101 | long __shared_weak_owners_; | |
| 102 | ||
| 103 | public: | |
| 104 | _LIBCPP_HIDE_FROM_ABI explicit __shared_weak_count(long __refs = 0) _NOEXCEPT | |
| 105 | : __shared_count(__refs), | |
| 106 | __shared_weak_owners_(__refs) {} | |
| 107 | ||
| 108 | protected: | |
| 109 | ~__shared_weak_count() override; | |
| 110 | ||
| 111 | public: | |
| 112 | #if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS) | |
| 113 | void __add_shared() noexcept; | |
| 114 | void __add_weak() noexcept; | |
| 115 | void __release_shared() noexcept; | |
| 116 | #else | |
| 117 | _LIBCPP_HIDE_FROM_ABI void __add_shared() _NOEXCEPT { __shared_count::__add_shared(); } | |
| 118 | _LIBCPP_HIDE_FROM_ABI void __add_weak() _NOEXCEPT { __libcpp_atomic_refcount_increment(__shared_weak_owners_); } | |
| 119 | _LIBCPP_HIDE_FROM_ABI void __release_shared() _NOEXCEPT { | |
| 120 | if (__shared_count::__release_shared()) | |
| 121 | __release_weak(); | |
| 122 | } | |
| 123 | #endif | |
| 124 | void __release_weak() _NOEXCEPT; | |
| 125 | _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __shared_count::use_count(); } | |
| 126 | __shared_weak_count* lock() _NOEXCEPT; | |
| 127 | ||
| 128 | virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; | |
| 129 | ||
| 130 | private: | |
| 131 | virtual void __on_zero_shared_weak() _NOEXCEPT = 0; | |
| 132 | }; | |
| 133 | ||
| 134 | _LIBCPP_END_NAMESPACE_STD | |
| 135 | ||
| 136 | #endif // _LIBCPP___MEMORY_SHARED_COUNT_H |
lib/libcxx/include/__memory/shared_ptr.h+67-177| ... | ... | @@ -13,6 +13,8 @@ |
| 13 | 13 | #include <__compare/compare_three_way.h> |
| 14 | 14 | #include <__compare/ordering.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__cstddef/nullptr_t.h> | |
| 17 | #include <__cstddef/ptrdiff_t.h> | |
| 16 | 18 | #include <__exception/exception.h> |
| 17 | 19 | #include <__functional/binary_function.h> |
| 18 | 20 | #include <__functional/operations.h> |
| ... | ... | @@ -28,20 +30,26 @@ |
| 28 | 30 | #include <__memory/compressed_pair.h> |
| 29 | 31 | #include <__memory/construct_at.h> |
| 30 | 32 | #include <__memory/pointer_traits.h> |
| 33 | #include <__memory/shared_count.h> | |
| 31 | 34 | #include <__memory/uninitialized_algorithms.h> |
| 32 | 35 | #include <__memory/unique_ptr.h> |
| 33 | 36 | #include <__type_traits/add_lvalue_reference.h> |
| 34 | 37 | #include <__type_traits/conditional.h> |
| 35 | 38 | #include <__type_traits/conjunction.h> |
| 36 | 39 | #include <__type_traits/disjunction.h> |
| 40 | #include <__type_traits/enable_if.h> | |
| 41 | #include <__type_traits/integral_constant.h> | |
| 37 | 42 | #include <__type_traits/is_array.h> |
| 38 | 43 | #include <__type_traits/is_bounded_array.h> |
| 39 | 44 | #include <__type_traits/is_constructible.h> |
| 40 | 45 | #include <__type_traits/is_convertible.h> |
| 46 | #include <__type_traits/is_function.h> | |
| 41 | 47 | #include <__type_traits/is_reference.h> |
| 48 | #include <__type_traits/is_same.h> | |
| 42 | 49 | #include <__type_traits/is_unbounded_array.h> |
| 43 | 50 | #include <__type_traits/nat.h> |
| 44 | 51 | #include <__type_traits/negation.h> |
| 52 | #include <__type_traits/remove_cv.h> | |
| 45 | 53 | #include <__type_traits/remove_extent.h> |
| 46 | 54 | #include <__type_traits/remove_reference.h> |
| 47 | 55 | #include <__utility/declval.h> |
| ... | ... | @@ -49,10 +57,8 @@ |
| 49 | 57 | #include <__utility/move.h> |
| 50 | 58 | #include <__utility/swap.h> |
| 51 | 59 | #include <__verbose_abort> |
| 52 | #include <cstddef> | |
| 53 | #include <new> | |
| 54 | 60 | #include <typeinfo> |
| 55 | #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) | |
| 61 | #if _LIBCPP_HAS_ATOMIC_HEADER | |
| 56 | 62 | # include <__atomic/memory_order.h> |
| 57 | 63 | #endif |
| 58 | 64 | |
| ... | ... | @@ -65,53 +71,6 @@ _LIBCPP_PUSH_MACROS |
| 65 | 71 | |
| 66 | 72 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 67 | 73 | |
| 68 | // NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively) | |
| 69 | // should be sufficient for thread safety. | |
| 70 | // See https://llvm.org/PR22803 | |
| 71 | #if defined(__clang__) && __has_builtin(__atomic_add_fetch) && defined(__ATOMIC_RELAXED) && defined(__ATOMIC_ACQ_REL) | |
| 72 | # define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT | |
| 73 | #elif defined(_LIBCPP_COMPILER_GCC) | |
| 74 | # define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT | |
| 75 | #endif | |
| 76 | ||
| 77 | template <class _ValueType> | |
| 78 | inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_relaxed_load(_ValueType const* __value) { | |
| 79 | #if !defined(_LIBCPP_HAS_NO_THREADS) && defined(__ATOMIC_RELAXED) && \ | |
| 80 | (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC)) | |
| 81 | return __atomic_load_n(__value, __ATOMIC_RELAXED); | |
| 82 | #else | |
| 83 | return *__value; | |
| 84 | #endif | |
| 85 | } | |
| 86 | ||
| 87 | template <class _ValueType> | |
| 88 | inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const* __value) { | |
| 89 | #if !defined(_LIBCPP_HAS_NO_THREADS) && defined(__ATOMIC_ACQUIRE) && \ | |
| 90 | (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC)) | |
| 91 | return __atomic_load_n(__value, __ATOMIC_ACQUIRE); | |
| 92 | #else | |
| 93 | return *__value; | |
| 94 | #endif | |
| 95 | } | |
| 96 | ||
| 97 | template <class _Tp> | |
| 98 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT { | |
| 99 | #if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 100 | return __atomic_add_fetch(&__t, 1, __ATOMIC_RELAXED); | |
| 101 | #else | |
| 102 | return __t += 1; | |
| 103 | #endif | |
| 104 | } | |
| 105 | ||
| 106 | template <class _Tp> | |
| 107 | inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT { | |
| 108 | #if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 109 | return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL); | |
| 110 | #else | |
| 111 | return __t -= 1; | |
| 112 | #endif | |
| 113 | } | |
| 114 | ||
| 115 | 74 | class _LIBCPP_EXPORTED_FROM_ABI bad_weak_ptr : public std::exception { |
| 116 | 75 | public: |
| 117 | 76 | _LIBCPP_HIDE_FROM_ABI bad_weak_ptr() _NOEXCEPT = default; |
| ... | ... | @@ -121,8 +80,8 @@ public: |
| 121 | 80 | const char* what() const _NOEXCEPT override; |
| 122 | 81 | }; |
| 123 | 82 | |
| 124 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() { | |
| 125 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 83 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() { | |
| 84 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 126 | 85 | throw bad_weak_ptr(); |
| 127 | 86 | #else |
| 128 | 87 | _LIBCPP_VERBOSE_ABORT("bad_weak_ptr was thrown in -fno-exceptions mode"); |
| ... | ... | @@ -132,79 +91,15 @@ _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() { |
| 132 | 91 | template <class _Tp> |
| 133 | 92 | class _LIBCPP_TEMPLATE_VIS weak_ptr; |
| 134 | 93 | |
| 135 | class _LIBCPP_EXPORTED_FROM_ABI __shared_count { | |
| 136 | __shared_count(const __shared_count&); | |
| 137 | __shared_count& operator=(const __shared_count&); | |
| 138 | ||
| 139 | protected: | |
| 140 | long __shared_owners_; | |
| 141 | virtual ~__shared_count(); | |
| 142 | ||
| 143 | private: | |
| 144 | virtual void __on_zero_shared() _NOEXCEPT = 0; | |
| 145 | ||
| 146 | public: | |
| 147 | _LIBCPP_HIDE_FROM_ABI explicit __shared_count(long __refs = 0) _NOEXCEPT : __shared_owners_(__refs) {} | |
| 148 | ||
| 149 | #if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS) | |
| 150 | void __add_shared() noexcept; | |
| 151 | bool __release_shared() noexcept; | |
| 152 | #else | |
| 153 | _LIBCPP_HIDE_FROM_ABI void __add_shared() _NOEXCEPT { __libcpp_atomic_refcount_increment(__shared_owners_); } | |
| 154 | _LIBCPP_HIDE_FROM_ABI bool __release_shared() _NOEXCEPT { | |
| 155 | if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1) { | |
| 156 | __on_zero_shared(); | |
| 157 | return true; | |
| 158 | } | |
| 159 | return false; | |
| 160 | } | |
| 161 | #endif | |
| 162 | _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __libcpp_relaxed_load(&__shared_owners_) + 1; } | |
| 163 | }; | |
| 164 | ||
| 165 | class _LIBCPP_EXPORTED_FROM_ABI __shared_weak_count : private __shared_count { | |
| 166 | long __shared_weak_owners_; | |
| 167 | ||
| 168 | public: | |
| 169 | _LIBCPP_HIDE_FROM_ABI explicit __shared_weak_count(long __refs = 0) _NOEXCEPT | |
| 170 | : __shared_count(__refs), | |
| 171 | __shared_weak_owners_(__refs) {} | |
| 172 | ||
| 173 | protected: | |
| 174 | ~__shared_weak_count() override; | |
| 175 | ||
| 176 | public: | |
| 177 | #if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS) | |
| 178 | void __add_shared() noexcept; | |
| 179 | void __add_weak() noexcept; | |
| 180 | void __release_shared() noexcept; | |
| 181 | #else | |
| 182 | _LIBCPP_HIDE_FROM_ABI void __add_shared() _NOEXCEPT { __shared_count::__add_shared(); } | |
| 183 | _LIBCPP_HIDE_FROM_ABI void __add_weak() _NOEXCEPT { __libcpp_atomic_refcount_increment(__shared_weak_owners_); } | |
| 184 | _LIBCPP_HIDE_FROM_ABI void __release_shared() _NOEXCEPT { | |
| 185 | if (__shared_count::__release_shared()) | |
| 186 | __release_weak(); | |
| 187 | } | |
| 188 | #endif | |
| 189 | void __release_weak() _NOEXCEPT; | |
| 190 | _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT { return __shared_count::use_count(); } | |
| 191 | __shared_weak_count* lock() _NOEXCEPT; | |
| 192 | ||
| 193 | virtual const void* __get_deleter(const type_info&) const _NOEXCEPT; | |
| 194 | ||
| 195 | private: | |
| 196 | virtual void __on_zero_shared_weak() _NOEXCEPT = 0; | |
| 197 | }; | |
| 198 | ||
| 199 | 94 | template <class _Tp, class _Dp, class _Alloc> |
| 200 | 95 | class __shared_ptr_pointer : public __shared_weak_count { |
| 201 | __compressed_pair<__compressed_pair<_Tp, _Dp>, _Alloc> __data_; | |
| 96 | _LIBCPP_COMPRESSED_TRIPLE(_Tp, __ptr_, _Dp, __deleter_, _Alloc, __alloc_); | |
| 202 | 97 | |
| 203 | 98 | public: |
| 204 | 99 | _LIBCPP_HIDE_FROM_ABI __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) |
| 205 | : __data_(__compressed_pair<_Tp, _Dp>(__p, std::move(__d)), std::move(__a)) {} | |
| 100 | : __ptr_(__p), __deleter_(std::move(__d)), __alloc_(std::move(__a)) {} | |
| 206 | 101 | |
| 207 | #ifndef _LIBCPP_HAS_NO_RTTI | |
| 102 | #if _LIBCPP_HAS_RTTI | |
| 208 | 103 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* __get_deleter(const type_info&) const _NOEXCEPT override; |
| 209 | 104 | #endif |
| 210 | 105 | |
| ... | ... | @@ -213,19 +108,19 @@ private: |
| 213 | 108 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override; |
| 214 | 109 | }; |
| 215 | 110 | |
| 216 | #ifndef _LIBCPP_HAS_NO_RTTI | |
| 111 | #if _LIBCPP_HAS_RTTI | |
| 217 | 112 | |
| 218 | 113 | template <class _Tp, class _Dp, class _Alloc> |
| 219 | 114 | const void* __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT { |
| 220 | return __t == typeid(_Dp) ? std::addressof(__data_.first().second()) : nullptr; | |
| 115 | return __t == typeid(_Dp) ? std::addressof(__deleter_) : nullptr; | |
| 221 | 116 | } |
| 222 | 117 | |
| 223 | #endif // _LIBCPP_HAS_NO_RTTI | |
| 118 | #endif // _LIBCPP_HAS_RTTI | |
| 224 | 119 | |
| 225 | 120 | template <class _Tp, class _Dp, class _Alloc> |
| 226 | 121 | void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT { |
| 227 | __data_.first().second()(__data_.first().first()); | |
| 228 | __data_.first().second().~_Dp(); | |
| 122 | __deleter_(__ptr_); | |
| 123 | __deleter_.~_Dp(); | |
| 229 | 124 | } |
| 230 | 125 | |
| 231 | 126 | template <class _Tp, class _Dp, class _Alloc> |
| ... | ... | @@ -234,8 +129,8 @@ void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT { |
| 234 | 129 | typedef allocator_traits<_Al> _ATraits; |
| 235 | 130 | typedef pointer_traits<typename _ATraits::pointer> _PTraits; |
| 236 | 131 | |
| 237 | _Al __a(__data_.second()); | |
| 238 | __data_.second().~_Alloc(); | |
| 132 | _Al __a(__alloc_); | |
| 133 | __alloc_.~_Alloc(); | |
| 239 | 134 | __a.deallocate(_PTraits::pointer_to(*this), 1); |
| 240 | 135 | } |
| 241 | 136 | |
| ... | ... | @@ -246,33 +141,35 @@ struct __for_overwrite_tag {}; |
| 246 | 141 | |
| 247 | 142 | template <class _Tp, class _Alloc> |
| 248 | 143 | struct __shared_ptr_emplace : __shared_weak_count { |
| 144 | using __value_type _LIBCPP_NODEBUG = __remove_cv_t<_Tp>; | |
| 145 | ||
| 249 | 146 | template <class... _Args, |
| 250 | 147 | class _Allocator = _Alloc, |
| 251 | 148 | __enable_if_t<is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> |
| 252 | 149 | _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&...) : __storage_(std::move(__a)) { |
| 253 | 150 | static_assert( |
| 254 | 151 | sizeof...(_Args) == 0, "No argument should be provided to the control block when using _for_overwrite"); |
| 255 | ::new ((void*)__get_elem()) _Tp; | |
| 152 | ::new (static_cast<void*>(__get_elem())) __value_type; | |
| 256 | 153 | } |
| 257 | 154 | |
| 258 | 155 | template <class... _Args, |
| 259 | 156 | class _Allocator = _Alloc, |
| 260 | 157 | __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> |
| 261 | 158 | _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&... __args) : __storage_(std::move(__a)) { |
| 262 | using _TpAlloc = typename __allocator_traits_rebind<_Alloc, __remove_cv_t<_Tp> >::type; | |
| 159 | using _TpAlloc = typename __allocator_traits_rebind<_Alloc, __value_type>::type; | |
| 263 | 160 | _TpAlloc __tmp(*__get_alloc()); |
| 264 | 161 | allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), std::forward<_Args>(__args)...); |
| 265 | 162 | } |
| 266 | 163 | |
| 267 | 164 | _LIBCPP_HIDE_FROM_ABI _Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); } |
| 268 | 165 | |
| 269 | _LIBCPP_HIDE_FROM_ABI _Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); } | |
| 166 | _LIBCPP_HIDE_FROM_ABI __value_type* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); } | |
| 270 | 167 | |
| 271 | 168 | private: |
| 272 | 169 | template <class _Allocator = _Alloc, |
| 273 | 170 | __enable_if_t<is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> |
| 274 | 171 | _LIBCPP_HIDE_FROM_ABI void __on_zero_shared_impl() _NOEXCEPT { |
| 275 | __get_elem()->~_Tp(); | |
| 172 | __get_elem()->~__value_type(); | |
| 276 | 173 | } |
| 277 | 174 | |
| 278 | 175 | template <class _Allocator = _Alloc, |
| ... | ... | @@ -293,36 +190,28 @@ private: |
| 293 | 190 | allocator_traits<_ControlBlockAlloc>::deallocate(__tmp, pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1); |
| 294 | 191 | } |
| 295 | 192 | |
| 193 | // TODO: It should be possible to refactor this to remove `_Storage` entirely. | |
| 296 | 194 | // This class implements the control block for non-array shared pointers created |
| 297 | 195 | // through `std::allocate_shared` and `std::make_shared`. |
| 298 | // | |
| 299 | // In previous versions of the library, we used a compressed pair to store | |
| 300 | // both the _Alloc and the _Tp. This implies using EBO, which is incompatible | |
| 301 | // with Allocator construction for _Tp. To allow implementing P0674 in C++20, | |
| 302 | // we now use a properly aligned char buffer while making sure that we maintain | |
| 303 | // the same layout that we had when we used a compressed pair. | |
| 304 | using _CompressedPair = __compressed_pair<_Alloc, _Tp>; | |
| 305 | struct _ALIGNAS_TYPE(_CompressedPair) _Storage { | |
| 306 | char __blob_[sizeof(_CompressedPair)]; | |
| 196 | struct _Storage { | |
| 197 | struct _Data { | |
| 198 | _LIBCPP_COMPRESSED_PAIR(_Alloc, __alloc_, __value_type, __elem_); | |
| 199 | }; | |
| 200 | ||
| 201 | _ALIGNAS_TYPE(_Data) char __buffer_[sizeof(_Data)]; | |
| 307 | 202 | |
| 308 | 203 | _LIBCPP_HIDE_FROM_ABI explicit _Storage(_Alloc&& __a) { ::new ((void*)__get_alloc()) _Alloc(std::move(__a)); } |
| 309 | 204 | _LIBCPP_HIDE_FROM_ABI ~_Storage() { __get_alloc()->~_Alloc(); } |
| 205 | ||
| 310 | 206 | _LIBCPP_HIDE_FROM_ABI _Alloc* __get_alloc() _NOEXCEPT { |
| 311 | _CompressedPair* __as_pair = reinterpret_cast<_CompressedPair*>(__blob_); | |
| 312 | typename _CompressedPair::_Base1* __first = _CompressedPair::__get_first_base(__as_pair); | |
| 313 | _Alloc* __alloc = reinterpret_cast<_Alloc*>(__first); | |
| 314 | return __alloc; | |
| 207 | return std::addressof(reinterpret_cast<_Data*>(__buffer_)->__alloc_); | |
| 315 | 208 | } |
| 316 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp* __get_elem() _NOEXCEPT { | |
| 317 | _CompressedPair* __as_pair = reinterpret_cast<_CompressedPair*>(__blob_); | |
| 318 | typename _CompressedPair::_Base2* __second = _CompressedPair::__get_second_base(__as_pair); | |
| 319 | _Tp* __elem = reinterpret_cast<_Tp*>(__second); | |
| 320 | return __elem; | |
| 209 | ||
| 210 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI __value_type* __get_elem() _NOEXCEPT { | |
| 211 | return std::addressof(reinterpret_cast<_Data*>(__buffer_)->__elem_); | |
| 321 | 212 | } |
| 322 | 213 | }; |
| 323 | 214 | |
| 324 | static_assert(_LIBCPP_ALIGNOF(_Storage) == _LIBCPP_ALIGNOF(_CompressedPair), ""); | |
| 325 | static_assert(sizeof(_Storage) == sizeof(_CompressedPair), ""); | |
| 326 | 215 | _Storage __storage_; |
| 327 | 216 | }; |
| 328 | 217 | |
| ... | ... | @@ -404,7 +293,8 @@ struct __shared_ptr_deleter_ctor_reqs { |
| 404 | 293 | }; |
| 405 | 294 | |
| 406 | 295 | template <class _Dp> |
| 407 | using __shared_ptr_nullptr_deleter_ctor_reqs = _And<is_move_constructible<_Dp>, __well_formed_deleter<_Dp, nullptr_t> >; | |
| 296 | using __shared_ptr_nullptr_deleter_ctor_reqs _LIBCPP_NODEBUG = | |
| 297 | _And<is_move_constructible<_Dp>, __well_formed_deleter<_Dp, nullptr_t> >; | |
| 408 | 298 | |
| 409 | 299 | #if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI) |
| 410 | 300 | # define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__)) |
| ... | ... | @@ -426,7 +316,7 @@ public: |
| 426 | 316 | |
| 427 | 317 | // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require |
| 428 | 318 | // any bookkeeping, so it's always trivially relocatable. |
| 429 | using __trivially_relocatable = shared_ptr; | |
| 319 | using __trivially_relocatable _LIBCPP_NODEBUG = shared_ptr; | |
| 430 | 320 | |
| 431 | 321 | private: |
| 432 | 322 | element_type* __ptr_; |
| ... | ... | @@ -459,9 +349,9 @@ public: |
| 459 | 349 | |
| 460 | 350 | template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0> |
| 461 | 351 | _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) { |
| 462 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 352 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 463 | 353 | try { |
| 464 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 354 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 465 | 355 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; |
| 466 | 356 | typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT> _CntrlBlk; |
| 467 | 357 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -470,12 +360,12 @@ public: |
| 470 | 360 | __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); |
| 471 | 361 | #endif // not _LIBCPP_CXX03_LANG |
| 472 | 362 | __enable_weak_this(__p, __p); |
| 473 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 363 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 474 | 364 | } catch (...) { |
| 475 | 365 | __d(__p); |
| 476 | 366 | throw; |
| 477 | 367 | } |
| 478 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 368 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 479 | 369 | } |
| 480 | 370 | |
| 481 | 371 | template <class _Yp, |
| ... | ... | @@ -483,9 +373,9 @@ public: |
| 483 | 373 | class _Alloc, |
| 484 | 374 | __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0> |
| 485 | 375 | _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) { |
| 486 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 376 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 487 | 377 | try { |
| 488 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 378 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 489 | 379 | typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; |
| 490 | 380 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; |
| 491 | 381 | typedef __allocator_destructor<_A2> _D2; |
| ... | ... | @@ -499,12 +389,12 @@ public: |
| 499 | 389 | #endif // not _LIBCPP_CXX03_LANG |
| 500 | 390 | __cntrl_ = std::addressof(*__hold2.release()); |
| 501 | 391 | __enable_weak_this(__p, __p); |
| 502 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 392 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 503 | 393 | } catch (...) { |
| 504 | 394 | __d(__p); |
| 505 | 395 | throw; |
| 506 | 396 | } |
| 507 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 397 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 508 | 398 | } |
| 509 | 399 | |
| 510 | 400 | template <class _Dp> |
| ... | ... | @@ -513,9 +403,9 @@ public: |
| 513 | 403 | _Dp __d, |
| 514 | 404 | __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag()) |
| 515 | 405 | : __ptr_(nullptr) { |
| 516 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 406 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 517 | 407 | try { |
| 518 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 408 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 519 | 409 | typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; |
| 520 | 410 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT> _CntrlBlk; |
| 521 | 411 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -523,12 +413,12 @@ public: |
| 523 | 413 | #else |
| 524 | 414 | __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); |
| 525 | 415 | #endif // not _LIBCPP_CXX03_LANG |
| 526 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 416 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 527 | 417 | } catch (...) { |
| 528 | 418 | __d(__p); |
| 529 | 419 | throw; |
| 530 | 420 | } |
| 531 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 421 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 532 | 422 | } |
| 533 | 423 | |
| 534 | 424 | template <class _Dp, class _Alloc> |
| ... | ... | @@ -538,9 +428,9 @@ public: |
| 538 | 428 | _Alloc __a, |
| 539 | 429 | __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag()) |
| 540 | 430 | : __ptr_(nullptr) { |
| 541 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 431 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 542 | 432 | try { |
| 543 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 433 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 544 | 434 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; |
| 545 | 435 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; |
| 546 | 436 | typedef __allocator_destructor<_A2> _D2; |
| ... | ... | @@ -553,12 +443,12 @@ public: |
| 553 | 443 | _CntrlBlk(__p, __d, __a); |
| 554 | 444 | #endif // not _LIBCPP_CXX03_LANG |
| 555 | 445 | __cntrl_ = std::addressof(*__hold2.release()); |
| 556 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 446 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 557 | 447 | } catch (...) { |
| 558 | 448 | __d(__p); |
| 559 | 449 | throw; |
| 560 | 450 | } |
| 561 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 451 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 562 | 452 | } |
| 563 | 453 | |
| 564 | 454 | template <class _Yp> |
| ... | ... | @@ -771,12 +661,12 @@ public: |
| 771 | 661 | } |
| 772 | 662 | #endif |
| 773 | 663 | |
| 774 | #ifndef _LIBCPP_HAS_NO_RTTI | |
| 664 | #if _LIBCPP_HAS_RTTI | |
| 775 | 665 | template <class _Dp> |
| 776 | 666 | _LIBCPP_HIDE_FROM_ABI _Dp* __get_deleter() const _NOEXCEPT { |
| 777 | 667 | return static_cast<_Dp*>(__cntrl_ ? const_cast<void*>(__cntrl_->__get_deleter(typeid(_Dp))) : nullptr); |
| 778 | 668 | } |
| 779 | #endif // _LIBCPP_HAS_NO_RTTI | |
| 669 | #endif // _LIBCPP_HAS_RTTI | |
| 780 | 670 | |
| 781 | 671 | template <class _Yp, class _CntrlBlk> |
| 782 | 672 | _LIBCPP_HIDE_FROM_ABI static shared_ptr<_Tp> __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT { |
| ... | ... | @@ -959,7 +849,7 @@ private: |
| 959 | 849 | template <class _Array, class _Alloc, class... _Arg> |
| 960 | 850 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Array> |
| 961 | 851 | __allocate_shared_unbounded_array(const _Alloc& __a, size_t __n, _Arg&&... __arg) { |
| 962 | static_assert(__libcpp_is_unbounded_array<_Array>::value); | |
| 852 | static_assert(__is_unbounded_array_v<_Array>); | |
| 963 | 853 | // We compute the number of bytes necessary to hold the control block and the |
| 964 | 854 | // array elements. Then, we allocate an array of properly-aligned dummy structs |
| 965 | 855 | // large enough to hold the control block and array. This allows shifting the |
| ... | ... | @@ -1036,7 +926,7 @@ private: |
| 1036 | 926 | |
| 1037 | 927 | template <class _Array, class _Alloc, class... _Arg> |
| 1038 | 928 | _LIBCPP_HIDE_FROM_ABI shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&&... __arg) { |
| 1039 | static_assert(__libcpp_is_bounded_array<_Array>::value); | |
| 929 | static_assert(__is_bounded_array_v<_Array>); | |
| 1040 | 930 | using _ControlBlock = __bounded_array_control_block<_Array, _Alloc>; |
| 1041 | 931 | using _ControlBlockAlloc = __allocator_traits_rebind_t<_Alloc, _ControlBlock>; |
| 1042 | 932 | |
| ... | ... | @@ -1301,14 +1191,14 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(shared_ptr<_Up>&& |
| 1301 | 1191 | } |
| 1302 | 1192 | #endif |
| 1303 | 1193 | |
| 1304 | #ifndef _LIBCPP_HAS_NO_RTTI | |
| 1194 | #if _LIBCPP_HAS_RTTI | |
| 1305 | 1195 | |
| 1306 | 1196 | template <class _Dp, class _Tp> |
| 1307 | 1197 | inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT { |
| 1308 | 1198 | return __p.template __get_deleter<_Dp>(); |
| 1309 | 1199 | } |
| 1310 | 1200 | |
| 1311 | #endif // _LIBCPP_HAS_NO_RTTI | |
| 1201 | #endif // _LIBCPP_HAS_RTTI | |
| 1312 | 1202 | |
| 1313 | 1203 | template <class _Tp> |
| 1314 | 1204 | class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr { |
| ... | ... | @@ -1321,7 +1211,7 @@ public: |
| 1321 | 1211 | |
| 1322 | 1212 | // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require |
| 1323 | 1213 | // any bookkeeping, so it's always trivially relocatable. |
| 1324 | using __trivially_relocatable = weak_ptr; | |
| 1214 | using __trivially_relocatable _LIBCPP_NODEBUG = weak_ptr; | |
| 1325 | 1215 | |
| 1326 | 1216 | private: |
| 1327 | 1217 | element_type* __ptr_; |
| ... | ... | @@ -1583,7 +1473,7 @@ template <class _CharT, class _Traits, class _Yp> |
| 1583 | 1473 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| 1584 | 1474 | operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); |
| 1585 | 1475 | |
| 1586 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 1476 | #if _LIBCPP_HAS_THREADS | |
| 1587 | 1477 | |
| 1588 | 1478 | class _LIBCPP_EXPORTED_FROM_ABI __sp_mut { |
| 1589 | 1479 | void* __lx_; |
| ... | ... | @@ -1685,7 +1575,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_weak_explicit( |
| 1685 | 1575 | return std::atomic_compare_exchange_weak(__p, __v, __w); |
| 1686 | 1576 | } |
| 1687 | 1577 | |
| 1688 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 1578 | #endif // _LIBCPP_HAS_THREADS | |
| 1689 | 1579 | |
| 1690 | 1580 | _LIBCPP_END_NAMESPACE_STD |
| 1691 | 1581 |
lib/libcxx/include/__memory/temporary_buffer.h+13-43| ... | ... | @@ -11,65 +11,35 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 15 | #include <__memory/unique_temporary_buffer.h> | |
| 14 | 16 | #include <__utility/pair.h> |
| 15 | #include <cstddef> | |
| 16 | #include <new> | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | # pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER) | |
| 23 | ||
| 22 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 25 | |
| 24 | 26 | template <class _Tp> |
| 25 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t> | |
| 27 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t> | |
| 26 | 28 | get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT { |
| 27 | pair<_Tp*, ptrdiff_t> __r(0, 0); | |
| 28 | const ptrdiff_t __m = | |
| 29 | (~ptrdiff_t(0) ^ ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) / sizeof(_Tp); | |
| 30 | if (__n > __m) | |
| 31 | __n = __m; | |
| 32 | while (__n > 0) { | |
| 33 | #if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) | |
| 34 | if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) { | |
| 35 | align_val_t __al = align_val_t(_LIBCPP_ALIGNOF(_Tp)); | |
| 36 | __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), __al, nothrow)); | |
| 37 | } else { | |
| 38 | __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); | |
| 39 | } | |
| 40 | #else | |
| 41 | if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) { | |
| 42 | // Since aligned operator new is unavailable, return an empty | |
| 43 | // buffer rather than one with invalid alignment. | |
| 44 | return __r; | |
| 45 | } | |
| 46 | ||
| 47 | __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow)); | |
| 48 | #endif | |
| 49 | ||
| 50 | if (__r.first) { | |
| 51 | __r.second = __n; | |
| 52 | break; | |
| 53 | } | |
| 54 | __n /= 2; | |
| 55 | } | |
| 56 | return __r; | |
| 29 | __unique_temporary_buffer<_Tp> __unique_buf = std::__allocate_unique_temporary_buffer<_Tp>(__n); | |
| 30 | pair<_Tp*, ptrdiff_t> __result(__unique_buf.get(), __unique_buf.get_deleter().__count_); | |
| 31 | __unique_buf.release(); | |
| 32 | return __result; | |
| 57 | 33 | } |
| 58 | 34 | |
| 59 | 35 | template <class _Tp> |
| 60 | 36 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 void return_temporary_buffer(_Tp* __p) _NOEXCEPT { |
| 61 | std::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp)); | |
| 37 | __unique_temporary_buffer<_Tp> __unique_buf(__p); | |
| 38 | (void)__unique_buf; | |
| 62 | 39 | } |
| 63 | 40 | |
| 64 | struct __return_temporary_buffer { | |
| 65 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 66 | template <class _Tp> | |
| 67 | _LIBCPP_HIDE_FROM_ABI void operator()(_Tp* __p) const { | |
| 68 | std::return_temporary_buffer(__p); | |
| 69 | } | |
| 70 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 71 | }; | |
| 72 | ||
| 73 | 41 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 42 | |
| 43 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TEMPORARY_BUFFER) | |
| 44 | ||
| 75 | 45 | #endif // _LIBCPP___MEMORY_TEMPORARY_BUFFER_H |
lib/libcxx/include/__memory/uninitialized_algorithms.h+61-59| ... | ... | @@ -15,16 +15,18 @@ |
| 15 | 15 | #include <__algorithm/unwrap_iter.h> |
| 16 | 16 | #include <__algorithm/unwrap_range.h> |
| 17 | 17 | #include <__config> |
| 18 | #include <__cstddef/size_t.h> | |
| 18 | 19 | #include <__iterator/iterator_traits.h> |
| 19 | 20 | #include <__iterator/reverse_iterator.h> |
| 20 | 21 | #include <__memory/addressof.h> |
| 21 | 22 | #include <__memory/allocator_traits.h> |
| 22 | 23 | #include <__memory/construct_at.h> |
| 23 | 24 | #include <__memory/pointer_traits.h> |
| 24 | #include <__memory/voidify.h> | |
| 25 | #include <__type_traits/enable_if.h> | |
| 25 | 26 | #include <__type_traits/extent.h> |
| 26 | 27 | #include <__type_traits/is_array.h> |
| 27 | 28 | #include <__type_traits/is_constant_evaluated.h> |
| 29 | #include <__type_traits/is_same.h> | |
| 28 | 30 | #include <__type_traits/is_trivially_assignable.h> |
| 29 | 31 | #include <__type_traits/is_trivially_constructible.h> |
| 30 | 32 | #include <__type_traits/is_trivially_relocatable.h> |
| ... | ... | @@ -35,7 +37,6 @@ |
| 35 | 37 | #include <__utility/exception_guard.h> |
| 36 | 38 | #include <__utility/move.h> |
| 37 | 39 | #include <__utility/pair.h> |
| 38 | #include <new> | |
| 39 | 40 | |
| 40 | 41 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | 42 | # pragma GCC system_header |
| ... | ... | @@ -59,12 +60,12 @@ template <class _ValueType, class _InputIterator, class _Sentinel1, class _Forwa |
| 59 | 60 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_copy( |
| 60 | 61 | _InputIterator __ifirst, _Sentinel1 __ilast, _ForwardIterator __ofirst, _EndPredicate __stop_copying) { |
| 61 | 62 | _ForwardIterator __idx = __ofirst; |
| 62 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 63 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 63 | 64 | try { |
| 64 | 65 | #endif |
| 65 | 66 | for (; __ifirst != __ilast && !__stop_copying(__idx); ++__ifirst, (void)++__idx) |
| 66 | ::new (std::__voidify(*__idx)) _ValueType(*__ifirst); | |
| 67 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 67 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst); | |
| 68 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 68 | 69 | } catch (...) { |
| 69 | 70 | std::__destroy(__ofirst, __idx); |
| 70 | 71 | throw; |
| ... | ... | @@ -89,12 +90,12 @@ template <class _ValueType, class _InputIterator, class _Size, class _ForwardIte |
| 89 | 90 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> |
| 90 | 91 | __uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_copying) { |
| 91 | 92 | _ForwardIterator __idx = __ofirst; |
| 92 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 93 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 93 | 94 | try { |
| 94 | 95 | #endif |
| 95 | 96 | for (; __n > 0 && !__stop_copying(__idx); ++__ifirst, (void)++__idx, (void)--__n) |
| 96 | ::new (std::__voidify(*__idx)) _ValueType(*__ifirst); | |
| 97 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 97 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst); | |
| 98 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 98 | 99 | } catch (...) { |
| 99 | 100 | std::__destroy(__ofirst, __idx); |
| 100 | 101 | throw; |
| ... | ... | @@ -119,12 +120,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel, class _Tp> |
| 119 | 120 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 120 | 121 | __uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) { |
| 121 | 122 | _ForwardIterator __idx = __first; |
| 122 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 123 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 123 | 124 | try { |
| 124 | 125 | #endif |
| 125 | 126 | for (; __idx != __last; ++__idx) |
| 126 | ::new (std::__voidify(*__idx)) _ValueType(__x); | |
| 127 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 127 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__x); | |
| 128 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 128 | 129 | } catch (...) { |
| 129 | 130 | std::__destroy(__first, __idx); |
| 130 | 131 | throw; |
| ... | ... | @@ -147,12 +148,12 @@ template <class _ValueType, class _ForwardIterator, class _Size, class _Tp> |
| 147 | 148 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 148 | 149 | __uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { |
| 149 | 150 | _ForwardIterator __idx = __first; |
| 150 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 151 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 151 | 152 | try { |
| 152 | 153 | #endif |
| 153 | 154 | for (; __n > 0; ++__idx, (void)--__n) |
| 154 | ::new (std::__voidify(*__idx)) _ValueType(__x); | |
| 155 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 155 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__x); | |
| 156 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 156 | 157 | } catch (...) { |
| 157 | 158 | std::__destroy(__first, __idx); |
| 158 | 159 | throw; |
| ... | ... | @@ -177,12 +178,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel> |
| 177 | 178 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 178 | 179 | __uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) { |
| 179 | 180 | auto __idx = __first; |
| 180 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 181 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 181 | 182 | try { |
| 182 | 183 | # endif |
| 183 | 184 | for (; __idx != __last; ++__idx) |
| 184 | ::new (std::__voidify(*__idx)) _ValueType; | |
| 185 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 185 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType; | |
| 186 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 186 | 187 | } catch (...) { |
| 187 | 188 | std::__destroy(__first, __idx); |
| 188 | 189 | throw; |
| ... | ... | @@ -203,12 +204,12 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterat |
| 203 | 204 | template <class _ValueType, class _ForwardIterator, class _Size> |
| 204 | 205 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) { |
| 205 | 206 | auto __idx = __first; |
| 206 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 207 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 207 | 208 | try { |
| 208 | 209 | # endif |
| 209 | 210 | for (; __n > 0; ++__idx, (void)--__n) |
| 210 | ::new (std::__voidify(*__idx)) _ValueType; | |
| 211 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 211 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType; | |
| 212 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 212 | 213 | } catch (...) { |
| 213 | 214 | std::__destroy(__first, __idx); |
| 214 | 215 | throw; |
| ... | ... | @@ -230,12 +231,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel> |
| 230 | 231 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator |
| 231 | 232 | __uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) { |
| 232 | 233 | auto __idx = __first; |
| 233 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 234 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 234 | 235 | try { |
| 235 | 236 | # endif |
| 236 | 237 | for (; __idx != __last; ++__idx) |
| 237 | ::new (std::__voidify(*__idx)) _ValueType(); | |
| 238 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 238 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(); | |
| 239 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 239 | 240 | } catch (...) { |
| 240 | 241 | std::__destroy(__first, __idx); |
| 241 | 242 | throw; |
| ... | ... | @@ -256,12 +257,12 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator |
| 256 | 257 | template <class _ValueType, class _ForwardIterator, class _Size> |
| 257 | 258 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) { |
| 258 | 259 | auto __idx = __first; |
| 259 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 260 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 260 | 261 | try { |
| 261 | 262 | # endif |
| 262 | 263 | for (; __n > 0; ++__idx, (void)--__n) |
| 263 | ::new (std::__voidify(*__idx)) _ValueType(); | |
| 264 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 264 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(); | |
| 265 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 265 | 266 | } catch (...) { |
| 266 | 267 | std::__destroy(__first, __idx); |
| 267 | 268 | throw; |
| ... | ... | @@ -292,13 +293,13 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitiali |
| 292 | 293 | _EndPredicate __stop_moving, |
| 293 | 294 | _IterMove __iter_move) { |
| 294 | 295 | auto __idx = __ofirst; |
| 295 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 296 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 296 | 297 | try { |
| 297 | 298 | # endif |
| 298 | 299 | for (; __ifirst != __ilast && !__stop_moving(__idx); ++__idx, (void)++__ifirst) { |
| 299 | ::new (std::__voidify(*__idx)) _ValueType(__iter_move(__ifirst)); | |
| 300 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst)); | |
| 300 | 301 | } |
| 301 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 302 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 302 | 303 | } catch (...) { |
| 303 | 304 | std::__destroy(__ofirst, __idx); |
| 304 | 305 | throw; |
| ... | ... | @@ -330,12 +331,12 @@ template <class _ValueType, |
| 330 | 331 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move_n( |
| 331 | 332 | _InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_moving, _IterMove __iter_move) { |
| 332 | 333 | auto __idx = __ofirst; |
| 333 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 334 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 334 | 335 | try { |
| 335 | 336 | # endif |
| 336 | 337 | for (; __n > 0 && !__stop_moving(__idx); ++__idx, (void)++__ifirst, --__n) |
| 337 | ::new (std::__voidify(*__idx)) _ValueType(__iter_move(__ifirst)); | |
| 338 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 338 | ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst)); | |
| 339 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 339 | 340 | } catch (...) { |
| 340 | 341 | std::__destroy(__ofirst, __idx); |
| 341 | 342 | throw; |
| ... | ... | @@ -375,7 +376,7 @@ __allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _Bidir |
| 375 | 376 | return; |
| 376 | 377 | |
| 377 | 378 | if constexpr (is_array_v<_ValueType>) { |
| 378 | static_assert(!__libcpp_is_unbounded_array<_ValueType>::value, | |
| 379 | static_assert(!__is_unbounded_array_v<_ValueType>, | |
| 379 | 380 | "arrays of unbounded arrays don't exist, but if they did we would mess up here"); |
| 380 | 381 | |
| 381 | 382 | using _Element = remove_extent_t<_ValueType>; |
| ... | ... | @@ -562,17 +563,13 @@ struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_ty |
| 562 | 563 | |
| 563 | 564 | template <class _Alloc, |
| 564 | 565 | class _In, |
| 565 | class _RawTypeIn = __remove_const_t<_In>, | |
| 566 | 566 | class _Out, |
| 567 | __enable_if_t< | |
| 568 | // using _RawTypeIn because of the allocator<T const> extension | |
| 569 | is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value && | |
| 570 | is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value && | |
| 571 | __allocator_has_trivial_copy_construct<_Alloc, _RawTypeIn>::value, | |
| 572 | int> = 0> | |
| 567 | __enable_if_t<is_trivially_copy_constructible<_In>::value && is_trivially_copy_assignable<_In>::value && | |
| 568 | is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value && | |
| 569 | __allocator_has_trivial_copy_construct<_Alloc, _In>::value, | |
| 570 | int> = 0> | |
| 573 | 571 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out* |
| 574 | 572 | __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> | |
| 576 | 573 | if (__libcpp_is_constant_evaluated()) { |
| 577 | 574 | while (__first1 != __last1) { |
| 578 | 575 | std::__construct_at(std::__to_address(__first2), *__first1); |
| ... | ... | @@ -581,16 +578,16 @@ __uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* |
| 581 | 578 | } |
| 582 | 579 | return __first2; |
| 583 | 580 | } else { |
| 584 | return std::copy(__first1, __last1, const_cast<_RawTypeIn*>(__first2)); | |
| 581 | return std::copy(__first1, __last1, __first2); | |
| 585 | 582 | } |
| 586 | 583 | } |
| 587 | 584 | |
| 588 | 585 | template <class _Alloc, class _Iter1, class _Sent1, class _Iter2> |
| 589 | 586 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2 |
| 590 | 587 | __uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) { |
| 591 | auto __unwrapped_range = std::__unwrap_range(__first1, __last1); | |
| 588 | auto __unwrapped_range = std::__unwrap_range(std::move(__first1), std::move(__last1)); | |
| 592 | 589 | auto __result = std::__uninitialized_allocator_copy_impl( |
| 593 | __alloc, __unwrapped_range.first, __unwrapped_range.second, std::__unwrap_iter(__first2)); | |
| 590 | __alloc, std::move(__unwrapped_range.first), std::move(__unwrapped_range.second), std::__unwrap_iter(__first2)); | |
| 594 | 591 | return std::__rewrap_iter(__first2, __result); |
| 595 | 592 | } |
| 596 | 593 | |
| ... | ... | @@ -615,26 +612,28 @@ struct __allocator_has_trivial_destroy<allocator<_Tp>, _Up> : true_type {}; |
| 615 | 612 | // [__first, __last) doesn't contain any objects |
| 616 | 613 | // |
| 617 | 614 | // 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) { | |
| 615 | // - is_nothrow_move_constructible<_ValueType> | |
| 616 | // - is_copy_constructible<_ValueType> | |
| 617 | // - __libcpp_is_trivially_relocatable<_ValueType> | |
| 618 | template <class _Alloc, class _ContiguousIterator> | |
| 619 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __uninitialized_allocator_relocate( | |
| 620 | _Alloc& __alloc, _ContiguousIterator __first, _ContiguousIterator __last, _ContiguousIterator __result) { | |
| 621 | static_assert(__libcpp_is_contiguous_iterator<_ContiguousIterator>::value, ""); | |
| 622 | using _ValueType = typename iterator_traits<_ContiguousIterator>::value_type; | |
| 624 | 623 | static_assert(__is_cpp17_move_insertable<_Alloc>::value, |
| 625 | 624 | "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) { | |
| 625 | if (__libcpp_is_constant_evaluated() || !__libcpp_is_trivially_relocatable<_ValueType>::value || | |
| 626 | !__allocator_has_trivial_move_construct<_Alloc, _ValueType>::value || | |
| 627 | !__allocator_has_trivial_destroy<_Alloc, _ValueType>::value) { | |
| 629 | 628 | auto __destruct_first = __result; |
| 630 | auto __guard = | |
| 631 | std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Tp*>(__alloc, __destruct_first, __result)); | |
| 629 | auto __guard = std::__make_exception_guard( | |
| 630 | _AllocatorDestroyRangeReverse<_Alloc, _ContiguousIterator>(__alloc, __destruct_first, __result)); | |
| 632 | 631 | auto __iter = __first; |
| 633 | 632 | while (__iter != __last) { |
| 634 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 635 | allocator_traits<_Alloc>::construct(__alloc, __result, std::move_if_noexcept(*__iter)); | |
| 633 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 634 | allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__result), std::move_if_noexcept(*__iter)); | |
| 636 | 635 | #else |
| 637 | allocator_traits<_Alloc>::construct(__alloc, __result, std::move(*__iter)); | |
| 636 | allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__result), std::move(*__iter)); | |
| 638 | 637 | #endif |
| 639 | 638 | ++__iter; |
| 640 | 639 | ++__result; |
| ... | ... | @@ -642,7 +641,10 @@ __uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _ |
| 642 | 641 | __guard.__complete(); |
| 643 | 642 | std::__allocator_destroy(__alloc, __first, __last); |
| 644 | 643 | } else { |
| 645 | __builtin_memcpy(const_cast<__remove_const_t<_Tp>*>(__result), __first, sizeof(_Tp) * (__last - __first)); | |
| 644 | // Casting to void* to suppress clang complaining that this is technically UB. | |
| 645 | __builtin_memcpy(static_cast<void*>(std::__to_address(__result)), | |
| 646 | std::__to_address(__first), | |
| 647 | sizeof(_ValueType) * (__last - __first)); | |
| 646 | 648 | } |
| 647 | 649 | } |
| 648 | 650 |
lib/libcxx/include/__memory/unique_ptr.h+243-113| ... | ... | @@ -10,22 +10,30 @@ |
| 10 | 10 | #ifndef _LIBCPP___MEMORY_UNIQUE_PTR_H |
| 11 | 11 | #define _LIBCPP___MEMORY_UNIQUE_PTR_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__compare/compare_three_way.h> |
| 14 | 15 | #include <__compare/compare_three_way_result.h> |
| 15 | 16 | #include <__compare/three_way_comparable.h> |
| 16 | 17 | #include <__config> |
| 18 | #include <__cstddef/nullptr_t.h> | |
| 19 | #include <__cstddef/size_t.h> | |
| 17 | 20 | #include <__functional/hash.h> |
| 18 | 21 | #include <__functional/operations.h> |
| 19 | 22 | #include <__memory/allocator_traits.h> // __pointer |
| 23 | #include <__memory/array_cookie.h> | |
| 20 | 24 | #include <__memory/auto_ptr.h> |
| 21 | 25 | #include <__memory/compressed_pair.h> |
| 26 | #include <__memory/pointer_traits.h> | |
| 22 | 27 | #include <__type_traits/add_lvalue_reference.h> |
| 23 | 28 | #include <__type_traits/common_type.h> |
| 24 | 29 | #include <__type_traits/conditional.h> |
| 25 | 30 | #include <__type_traits/dependent_type.h> |
| 31 | #include <__type_traits/enable_if.h> | |
| 26 | 32 | #include <__type_traits/integral_constant.h> |
| 27 | 33 | #include <__type_traits/is_array.h> |
| 28 | 34 | #include <__type_traits/is_assignable.h> |
| 35 | #include <__type_traits/is_bounded_array.h> | |
| 36 | #include <__type_traits/is_constant_evaluated.h> | |
| 29 | 37 | #include <__type_traits/is_constructible.h> |
| 30 | 38 | #include <__type_traits/is_convertible.h> |
| 31 | 39 | #include <__type_traits/is_function.h> |
| ... | ... | @@ -34,14 +42,15 @@ |
| 34 | 42 | #include <__type_traits/is_same.h> |
| 35 | 43 | #include <__type_traits/is_swappable.h> |
| 36 | 44 | #include <__type_traits/is_trivially_relocatable.h> |
| 45 | #include <__type_traits/is_unbounded_array.h> | |
| 37 | 46 | #include <__type_traits/is_void.h> |
| 38 | 47 | #include <__type_traits/remove_extent.h> |
| 39 | #include <__type_traits/remove_pointer.h> | |
| 40 | 48 | #include <__type_traits/type_identity.h> |
| 41 | 49 | #include <__utility/declval.h> |
| 42 | 50 | #include <__utility/forward.h> |
| 43 | 51 | #include <__utility/move.h> |
| 44 | #include <cstddef> | |
| 52 | #include <__utility/private_constructor_tag.h> | |
| 53 | #include <cstdint> | |
| 45 | 54 | |
| 46 | 55 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 47 | 56 | # pragma GCC system_header |
| ... | ... | @@ -52,17 +61,6 @@ _LIBCPP_PUSH_MACROS |
| 52 | 61 | |
| 53 | 62 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 54 | 63 | |
| 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 | ||
| 66 | 64 | template <class _Tp> |
| 67 | 65 | struct _LIBCPP_TEMPLATE_VIS default_delete { |
| 68 | 66 | static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types"); |
| ... | ... | @@ -106,6 +104,12 @@ public: |
| 106 | 104 | } |
| 107 | 105 | }; |
| 108 | 106 | |
| 107 | template <class _Deleter> | |
| 108 | struct __is_default_deleter : false_type {}; | |
| 109 | ||
| 110 | template <class _Tp> | |
| 111 | struct __is_default_deleter<default_delete<_Tp> > : true_type {}; | |
| 112 | ||
| 109 | 113 | template <class _Deleter> |
| 110 | 114 | struct __unique_ptr_deleter_sfinae { |
| 111 | 115 | static_assert(!is_reference<_Deleter>::value, "incorrect specialization"); |
| ... | ... | @@ -139,7 +143,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr { |
| 139 | 143 | public: |
| 140 | 144 | typedef _Tp element_type; |
| 141 | 145 | typedef _Dp deleter_type; |
| 142 | typedef _LIBCPP_NODEBUG typename __pointer<_Tp, deleter_type>::type pointer; | |
| 146 | using pointer _LIBCPP_NODEBUG = __pointer<_Tp, deleter_type>; | |
| 143 | 147 | |
| 144 | 148 | static_assert(!is_rvalue_reference<deleter_type>::value, "the specified deleter type cannot be an rvalue reference"); |
| 145 | 149 | |
| ... | ... | @@ -149,15 +153,15 @@ public: |
| 149 | 153 | // |
| 150 | 154 | // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no |
| 151 | 155 | // references to itself. This means that the entire structure is trivially relocatable if its members are. |
| 152 | using __trivially_relocatable = __conditional_t< | |
| 156 | using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t< | |
| 153 | 157 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, |
| 154 | 158 | unique_ptr, |
| 155 | 159 | void>; |
| 156 | 160 | |
| 157 | 161 | private: |
| 158 | __compressed_pair<pointer, deleter_type> __ptr_; | |
| 162 | _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_); | |
| 159 | 163 | |
| 160 | typedef _LIBCPP_NODEBUG __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE; | |
| 164 | using _DeleterSFINAE _LIBCPP_NODEBUG = __unique_ptr_deleter_sfinae<_Dp>; | |
| 161 | 165 | |
| 162 | 166 | template <bool _Dummy> |
| 163 | 167 | using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type; |
| ... | ... | @@ -185,27 +189,29 @@ private: |
| 185 | 189 | (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) >; |
| 186 | 190 | |
| 187 | 191 | template <class _UDel> |
| 188 | using _EnableIfDeleterAssignable = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value >; | |
| 192 | using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value >; | |
| 189 | 193 | |
| 190 | 194 | public: |
| 191 | 195 | template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 192 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {} | |
| 196 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(), __deleter_() {} | |
| 193 | 197 | |
| 194 | 198 | template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 195 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT | |
| 196 | : __ptr_(__value_init_tag(), __value_init_tag()) {} | |
| 199 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(), __deleter_() {} | |
| 197 | 200 | |
| 198 | 201 | template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 199 | _LIBCPP_HIDE_FROM_ABI | |
| 200 | _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {} | |
| 202 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT | |
| 203 | : __ptr_(__p), | |
| 204 | __deleter_() {} | |
| 201 | 205 | |
| 202 | 206 | template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > > |
| 203 | 207 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT |
| 204 | : __ptr_(__p, __d) {} | |
| 208 | : __ptr_(__p), | |
| 209 | __deleter_(__d) {} | |
| 205 | 210 | |
| 206 | 211 | template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > > |
| 207 | 212 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT |
| 208 | : __ptr_(__p, std::move(__d)) { | |
| 213 | : __ptr_(__p), | |
| 214 | __deleter_(std::move(__d)) { | |
| 209 | 215 | static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); |
| 210 | 216 | } |
| 211 | 217 | |
| ... | ... | @@ -213,24 +219,26 @@ public: |
| 213 | 219 | _LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete; |
| 214 | 220 | |
| 215 | 221 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT |
| 216 | : __ptr_(__u.release(), std::forward<deleter_type>(__u.get_deleter())) {} | |
| 222 | : __ptr_(__u.release()), | |
| 223 | __deleter_(std::forward<deleter_type>(__u.get_deleter())) {} | |
| 217 | 224 | |
| 218 | 225 | template <class _Up, |
| 219 | 226 | class _Ep, |
| 220 | 227 | class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>, |
| 221 | 228 | class = _EnableIfDeleterConvertible<_Ep> > |
| 222 | 229 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT |
| 223 | : __ptr_(__u.release(), std::forward<_Ep>(__u.get_deleter())) {} | |
| 230 | : __ptr_(__u.release()), | |
| 231 | __deleter_(std::forward<_Ep>(__u.get_deleter())) {} | |
| 224 | 232 | |
| 225 | 233 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) |
| 226 | 234 | template <class _Up, |
| 227 | 235 | __enable_if_t<is_convertible<_Up*, _Tp*>::value && is_same<_Dp, default_delete<_Tp> >::value, int> = 0> |
| 228 | _LIBCPP_HIDE_FROM_ABI unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release(), __value_init_tag()) {} | |
| 236 | _LIBCPP_HIDE_FROM_ABI unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release()), __deleter_() {} | |
| 229 | 237 | #endif |
| 230 | 238 | |
| 231 | 239 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT { |
| 232 | 240 | reset(__u.release()); |
| 233 | __ptr_.second() = std::forward<deleter_type>(__u.get_deleter()); | |
| 241 | __deleter_ = std::forward<deleter_type>(__u.get_deleter()); | |
| 234 | 242 | return *this; |
| 235 | 243 | } |
| 236 | 244 | |
| ... | ... | @@ -240,7 +248,7 @@ public: |
| 240 | 248 | class = _EnableIfDeleterAssignable<_Ep> > |
| 241 | 249 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT { |
| 242 | 250 | reset(__u.release()); |
| 243 | __ptr_.second() = std::forward<_Ep>(__u.get_deleter()); | |
| 251 | __deleter_ = std::forward<_Ep>(__u.get_deleter()); | |
| 244 | 252 | return *this; |
| 245 | 253 | } |
| 246 | 254 | |
| ... | ... | @@ -266,33 +274,135 @@ public: |
| 266 | 274 | } |
| 267 | 275 | |
| 268 | 276 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const |
| 269 | _NOEXCEPT_(__is_noexcept_deref_or_void<pointer>::value) { | |
| 270 | return *__ptr_.first(); | |
| 277 | _NOEXCEPT_(_NOEXCEPT_(*std::declval<pointer>())) { | |
| 278 | return *__ptr_; | |
| 271 | 279 | } |
| 272 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_.first(); } | |
| 273 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); } | |
| 274 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __ptr_.second(); } | |
| 280 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_; } | |
| 281 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; } | |
| 282 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; } | |
| 275 | 283 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT { |
| 276 | return __ptr_.second(); | |
| 284 | return __deleter_; | |
| 277 | 285 | } |
| 278 | 286 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT { |
| 279 | return __ptr_.first() != nullptr; | |
| 287 | return __ptr_ != nullptr; | |
| 280 | 288 | } |
| 281 | 289 | |
| 282 | 290 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT { |
| 283 | pointer __t = __ptr_.first(); | |
| 284 | __ptr_.first() = pointer(); | |
| 291 | pointer __t = __ptr_; | |
| 292 | __ptr_ = pointer(); | |
| 285 | 293 | return __t; |
| 286 | 294 | } |
| 287 | 295 | |
| 288 | 296 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(pointer __p = pointer()) _NOEXCEPT { |
| 289 | pointer __tmp = __ptr_.first(); | |
| 290 | __ptr_.first() = __p; | |
| 297 | pointer __tmp = __ptr_; | |
| 298 | __ptr_ = __p; | |
| 291 | 299 | if (__tmp) |
| 292 | __ptr_.second()(__tmp); | |
| 300 | __deleter_(__tmp); | |
| 293 | 301 | } |
| 294 | 302 | |
| 295 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); } | |
| 303 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { | |
| 304 | using std::swap; | |
| 305 | swap(__ptr_, __u.__ptr_); | |
| 306 | swap(__deleter_, __u.__deleter_); | |
| 307 | } | |
| 308 | }; | |
| 309 | ||
| 310 | // Bounds checking in unique_ptr<T[]> | |
| 311 | // ================================== | |
| 312 | // | |
| 313 | // We provide some helper classes that allow bounds checking when accessing a unique_ptr<T[]>. | |
| 314 | // There are a few cases where bounds checking can be implemented: | |
| 315 | // | |
| 316 | // 1. When an array cookie (see [1]) exists at the beginning of the array allocation, we are | |
| 317 | // able to reuse that cookie to extract the size of the array and perform bounds checking. | |
| 318 | // An array cookie is a size inserted at the beginning of the allocation by the compiler. | |
| 319 | // That size is inserted implicitly when doing `new T[n]` in some cases (as of writing this | |
| 320 | // exactly when the array elements are not trivially destructible), and its main purpose is | |
| 321 | // to allow the runtime to destroy the `n` array elements when doing `delete[] array`. | |
| 322 | // When we are able to use array cookies, we reuse information already available in the | |
| 323 | // current runtime, so bounds checking does not require changing libc++'s ABI. | |
| 324 | // | |
| 325 | // However, note that we cannot assume the presence of an array cookie when a custom deleter | |
| 326 | // is used, because the unique_ptr could have been created from an allocation that wasn't | |
| 327 | // obtained via `new T[n]` (since it may not be deleted with `delete[] arr`). | |
| 328 | // | |
| 329 | // 2. When the "bounded unique_ptr" ABI configuration (controlled by `_LIBCPP_ABI_BOUNDED_UNIQUE_PTR`) | |
| 330 | // is enabled, we store the size of the allocation (when it is known) so we can check it when | |
| 331 | // indexing into the `unique_ptr`. That changes the layout of `std::unique_ptr<T[]>`, which is | |
| 332 | // an ABI break from the default configuration. | |
| 333 | // | |
| 334 | // Note that even under this ABI configuration, we can't always know the size of the unique_ptr. | |
| 335 | // Indeed, the size of the allocation can only be known when the unique_ptr is created via | |
| 336 | // make_unique or a similar API. For example, it can't be known when constructed from an arbitrary | |
| 337 | // pointer, in which case we are not able to check the bounds on access: | |
| 338 | // | |
| 339 | // unique_ptr<T[], MyDeleter> ptr(new T[3]); | |
| 340 | // | |
| 341 | // When we don't know the size of the allocation via the API used to create the unique_ptr, we | |
| 342 | // try to fall back to using an array cookie when available. | |
| 343 | // | |
| 344 | // Finally, note that when this ABI configuration is enabled, we have no choice but to always | |
| 345 | // make space for the size to be stored in the unique_ptr. Indeed, while we might want to avoid | |
| 346 | // storing the size when an array cookie is available, knowing whether an array cookie is available | |
| 347 | // requires the type stored in the unique_ptr to be complete, while unique_ptr can normally | |
| 348 | // accommodate incomplete types. | |
| 349 | // | |
| 350 | // (1) Implementation where we rely on the array cookie to know the size of the allocation, if | |
| 351 | // an array cookie exists. | |
| 352 | struct __unique_ptr_array_bounds_stateless { | |
| 353 | __unique_ptr_array_bounds_stateless() = default; | |
| 354 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __unique_ptr_array_bounds_stateless(size_t) {} | |
| 355 | ||
| 356 | template <class _Deleter, | |
| 357 | class _Tp, | |
| 358 | __enable_if_t<__is_default_deleter<_Deleter>::value && __has_array_cookie<_Tp>::value, int> = 0> | |
| 359 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const { | |
| 360 | // In constant expressions, we can't check the array cookie so we just pretend that the index | |
| 361 | // is in-bounds. The compiler catches invalid accesses anyway. | |
| 362 | if (__libcpp_is_constant_evaluated()) | |
| 363 | return true; | |
| 364 | size_t __cookie = std::__get_array_cookie(__ptr); | |
| 365 | return __index < __cookie; | |
| 366 | } | |
| 367 | ||
| 368 | template <class _Deleter, | |
| 369 | class _Tp, | |
| 370 | __enable_if_t<!__is_default_deleter<_Deleter>::value || !__has_array_cookie<_Tp>::value, int> = 0> | |
| 371 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t) const { | |
| 372 | return true; // If we don't have an array cookie, we assume the access is in-bounds | |
| 373 | } | |
| 374 | }; | |
| 375 | ||
| 376 | // (2) Implementation where we store the size in the class whenever we have it. | |
| 377 | // | |
| 378 | // Semantically, we'd need to store the size as an optional<size_t>. However, since that | |
| 379 | // is really heavy weight, we instead store a size_t and use SIZE_MAX as a magic value | |
| 380 | // meaning that we don't know the size. | |
| 381 | struct __unique_ptr_array_bounds_stored { | |
| 382 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __unique_ptr_array_bounds_stored() : __size_(SIZE_MAX) {} | |
| 383 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __unique_ptr_array_bounds_stored(size_t __size) : __size_(__size) {} | |
| 384 | ||
| 385 | // Use the array cookie if there's one | |
| 386 | template <class _Deleter, | |
| 387 | class _Tp, | |
| 388 | __enable_if_t<__is_default_deleter<_Deleter>::value && __has_array_cookie<_Tp>::value, int> = 0> | |
| 389 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const { | |
| 390 | if (__libcpp_is_constant_evaluated()) | |
| 391 | return true; | |
| 392 | size_t __cookie = std::__get_array_cookie(__ptr); | |
| 393 | return __index < __cookie; | |
| 394 | } | |
| 395 | ||
| 396 | // Otherwise, fall back on the stored size (if any) | |
| 397 | template <class _Deleter, | |
| 398 | class _Tp, | |
| 399 | __enable_if_t<!__is_default_deleter<_Deleter>::value || !__has_array_cookie<_Tp>::value, int> = 0> | |
| 400 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t __index) const { | |
| 401 | return __index < __size_; | |
| 402 | } | |
| 403 | ||
| 404 | private: | |
| 405 | size_t __size_; | |
| 296 | 406 | }; |
| 297 | 407 | |
| 298 | 408 | template <class _Tp, class _Dp> |
| ... | ... | @@ -300,21 +410,31 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> |
| 300 | 410 | public: |
| 301 | 411 | typedef _Tp element_type; |
| 302 | 412 | typedef _Dp deleter_type; |
| 303 | typedef typename __pointer<_Tp, deleter_type>::type pointer; | |
| 413 | using pointer = __pointer<_Tp, deleter_type>; | |
| 304 | 414 | |
| 305 | 415 | // A unique_ptr contains the following members which may be trivially relocatable: |
| 306 | // - pointer : this may be trivially relocatable, so it's checked | |
| 416 | // - pointer: this may be trivially relocatable, so it's checked | |
| 307 | 417 | // - deleter_type: this may be trivially relocatable, so it's checked |
| 418 | // - (optionally) size: this is trivially relocatable | |
| 308 | 419 | // |
| 309 | 420 | // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no |
| 310 | 421 | // references to itself. This means that the entire structure is trivially relocatable if its members are. |
| 311 | using __trivially_relocatable = __conditional_t< | |
| 422 | using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t< | |
| 312 | 423 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value, |
| 313 | 424 | unique_ptr, |
| 314 | 425 | void>; |
| 315 | 426 | |
| 316 | 427 | private: |
| 317 | __compressed_pair<pointer, deleter_type> __ptr_; | |
| 428 | template <class _Up, class _OtherDeleter> | |
| 429 | friend class unique_ptr; | |
| 430 | ||
| 431 | _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_); | |
| 432 | #ifdef _LIBCPP_ABI_BOUNDED_UNIQUE_PTR | |
| 433 | using _BoundsChecker _LIBCPP_NODEBUG = __unique_ptr_array_bounds_stored; | |
| 434 | #else | |
| 435 | using _BoundsChecker _LIBCPP_NODEBUG = __unique_ptr_array_bounds_stateless; | |
| 436 | #endif | |
| 437 | _LIBCPP_NO_UNIQUE_ADDRESS _BoundsChecker __checker_; | |
| 318 | 438 | |
| 319 | 439 | template <class _From> |
| 320 | 440 | struct _CheckArrayPointerConversion : is_same<_From, pointer> {}; |
| ... | ... | @@ -363,42 +483,54 @@ private: |
| 363 | 483 | |
| 364 | 484 | public: |
| 365 | 485 | template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 366 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {} | |
| 486 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(), __deleter_() {} | |
| 367 | 487 | |
| 368 | 488 | template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 369 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT | |
| 370 | : __ptr_(__value_init_tag(), __value_init_tag()) {} | |
| 489 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(), __deleter_() {} | |
| 371 | 490 | |
| 372 | 491 | template <class _Pp, |
| 373 | 492 | bool _Dummy = true, |
| 374 | 493 | class = _EnableIfDeleterDefaultConstructible<_Dummy>, |
| 375 | 494 | class = _EnableIfPointerConvertible<_Pp> > |
| 376 | _LIBCPP_HIDE_FROM_ABI | |
| 377 | _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {} | |
| 495 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __ptr) _NOEXCEPT | |
| 496 | : __ptr_(__ptr), | |
| 497 | __deleter_() {} | |
| 498 | ||
| 499 | // Private constructor used by make_unique & friends to pass the size that was allocated | |
| 500 | template <class _Tag, class _Ptr, __enable_if_t<is_same<_Tag, __private_constructor_tag>::value, int> = 0> | |
| 501 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Tag, _Ptr __ptr, size_t __size) _NOEXCEPT | |
| 502 | : __ptr_(__ptr), | |
| 503 | __checker_(__size) {} | |
| 378 | 504 | |
| 379 | 505 | template <class _Pp, |
| 380 | 506 | bool _Dummy = true, |
| 381 | 507 | class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >, |
| 382 | 508 | class = _EnableIfPointerConvertible<_Pp> > |
| 383 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) _NOEXCEPT | |
| 384 | : __ptr_(__p, __d) {} | |
| 509 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __ptr, _LValRefType<_Dummy> __deleter) _NOEXCEPT | |
| 510 | : __ptr_(__ptr), | |
| 511 | __deleter_(__deleter) {} | |
| 385 | 512 | |
| 386 | 513 | template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > > |
| 387 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) _NOEXCEPT | |
| 388 | : __ptr_(nullptr, __d) {} | |
| 514 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _LValRefType<_Dummy> __deleter) _NOEXCEPT | |
| 515 | : __ptr_(nullptr), | |
| 516 | __deleter_(__deleter) {} | |
| 389 | 517 | |
| 390 | 518 | template <class _Pp, |
| 391 | 519 | bool _Dummy = true, |
| 392 | 520 | class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >, |
| 393 | 521 | class = _EnableIfPointerConvertible<_Pp> > |
| 394 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT | |
| 395 | : __ptr_(__p, std::move(__d)) { | |
| 522 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 | |
| 523 | unique_ptr(_Pp __ptr, _GoodRValRefType<_Dummy> __deleter) _NOEXCEPT | |
| 524 | : __ptr_(__ptr), | |
| 525 | __deleter_(std::move(__deleter)) { | |
| 396 | 526 | static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); |
| 397 | 527 | } |
| 398 | 528 | |
| 399 | 529 | template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > > |
| 400 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT | |
| 401 | : __ptr_(nullptr, std::move(__d)) { | |
| 530 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 | |
| 531 | unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __deleter) _NOEXCEPT | |
| 532 | : __ptr_(nullptr), | |
| 533 | __deleter_(std::move(__deleter)) { | |
| 402 | 534 | static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference"); |
| 403 | 535 | } |
| 404 | 536 | |
| ... | ... | @@ -406,14 +538,17 @@ public: |
| 406 | 538 | bool _Dummy = true, |
| 407 | 539 | class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >, |
| 408 | 540 | class = _EnableIfPointerConvertible<_Pp> > |
| 409 | _LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete; | |
| 541 | _LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __ptr, _BadRValRefType<_Dummy> __deleter) = delete; | |
| 410 | 542 | |
| 411 | 543 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT |
| 412 | : __ptr_(__u.release(), std::forward<deleter_type>(__u.get_deleter())) {} | |
| 544 | : __ptr_(__u.release()), | |
| 545 | __deleter_(std::forward<deleter_type>(__u.get_deleter())), | |
| 546 | __checker_(std::move(__u.__checker_)) {} | |
| 413 | 547 | |
| 414 | 548 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT { |
| 415 | 549 | reset(__u.release()); |
| 416 | __ptr_.second() = std::forward<deleter_type>(__u.get_deleter()); | |
| 550 | __deleter_ = std::forward<deleter_type>(__u.get_deleter()); | |
| 551 | __checker_ = std::move(__u.__checker_); | |
| 417 | 552 | return *this; |
| 418 | 553 | } |
| 419 | 554 | |
| ... | ... | @@ -422,7 +557,9 @@ public: |
| 422 | 557 | class = _EnableIfMoveConvertible<unique_ptr<_Up, _Ep>, _Up>, |
| 423 | 558 | class = _EnableIfDeleterConvertible<_Ep> > |
| 424 | 559 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT |
| 425 | : __ptr_(__u.release(), std::forward<_Ep>(__u.get_deleter())) {} | |
| 560 | : __ptr_(__u.release()), | |
| 561 | __deleter_(std::forward<_Ep>(__u.get_deleter())), | |
| 562 | __checker_(std::move(__u.__checker_)) {} | |
| 426 | 563 | |
| 427 | 564 | template <class _Up, |
| 428 | 565 | class _Ep, |
| ... | ... | @@ -430,7 +567,8 @@ public: |
| 430 | 567 | class = _EnableIfDeleterAssignable<_Ep> > |
| 431 | 568 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT { |
| 432 | 569 | reset(__u.release()); |
| 433 | __ptr_.second() = std::forward<_Ep>(__u.get_deleter()); | |
| 570 | __deleter_ = std::forward<_Ep>(__u.get_deleter()); | |
| 571 | __checker_ = std::move(__u.__checker_); | |
| 434 | 572 | return *this; |
| 435 | 573 | } |
| 436 | 574 | |
| ... | ... | @@ -448,41 +586,52 @@ public: |
| 448 | 586 | } |
| 449 | 587 | |
| 450 | 588 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator[](size_t __i) const { |
| 451 | return __ptr_.first()[__i]; | |
| 589 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__checker_.__in_bounds<deleter_type>(std::__to_address(__ptr_), __i), | |
| 590 | "unique_ptr<T[]>::operator[](index): index out of range"); | |
| 591 | return __ptr_[__i]; | |
| 452 | 592 | } |
| 453 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_.first(); } | |
| 593 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT { return __ptr_; } | |
| 454 | 594 | |
| 455 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __ptr_.second(); } | |
| 595 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; } | |
| 456 | 596 | |
| 457 | 597 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT { |
| 458 | return __ptr_.second(); | |
| 598 | return __deleter_; | |
| 459 | 599 | } |
| 460 | 600 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit operator bool() const _NOEXCEPT { |
| 461 | return __ptr_.first() != nullptr; | |
| 601 | return __ptr_ != nullptr; | |
| 462 | 602 | } |
| 463 | 603 | |
| 464 | 604 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer release() _NOEXCEPT { |
| 465 | pointer __t = __ptr_.first(); | |
| 466 | __ptr_.first() = pointer(); | |
| 605 | pointer __t = __ptr_; | |
| 606 | __ptr_ = pointer(); | |
| 607 | // The deleter and the optional bounds-checker are left unchanged. The bounds-checker | |
| 608 | // will be reinitialized appropriately when/if the unique_ptr gets assigned-to or reset. | |
| 467 | 609 | return __t; |
| 468 | 610 | } |
| 469 | 611 | |
| 470 | 612 | template <class _Pp, __enable_if_t<_CheckArrayPointerConversion<_Pp>::value, int> = 0> |
| 471 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(_Pp __p) _NOEXCEPT { | |
| 472 | pointer __tmp = __ptr_.first(); | |
| 473 | __ptr_.first() = __p; | |
| 613 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(_Pp __ptr) _NOEXCEPT { | |
| 614 | pointer __tmp = __ptr_; | |
| 615 | __ptr_ = __ptr; | |
| 616 | __checker_ = _BoundsChecker(); | |
| 474 | 617 | if (__tmp) |
| 475 | __ptr_.second()(__tmp); | |
| 618 | __deleter_(__tmp); | |
| 476 | 619 | } |
| 477 | 620 | |
| 478 | 621 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void reset(nullptr_t = nullptr) _NOEXCEPT { |
| 479 | pointer __tmp = __ptr_.first(); | |
| 480 | __ptr_.first() = nullptr; | |
| 622 | pointer __tmp = __ptr_; | |
| 623 | __ptr_ = nullptr; | |
| 624 | __checker_ = _BoundsChecker(); | |
| 481 | 625 | if (__tmp) |
| 482 | __ptr_.second()(__tmp); | |
| 626 | __deleter_(__tmp); | |
| 483 | 627 | } |
| 484 | 628 | |
| 485 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); } | |
| 629 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { | |
| 630 | using std::swap; | |
| 631 | swap(__ptr_, __u.__ptr_); | |
| 632 | swap(__deleter_, __u.__deleter_); | |
| 633 | swap(__checker_, __u.__checker_); | |
| 634 | } | |
| 486 | 635 | }; |
| 487 | 636 | |
| 488 | 637 | template <class _Tp, class _Dp, __enable_if_t<__is_swappable_v<_Dp>, int> = 0> |
| ... | ... | @@ -613,55 +762,36 @@ operator<=>(const unique_ptr<_T1, _D1>& __x, nullptr_t) { |
| 613 | 762 | |
| 614 | 763 | #if _LIBCPP_STD_VER >= 14 |
| 615 | 764 | |
| 616 | template <class _Tp> | |
| 617 | struct __unique_if { | |
| 618 | typedef unique_ptr<_Tp> __unique_single; | |
| 619 | }; | |
| 620 | ||
| 621 | template <class _Tp> | |
| 622 | struct __unique_if<_Tp[]> { | |
| 623 | typedef unique_ptr<_Tp[]> __unique_array_unknown_bound; | |
| 624 | }; | |
| 625 | ||
| 626 | template <class _Tp, size_t _Np> | |
| 627 | struct __unique_if<_Tp[_Np]> { | |
| 628 | typedef void __unique_array_known_bound; | |
| 629 | }; | |
| 630 | ||
| 631 | template <class _Tp, class... _Args> | |
| 632 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single | |
| 633 | make_unique(_Args&&... __args) { | |
| 765 | template <class _Tp, class... _Args, enable_if_t<!is_array<_Tp>::value, int> = 0> | |
| 766 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique(_Args&&... __args) { | |
| 634 | 767 | return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); |
| 635 | 768 | } |
| 636 | 769 | |
| 637 | template <class _Tp> | |
| 638 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound | |
| 639 | make_unique(size_t __n) { | |
| 770 | template <class _Tp, enable_if_t<__is_unbounded_array_v<_Tp>, int> = 0> | |
| 771 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique(size_t __n) { | |
| 640 | 772 | typedef __remove_extent_t<_Tp> _Up; |
| 641 | return unique_ptr<_Tp>(new _Up[__n]()); | |
| 773 | return unique_ptr<_Tp>(__private_constructor_tag(), new _Up[__n](), __n); | |
| 642 | 774 | } |
| 643 | 775 | |
| 644 | template <class _Tp, class... _Args> | |
| 645 | typename __unique_if<_Tp>::__unique_array_known_bound make_unique(_Args&&...) = delete; | |
| 776 | template <class _Tp, class... _Args, enable_if_t<__is_bounded_array_v<_Tp>, int> = 0> | |
| 777 | void make_unique(_Args&&...) = delete; | |
| 646 | 778 | |
| 647 | 779 | #endif // _LIBCPP_STD_VER >= 14 |
| 648 | 780 | |
| 649 | 781 | #if _LIBCPP_STD_VER >= 20 |
| 650 | 782 | |
| 651 | template <class _Tp> | |
| 652 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_single | |
| 653 | make_unique_for_overwrite() { | |
| 783 | template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0> | |
| 784 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique_for_overwrite() { | |
| 654 | 785 | return unique_ptr<_Tp>(new _Tp); |
| 655 | 786 | } |
| 656 | 787 | |
| 657 | template <class _Tp> | |
| 658 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __unique_if<_Tp>::__unique_array_unknown_bound | |
| 659 | make_unique_for_overwrite(size_t __n) { | |
| 660 | return unique_ptr<_Tp>(new __remove_extent_t<_Tp>[__n]); | |
| 788 | template <class _Tp, enable_if_t<is_unbounded_array_v<_Tp>, int> = 0> | |
| 789 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr<_Tp> make_unique_for_overwrite(size_t __n) { | |
| 790 | return unique_ptr<_Tp>(__private_constructor_tag(), new __remove_extent_t<_Tp>[__n], __n); | |
| 661 | 791 | } |
| 662 | 792 | |
| 663 | template <class _Tp, class... _Args> | |
| 664 | typename __unique_if<_Tp>::__unique_array_known_bound make_unique_for_overwrite(_Args&&...) = delete; | |
| 793 | template <class _Tp, class... _Args, enable_if_t<is_bounded_array_v<_Tp>, int> = 0> | |
| 794 | void make_unique_for_overwrite(_Args&&...) = delete; | |
| 665 | 795 | |
| 666 | 796 | #endif // _LIBCPP_STD_VER >= 20 |
| 667 | 797 |
lib/libcxx/include/__memory/unique_temporary_buffer.h created+93| ... | ... | @@ -0,0 +1,93 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H | |
| 11 | #define _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H | |
| 12 | ||
| 13 | #include <__assert> | |
| 14 | #include <__config> | |
| 15 | ||
| 16 | #include <__cstddef/ptrdiff_t.h> | |
| 17 | #include <__memory/allocator.h> | |
| 18 | #include <__memory/unique_ptr.h> | |
| 19 | #include <__new/allocate.h> | |
| 20 | #include <__new/global_new_delete.h> | |
| 21 | #include <__type_traits/is_constant_evaluated.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | template <class _Tp> | |
| 30 | struct __temporary_buffer_deleter { | |
| 31 | ptrdiff_t __count_; // ignored in non-constant evaluation | |
| 32 | ||
| 33 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __temporary_buffer_deleter() _NOEXCEPT : __count_(0) {} | |
| 34 | _LIBCPP_HIDE_FROM_ABI | |
| 35 | _LIBCPP_CONSTEXPR explicit __temporary_buffer_deleter(ptrdiff_t __count) _NOEXCEPT : __count_(__count) {} | |
| 36 | ||
| 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) _NOEXCEPT { | |
| 38 | if (__libcpp_is_constant_evaluated()) { | |
| 39 | allocator<_Tp>().deallocate(__ptr, __count_); | |
| 40 | return; | |
| 41 | } | |
| 42 | ||
| 43 | std::__libcpp_deallocate_unsized<_Tp>(__ptr); | |
| 44 | } | |
| 45 | }; | |
| 46 | ||
| 47 | template <class _Tp> | |
| 48 | using __unique_temporary_buffer _LIBCPP_NODEBUG = unique_ptr<_Tp, __temporary_buffer_deleter<_Tp> >; | |
| 49 | ||
| 50 | template <class _Tp> | |
| 51 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_CONSTEXPR_SINCE_CXX23 __unique_temporary_buffer<_Tp> | |
| 52 | __allocate_unique_temporary_buffer(ptrdiff_t __count) { | |
| 53 | using __deleter_type = __temporary_buffer_deleter<_Tp>; | |
| 54 | using __unique_buffer_type = __unique_temporary_buffer<_Tp>; | |
| 55 | ||
| 56 | if (__libcpp_is_constant_evaluated()) { | |
| 57 | return __unique_buffer_type(allocator<_Tp>().allocate(__count), __deleter_type(__count)); | |
| 58 | } | |
| 59 | ||
| 60 | _Tp* __ptr = nullptr; | |
| 61 | const ptrdiff_t __max_count = | |
| 62 | (~ptrdiff_t(0) ^ ptrdiff_t(ptrdiff_t(1) << (sizeof(ptrdiff_t) * __CHAR_BIT__ - 1))) / sizeof(_Tp); | |
| 63 | if (__count > __max_count) | |
| 64 | __count = __max_count; | |
| 65 | while (__count > 0) { | |
| 66 | #if _LIBCPP_HAS_ALIGNED_ALLOCATION | |
| 67 | if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) { | |
| 68 | align_val_t __al = align_val_t(_LIBCPP_ALIGNOF(_Tp)); | |
| 69 | __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), __al, nothrow)); | |
| 70 | } else { | |
| 71 | __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), nothrow)); | |
| 72 | } | |
| 73 | #else | |
| 74 | if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) { | |
| 75 | // Since aligned operator new is unavailable, constructs an empty buffer rather than one with invalid alignment. | |
| 76 | return __unique_buffer_type(); | |
| 77 | } | |
| 78 | ||
| 79 | __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), nothrow)); | |
| 80 | #endif | |
| 81 | ||
| 82 | if (__ptr) { | |
| 83 | break; | |
| 84 | } | |
| 85 | __count /= 2; | |
| 86 | } | |
| 87 | ||
| 88 | return __unique_buffer_type(__ptr, __deleter_type(__count)); | |
| 89 | } | |
| 90 | ||
| 91 | _LIBCPP_END_NAMESPACE_STD | |
| 92 | ||
| 93 | #endif // _LIBCPP___MEMORY_UNIQUE_TEMPORARY_BUFFER_H |
lib/libcxx/include/__memory/uses_allocator.h+1-1| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_USES_ALLOCATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__type_traits/integral_constant.h> | |
| 14 | 15 | #include <__type_traits/is_convertible.h> |
| 15 | #include <cstddef> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | # pragma GCC system_header |
lib/libcxx/include/__memory/uses_allocator_construction.h+122-129| ... | ... | @@ -40,104 +40,8 @@ inline constexpr bool __is_std_pair<pair<_Type1, _Type2>> = true; |
| 40 | 40 | template <class _Tp> |
| 41 | 41 | inline constexpr bool __is_cv_std_pair = __is_std_pair<remove_cv_t<_Tp>>; |
| 42 | 42 | |
| 43 | template <class _Type, class _Alloc, class... _Args, __enable_if_t<!__is_cv_std_pair<_Type>, int> = 0> | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 45 | __uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept { | |
| 46 | if constexpr (!uses_allocator_v<remove_cv_t<_Type>, _Alloc> && is_constructible_v<_Type, _Args...>) { | |
| 47 | return std::forward_as_tuple(std::forward<_Args>(__args)...); | |
| 48 | } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> && | |
| 49 | is_constructible_v<_Type, allocator_arg_t, const _Alloc&, _Args...>) { | |
| 50 | return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(allocator_arg, __alloc, std::forward<_Args>(__args)...); | |
| 51 | } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> && | |
| 52 | is_constructible_v<_Type, _Args..., const _Alloc&>) { | |
| 53 | return std::forward_as_tuple(std::forward<_Args>(__args)..., __alloc); | |
| 54 | } else { | |
| 55 | static_assert( | |
| 56 | sizeof(_Type) + 1 == 0, "If uses_allocator_v<Type> is true, the type has to be allocator-constructible"); | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | template <class _Pair, class _Alloc, class _Tuple1, class _Tuple2, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> | |
| 61 | _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args( | |
| 62 | const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept { | |
| 63 | return std::make_tuple( | |
| 64 | piecewise_construct, | |
| 65 | std::apply( | |
| 66 | [&__alloc](auto&&... __args1) { | |
| 67 | return std::__uses_allocator_construction_args<typename _Pair::first_type>( | |
| 68 | __alloc, std::forward<decltype(__args1)>(__args1)...); | |
| 69 | }, | |
| 70 | std::forward<_Tuple1>(__x)), | |
| 71 | std::apply( | |
| 72 | [&__alloc](auto&&... __args2) { | |
| 73 | return std::__uses_allocator_construction_args<typename _Pair::second_type>( | |
| 74 | __alloc, std::forward<decltype(__args2)>(__args2)...); | |
| 75 | }, | |
| 76 | std::forward<_Tuple2>(__y))); | |
| 77 | } | |
| 78 | ||
| 79 | template <class _Pair, class _Alloc, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> | |
| 80 | _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc) noexcept { | |
| 81 | return std::__uses_allocator_construction_args<_Pair>(__alloc, piecewise_construct, tuple<>{}, tuple<>{}); | |
| 82 | } | |
| 83 | ||
| 84 | template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> | |
| 85 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 86 | __uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept { | |
| 87 | return std::__uses_allocator_construction_args<_Pair>( | |
| 88 | __alloc, | |
| 89 | piecewise_construct, | |
| 90 | std::forward_as_tuple(std::forward<_Up>(__u)), | |
| 91 | std::forward_as_tuple(std::forward<_Vp>(__v))); | |
| 92 | } | |
| 93 | ||
| 94 | # if _LIBCPP_STD_VER >= 23 | |
| 95 | template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> | |
| 96 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 97 | __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept { | |
| 98 | return std::__uses_allocator_construction_args<_Pair>( | |
| 99 | __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second)); | |
| 100 | } | |
| 101 | # endif | |
| 102 | ||
| 103 | template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> | |
| 104 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 105 | __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept { | |
| 106 | return std::__uses_allocator_construction_args<_Pair>( | |
| 107 | __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second)); | |
| 108 | } | |
| 109 | ||
| 110 | template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> | |
| 111 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 112 | __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept { | |
| 113 | return std::__uses_allocator_construction_args<_Pair>( | |
| 114 | __alloc, | |
| 115 | piecewise_construct, | |
| 116 | std::forward_as_tuple(std::get<0>(std::move(__pair))), | |
| 117 | std::forward_as_tuple(std::get<1>(std::move(__pair)))); | |
| 118 | } | |
| 119 | ||
| 120 | # if _LIBCPP_STD_VER >= 23 | |
| 121 | template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> | |
| 122 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 123 | __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept { | |
| 124 | return std::__uses_allocator_construction_args<_Pair>( | |
| 125 | __alloc, | |
| 126 | piecewise_construct, | |
| 127 | std::forward_as_tuple(std::get<0>(std::move(__pair))), | |
| 128 | std::forward_as_tuple(std::get<1>(std::move(__pair)))); | |
| 129 | } | |
| 130 | ||
| 131 | template <class _Pair, class _Alloc, __pair_like_no_subrange _PairLike, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> | |
| 132 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 133 | __uses_allocator_construction_args(const _Alloc& __alloc, _PairLike&& __p) noexcept { | |
| 134 | return std::__uses_allocator_construction_args<_Pair>( | |
| 135 | __alloc, | |
| 136 | piecewise_construct, | |
| 137 | std::forward_as_tuple(std::get<0>(std::forward<_PairLike>(__p))), | |
| 138 | std::forward_as_tuple(std::get<1>(std::forward<_PairLike>(__p)))); | |
| 139 | } | |
| 140 | # endif | |
| 43 | template <class _Tp, class = void> | |
| 44 | struct __uses_allocator_construction_args; | |
| 141 | 45 | |
| 142 | 46 | namespace __uses_allocator_detail { |
| 143 | 47 | |
| ... | ... | @@ -165,46 +69,135 @@ inline constexpr bool __uses_allocator_constraints = __is_cv_std_pair<_Tp> && !_ |
| 165 | 69 | |
| 166 | 70 | } // namespace __uses_allocator_detail |
| 167 | 71 | |
| 168 | template < class _Pair, | |
| 169 | class _Alloc, | |
| 170 | class _Type, | |
| 171 | __enable_if_t<__uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int> = 0> | |
| 172 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 173 | __uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept; | |
| 174 | ||
| 175 | 72 | template <class _Type, class _Alloc, class... _Args> |
| 176 | 73 | _LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args); |
| 177 | 74 | |
| 178 | template < class _Pair, | |
| 179 | class _Alloc, | |
| 180 | class _Type, | |
| 181 | __enable_if_t< __uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int>> | |
| 182 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 183 | __uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept { | |
| 184 | struct __pair_constructor { | |
| 185 | using _PairMutable = remove_cv_t<_Pair>; | |
| 75 | template <class _Pair> | |
| 76 | struct __uses_allocator_construction_args<_Pair, __enable_if_t<__is_cv_std_pair<_Pair>>> { | |
| 77 | template <class _Alloc, class _Tuple1, class _Tuple2> | |
| 78 | static _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 79 | __apply(const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept { | |
| 80 | return std::make_tuple( | |
| 81 | piecewise_construct, | |
| 82 | std::apply( | |
| 83 | [&__alloc](auto&&... __args1) { | |
| 84 | return __uses_allocator_construction_args<typename _Pair::first_type>::__apply( | |
| 85 | __alloc, std::forward<decltype(__args1)>(__args1)...); | |
| 86 | }, | |
| 87 | std::forward<_Tuple1>(__x)), | |
| 88 | std::apply( | |
| 89 | [&__alloc](auto&&... __args2) { | |
| 90 | return __uses_allocator_construction_args<typename _Pair::second_type>::__apply( | |
| 91 | __alloc, std::forward<decltype(__args2)>(__args2)...); | |
| 92 | }, | |
| 93 | std::forward<_Tuple2>(__y))); | |
| 94 | } | |
| 186 | 95 | |
| 187 | _LIBCPP_HIDDEN constexpr auto __do_construct(const _PairMutable& __pair) const { | |
| 188 | return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair); | |
| 189 | } | |
| 96 | template <class _Alloc> | |
| 97 | static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc) noexcept { | |
| 98 | return __uses_allocator_construction_args<_Pair>::__apply(__alloc, piecewise_construct, tuple<>{}, tuple<>{}); | |
| 99 | } | |
| 190 | 100 | |
| 191 | _LIBCPP_HIDDEN constexpr auto __do_construct(_PairMutable&& __pair) const { | |
| 192 | return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair)); | |
| 193 | } | |
| 101 | template <class _Alloc, class _Up, class _Vp> | |
| 102 | static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept { | |
| 103 | return __uses_allocator_construction_args<_Pair>::__apply( | |
| 104 | __alloc, | |
| 105 | piecewise_construct, | |
| 106 | std::forward_as_tuple(std::forward<_Up>(__u)), | |
| 107 | std::forward_as_tuple(std::forward<_Vp>(__v))); | |
| 108 | } | |
| 194 | 109 | |
| 195 | const _Alloc& __alloc_; | |
| 196 | _Type& __value_; | |
| 110 | # if _LIBCPP_STD_VER >= 23 | |
| 111 | template <class _Alloc, class _Up, class _Vp> | |
| 112 | static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept { | |
| 113 | return __uses_allocator_construction_args<_Pair>::__apply( | |
| 114 | __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second)); | |
| 115 | } | |
| 116 | # endif | |
| 197 | 117 | |
| 198 | _LIBCPP_HIDDEN constexpr operator _PairMutable() const { return __do_construct(std::forward<_Type>(__value_)); } | |
| 199 | }; | |
| 118 | template <class _Alloc, class _Up, class _Vp> | |
| 119 | static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept { | |
| 120 | return __uses_allocator_construction_args<_Pair>::__apply( | |
| 121 | __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second)); | |
| 122 | } | |
| 200 | 123 | |
| 201 | return std::make_tuple(__pair_constructor{__alloc, __value}); | |
| 202 | } | |
| 124 | template <class _Alloc, class _Up, class _Vp> | |
| 125 | static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept { | |
| 126 | return __uses_allocator_construction_args<_Pair>::__apply( | |
| 127 | __alloc, | |
| 128 | piecewise_construct, | |
| 129 | std::forward_as_tuple(std::get<0>(std::move(__pair))), | |
| 130 | std::forward_as_tuple(std::get<1>(std::move(__pair)))); | |
| 131 | } | |
| 132 | ||
| 133 | # if _LIBCPP_STD_VER >= 23 | |
| 134 | template <class _Alloc, class _Up, class _Vp> | |
| 135 | static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept { | |
| 136 | return __uses_allocator_construction_args<_Pair>::__apply( | |
| 137 | __alloc, | |
| 138 | piecewise_construct, | |
| 139 | std::forward_as_tuple(std::get<0>(std::move(__pair))), | |
| 140 | std::forward_as_tuple(std::get<1>(std::move(__pair)))); | |
| 141 | } | |
| 142 | ||
| 143 | template < class _Alloc, __pair_like_no_subrange _PairLike> | |
| 144 | static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _PairLike&& __p) noexcept { | |
| 145 | return __uses_allocator_construction_args<_Pair>::__apply( | |
| 146 | __alloc, | |
| 147 | piecewise_construct, | |
| 148 | std::forward_as_tuple(std::get<0>(std::forward<_PairLike>(__p))), | |
| 149 | std::forward_as_tuple(std::get<1>(std::forward<_PairLike>(__p)))); | |
| 150 | } | |
| 151 | # endif | |
| 152 | ||
| 153 | template <class _Alloc, | |
| 154 | class _Type, | |
| 155 | __enable_if_t<__uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int> = 0> | |
| 156 | static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _Type&& __value) noexcept { | |
| 157 | struct __pair_constructor { | |
| 158 | using _PairMutable = remove_cv_t<_Pair>; | |
| 159 | ||
| 160 | _LIBCPP_HIDDEN constexpr auto __do_construct(const _PairMutable& __pair) const { | |
| 161 | return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair); | |
| 162 | } | |
| 163 | ||
| 164 | _LIBCPP_HIDDEN constexpr auto __do_construct(_PairMutable&& __pair) const { | |
| 165 | return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair)); | |
| 166 | } | |
| 167 | ||
| 168 | const _Alloc& __alloc_; | |
| 169 | _Type& __value_; | |
| 170 | ||
| 171 | _LIBCPP_HIDDEN constexpr operator _PairMutable() const { return __do_construct(std::forward<_Type>(__value_)); } | |
| 172 | }; | |
| 173 | ||
| 174 | return std::make_tuple(__pair_constructor{__alloc, __value}); | |
| 175 | } | |
| 176 | }; | |
| 177 | ||
| 178 | template <class _Type> | |
| 179 | struct __uses_allocator_construction_args<_Type, __enable_if_t<!__is_cv_std_pair<_Type>>> { | |
| 180 | template <class _Alloc, class... _Args> | |
| 181 | static _LIBCPP_HIDE_FROM_ABI constexpr auto __apply(const _Alloc& __alloc, _Args&&... __args) noexcept { | |
| 182 | if constexpr (!uses_allocator_v<remove_cv_t<_Type>, _Alloc> && is_constructible_v<_Type, _Args...>) { | |
| 183 | return std::forward_as_tuple(std::forward<_Args>(__args)...); | |
| 184 | } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> && | |
| 185 | is_constructible_v<_Type, allocator_arg_t, const _Alloc&, _Args...>) { | |
| 186 | return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(allocator_arg, __alloc, std::forward<_Args>(__args)...); | |
| 187 | } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> && | |
| 188 | is_constructible_v<_Type, _Args..., const _Alloc&>) { | |
| 189 | return std::forward_as_tuple(std::forward<_Args>(__args)..., __alloc); | |
| 190 | } else { | |
| 191 | static_assert( | |
| 192 | sizeof(_Type) + 1 == 0, "If uses_allocator_v<Type> is true, the type has to be allocator-constructible"); | |
| 193 | } | |
| 194 | } | |
| 195 | }; | |
| 203 | 196 | |
| 204 | 197 | template <class _Type, class _Alloc, class... _Args> |
| 205 | 198 | _LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args) { |
| 206 | 199 | return std::make_from_tuple<_Type>( |
| 207 | std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...)); | |
| 200 | __uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...)); | |
| 208 | 201 | } |
| 209 | 202 | |
| 210 | 203 | template <class _Type, class _Alloc, class... _Args> |
| ... | ... | @@ -212,7 +205,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Type* |
| 212 | 205 | __uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Args&&... __args) { |
| 213 | 206 | return std::apply( |
| 214 | 207 | [&__ptr](auto&&... __xs) { return std::__construct_at(__ptr, std::forward<decltype(__xs)>(__xs)...); }, |
| 215 | std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...)); | |
| 208 | __uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...)); | |
| 216 | 209 | } |
| 217 | 210 | |
| 218 | 211 | #endif // _LIBCPP_STD_VER >= 17 |
| ... | ... | @@ -221,8 +214,8 @@ __uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _ |
| 221 | 214 | |
| 222 | 215 | template <class _Type, class _Alloc, class... _Args> |
| 223 | 216 | _LIBCPP_HIDE_FROM_ABI constexpr auto uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept |
| 224 | -> decltype(std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...)) { | |
| 225 | return /*--*/ std::__uses_allocator_construction_args<_Type>(__alloc, std::forward<_Args>(__args)...); | |
| 217 | -> decltype(__uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...)) { | |
| 218 | return /*--*/ __uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...); | |
| 226 | 219 | } |
| 227 | 220 | |
| 228 | 221 | template <class _Type, class _Alloc, class... _Args> |
lib/libcxx/include/__memory/voidify.h deleted-30| ... | ... | @@ -1,30 +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___MEMORY_VOIDIFY_H | |
| 11 | #define _LIBCPP___MEMORY_VOIDIFY_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__memory/addressof.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 <typename _Tp> | |
| 23 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void* __voidify(_Tp& __from) { | |
| 24 | // Cast away cv-qualifiers to allow modifying elements of a range through const iterators. | |
| 25 | return const_cast<void*>(static_cast<const volatile void*>(std::addressof(__from))); | |
| 26 | } | |
| 27 | ||
| 28 | _LIBCPP_END_NAMESPACE_STD | |
| 29 | ||
| 30 | #endif // _LIBCPP___MEMORY_VOIDIFY_H |
lib/libcxx/include/__memory_resource/memory_resource.h+2-1| ... | ... | @@ -10,8 +10,9 @@ |
| 10 | 10 | #define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/max_align_t.h> | |
| 14 | #include <__cstddef/size_t.h> | |
| 13 | 15 | #include <__fwd/memory_resource.h> |
| 14 | #include <cstddef> | |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 18 | # pragma GCC system_header |
lib/libcxx/include/__memory_resource/monotonic_buffer_resource.h+2-5| ... | ... | @@ -10,9 +10,9 @@ |
| 10 | 10 | #define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__memory/addressof.h> |
| 14 | 15 | #include <__memory_resource/memory_resource.h> |
| 15 | #include <cstddef> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | # pragma GCC system_header |
| ... | ... | @@ -27,8 +27,7 @@ namespace pmr { |
| 27 | 27 | // [mem.res.monotonic.buffer] |
| 28 | 28 | |
| 29 | 29 | class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resource : public memory_resource { |
| 30 | static const size_t __default_buffer_capacity = 1024; | |
| 31 | static const size_t __default_buffer_alignment = 16; | |
| 30 | static constexpr size_t __default_buffer_capacity = 1024; | |
| 32 | 31 | |
| 33 | 32 | struct __chunk_footer { |
| 34 | 33 | __chunk_footer* __next_; |
| ... | ... | @@ -38,7 +37,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resour |
| 38 | 37 | _LIBCPP_HIDE_FROM_ABI size_t __allocation_size() { |
| 39 | 38 | return (reinterpret_cast<char*>(this) - __start_) + sizeof(*this); |
| 40 | 39 | } |
| 41 | void* __try_allocate_from_chunk(size_t, size_t); | |
| 42 | 40 | }; |
| 43 | 41 | |
| 44 | 42 | struct __initial_descriptor { |
| ... | ... | @@ -48,7 +46,6 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI monotonic_buffer_resour |
| 48 | 46 | char* __end_; |
| 49 | 47 | size_t __size_; |
| 50 | 48 | }; |
| 51 | void* __try_allocate_from_chunk(size_t, size_t); | |
| 52 | 49 | }; |
| 53 | 50 | |
| 54 | 51 | public: |
lib/libcxx/include/__memory_resource/polymorphic_allocator.h+17-2| ... | ... | @@ -11,12 +11,14 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__assert> |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/byte.h> | |
| 15 | #include <__cstddef/max_align_t.h> | |
| 14 | 16 | #include <__fwd/pair.h> |
| 15 | 17 | #include <__memory_resource/memory_resource.h> |
| 18 | #include <__new/exceptions.h> | |
| 19 | #include <__new/placement_new_delete.h> | |
| 16 | 20 | #include <__utility/exception_guard.h> |
| 17 | #include <cstddef> | |
| 18 | 21 | #include <limits> |
| 19 | #include <new> | |
| 20 | 22 | #include <tuple> |
| 21 | 23 | |
| 22 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -174,6 +176,19 @@ public: |
| 174 | 176 | |
| 175 | 177 | _LIBCPP_HIDE_FROM_ABI memory_resource* resource() const noexcept { return __res_; } |
| 176 | 178 | |
| 179 | _LIBCPP_HIDE_FROM_ABI friend bool | |
| 180 | operator==(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept { | |
| 181 | return *__lhs.resource() == *__rhs.resource(); | |
| 182 | } | |
| 183 | ||
| 184 | # if _LIBCPP_STD_VER <= 17 | |
| 185 | // This overload is not specified, it was added due to LWG3683. | |
| 186 | _LIBCPP_HIDE_FROM_ABI friend bool | |
| 187 | operator!=(const polymorphic_allocator& __lhs, const polymorphic_allocator& __rhs) noexcept { | |
| 188 | return *__lhs.resource() != *__rhs.resource(); | |
| 189 | } | |
| 190 | # endif | |
| 191 | ||
| 177 | 192 | private: |
| 178 | 193 | template <class... _Args, size_t... _Is> |
| 179 | 194 | _LIBCPP_HIDE_FROM_ABI tuple<_Args&&...> |
lib/libcxx/include/__memory_resource/pool_options.h+1-1| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___MEMORY_RESOURCE_POOL_OPTIONS_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 16 | # pragma GCC system_header |
lib/libcxx/include/__memory_resource/synchronized_pool_resource.h+7-6| ... | ... | @@ -10,11 +10,12 @@ |
| 10 | 10 | #define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__memory_resource/memory_resource.h> |
| 14 | 15 | #include <__memory_resource/pool_options.h> |
| 15 | 16 | #include <__memory_resource/unsynchronized_pool_resource.h> |
| 16 | #include <cstddef> | |
| 17 | #include <mutex> | |
| 17 | #include <__mutex/mutex.h> | |
| 18 | #include <__mutex/unique_lock.h> | |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 21 | # pragma GCC system_header |
| ... | ... | @@ -49,7 +50,7 @@ public: |
| 49 | 50 | synchronized_pool_resource& operator=(const synchronized_pool_resource&) = delete; |
| 50 | 51 | |
| 51 | 52 | _LIBCPP_HIDE_FROM_ABI void release() { |
| 52 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 53 | # if _LIBCPP_HAS_THREADS | |
| 53 | 54 | unique_lock<mutex> __lk(__mut_); |
| 54 | 55 | # endif |
| 55 | 56 | __unsync_.release(); |
| ... | ... | @@ -61,14 +62,14 @@ public: |
| 61 | 62 | |
| 62 | 63 | protected: |
| 63 | 64 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void* do_allocate(size_t __bytes, size_t __align) override { |
| 64 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 65 | # if _LIBCPP_HAS_THREADS | |
| 65 | 66 | unique_lock<mutex> __lk(__mut_); |
| 66 | 67 | # endif |
| 67 | 68 | return __unsync_.allocate(__bytes, __align); |
| 68 | 69 | } |
| 69 | 70 | |
| 70 | 71 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL void do_deallocate(void* __p, size_t __bytes, size_t __align) override { |
| 71 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 72 | # if _LIBCPP_HAS_THREADS | |
| 72 | 73 | unique_lock<mutex> __lk(__mut_); |
| 73 | 74 | # endif |
| 74 | 75 | return __unsync_.deallocate(__p, __bytes, __align); |
| ... | ... | @@ -77,7 +78,7 @@ protected: |
| 77 | 78 | bool do_is_equal(const memory_resource& __other) const noexcept override; // key function |
| 78 | 79 | |
| 79 | 80 | private: |
| 80 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 81 | # if _LIBCPP_HAS_THREADS | |
| 81 | 82 | mutex __mut_; |
| 82 | 83 | # endif |
| 83 | 84 | unsynchronized_pool_resource __unsync_; |
lib/libcxx/include/__memory_resource/unsynchronized_pool_resource.h+1-1| ... | ... | @@ -10,9 +10,9 @@ |
| 10 | 10 | #define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__memory_resource/memory_resource.h> |
| 14 | 15 | #include <__memory_resource/pool_options.h> |
| 15 | #include <cstddef> | |
| 16 | 16 | #include <cstdint> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__mutex/lock_guard.h+2-2| ... | ... | @@ -27,13 +27,13 @@ private: |
| 27 | 27 | mutex_type& __m_; |
| 28 | 28 | |
| 29 | 29 | public: |
| 30 | _LIBCPP_NODISCARD | |
| 30 | [[__nodiscard__]] | |
| 31 | 31 | _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) |
| 32 | 32 | : __m_(__m) { |
| 33 | 33 | __m_.lock(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t) | |
| 36 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t) | |
| 37 | 37 | _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m)) |
| 38 | 38 | : __m_(__m) {} |
| 39 | 39 | _LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); } |
lib/libcxx/include/__mutex/mutex.h+3-3| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | # pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 20 | #if _LIBCPP_HAS_THREADS | |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| ... | ... | @@ -30,7 +30,7 @@ public: |
| 30 | 30 | mutex(const mutex&) = delete; |
| 31 | 31 | mutex& operator=(const mutex&) = delete; |
| 32 | 32 | |
| 33 | # if defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION) | |
| 33 | # if _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION | |
| 34 | 34 | _LIBCPP_HIDE_FROM_ABI ~mutex() = default; |
| 35 | 35 | # else |
| 36 | 36 | ~mutex() _NOEXCEPT; |
| ... | ... | @@ -48,6 +48,6 @@ static_assert(is_nothrow_default_constructible<mutex>::value, "the default const |
| 48 | 48 | |
| 49 | 49 | _LIBCPP_END_NAMESPACE_STD |
| 50 | 50 | |
| 51 | #endif // _LIBCPP_HAS_NO_THREADS | |
| 51 | #endif // _LIBCPP_HAS_THREADS | |
| 52 | 52 | |
| 53 | 53 | #endif // _LIBCPP___MUTEX_MUTEX_H |
lib/libcxx/include/__mutex/once_flag.h+1-1| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__functional/invoke.h> |
| 14 | #include <__memory/shared_ptr.h> // __libcpp_acquire_load | |
| 14 | #include <__memory/shared_count.h> // __libcpp_acquire_load | |
| 15 | 15 | #include <__tuple/tuple_indices.h> |
| 16 | 16 | #include <__tuple/tuple_size.h> |
| 17 | 17 | #include <__utility/forward.h> |
lib/libcxx/include/__mutex/unique_lock.h+19-23| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__memory/addressof.h> |
| 16 | 16 | #include <__mutex/tag_types.h> |
| 17 | #include <__system_error/system_error.h> | |
| 17 | #include <__system_error/throw_system_error.h> | |
| 18 | 18 | #include <__utility/swap.h> |
| 19 | 19 | #include <cerrno> |
| 20 | 20 | |
| ... | ... | @@ -22,8 +22,6 @@ |
| 22 | 22 | # pragma GCC system_header |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 26 | ||
| 27 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 26 | |
| 29 | 27 | template <class _Mutex> |
| ... | ... | @@ -36,28 +34,28 @@ private: |
| 36 | 34 | bool __owns_; |
| 37 | 35 | |
| 38 | 36 | public: |
| 39 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {} | |
| 40 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI explicit unique_lock(mutex_type& __m) | |
| 37 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {} | |
| 38 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI explicit unique_lock(mutex_type& __m) | |
| 41 | 39 | : __m_(std::addressof(__m)), __owns_(true) { |
| 42 | 40 | __m_->lock(); |
| 43 | 41 | } |
| 44 | 42 | |
| 45 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT | |
| 43 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT | |
| 46 | 44 | : __m_(std::addressof(__m)), |
| 47 | 45 | __owns_(false) {} |
| 48 | 46 | |
| 49 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, try_to_lock_t) | |
| 47 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, try_to_lock_t) | |
| 50 | 48 | : __m_(std::addressof(__m)), __owns_(__m.try_lock()) {} |
| 51 | 49 | |
| 52 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, adopt_lock_t) | |
| 50 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, adopt_lock_t) | |
| 53 | 51 | : __m_(std::addressof(__m)), __owns_(true) {} |
| 54 | 52 | |
| 55 | 53 | template <class _Clock, class _Duration> |
| 56 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t) | |
| 54 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t) | |
| 57 | 55 | : __m_(std::addressof(__m)), __owns_(__m.try_lock_until(__t)) {} |
| 58 | 56 | |
| 59 | 57 | template <class _Rep, class _Period> |
| 60 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d) | |
| 58 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d) | |
| 61 | 59 | : __m_(std::addressof(__m)), __owns_(__m.try_lock_for(__d)) {} |
| 62 | 60 | |
| 63 | 61 | _LIBCPP_HIDE_FROM_ABI ~unique_lock() { |
| ... | ... | @@ -68,7 +66,7 @@ public: |
| 68 | 66 | unique_lock(unique_lock const&) = delete; |
| 69 | 67 | unique_lock& operator=(unique_lock const&) = delete; |
| 70 | 68 | |
| 71 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(unique_lock&& __u) _NOEXCEPT | |
| 69 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI unique_lock(unique_lock&& __u) _NOEXCEPT | |
| 72 | 70 | : __m_(__u.__m_), |
| 73 | 71 | __owns_(__u.__owns_) { |
| 74 | 72 | __u.__m_ = nullptr; |
| ... | ... | @@ -86,16 +84,16 @@ public: |
| 86 | 84 | return *this; |
| 87 | 85 | } |
| 88 | 86 | |
| 89 | void lock(); | |
| 90 | bool try_lock(); | |
| 87 | _LIBCPP_HIDE_FROM_ABI void lock(); | |
| 88 | _LIBCPP_HIDE_FROM_ABI bool try_lock(); | |
| 91 | 89 | |
| 92 | 90 | template <class _Rep, class _Period> |
| 93 | bool try_lock_for(const chrono::duration<_Rep, _Period>& __d); | |
| 91 | _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d); | |
| 94 | 92 | |
| 95 | 93 | template <class _Clock, class _Duration> |
| 96 | bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); | |
| 94 | _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t); | |
| 97 | 95 | |
| 98 | void unlock(); | |
| 96 | _LIBCPP_HIDE_FROM_ABI void unlock(); | |
| 99 | 97 | |
| 100 | 98 | _LIBCPP_HIDE_FROM_ABI void swap(unique_lock& __u) _NOEXCEPT { |
| 101 | 99 | std::swap(__m_, __u.__m_); |
| ... | ... | @@ -116,7 +114,7 @@ public: |
| 116 | 114 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock); |
| 117 | 115 | |
| 118 | 116 | template <class _Mutex> |
| 119 | void unique_lock<_Mutex>::lock() { | |
| 117 | _LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() { | |
| 120 | 118 | if (__m_ == nullptr) |
| 121 | 119 | __throw_system_error(EPERM, "unique_lock::lock: references null mutex"); |
| 122 | 120 | if (__owns_) |
| ... | ... | @@ -126,7 +124,7 @@ void unique_lock<_Mutex>::lock() { |
| 126 | 124 | } |
| 127 | 125 | |
| 128 | 126 | template <class _Mutex> |
| 129 | bool unique_lock<_Mutex>::try_lock() { | |
| 127 | _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock() { | |
| 130 | 128 | if (__m_ == nullptr) |
| 131 | 129 | __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex"); |
| 132 | 130 | if (__owns_) |
| ... | ... | @@ -137,7 +135,7 @@ bool unique_lock<_Mutex>::try_lock() { |
| 137 | 135 | |
| 138 | 136 | template <class _Mutex> |
| 139 | 137 | template <class _Rep, class _Period> |
| 140 | bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) { | |
| 138 | _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) { | |
| 141 | 139 | if (__m_ == nullptr) |
| 142 | 140 | __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex"); |
| 143 | 141 | if (__owns_) |
| ... | ... | @@ -148,7 +146,7 @@ bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __ |
| 148 | 146 | |
| 149 | 147 | template <class _Mutex> |
| 150 | 148 | template <class _Clock, class _Duration> |
| 151 | bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { | |
| 149 | _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) { | |
| 152 | 150 | if (__m_ == nullptr) |
| 153 | 151 | __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex"); |
| 154 | 152 | if (__owns_) |
| ... | ... | @@ -158,7 +156,7 @@ bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Durat |
| 158 | 156 | } |
| 159 | 157 | |
| 160 | 158 | template <class _Mutex> |
| 161 | void unique_lock<_Mutex>::unlock() { | |
| 159 | _LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::unlock() { | |
| 162 | 160 | if (!__owns_) |
| 163 | 161 | __throw_system_error(EPERM, "unique_lock::unlock: not locked"); |
| 164 | 162 | __m_->unlock(); |
| ... | ... | @@ -172,6 +170,4 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(unique_lock<_Mutex>& __x, unique_lock<_Mu |
| 172 | 170 | |
| 173 | 171 | _LIBCPP_END_NAMESPACE_STD |
| 174 | 172 | |
| 175 | #endif // _LIBCPP_HAS_NO_THREADS | |
| 176 | ||
| 177 | 173 | #endif // _LIBCPP___MUTEX_UNIQUE_LOCK_H |
lib/libcxx/include/__new/align_val_t.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___NEW_ALIGN_VAL_T_H | |
| 10 | #define _LIBCPP___NEW_ALIGN_VAL_T_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | // purposefully not using versioning namespace | |
| 20 | namespace std { | |
| 21 | #if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME) | |
| 22 | # ifndef _LIBCPP_CXX03_LANG | |
| 23 | enum class align_val_t : size_t {}; | |
| 24 | # else | |
| 25 | enum align_val_t { __zero = 0, __max = (size_t)-1 }; | |
| 26 | # endif | |
| 27 | #endif | |
| 28 | } // namespace std | |
| 29 | ||
| 30 | #endif // _LIBCPP___NEW_ALIGN_VAL_T_H |
lib/libcxx/include/__new/allocate.h created+110| ... | ... | @@ -0,0 +1,110 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___NEW_ALLOCATE_H | |
| 10 | #define _LIBCPP___NEW_ALLOCATE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__cstddef/max_align_t.h> | |
| 14 | #include <__cstddef/size_t.h> | |
| 15 | #include <__new/align_val_t.h> | |
| 16 | #include <__new/global_new_delete.h> // for _LIBCPP_HAS_SIZED_DEALLOCATION | |
| 17 | #include <__type_traits/type_identity.h> | |
| 18 | #include <__utility/element_count.h> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(size_t __align) _NOEXCEPT { | |
| 27 | #ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__ | |
| 28 | return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__; | |
| 29 | #else | |
| 30 | return __align > _LIBCPP_ALIGNOF(max_align_t); | |
| 31 | #endif | |
| 32 | } | |
| 33 | ||
| 34 | template <class... _Args> | |
| 35 | _LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) { | |
| 36 | #if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) | |
| 37 | return __builtin_operator_new(__args...); | |
| 38 | #else | |
| 39 | return ::operator new(__args...); | |
| 40 | #endif | |
| 41 | } | |
| 42 | ||
| 43 | template <class... _Args> | |
| 44 | _LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT { | |
| 45 | #if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) | |
| 46 | __builtin_operator_delete(__args...); | |
| 47 | #else | |
| 48 | ::operator delete(__args...); | |
| 49 | #endif | |
| 50 | } | |
| 51 | ||
| 52 | template <class _Tp> | |
| 53 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp* | |
| 54 | __libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) { | |
| 55 | size_t __size = static_cast<size_t>(__n) * sizeof(_Tp); | |
| 56 | #if _LIBCPP_HAS_ALIGNED_ALLOCATION | |
| 57 | if (__is_overaligned_for_new(__align)) { | |
| 58 | const align_val_t __align_val = static_cast<align_val_t>(__align); | |
| 59 | return static_cast<_Tp*>(std::__libcpp_operator_new(__size, __align_val)); | |
| 60 | } | |
| 61 | #endif | |
| 62 | ||
| 63 | (void)__align; | |
| 64 | return static_cast<_Tp*>(std::__libcpp_operator_new(__size)); | |
| 65 | } | |
| 66 | ||
| 67 | #if _LIBCPP_HAS_SIZED_DEALLOCATION | |
| 68 | # define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) __VA_ARGS__ | |
| 69 | #else | |
| 70 | # define _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(...) /* nothing */ | |
| 71 | #endif | |
| 72 | ||
| 73 | template <class _Tp> | |
| 74 | inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate( | |
| 75 | __type_identity_t<_Tp>* __ptr, __element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT { | |
| 76 | size_t __size = static_cast<size_t>(__n) * sizeof(_Tp); | |
| 77 | (void)__size; | |
| 78 | #if !_LIBCPP_HAS_ALIGNED_ALLOCATION | |
| 79 | (void)__align; | |
| 80 | return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size)); | |
| 81 | #else | |
| 82 | if (__is_overaligned_for_new(__align)) { | |
| 83 | const align_val_t __align_val = static_cast<align_val_t>(__align); | |
| 84 | return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size), __align_val); | |
| 85 | } else { | |
| 86 | return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size)); | |
| 87 | } | |
| 88 | #endif | |
| 89 | } | |
| 90 | ||
| 91 | #undef _LIBCPP_ONLY_IF_SIZED_DEALLOCATION | |
| 92 | ||
| 93 | template <class _Tp> | |
| 94 | inline _LIBCPP_HIDE_FROM_ABI void | |
| 95 | __libcpp_deallocate_unsized(__type_identity_t<_Tp>* __ptr, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT { | |
| 96 | #if !_LIBCPP_HAS_ALIGNED_ALLOCATION | |
| 97 | (void)__align; | |
| 98 | return std::__libcpp_operator_delete(__ptr); | |
| 99 | #else | |
| 100 | if (__is_overaligned_for_new(__align)) { | |
| 101 | const align_val_t __align_val = static_cast<align_val_t>(__align); | |
| 102 | return std::__libcpp_operator_delete(__ptr, __align_val); | |
| 103 | } else { | |
| 104 | return std::__libcpp_operator_delete(__ptr); | |
| 105 | } | |
| 106 | #endif | |
| 107 | } | |
| 108 | _LIBCPP_END_NAMESPACE_STD | |
| 109 | ||
| 110 | #endif // _LIBCPP___NEW_ALLOCATE_H |
lib/libcxx/include/__new/destroying_delete_t.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___NEW_DESTROYING_DELETE_T_H | |
| 10 | #define _LIBCPP___NEW_DESTROYING_DELETE_T_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | #if _LIBCPP_STD_VER >= 20 | |
| 19 | // purposefully not using versioning namespace | |
| 20 | namespace std { | |
| 21 | // Enable the declaration even if the compiler doesn't support the language | |
| 22 | // feature. | |
| 23 | struct destroying_delete_t { | |
| 24 | explicit destroying_delete_t() = default; | |
| 25 | }; | |
| 26 | inline constexpr destroying_delete_t destroying_delete{}; | |
| 27 | } // namespace std | |
| 28 | #endif | |
| 29 | ||
| 30 | #endif // _LIBCPP___NEW_DESTROYING_DELETE_T_H |
lib/libcxx/include/__new/exceptions.h created+74| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___NEW_EXCEPTIONS_H | |
| 10 | #define _LIBCPP___NEW_EXCEPTIONS_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__exception/exception.h> | |
| 14 | #include <__verbose_abort> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | // purposefully not using versioning namespace | |
| 21 | namespace std { | |
| 22 | #if !defined(_LIBCPP_ABI_VCRUNTIME) | |
| 23 | ||
| 24 | class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception { | |
| 25 | public: | |
| 26 | bad_alloc() _NOEXCEPT; | |
| 27 | _LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default; | |
| 28 | _LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default; | |
| 29 | ~bad_alloc() _NOEXCEPT override; | |
| 30 | const char* what() const _NOEXCEPT override; | |
| 31 | }; | |
| 32 | ||
| 33 | class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length : public bad_alloc { | |
| 34 | public: | |
| 35 | bad_array_new_length() _NOEXCEPT; | |
| 36 | _LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default; | |
| 37 | _LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default; | |
| 38 | ~bad_array_new_length() _NOEXCEPT override; | |
| 39 | const char* what() const _NOEXCEPT override; | |
| 40 | }; | |
| 41 | ||
| 42 | #elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME | |
| 43 | ||
| 44 | // When _HAS_EXCEPTIONS == 0, these complete definitions are needed, | |
| 45 | // since they would normally be provided in vcruntime_exception.h | |
| 46 | class bad_alloc : public exception { | |
| 47 | public: | |
| 48 | bad_alloc() noexcept : exception("bad allocation") {} | |
| 49 | ||
| 50 | private: | |
| 51 | friend class bad_array_new_length; | |
| 52 | ||
| 53 | bad_alloc(char const* const __message) noexcept : exception(__message) {} | |
| 54 | }; | |
| 55 | ||
| 56 | class bad_array_new_length : public bad_alloc { | |
| 57 | public: | |
| 58 | bad_array_new_length() noexcept : bad_alloc("bad array new length") {} | |
| 59 | }; | |
| 60 | ||
| 61 | #endif // defined(_LIBCPP_ABI_VCRUNTIME) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 | |
| 62 | ||
| 63 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_bad_alloc(); // not in C++ spec | |
| 64 | ||
| 65 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_array_new_length() { | |
| 66 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 67 | throw bad_array_new_length(); | |
| 68 | #else | |
| 69 | _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode"); | |
| 70 | #endif | |
| 71 | } | |
| 72 | } // namespace std | |
| 73 | ||
| 74 | #endif // _LIBCPP___NEW_EXCEPTIONS_H |
lib/libcxx/include/__new/global_new_delete.h created+77| ... | ... | @@ -0,0 +1,77 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___NEW_GLOBAL_NEW_DELETE_H | |
| 10 | #define _LIBCPP___NEW_GLOBAL_NEW_DELETE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | #include <__new/align_val_t.h> | |
| 15 | #include <__new/exceptions.h> | |
| 16 | #include <__new/nothrow_t.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | #if defined(_LIBCPP_CXX03_LANG) | |
| 23 | # define _THROW_BAD_ALLOC throw(std::bad_alloc) | |
| 24 | #else | |
| 25 | # define _THROW_BAD_ALLOC | |
| 26 | #endif | |
| 27 | ||
| 28 | #if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L | |
| 29 | # define _LIBCPP_HAS_SIZED_DEALLOCATION 1 | |
| 30 | #else | |
| 31 | # define _LIBCPP_HAS_SIZED_DEALLOCATION 0 | |
| 32 | #endif | |
| 33 | ||
| 34 | #if defined(_LIBCPP_ABI_VCRUNTIME) | |
| 35 | # include <new.h> | |
| 36 | #else | |
| 37 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC; | |
| 38 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT | |
| 39 | _LIBCPP_NOALIAS; | |
| 40 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; | |
| 41 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; | |
| 42 | # if _LIBCPP_HAS_SIZED_DEALLOCATION | |
| 43 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; | |
| 44 | # endif | |
| 45 | ||
| 46 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC; | |
| 47 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT | |
| 48 | _LIBCPP_NOALIAS; | |
| 49 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; | |
| 50 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; | |
| 51 | # if _LIBCPP_HAS_SIZED_DEALLOCATION | |
| 52 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT; | |
| 53 | # endif | |
| 54 | ||
| 55 | # if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION | |
| 56 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; | |
| 57 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* | |
| 58 | operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; | |
| 59 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; | |
| 60 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; | |
| 61 | # if _LIBCPP_HAS_SIZED_DEALLOCATION | |
| 62 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; | |
| 63 | # endif | |
| 64 | ||
| 65 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* | |
| 66 | operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; | |
| 67 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* | |
| 68 | operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; | |
| 69 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; | |
| 70 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; | |
| 71 | # if _LIBCPP_HAS_SIZED_DEALLOCATION | |
| 72 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; | |
| 73 | # endif | |
| 74 | # endif | |
| 75 | #endif | |
| 76 | ||
| 77 | #endif // _LIBCPP___NEW_GLOBAL_NEW_DELETE_H |
lib/libcxx/include/__new/interference_size.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___NEW_INTERFERENCE_SIZE_H | |
| 10 | #define _LIBCPP___NEW_INTERFERENCE_SIZE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER >= 17 | |
| 22 | ||
| 23 | # if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) | |
| 24 | ||
| 25 | inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE; | |
| 26 | inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE; | |
| 27 | ||
| 28 | # endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) | |
| 29 | ||
| 30 | #endif // _LIBCPP_STD_VER >= 17 | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___NEW_INTERFERENCE_SIZE_H |
lib/libcxx/include/__new/launder.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___NEW_LAUNDER_H | |
| 10 | #define _LIBCPP___NEW_LAUNDER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/is_function.h> | |
| 14 | #include <__type_traits/is_void.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 | template <class _Tp> | |
| 22 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT { | |
| 23 | static_assert(!(is_function<_Tp>::value), "can't launder functions"); | |
| 24 | static_assert(!is_void<_Tp>::value, "can't launder cv-void"); | |
| 25 | return __builtin_launder(__p); | |
| 26 | } | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER >= 17 | |
| 29 | template <class _Tp> | |
| 30 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept { | |
| 31 | return std::__launder(__p); | |
| 32 | } | |
| 33 | #endif | |
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___NEW_LAUNDER_H |
lib/libcxx/include/__new/new_handler.h created+29| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___NEW_NEW_HANDLER_H | |
| 10 | #define _LIBCPP___NEW_NEW_HANDLER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | #if defined(_LIBCPP_ABI_VCRUNTIME) | |
| 19 | # include <new.h> | |
| 20 | #else | |
| 21 | // purposefully not using versioning namespace | |
| 22 | namespace std { | |
| 23 | typedef void (*new_handler)(); | |
| 24 | _LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT; | |
| 25 | _LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT; | |
| 26 | } // namespace std | |
| 27 | #endif // _LIBCPP_ABI_VCRUNTIME | |
| 28 | ||
| 29 | #endif // _LIBCPP___NEW_NEW_HANDLER_H |
lib/libcxx/include/__new/nothrow_t.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___NEW_NOTHROW_T_H | |
| 10 | #define _LIBCPP___NEW_NOTHROW_T_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | #if defined(_LIBCPP_ABI_VCRUNTIME) | |
| 19 | # include <new.h> | |
| 20 | #else | |
| 21 | // purposefully not using versioning namespace | |
| 22 | namespace std { | |
| 23 | struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t { | |
| 24 | explicit nothrow_t() = default; | |
| 25 | }; | |
| 26 | extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow; | |
| 27 | } // namespace std | |
| 28 | #endif // _LIBCPP_ABI_VCRUNTIME | |
| 29 | ||
| 30 | #endif // _LIBCPP___NEW_NOTHROW_T_H |
lib/libcxx/include/__new/placement_new_delete.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___NEW_PLACEMENT_NEW_DELETE_H | |
| 10 | #define _LIBCPP___NEW_PLACEMENT_NEW_DELETE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | #if defined(_LIBCPP_ABI_VCRUNTIME) | |
| 20 | # include <new.h> | |
| 21 | #else | |
| 22 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void* | |
| 23 | operator new(std::size_t, void* __p) _NOEXCEPT { | |
| 24 | return __p; | |
| 25 | } | |
| 26 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void* | |
| 27 | operator new[](std::size_t, void* __p) _NOEXCEPT { | |
| 28 | return __p; | |
| 29 | } | |
| 30 | inline _LIBCPP_HIDE_FROM_ABI void operator delete(void*, void*) _NOEXCEPT {} | |
| 31 | inline _LIBCPP_HIDE_FROM_ABI void operator delete[](void*, void*) _NOEXCEPT {} | |
| 32 | #endif | |
| 33 | ||
| 34 | #endif // _LIBCPP___NEW_PLACEMENT_NEW_DELETE_H |
lib/libcxx/include/__node_handle+2-2| ... | ... | @@ -188,10 +188,10 @@ struct __map_node_handle_specifics { |
| 188 | 188 | }; |
| 189 | 189 | |
| 190 | 190 | template <class _NodeType, class _Alloc> |
| 191 | using __set_node_handle = __basic_node_handle< _NodeType, _Alloc, __set_node_handle_specifics>; | |
| 191 | using __set_node_handle _LIBCPP_NODEBUG = __basic_node_handle< _NodeType, _Alloc, __set_node_handle_specifics>; | |
| 192 | 192 | |
| 193 | 193 | template <class _NodeType, class _Alloc> |
| 194 | using __map_node_handle = __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>; | |
| 194 | using __map_node_handle _LIBCPP_NODEBUG = __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>; | |
| 195 | 195 | |
| 196 | 196 | template <class _Iterator, class _NodeType> |
| 197 | 197 | struct _LIBCPP_TEMPLATE_VIS __insert_return_type { |
lib/libcxx/include/__numeric/gcd_lcm.h+10-13| ... | ... | @@ -55,7 +55,8 @@ template <class _Tp> |
| 55 | 55 | constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) { |
| 56 | 56 | static_assert(!is_signed<_Tp>::value, ""); |
| 57 | 57 | |
| 58 | // From: https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor | |
| 58 | // Using Binary GCD algorithm https://en.wikipedia.org/wiki/Binary_GCD_algorithm, based on an implementation | |
| 59 | // from https://lemire.me/blog/2024/04/13/greatest-common-divisor-the-extended-euclidean-algorithm-and-speed/ | |
| 59 | 60 | // |
| 60 | 61 | // If power of two divides both numbers, we can push it out. |
| 61 | 62 | // - gcd( 2^x * a, 2^x * b) = 2^x * gcd(a, b) |
| ... | ... | @@ -76,21 +77,17 @@ constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) { |
| 76 | 77 | if (__a == 0) |
| 77 | 78 | return __b; |
| 78 | 79 | |
| 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; | |
| 80 | _Tp __c = __a | __b; | |
| 81 | int __shift = std::__countr_zero(__c); | |
| 82 | __a >>= std::__countr_zero(__a); | |
| 84 | 83 | do { |
| 85 | _Tp __diff = __a - __b; | |
| 86 | if (__a > __b) { | |
| 87 | __a = __b; | |
| 88 | __b = __diff; | |
| 84 | _Tp __t = __b >> std::__countr_zero(__b); | |
| 85 | if (__a > __t) { | |
| 86 | __b = __a - __t; | |
| 87 | __a = __t; | |
| 89 | 88 | } else { |
| 90 | __b = __b - __a; | |
| 89 | __b = __t - __a; | |
| 91 | 90 | } |
| 92 | if (__diff != 0) | |
| 93 | __b >>= std::__countr_zero(__diff); | |
| 94 | 91 | } while (__b != 0); |
| 95 | 92 | return __a << __shift; |
| 96 | 93 | } |
lib/libcxx/include/__numeric/midpoint.h+1-1| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | #define _LIBCPP___NUMERIC_MIDPOINT_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__type_traits/enable_if.h> |
| 15 | 16 | #include <__type_traits/is_floating_point.h> |
| 16 | 17 | #include <__type_traits/is_integral.h> |
| ... | ... | @@ -21,7 +22,6 @@ |
| 21 | 22 | #include <__type_traits/is_void.h> |
| 22 | 23 | #include <__type_traits/make_unsigned.h> |
| 23 | 24 | #include <__type_traits/remove_pointer.h> |
| 24 | #include <cstddef> | |
| 25 | 25 | #include <limits> |
| 26 | 26 | |
| 27 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__numeric/pstl.h+2-2| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | _LIBCPP_PUSH_MACROS |
| 19 | 19 | #include <__undef_macros> |
| 20 | 20 | |
| 21 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | |
| 21 | #if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17 | |
| 22 | 22 | |
| 23 | 23 | # include <__functional/identity.h> |
| 24 | 24 | # include <__functional/operations.h> |
| ... | ... | @@ -167,7 +167,7 @@ _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( |
| 167 | 167 | |
| 168 | 168 | _LIBCPP_END_NAMESPACE_STD |
| 169 | 169 | |
| 170 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | |
| 170 | #endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17 | |
| 171 | 171 | |
| 172 | 172 | _LIBCPP_POP_MACROS |
| 173 | 173 |
lib/libcxx/include/__ostream/basic_ostream.h+133-315| ... | ... | @@ -10,29 +10,32 @@ |
| 10 | 10 | #define _LIBCPP___OSTREAM_BASIC_OSTREAM_H |
| 11 | 11 | |
| 12 | 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 | |
| 13 | ||
| 14 | #if _LIBCPP_HAS_LOCALIZATION | |
| 15 | ||
| 16 | # include <__exception/operations.h> | |
| 17 | # include <__fwd/memory.h> | |
| 18 | # include <__memory/unique_ptr.h> | |
| 19 | # include <__new/exceptions.h> | |
| 20 | # include <__ostream/put_character_sequence.h> | |
| 21 | # include <__system_error/error_code.h> | |
| 22 | # include <__type_traits/conjunction.h> | |
| 23 | # include <__type_traits/enable_if.h> | |
| 24 | # include <__type_traits/is_base_of.h> | |
| 25 | # include <__type_traits/void_t.h> | |
| 26 | # include <__utility/declval.h> | |
| 27 | # include <bitset> | |
| 28 | # include <ios> | |
| 29 | # include <locale> | |
| 30 | # include <streambuf> | |
| 31 | # include <string_view> | |
| 32 | ||
| 33 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 34 | # pragma GCC system_header | |
| 35 | # endif | |
| 33 | 36 | |
| 34 | 37 | _LIBCPP_PUSH_MACROS |
| 35 | #include <__undef_macros> | |
| 38 | # include <__undef_macros> | |
| 36 | 39 | |
| 37 | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 38 | 41 | |
| ... | ... | @@ -85,6 +88,55 @@ public: |
| 85 | 88 | return *this; |
| 86 | 89 | } |
| 87 | 90 | |
| 91 | template <class _Tp> | |
| 92 | _LIBCPP_HIDE_FROM_ABI basic_ostream& __put_num(_Tp __value) { | |
| 93 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 94 | try { | |
| 95 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 96 | sentry __s(*this); | |
| 97 | if (__s) { | |
| 98 | using _Fp = num_put<char_type, ostreambuf_iterator<char_type, traits_type> >; | |
| 99 | const _Fp& __facet = std::use_facet<_Fp>(this->getloc()); | |
| 100 | if (__facet.put(*this, *this, this->fill(), __value).failed()) | |
| 101 | this->setstate(ios_base::badbit | ios_base::failbit); | |
| 102 | } | |
| 103 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 104 | } catch (...) { | |
| 105 | this->__set_badbit_and_consider_rethrow(); | |
| 106 | } | |
| 107 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 108 | return *this; | |
| 109 | } | |
| 110 | ||
| 111 | template <class _Tp> | |
| 112 | _LIBCPP_HIDE_FROM_ABI basic_ostream& __put_num_integer_promote(_Tp __value) { | |
| 113 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 114 | try { | |
| 115 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 116 | sentry __s(*this); | |
| 117 | if (__s) { | |
| 118 | ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; | |
| 119 | ||
| 120 | using _Fp = num_put<char_type, ostreambuf_iterator<char_type, traits_type> >; | |
| 121 | const _Fp& __facet = std::use_facet<_Fp>(this->getloc()); | |
| 122 | if (__facet | |
| 123 | .put(*this, | |
| 124 | *this, | |
| 125 | this->fill(), | |
| 126 | __flags == ios_base::oct || __flags == ios_base::hex | |
| 127 | ? static_cast<__copy_unsigned_t<_Tp, long> >(std::__to_unsigned_like(__value)) | |
| 128 | : static_cast<__copy_unsigned_t<_Tp, long> >(__value)) | |
| 129 | .failed()) | |
| 130 | this->setstate(ios_base::badbit | ios_base::failbit); | |
| 131 | } | |
| 132 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 133 | } catch (...) { | |
| 134 | this->__set_badbit_and_consider_rethrow(); | |
| 135 | } | |
| 136 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 137 | return *this; | |
| 138 | } | |
| 139 | ||
| 88 | 140 | basic_ostream& operator<<(bool __n); |
| 89 | 141 | basic_ostream& operator<<(short __n); |
| 90 | 142 | basic_ostream& operator<<(unsigned short __n); |
| ... | ... | @@ -99,19 +151,19 @@ public: |
| 99 | 151 | basic_ostream& operator<<(long double __f); |
| 100 | 152 | basic_ostream& operator<<(const void* __p); |
| 101 | 153 | |
| 102 | #if _LIBCPP_STD_VER >= 23 | |
| 154 | # if _LIBCPP_STD_VER >= 23 | |
| 103 | 155 | _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(const volatile void* __p) { |
| 104 | 156 | return operator<<(const_cast<const void*>(__p)); |
| 105 | 157 | } |
| 106 | #endif | |
| 158 | # endif | |
| 107 | 159 | |
| 108 | 160 | basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb); |
| 109 | 161 | |
| 110 | #if _LIBCPP_STD_VER >= 17 | |
| 162 | # if _LIBCPP_STD_VER >= 17 | |
| 111 | 163 | // LWG 2221 - nullptr. This is not backported to older standards modes. |
| 112 | 164 | // See https://reviews.llvm.org/D127033 for more info on the rationale. |
| 113 | 165 | _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(nullptr_t) { return *this << "nullptr"; } |
| 114 | #endif | |
| 166 | # endif | |
| 115 | 167 | |
| 116 | 168 | // 27.7.2.7 Unformatted output: |
| 117 | 169 | basic_ostream& put(char_type __c); |
| ... | ... | @@ -152,16 +204,16 @@ basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& _ |
| 152 | 204 | |
| 153 | 205 | template <class _CharT, class _Traits> |
| 154 | 206 | 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 | |
| 207 | if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && uncaught_exceptions() == 0) { | |
| 208 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 157 | 209 | try { |
| 158 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 210 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 159 | 211 | if (__os_.rdbuf()->pubsync() == -1) |
| 160 | 212 | __os_.setstate(ios_base::badbit); |
| 161 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 213 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 162 | 214 | } catch (...) { |
| 163 | 215 | } |
| 164 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 216 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 165 | 217 | } |
| 166 | 218 | } |
| 167 | 219 | |
| ... | ... | @@ -182,15 +234,15 @@ basic_ostream<_CharT, _Traits>::~basic_ostream() {} |
| 182 | 234 | template <class _CharT, class _Traits> |
| 183 | 235 | basic_ostream<_CharT, _Traits>& |
| 184 | 236 | basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) { |
| 185 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 237 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 186 | 238 | try { |
| 187 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 239 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 188 | 240 | sentry __s(*this); |
| 189 | 241 | if (__s) { |
| 190 | 242 | if (__sb) { |
| 191 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 243 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 192 | 244 | try { |
| 193 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 245 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 194 | 246 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; |
| 195 | 247 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; |
| 196 | 248 | _Ip __i(__sb); |
| ... | ... | @@ -204,321 +256,85 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_typ |
| 204 | 256 | } |
| 205 | 257 | if (__c == 0) |
| 206 | 258 | this->setstate(ios_base::failbit); |
| 207 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 259 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 208 | 260 | } catch (...) { |
| 209 | 261 | this->__set_failbit_and_consider_rethrow(); |
| 210 | 262 | } |
| 211 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 263 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 212 | 264 | } else |
| 213 | 265 | this->setstate(ios_base::badbit); |
| 214 | 266 | } |
| 215 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 267 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 216 | 268 | } catch (...) { |
| 217 | 269 | this->__set_badbit_and_consider_rethrow(); |
| 218 | 270 | } |
| 219 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 271 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 220 | 272 | return *this; |
| 221 | 273 | } |
| 222 | 274 | |
| 223 | 275 | template <class _CharT, class _Traits> |
| 224 | 276 | 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; | |
| 277 | return __put_num(__n); | |
| 241 | 278 | } |
| 242 | 279 | |
| 243 | 280 | template <class _CharT, class _Traits> |
| 244 | 281 | 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; | |
| 282 | return __put_num_integer_promote(__n); | |
| 268 | 283 | } |
| 269 | 284 | |
| 270 | 285 | template <class _CharT, class _Traits> |
| 271 | 286 | 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; | |
| 287 | return __put_num_integer_promote(__n); | |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | template <class _CharT, class _Traits> |
| 291 | 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; | |
| 292 | return __put_num_integer_promote(__n); | |
| 315 | 293 | } |
| 316 | 294 | |
| 317 | 295 | template <class _CharT, class _Traits> |
| 318 | 296 | 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; | |
| 297 | return __put_num_integer_promote(__n); | |
| 335 | 298 | } |
| 336 | 299 | |
| 337 | 300 | template <class _CharT, class _Traits> |
| 338 | 301 | 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; | |
| 302 | return __put_num(__n); | |
| 355 | 303 | } |
| 356 | 304 | |
| 357 | 305 | template <class _CharT, class _Traits> |
| 358 | 306 | 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; | |
| 307 | return __put_num(__n); | |
| 375 | 308 | } |
| 376 | 309 | |
| 377 | 310 | template <class _CharT, class _Traits> |
| 378 | 311 | 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; | |
| 312 | return __put_num(__n); | |
| 395 | 313 | } |
| 396 | 314 | |
| 397 | 315 | template <class _CharT, class _Traits> |
| 398 | 316 | 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; | |
| 317 | return __put_num(__n); | |
| 415 | 318 | } |
| 416 | 319 | |
| 417 | 320 | template <class _CharT, class _Traits> |
| 418 | 321 | 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; | |
| 322 | return *this << static_cast<double>(__n); | |
| 435 | 323 | } |
| 436 | 324 | |
| 437 | 325 | template <class _CharT, class _Traits> |
| 438 | 326 | 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; | |
| 327 | return __put_num(__n); | |
| 455 | 328 | } |
| 456 | 329 | |
| 457 | 330 | template <class _CharT, class _Traits> |
| 458 | 331 | 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; | |
| 332 | return __put_num(__n); | |
| 475 | 333 | } |
| 476 | 334 | |
| 477 | 335 | template <class _CharT, class _Traits> |
| 478 | 336 | 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; | |
| 337 | return __put_num(__n); | |
| 522 | 338 | } |
| 523 | 339 | |
| 524 | 340 | template <class _CharT, class _Traits> |
| ... | ... | @@ -528,9 +344,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_ |
| 528 | 344 | |
| 529 | 345 | template <class _CharT, class _Traits> |
| 530 | 346 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) { |
| 531 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 347 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 532 | 348 | try { |
| 533 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 349 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 534 | 350 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 535 | 351 | if (__s) { |
| 536 | 352 | _CharT __c = __os.widen(__cn); |
| ... | ... | @@ -545,11 +361,11 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_ |
| 545 | 361 | .failed()) |
| 546 | 362 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 547 | 363 | } |
| 548 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 364 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 549 | 365 | } catch (...) { |
| 550 | 366 | __os.__set_badbit_and_consider_rethrow(); |
| 551 | 367 | } |
| 552 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 368 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 553 | 369 | return __os; |
| 554 | 370 | } |
| 555 | 371 | |
| ... | ... | @@ -577,9 +393,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) { |
| 577 | 393 | template <class _CharT, class _Traits> |
| 578 | 394 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| 579 | 395 | operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) { |
| 580 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 396 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 581 | 397 | try { |
| 582 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 398 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 583 | 399 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 584 | 400 | if (__s) { |
| 585 | 401 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; |
| ... | ... | @@ -606,11 +422,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) { |
| 606 | 422 | .failed()) |
| 607 | 423 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 608 | 424 | } |
| 609 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 425 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 610 | 426 | } catch (...) { |
| 611 | 427 | __os.__set_badbit_and_consider_rethrow(); |
| 612 | 428 | } |
| 613 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 429 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 614 | 430 | return __os; |
| 615 | 431 | } |
| 616 | 432 | |
| ... | ... | @@ -635,9 +451,9 @@ operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) { |
| 635 | 451 | |
| 636 | 452 | template <class _CharT, class _Traits> |
| 637 | 453 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) { |
| 638 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 454 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 639 | 455 | try { |
| 640 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 456 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 641 | 457 | sentry __s(*this); |
| 642 | 458 | if (__s) { |
| 643 | 459 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; |
| ... | ... | @@ -646,37 +462,37 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __ |
| 646 | 462 | if (__o.failed()) |
| 647 | 463 | this->setstate(ios_base::badbit); |
| 648 | 464 | } |
| 649 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 465 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 650 | 466 | } catch (...) { |
| 651 | 467 | this->__set_badbit_and_consider_rethrow(); |
| 652 | 468 | } |
| 653 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 469 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 654 | 470 | return *this; |
| 655 | 471 | } |
| 656 | 472 | |
| 657 | 473 | template <class _CharT, class _Traits> |
| 658 | 474 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) { |
| 659 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 475 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 660 | 476 | try { |
| 661 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 477 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 662 | 478 | sentry __sen(*this); |
| 663 | 479 | if (__sen && __n) { |
| 664 | 480 | if (this->rdbuf()->sputn(__s, __n) != __n) |
| 665 | 481 | this->setstate(ios_base::badbit); |
| 666 | 482 | } |
| 667 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 483 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 668 | 484 | } catch (...) { |
| 669 | 485 | this->__set_badbit_and_consider_rethrow(); |
| 670 | 486 | } |
| 671 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 487 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 672 | 488 | return *this; |
| 673 | 489 | } |
| 674 | 490 | |
| 675 | 491 | template <class _CharT, class _Traits> |
| 676 | 492 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() { |
| 677 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 493 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 678 | 494 | try { |
| 679 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 495 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 680 | 496 | if (this->rdbuf()) { |
| 681 | 497 | sentry __s(*this); |
| 682 | 498 | if (__s) { |
| ... | ... | @@ -684,11 +500,11 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() { |
| 684 | 500 | this->setstate(ios_base::badbit); |
| 685 | 501 | } |
| 686 | 502 | } |
| 687 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 503 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 688 | 504 | } catch (...) { |
| 689 | 505 | this->__set_badbit_and_consider_rethrow(); |
| 690 | 506 | } |
| 691 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 507 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 692 | 508 | return *this; |
| 693 | 509 | } |
| 694 | 510 | |
| ... | ... | @@ -797,9 +613,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) { |
| 797 | 613 | std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); |
| 798 | 614 | } |
| 799 | 615 | |
| 800 | #if _LIBCPP_STD_VER >= 20 | |
| 616 | # if _LIBCPP_STD_VER >= 20 | |
| 801 | 617 | |
| 802 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 618 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 803 | 619 | template <class _Traits> |
| 804 | 620 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete; |
| 805 | 621 | |
| ... | ... | @@ -818,9 +634,9 @@ basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, co |
| 818 | 634 | template <class _Traits> |
| 819 | 635 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete; |
| 820 | 636 | |
| 821 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 637 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 822 | 638 | |
| 823 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 639 | # if _LIBCPP_HAS_CHAR8_T | |
| 824 | 640 | template <class _Traits> |
| 825 | 641 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete; |
| 826 | 642 | |
| ... | ... | @@ -832,7 +648,7 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const ch |
| 832 | 648 | |
| 833 | 649 | template <class _Traits> |
| 834 | 650 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete; |
| 835 | # endif | |
| 651 | # endif | |
| 836 | 652 | |
| 837 | 653 | template <class _Traits> |
| 838 | 654 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete; |
| ... | ... | @@ -846,15 +662,17 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const ch |
| 846 | 662 | template <class _Traits> |
| 847 | 663 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete; |
| 848 | 664 | |
| 849 | #endif // _LIBCPP_STD_VER >= 20 | |
| 665 | # endif // _LIBCPP_STD_VER >= 20 | |
| 850 | 666 | |
| 851 | 667 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>; |
| 852 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 668 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 853 | 669 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>; |
| 854 | #endif | |
| 670 | # endif | |
| 855 | 671 | |
| 856 | 672 | _LIBCPP_END_NAMESPACE_STD |
| 857 | 673 | |
| 858 | 674 | _LIBCPP_POP_MACROS |
| 859 | 675 | |
| 676 | #endif // _LIBCPP_HAS_LOCALIZATION | |
| 677 | ||
| 860 | 678 | #endif // _LIBCPP___OSTREAM_BASIC_OSTREAM_H |
lib/libcxx/include/__ostream/print.h+42-37| ... | ... | @@ -10,21 +10,24 @@ |
| 10 | 10 | #define _LIBCPP___OSTREAM_PRINT_H |
| 11 | 11 | |
| 12 | 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 | |
| 13 | ||
| 14 | #if _LIBCPP_HAS_LOCALIZATION | |
| 15 | ||
| 16 | # include <__fwd/ostream.h> | |
| 17 | # include <__iterator/ostreambuf_iterator.h> | |
| 18 | # include <__ostream/basic_ostream.h> | |
| 19 | # include <format> | |
| 20 | # include <ios> | |
| 21 | # include <locale> | |
| 22 | # include <print> | |
| 23 | ||
| 24 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | # endif | |
| 24 | 27 | |
| 25 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 29 | |
| 27 | #if _LIBCPP_STD_VER >= 23 | |
| 30 | # if _LIBCPP_STD_VER >= 23 | |
| 28 | 31 | |
| 29 | 32 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| 30 | 33 | _LIBCPP_HIDE_FROM_ABI inline void |
| ... | ... | @@ -49,9 +52,9 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _ |
| 49 | 52 | const char* __str = __o.data(); |
| 50 | 53 | size_t __len = __o.size(); |
| 51 | 54 | |
| 52 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 55 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 53 | 56 | try { |
| 54 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 57 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 55 | 58 | typedef ostreambuf_iterator<char> _Ip; |
| 56 | 59 | if (std::__pad_and_output( |
| 57 | 60 | _Ip(__os), |
| ... | ... | @@ -63,11 +66,11 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _ |
| 63 | 66 | .failed()) |
| 64 | 67 | __os.setstate(ios_base::badbit | ios_base::failbit); |
| 65 | 68 | |
| 66 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 69 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 67 | 70 | } catch (...) { |
| 68 | 71 | __os.__set_badbit_and_consider_rethrow(); |
| 69 | 72 | } |
| 70 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 73 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 71 | 74 | } |
| 72 | 75 | } |
| 73 | 76 | |
| ... | ... | @@ -91,12 +94,12 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view _ |
| 91 | 94 | // is determined in the same way as the print(FILE*, ...) overloads. |
| 92 | 95 | _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os); |
| 93 | 96 | |
| 94 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 97 | # if _LIBCPP_HAS_UNICODE | |
| 95 | 98 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| 96 | 99 | _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 | |
| 100 | # if _LIBCPP_AVAILABILITY_HAS_PRINT == 0 | |
| 98 | 101 | return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl); |
| 99 | # else | |
| 102 | # else | |
| 100 | 103 | FILE* __file = std::__get_ostream_file(__os); |
| 101 | 104 | if (!__file || !__print::__is_terminal(__file)) |
| 102 | 105 | return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl); |
| ... | ... | @@ -112,49 +115,49 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo |
| 112 | 115 | // This is the path for the native API, start with flushing. |
| 113 | 116 | __os.flush(); |
| 114 | 117 | |
| 115 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 118 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 116 | 119 | try { |
| 117 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 120 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 118 | 121 | ostream::sentry __s(__os); |
| 119 | 122 | if (__s) { |
| 120 | # ifndef _LIBCPP_WIN32API | |
| 123 | # ifndef _LIBCPP_WIN32API | |
| 121 | 124 | __print::__vprint_unicode_posix(__file, __fmt, __args, __write_nl, true); |
| 122 | # elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 125 | # elif _LIBCPP_HAS_WIDE_CHARACTERS | |
| 123 | 126 | __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 | # else | |
| 128 | # error "Windows builds with wchar_t disabled are not supported." | |
| 129 | # endif | |
| 127 | 130 | } |
| 128 | 131 | |
| 129 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 132 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 130 | 133 | } catch (...) { |
| 131 | 134 | __os.__set_badbit_and_consider_rethrow(); |
| 132 | 135 | } |
| 133 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 134 | # endif // _LIBCPP_AVAILABILITY_HAS_PRINT | |
| 136 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 137 | # endif // _LIBCPP_AVAILABILITY_HAS_PRINT | |
| 135 | 138 | } |
| 136 | 139 | |
| 137 | 140 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| 138 | 141 | _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(ostream& __os, string_view __fmt, format_args __args) { |
| 139 | 142 | std::__vprint_unicode(__os, __fmt, __args, false); |
| 140 | 143 | } |
| 141 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 144 | # endif // _LIBCPP_HAS_UNICODE | |
| 142 | 145 | |
| 143 | 146 | template <class... _Args> |
| 144 | 147 | _LIBCPP_HIDE_FROM_ABI void print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) { |
| 145 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 148 | # if _LIBCPP_HAS_UNICODE | |
| 146 | 149 | if constexpr (__print::__use_unicode_execution_charset) |
| 147 | 150 | std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), false); |
| 148 | 151 | else |
| 149 | 152 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false); |
| 150 | # else // _LIBCPP_HAS_NO_UNICODE | |
| 153 | # else // _LIBCPP_HAS_UNICODE | |
| 151 | 154 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false); |
| 152 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 155 | # endif // _LIBCPP_HAS_UNICODE | |
| 153 | 156 | } |
| 154 | 157 | |
| 155 | 158 | template <class... _Args> |
| 156 | 159 | _LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) { |
| 157 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 160 | # if _LIBCPP_HAS_UNICODE | |
| 158 | 161 | // Note the wording in the Standard is inefficient. The output of |
| 159 | 162 | // std::format is a std::string which is then copied. This solution |
| 160 | 163 | // just appends a newline at the end of the output. |
| ... | ... | @@ -162,9 +165,9 @@ _LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt, |
| 162 | 165 | std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), true); |
| 163 | 166 | else |
| 164 | 167 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true); |
| 165 | # else // _LIBCPP_HAS_NO_UNICODE | |
| 168 | # else // _LIBCPP_HAS_UNICODE | |
| 166 | 169 | std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true); |
| 167 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 170 | # endif // _LIBCPP_HAS_UNICODE | |
| 168 | 171 | } |
| 169 | 172 | |
| 170 | 173 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| ... | ... | @@ -172,8 +175,10 @@ _LIBCPP_HIDE_FROM_ABI inline void println(ostream& __os) { |
| 172 | 175 | std::print(__os, "\n"); |
| 173 | 176 | } |
| 174 | 177 | |
| 175 | #endif // _LIBCPP_STD_VER >= 23 | |
| 178 | # endif // _LIBCPP_STD_VER >= 23 | |
| 176 | 179 | |
| 177 | 180 | _LIBCPP_END_NAMESPACE_STD |
| 178 | 181 | |
| 182 | #endif // _LIBCPP_HAS_LOCALIZATION | |
| 183 | ||
| 179 | 184 | #endif // _LIBCPP___OSTREAM_PRINT_H |
lib/libcxx/include/__ostream/put_character_sequence.h created+59| ... | ... | @@ -0,0 +1,59 @@ |
| 1 | //===---------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_PUT_CHARACTER_SEQUENCE_H | |
| 10 | #define _LIBCPP___OSTREAM_PUT_CHARACTER_SEQUENCE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if _LIBCPP_HAS_LOCALIZATION | |
| 15 | ||
| 16 | # include <__cstddef/size_t.h> | |
| 17 | # include <__fwd/ostream.h> | |
| 18 | # include <__iterator/ostreambuf_iterator.h> | |
| 19 | # include <__locale_dir/pad_and_output.h> | |
| 20 | # include <ios> | |
| 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 | template <class _CharT, class _Traits> | |
| 29 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | |
| 30 | __put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str, size_t __len) { | |
| 31 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 32 | try { | |
| 33 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 34 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); | |
| 35 | if (__s) { | |
| 36 | typedef ostreambuf_iterator<_CharT, _Traits> _Ip; | |
| 37 | if (std::__pad_and_output( | |
| 38 | _Ip(__os), | |
| 39 | __str, | |
| 40 | (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str, | |
| 41 | __str + __len, | |
| 42 | __os, | |
| 43 | __os.fill()) | |
| 44 | .failed()) | |
| 45 | __os.setstate(ios_base::badbit | ios_base::failbit); | |
| 46 | } | |
| 47 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 48 | } catch (...) { | |
| 49 | __os.__set_badbit_and_consider_rethrow(); | |
| 50 | } | |
| 51 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 52 | return __os; | |
| 53 | } | |
| 54 | ||
| 55 | _LIBCPP_END_NAMESPACE_STD | |
| 56 | ||
| 57 | #endif // _LIBCPP_HAS_LOCALIZATION | |
| 58 | ||
| 59 | #endif // _LIBCPP___OSTREAM_PUT_CHARACTER_SEQUENCE_H |
lib/libcxx/include/__pstl/backend.h+14-10| ... | ... | @@ -19,16 +19,20 @@ |
| 19 | 19 | _LIBCPP_PUSH_MACROS |
| 20 | 20 | #include <__undef_macros> |
| 21 | 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 | |
| 22 | #if _LIBCPP_STD_VER >= 17 | |
| 23 | ||
| 24 | # if defined(_LIBCPP_PSTL_BACKEND_SERIAL) | |
| 25 | # include <__pstl/backends/default.h> | |
| 26 | # include <__pstl/backends/serial.h> | |
| 27 | # elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD) | |
| 28 | # include <__pstl/backends/default.h> | |
| 29 | # include <__pstl/backends/std_thread.h> | |
| 30 | # elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH) | |
| 31 | # include <__pstl/backends/default.h> | |
| 32 | # include <__pstl/backends/libdispatch.h> | |
| 33 | # endif | |
| 34 | ||
| 35 | #endif // _LIBCPP_STD_VER >= 17 | |
| 32 | 36 | |
| 33 | 37 | _LIBCPP_POP_MACROS |
| 34 | 38 |
lib/libcxx/include/__pstl/backend_fwd.h+15-9| ... | ... | @@ -39,6 +39,8 @@ _LIBCPP_PUSH_MACROS |
| 39 | 39 | // the user. |
| 40 | 40 | // |
| 41 | 41 | |
| 42 | #if _LIBCPP_STD_VER >= 17 | |
| 43 | ||
| 42 | 44 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 43 | 45 | namespace __pstl { |
| 44 | 46 | |
| ... | ... | @@ -50,18 +52,20 @@ struct __libdispatch_backend_tag; |
| 50 | 52 | struct __serial_backend_tag; |
| 51 | 53 | struct __std_thread_backend_tag; |
| 52 | 54 | |
| 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 | |
| 55 | # if defined(_LIBCPP_PSTL_BACKEND_SERIAL) | |
| 56 | using __current_configuration _LIBCPP_NODEBUG = __backend_configuration<__serial_backend_tag, __default_backend_tag>; | |
| 57 | # elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD) | |
| 58 | using __current_configuration _LIBCPP_NODEBUG = | |
| 59 | __backend_configuration<__std_thread_backend_tag, __default_backend_tag>; | |
| 60 | # elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH) | |
| 61 | using __current_configuration _LIBCPP_NODEBUG = | |
| 62 | __backend_configuration<__libdispatch_backend_tag, __default_backend_tag>; | |
| 63 | # else | |
| 60 | 64 | |
| 61 | 65 | // ...New vendors can add parallel backends here... |
| 62 | 66 | |
| 63 | # error "Invalid PSTL backend configuration" | |
| 64 | #endif | |
| 67 | # error "Invalid PSTL backend configuration" | |
| 68 | # endif | |
| 65 | 69 | |
| 66 | 70 | template <class _Backend, class _ExecutionPolicy> |
| 67 | 71 | struct __find_if; |
| ... | ... | @@ -296,6 +300,8 @@ struct __reduce; |
| 296 | 300 | } // namespace __pstl |
| 297 | 301 | _LIBCPP_END_NAMESPACE_STD |
| 298 | 302 | |
| 303 | #endif // _LIBCPP_STD_VER >= 17 | |
| 304 | ||
| 299 | 305 | _LIBCPP_POP_MACROS |
| 300 | 306 | |
| 301 | 307 | #endif // _LIBCPP___PSTL_BACKEND_FWD_H |
lib/libcxx/include/__pstl/backends/default.h+5-1| ... | ... | @@ -33,6 +33,8 @@ |
| 33 | 33 | _LIBCPP_PUSH_MACROS |
| 34 | 34 | #include <__undef_macros> |
| 35 | 35 | |
| 36 | #if _LIBCPP_STD_VER >= 17 | |
| 37 | ||
| 36 | 38 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 37 | 39 | namespace __pstl { |
| 38 | 40 | |
| ... | ... | @@ -163,7 +165,7 @@ struct __is_partitioned<__default_backend_tag, _ExecutionPolicy> { |
| 163 | 165 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> |
| 164 | 166 | operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept { |
| 165 | 167 | using _FindIfNot = __dispatch<__find_if_not, __current_configuration, _ExecutionPolicy>; |
| 166 | auto __maybe_first = _FindIfNot()(__policy, std::move(__first), std::move(__last), __pred); | |
| 168 | auto __maybe_first = _FindIfNot()(__policy, std::move(__first), __last, __pred); | |
| 167 | 169 | if (__maybe_first == nullopt) |
| 168 | 170 | return nullopt; |
| 169 | 171 | |
| ... | ... | @@ -498,6 +500,8 @@ struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> { |
| 498 | 500 | } // namespace __pstl |
| 499 | 501 | _LIBCPP_END_NAMESPACE_STD |
| 500 | 502 | |
| 503 | #endif // _LIBCPP_STD_VER >= 17 | |
| 504 | ||
| 501 | 505 | _LIBCPP_POP_MACROS |
| 502 | 506 | |
| 503 | 507 | #endif // _LIBCPP___PSTL_BACKENDS_DEFAULT_H |
lib/libcxx/include/__pstl/backends/libdispatch.h+10-6| ... | ... | @@ -16,12 +16,14 @@ |
| 16 | 16 | #include <__algorithm/upper_bound.h> |
| 17 | 17 | #include <__atomic/atomic.h> |
| 18 | 18 | #include <__config> |
| 19 | #include <__cstddef/ptrdiff_t.h> | |
| 19 | 20 | #include <__exception/terminate.h> |
| 20 | 21 | #include <__iterator/iterator_traits.h> |
| 21 | 22 | #include <__iterator/move_iterator.h> |
| 22 | 23 | #include <__memory/allocator.h> |
| 23 | 24 | #include <__memory/construct_at.h> |
| 24 | 25 | #include <__memory/unique_ptr.h> |
| 26 | #include <__new/exceptions.h> | |
| 25 | 27 | #include <__numeric/reduce.h> |
| 26 | 28 | #include <__pstl/backend_fwd.h> |
| 27 | 29 | #include <__pstl/cpu_algos/any_of.h> |
| ... | ... | @@ -37,13 +39,13 @@ |
| 37 | 39 | #include <__utility/exception_guard.h> |
| 38 | 40 | #include <__utility/move.h> |
| 39 | 41 | #include <__utility/pair.h> |
| 40 | #include <cstddef> | |
| 41 | #include <new> | |
| 42 | 42 | #include <optional> |
| 43 | 43 | |
| 44 | 44 | _LIBCPP_PUSH_MACROS |
| 45 | 45 | #include <__undef_macros> |
| 46 | 46 | |
| 47 | #if _LIBCPP_STD_VER >= 17 | |
| 48 | ||
| 47 | 49 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 50 | namespace __pstl { |
| 49 | 51 | |
| ... | ... | @@ -140,15 +142,15 @@ struct __cpu_traits<__libdispatch_backend_tag> { |
| 140 | 142 | |
| 141 | 143 | unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges( |
| 142 | 144 | [&]() -> __merge_range_t* { |
| 143 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 145 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 144 | 146 | try { |
| 145 | #endif | |
| 147 | # endif | |
| 146 | 148 | return std::allocator<__merge_range_t>().allocate(__n_ranges); |
| 147 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 149 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 148 | 150 | } catch (const std::bad_alloc&) { |
| 149 | 151 | return nullptr; |
| 150 | 152 | } |
| 151 | #endif | |
| 153 | # endif | |
| 152 | 154 | }(), |
| 153 | 155 | __destroy); |
| 154 | 156 | |
| ... | ... | @@ -392,6 +394,8 @@ struct __fill<__libdispatch_backend_tag, _ExecutionPolicy> |
| 392 | 394 | } // namespace __pstl |
| 393 | 395 | _LIBCPP_END_NAMESPACE_STD |
| 394 | 396 | |
| 397 | #endif // _LIBCPP_STD_VER >= 17 | |
| 398 | ||
| 395 | 399 | _LIBCPP_POP_MACROS |
| 396 | 400 | |
| 397 | 401 | #endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H |
lib/libcxx/include/__pstl/backends/serial.h+4| ... | ... | @@ -30,6 +30,8 @@ |
| 30 | 30 | _LIBCPP_PUSH_MACROS |
| 31 | 31 | #include <__undef_macros> |
| 32 | 32 | |
| 33 | #if _LIBCPP_STD_VER >= 17 | |
| 34 | ||
| 33 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 36 | namespace __pstl { |
| 35 | 37 | |
| ... | ... | @@ -176,6 +178,8 @@ struct __transform_reduce_binary<__serial_backend_tag, _ExecutionPolicy> { |
| 176 | 178 | } // namespace __pstl |
| 177 | 179 | _LIBCPP_END_NAMESPACE_STD |
| 178 | 180 | |
| 181 | #endif // _LIBCPP_STD_VER >= 17 | |
| 182 | ||
| 179 | 183 | _LIBCPP_POP_MACROS |
| 180 | 184 | |
| 181 | 185 | #endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H |
lib/libcxx/include/__pstl/backends/std_thread.h+4-1| ... | ... | @@ -22,7 +22,6 @@ |
| 22 | 22 | #include <__pstl/cpu_algos/transform_reduce.h> |
| 23 | 23 | #include <__utility/empty.h> |
| 24 | 24 | #include <__utility/move.h> |
| 25 | #include <cstddef> | |
| 26 | 25 | #include <optional> |
| 27 | 26 | |
| 28 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -32,6 +31,8 @@ |
| 32 | 31 | _LIBCPP_PUSH_MACROS |
| 33 | 32 | #include <__undef_macros> |
| 34 | 33 | |
| 34 | #if _LIBCPP_STD_VER >= 17 | |
| 35 | ||
| 35 | 36 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 37 | namespace __pstl { |
| 37 | 38 | |
| ... | ... | @@ -131,6 +132,8 @@ struct __fill<__std_thread_backend_tag, _ExecutionPolicy> |
| 131 | 132 | } // namespace __pstl |
| 132 | 133 | _LIBCPP_END_NAMESPACE_STD |
| 133 | 134 | |
| 135 | #endif // _LIBCPP_STD_VER >= 17 | |
| 136 | ||
| 134 | 137 | _LIBCPP_POP_MACROS |
| 135 | 138 | |
| 136 | 139 | #endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H |
lib/libcxx/include/__pstl/cpu_algos/any_of.h+4| ... | ... | @@ -26,6 +26,8 @@ |
| 26 | 26 | _LIBCPP_PUSH_MACROS |
| 27 | 27 | #include <__undef_macros> |
| 28 | 28 | |
| 29 | #if _LIBCPP_STD_VER >= 17 | |
| 30 | ||
| 29 | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 32 | namespace __pstl { |
| 31 | 33 | |
| ... | ... | @@ -94,6 +96,8 @@ struct __cpu_parallel_any_of { |
| 94 | 96 | } // namespace __pstl |
| 95 | 97 | _LIBCPP_END_NAMESPACE_STD |
| 96 | 98 | |
| 99 | #endif // _LIBCPP_STD_VER >= 17 | |
| 100 | ||
| 97 | 101 | _LIBCPP_POP_MACROS |
| 98 | 102 | |
| 99 | 103 | #endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H |
lib/libcxx/include/__pstl/cpu_algos/cpu_traits.h+4-1| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #define _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 14 | 13 | |
| 15 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 15 | # pragma GCC system_header |
| ... | ... | @@ -19,6 +18,8 @@ |
| 19 | 18 | _LIBCPP_PUSH_MACROS |
| 20 | 19 | #include <__undef_macros> |
| 21 | 20 | |
| 21 | #if _LIBCPP_STD_VER >= 17 | |
| 22 | ||
| 22 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 24 | namespace __pstl { |
| 24 | 25 | |
| ... | ... | @@ -81,6 +82,8 @@ struct __cpu_traits; |
| 81 | 82 | } // namespace __pstl |
| 82 | 83 | _LIBCPP_END_NAMESPACE_STD |
| 83 | 84 | |
| 85 | #endif // _LIBCPP_STD_VER >= 17 | |
| 86 | ||
| 84 | 87 | _LIBCPP_POP_MACROS |
| 85 | 88 | |
| 86 | 89 | #endif // _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H |
lib/libcxx/include/__pstl/cpu_algos/fill.h+4| ... | ... | @@ -23,6 +23,8 @@ |
| 23 | 23 | # pragma GCC system_header |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | #if _LIBCPP_STD_VER >= 17 | |
| 27 | ||
| 26 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 29 | namespace __pstl { |
| 28 | 30 | |
| ... | ... | @@ -63,4 +65,6 @@ struct __cpu_parallel_fill { |
| 63 | 65 | } // namespace __pstl |
| 64 | 66 | _LIBCPP_END_NAMESPACE_STD |
| 65 | 67 | |
| 68 | #endif // _LIBCPP_STD_VER >= 17 | |
| 69 | ||
| 66 | 70 | #endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H |
lib/libcxx/include/__pstl/cpu_algos/find_if.h+4-1| ... | ... | @@ -21,7 +21,6 @@ |
| 21 | 21 | #include <__type_traits/is_execution_policy.h> |
| 22 | 22 | #include <__utility/move.h> |
| 23 | 23 | #include <__utility/pair.h> |
| 24 | #include <cstddef> | |
| 25 | 24 | #include <optional> |
| 26 | 25 | |
| 27 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -31,6 +30,8 @@ |
| 31 | 30 | _LIBCPP_PUSH_MACROS |
| 32 | 31 | #include <__undef_macros> |
| 33 | 32 | |
| 33 | #if _LIBCPP_STD_VER >= 17 | |
| 34 | ||
| 34 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 36 | namespace __pstl { |
| 36 | 37 | |
| ... | ... | @@ -132,6 +133,8 @@ struct __cpu_parallel_find_if { |
| 132 | 133 | } // namespace __pstl |
| 133 | 134 | _LIBCPP_END_NAMESPACE_STD |
| 134 | 135 | |
| 136 | #endif // _LIBCPP_STD_VER >= 17 | |
| 137 | ||
| 135 | 138 | _LIBCPP_POP_MACROS |
| 136 | 139 | |
| 137 | 140 | #endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H |
lib/libcxx/include/__pstl/cpu_algos/for_each.h+4| ... | ... | @@ -23,6 +23,8 @@ |
| 23 | 23 | # pragma GCC system_header |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | #if _LIBCPP_STD_VER >= 17 | |
| 27 | ||
| 26 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 29 | namespace __pstl { |
| 28 | 30 | |
| ... | ... | @@ -63,4 +65,6 @@ struct __cpu_parallel_for_each { |
| 63 | 65 | } // namespace __pstl |
| 64 | 66 | _LIBCPP_END_NAMESPACE_STD |
| 65 | 67 | |
| 68 | #endif // _LIBCPP_STD_VER >= 17 | |
| 69 | ||
| 66 | 70 | #endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H |
lib/libcxx/include/__pstl/cpu_algos/merge.h+4| ... | ... | @@ -26,6 +26,8 @@ |
| 26 | 26 | _LIBCPP_PUSH_MACROS |
| 27 | 27 | #include <__undef_macros> |
| 28 | 28 | |
| 29 | #if _LIBCPP_STD_VER >= 17 | |
| 30 | ||
| 29 | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 32 | namespace __pstl { |
| 31 | 33 | |
| ... | ... | @@ -80,6 +82,8 @@ struct __cpu_parallel_merge { |
| 80 | 82 | } // namespace __pstl |
| 81 | 83 | _LIBCPP_END_NAMESPACE_STD |
| 82 | 84 | |
| 85 | #endif // _LIBCPP_STD_VER >= 17 | |
| 86 | ||
| 83 | 87 | _LIBCPP_POP_MACROS |
| 84 | 88 | |
| 85 | 89 | #endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H |
lib/libcxx/include/__pstl/cpu_algos/stable_sort.h+4| ... | ... | @@ -21,6 +21,8 @@ |
| 21 | 21 | # pragma GCC system_header |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | #if _LIBCPP_STD_VER >= 17 | |
| 25 | ||
| 24 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 27 | namespace __pstl { |
| 26 | 28 | |
| ... | ... | @@ -44,4 +46,6 @@ struct __cpu_parallel_stable_sort { |
| 44 | 46 | } // namespace __pstl |
| 45 | 47 | _LIBCPP_END_NAMESPACE_STD |
| 46 | 48 | |
| 49 | #endif // _LIBCPP_STD_VER >= 17 | |
| 50 | ||
| 47 | 51 | #endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H |
lib/libcxx/include/__pstl/cpu_algos/transform.h+4| ... | ... | @@ -27,6 +27,8 @@ |
| 27 | 27 | _LIBCPP_PUSH_MACROS |
| 28 | 28 | #include <__undef_macros> |
| 29 | 29 | |
| 30 | #if _LIBCPP_STD_VER >= 17 | |
| 31 | ||
| 30 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 33 | namespace __pstl { |
| 32 | 34 | |
| ... | ... | @@ -148,6 +150,8 @@ struct __cpu_parallel_transform_binary { |
| 148 | 150 | } // namespace __pstl |
| 149 | 151 | _LIBCPP_END_NAMESPACE_STD |
| 150 | 152 | |
| 153 | #endif // _LIBCPP_STD_VER >= 17 | |
| 154 | ||
| 151 | 155 | _LIBCPP_POP_MACROS |
| 152 | 156 | |
| 153 | 157 | #endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H |
lib/libcxx/include/__pstl/cpu_algos/transform_reduce.h+4-2| ... | ... | @@ -20,8 +20,6 @@ |
| 20 | 20 | #include <__type_traits/is_arithmetic.h> |
| 21 | 21 | #include <__type_traits/is_execution_policy.h> |
| 22 | 22 | #include <__utility/move.h> |
| 23 | #include <cstddef> | |
| 24 | #include <new> | |
| 25 | 23 | #include <optional> |
| 26 | 24 | |
| 27 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -31,6 +29,8 @@ |
| 31 | 29 | _LIBCPP_PUSH_MACROS |
| 32 | 30 | #include <__undef_macros> |
| 33 | 31 | |
| 32 | #if _LIBCPP_STD_VER >= 17 | |
| 33 | ||
| 34 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 35 | namespace __pstl { |
| 36 | 36 | |
| ... | ... | @@ -211,6 +211,8 @@ struct __cpu_parallel_transform_reduce { |
| 211 | 211 | } // namespace __pstl |
| 212 | 212 | _LIBCPP_END_NAMESPACE_STD |
| 213 | 213 | |
| 214 | #endif // _LIBCPP_STD_VER >= 17 | |
| 215 | ||
| 214 | 216 | _LIBCPP_POP_MACROS |
| 215 | 217 | |
| 216 | 218 | #endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H |
lib/libcxx/include/__pstl/dispatch.h+6-1| ... | ... | @@ -23,6 +23,8 @@ |
| 23 | 23 | _LIBCPP_PUSH_MACROS |
| 24 | 24 | #include <__undef_macros> |
| 25 | 25 | |
| 26 | #if _LIBCPP_STD_VER >= 17 | |
| 27 | ||
| 26 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 29 | namespace __pstl { |
| 28 | 30 | |
| ... | ... | @@ -56,11 +58,14 @@ struct __find_first_implemented<_Algorithm, __backend_configuration<_B1, _Bn...> |
| 56 | 58 | __find_first_implemented<_Algorithm, __backend_configuration<_Bn...>, _ExecutionPolicy> > {}; |
| 57 | 59 | |
| 58 | 60 | template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy> |
| 59 | using __dispatch = typename __find_first_implemented<_Algorithm, _BackendConfiguration, _ExecutionPolicy>::type; | |
| 61 | using __dispatch _LIBCPP_NODEBUG = | |
| 62 | typename __find_first_implemented<_Algorithm, _BackendConfiguration, _ExecutionPolicy>::type; | |
| 60 | 63 | |
| 61 | 64 | } // namespace __pstl |
| 62 | 65 | _LIBCPP_END_NAMESPACE_STD |
| 63 | 66 | |
| 67 | #endif // _LIBCPP_STD_VER >= 17 | |
| 68 | ||
| 64 | 69 | _LIBCPP_POP_MACROS |
| 65 | 70 | |
| 66 | 71 | #endif // _LIBCPP___PSTL_DISPATCH_H |
lib/libcxx/include/__pstl/handle_exception.h+5-1| ... | ... | @@ -10,9 +10,9 @@ |
| 10 | 10 | #define _LIBCPP___PSTL_HANDLE_EXCEPTION_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__new/exceptions.h> | |
| 13 | 14 | #include <__utility/forward.h> |
| 14 | 15 | #include <__utility/move.h> |
| 15 | #include <new> // __throw_bad_alloc | |
| 16 | 16 | #include <optional> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -22,6 +22,8 @@ |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
| 23 | 23 | #include <__undef_macros> |
| 24 | 24 | |
| 25 | #if _LIBCPP_STD_VER >= 17 | |
| 26 | ||
| 25 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 28 | namespace __pstl { |
| 27 | 29 | |
| ... | ... | @@ -52,6 +54,8 @@ _LIBCPP_HIDE_FROM_ABI auto __handle_exception(_Args&&... __args) { |
| 52 | 54 | } // namespace __pstl |
| 53 | 55 | _LIBCPP_END_NAMESPACE_STD |
| 54 | 56 | |
| 57 | #endif // _LIBCPP_STD_VER >= 17 | |
| 58 | ||
| 55 | 59 | _LIBCPP_POP_MACROS |
| 56 | 60 | |
| 57 | 61 | #endif // _LIBCPP___PSTL_HANDLE_EXCEPTION_H |
lib/libcxx/include/__random/binomial_distribution.h+3-2| ... | ... | @@ -97,12 +97,13 @@ public: |
| 97 | 97 | } |
| 98 | 98 | }; |
| 99 | 99 | |
| 100 | #ifndef _LIBCPP_MSVCRT_LIKE | |
| 100 | // The LLVM C library provides this with conflicting `noexcept` attributes. | |
| 101 | #if !defined(_LIBCPP_MSVCRT_LIKE) && !defined(__LLVM_LIBC__) | |
| 101 | 102 | extern "C" double lgamma_r(double, int*); |
| 102 | 103 | #endif |
| 103 | 104 | |
| 104 | 105 | inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) { |
| 105 | #if defined(_LIBCPP_MSVCRT_LIKE) | |
| 106 | #if defined(_LIBCPP_MSVCRT_LIKE) || defined(__LLVM_LIBC__) | |
| 106 | 107 | return lgamma(__d); |
| 107 | 108 | #else |
| 108 | 109 | int __sign; |
lib/libcxx/include/__random/discard_block_engine.h+3-9| ... | ... | @@ -10,11 +10,11 @@ |
| 10 | 10 | #define _LIBCPP___RANDOM_DISCARD_BLOCK_ENGINE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__random/is_seed_sequence.h> |
| 14 | 15 | #include <__type_traits/enable_if.h> |
| 15 | 16 | #include <__type_traits/is_convertible.h> |
| 16 | 17 | #include <__utility/move.h> |
| 17 | #include <cstddef> | |
| 18 | 18 | #include <iosfwd> |
| 19 | 19 | #include <limits> |
| 20 | 20 | |
| ... | ... | @@ -43,8 +43,8 @@ public: |
| 43 | 43 | typedef typename _Engine::result_type result_type; |
| 44 | 44 | |
| 45 | 45 | // engine characteristics |
| 46 | static _LIBCPP_CONSTEXPR const size_t block_size = __p; | |
| 47 | static _LIBCPP_CONSTEXPR const size_t used_block = __r; | |
| 46 | static inline _LIBCPP_CONSTEXPR const size_t block_size = __p; | |
| 47 | static inline _LIBCPP_CONSTEXPR const size_t used_block = __r; | |
| 48 | 48 | |
| 49 | 49 | #ifdef _LIBCPP_CXX03_LANG |
| 50 | 50 | static const result_type _Min = _Engine::_Min; |
| ... | ... | @@ -110,12 +110,6 @@ public: |
| 110 | 110 | operator>>(basic_istream<_CharT, _Traits>& __is, discard_block_engine<_Eng, _Pp, _Rp>& __x); |
| 111 | 111 | }; |
| 112 | 112 | |
| 113 | template <class _Engine, size_t __p, size_t __r> | |
| 114 | _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::block_size; | |
| 115 | ||
| 116 | template <class _Engine, size_t __p, size_t __r> | |
| 117 | _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::used_block; | |
| 118 | ||
| 119 | 113 | template <class _Engine, size_t __p, size_t __r> |
| 120 | 114 | typename discard_block_engine<_Engine, __p, __r>::result_type discard_block_engine<_Engine, __p, __r>::operator()() { |
| 121 | 115 | if (__n_ >= static_cast<int>(__r)) { |
lib/libcxx/include/__random/discrete_distribution.h+2-2| ... | ... | @@ -13,10 +13,10 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__random/is_valid.h> |
| 15 | 15 | #include <__random/uniform_real_distribution.h> |
| 16 | #include <cstddef> | |
| 16 | #include <__vector/vector.h> | |
| 17 | #include <initializer_list> | |
| 17 | 18 | #include <iosfwd> |
| 18 | 19 | #include <numeric> |
| 19 | #include <vector> | |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 22 | # pragma GCC system_header |
lib/libcxx/include/__random/independent_bits_engine.h+1-1| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___RANDOM_INDEPENDENT_BITS_ENGINE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__fwd/istream.h> |
| 14 | 15 | #include <__fwd/ostream.h> |
| 15 | 16 | #include <__random/is_seed_sequence.h> |
| ... | ... | @@ -18,7 +19,6 @@ |
| 18 | 19 | #include <__type_traits/enable_if.h> |
| 19 | 20 | #include <__type_traits/is_convertible.h> |
| 20 | 21 | #include <__utility/move.h> |
| 21 | #include <cstddef> | |
| 22 | 22 | #include <limits> |
| 23 | 23 | |
| 24 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__random/is_valid.h+2-2| ... | ... | @@ -66,12 +66,12 @@ struct __libcpp_random_is_valid_inttype<unsigned long> : true_type {}; |
| 66 | 66 | template <> |
| 67 | 67 | struct __libcpp_random_is_valid_inttype<unsigned long long> : true_type {}; |
| 68 | 68 | |
| 69 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 69 | #if _LIBCPP_HAS_INT128 | |
| 70 | 70 | template <> |
| 71 | 71 | struct __libcpp_random_is_valid_inttype<__int128_t> : true_type {}; // extension |
| 72 | 72 | template <> |
| 73 | 73 | struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {}; // extension |
| 74 | #endif // _LIBCPP_HAS_NO_INT128 | |
| 74 | #endif // _LIBCPP_HAS_INT128 | |
| 75 | 75 | |
| 76 | 76 | // [rand.req.urng]/3: |
| 77 | 77 | // A class G meets the uniform random bit generator requirements if G models |
lib/libcxx/include/__random/linear_congruential_engine.h+6-22| ... | ... | @@ -48,7 +48,7 @@ struct __lce_alg_picker { |
| 48 | 48 | : _Schrage ? _LCE_Schrage |
| 49 | 49 | : _LCE_Promote; |
| 50 | 50 | |
| 51 | #ifdef _LIBCPP_HAS_NO_INT128 | |
| 51 | #if !_LIBCPP_HAS_INT128 | |
| 52 | 52 | static_assert(_Mp != (unsigned long long)(-1) || _Full || _Part || _Schrage, |
| 53 | 53 | "The current values for a, c, and m are not currently supported on platforms without __int128"); |
| 54 | 54 | #endif |
| ... | ... | @@ -63,7 +63,7 @@ struct __lce_ta; |
| 63 | 63 | |
| 64 | 64 | // 64 |
| 65 | 65 | |
| 66 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 66 | #if _LIBCPP_HAS_INT128 | |
| 67 | 67 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> |
| 68 | 68 | struct __lce_ta<_Ap, _Cp, _Mp, (unsigned long long)(-1), _LCE_Promote> { |
| 69 | 69 | typedef unsigned long long result_type; |
| ... | ... | @@ -251,12 +251,12 @@ public: |
| 251 | 251 | static_assert(_Min < _Max, "linear_congruential_engine invalid parameters"); |
| 252 | 252 | |
| 253 | 253 | // engine characteristics |
| 254 | static _LIBCPP_CONSTEXPR const result_type multiplier = __a; | |
| 255 | static _LIBCPP_CONSTEXPR const result_type increment = __c; | |
| 256 | static _LIBCPP_CONSTEXPR const result_type modulus = __m; | |
| 254 | static inline _LIBCPP_CONSTEXPR const result_type multiplier = __a; | |
| 255 | static inline _LIBCPP_CONSTEXPR const result_type increment = __c; | |
| 256 | static inline _LIBCPP_CONSTEXPR const result_type modulus = __m; | |
| 257 | 257 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; } |
| 258 | 258 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; } |
| 259 | static _LIBCPP_CONSTEXPR const result_type default_seed = 1u; | |
| 259 | static inline _LIBCPP_CONSTEXPR const result_type default_seed = 1u; | |
| 260 | 260 | |
| 261 | 261 | // constructors and seeding functions |
| 262 | 262 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -318,22 +318,6 @@ private: |
| 318 | 318 | operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); |
| 319 | 319 | }; |
| 320 | 320 | |
| 321 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 322 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 323 | linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier; | |
| 324 | ||
| 325 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 326 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 327 | linear_congruential_engine<_UIntType, __a, __c, __m>::increment; | |
| 328 | ||
| 329 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 330 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 331 | linear_congruential_engine<_UIntType, __a, __c, __m>::modulus; | |
| 332 | ||
| 333 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 334 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 335 | linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed; | |
| 336 | ||
| 337 | 321 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> |
| 338 | 322 | template <class _Sseq> |
| 339 | 323 | void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, integral_constant<unsigned, 1>) { |
lib/libcxx/include/__random/log2.h+5-5| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___RANDOM_LOG2_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/conditional.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
| ... | ... | @@ -38,7 +38,7 @@ struct __log2_imp<unsigned long long, 0, _Rp> { |
| 38 | 38 | static const size_t value = _Rp + 1; |
| 39 | 39 | }; |
| 40 | 40 | |
| 41 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 41 | #if _LIBCPP_HAS_INT128 | |
| 42 | 42 | |
| 43 | 43 | template <__uint128_t _Xp, size_t _Rp> |
| 44 | 44 | struct __log2_imp<__uint128_t, _Xp, _Rp> { |
| ... | ... | @@ -47,16 +47,16 @@ struct __log2_imp<__uint128_t, _Xp, _Rp> { |
| 47 | 47 | : __log2_imp<unsigned long long, _Xp, 63>::value; |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | #endif // _LIBCPP_HAS_NO_INT128 | |
| 50 | #endif // _LIBCPP_HAS_INT128 | |
| 51 | 51 | |
| 52 | 52 | template <class _UIntType, _UIntType _Xp> |
| 53 | 53 | struct __log2 { |
| 54 | 54 | static const size_t value = __log2_imp< |
| 55 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 55 | #if _LIBCPP_HAS_INT128 | |
| 56 | 56 | __conditional_t<sizeof(_UIntType) <= sizeof(unsigned long long), unsigned long long, __uint128_t>, |
| 57 | 57 | #else |
| 58 | 58 | unsigned long long, |
| 59 | #endif // _LIBCPP_HAS_NO_INT128 | |
| 59 | #endif // _LIBCPP_HAS_INT128 | |
| 60 | 60 | _Xp, |
| 61 | 61 | sizeof(_UIntType) * __CHAR_BIT__ - 1>::value; |
| 62 | 62 | }; |
lib/libcxx/include/__random/mersenne_twister_engine.h+16-338| ... | ... | @@ -12,8 +12,9 @@ |
| 12 | 12 | #include <__algorithm/equal.h> |
| 13 | 13 | #include <__algorithm/min.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/size_t.h> | |
| 15 | 16 | #include <__random/is_seed_sequence.h> |
| 16 | #include <cstddef> | |
| 17 | #include <__type_traits/enable_if.h> | |
| 17 | 18 | #include <cstdint> |
| 18 | 19 | #include <iosfwd> |
| 19 | 20 | #include <limits> |
| ... | ... | @@ -165,22 +166,22 @@ public: |
| 165 | 166 | static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters"); |
| 166 | 167 | |
| 167 | 168 | // engine characteristics |
| 168 | static _LIBCPP_CONSTEXPR const size_t word_size = __w; | |
| 169 | static _LIBCPP_CONSTEXPR const size_t state_size = __n; | |
| 170 | static _LIBCPP_CONSTEXPR const size_t shift_size = __m; | |
| 171 | static _LIBCPP_CONSTEXPR const size_t mask_bits = __r; | |
| 172 | static _LIBCPP_CONSTEXPR const result_type xor_mask = __a; | |
| 173 | static _LIBCPP_CONSTEXPR const size_t tempering_u = __u; | |
| 174 | static _LIBCPP_CONSTEXPR const result_type tempering_d = __d; | |
| 175 | static _LIBCPP_CONSTEXPR const size_t tempering_s = __s; | |
| 176 | static _LIBCPP_CONSTEXPR const result_type tempering_b = __b; | |
| 177 | static _LIBCPP_CONSTEXPR const size_t tempering_t = __t; | |
| 178 | static _LIBCPP_CONSTEXPR const result_type tempering_c = __c; | |
| 179 | static _LIBCPP_CONSTEXPR const size_t tempering_l = __l; | |
| 180 | static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f; | |
| 169 | static inline _LIBCPP_CONSTEXPR const size_t word_size = __w; | |
| 170 | static inline _LIBCPP_CONSTEXPR const size_t state_size = __n; | |
| 171 | static inline _LIBCPP_CONSTEXPR const size_t shift_size = __m; | |
| 172 | static inline _LIBCPP_CONSTEXPR const size_t mask_bits = __r; | |
| 173 | static inline _LIBCPP_CONSTEXPR const result_type xor_mask = __a; | |
| 174 | static inline _LIBCPP_CONSTEXPR const size_t tempering_u = __u; | |
| 175 | static inline _LIBCPP_CONSTEXPR const result_type tempering_d = __d; | |
| 176 | static inline _LIBCPP_CONSTEXPR const size_t tempering_s = __s; | |
| 177 | static inline _LIBCPP_CONSTEXPR const result_type tempering_b = __b; | |
| 178 | static inline _LIBCPP_CONSTEXPR const size_t tempering_t = __t; | |
| 179 | static inline _LIBCPP_CONSTEXPR const result_type tempering_c = __c; | |
| 180 | static inline _LIBCPP_CONSTEXPR const size_t tempering_l = __l; | |
| 181 | static inline _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f; | |
| 181 | 182 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; } |
| 182 | 183 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; } |
| 183 | static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u; | |
| 184 | static inline _LIBCPP_CONSTEXPR const result_type default_seed = 5489u; | |
| 184 | 185 | |
| 185 | 186 | // constructors and seeding functions |
| 186 | 187 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -309,329 +310,6 @@ private: |
| 309 | 310 | } |
| 310 | 311 | }; |
| 311 | 312 | |
| 312 | template <class _UIntType, | |
| 313 | size_t __w, | |
| 314 | size_t __n, | |
| 315 | size_t __m, | |
| 316 | size_t __r, | |
| 317 | _UIntType __a, | |
| 318 | size_t __u, | |
| 319 | _UIntType __d, | |
| 320 | size_t __s, | |
| 321 | _UIntType __b, | |
| 322 | size_t __t, | |
| 323 | _UIntType __c, | |
| 324 | size_t __l, | |
| 325 | _UIntType __f> | |
| 326 | _LIBCPP_CONSTEXPR const size_t | |
| 327 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size; | |
| 328 | ||
| 329 | template <class _UIntType, | |
| 330 | size_t __w, | |
| 331 | size_t __n, | |
| 332 | size_t __m, | |
| 333 | size_t __r, | |
| 334 | _UIntType __a, | |
| 335 | size_t __u, | |
| 336 | _UIntType __d, | |
| 337 | size_t __s, | |
| 338 | _UIntType __b, | |
| 339 | size_t __t, | |
| 340 | _UIntType __c, | |
| 341 | size_t __l, | |
| 342 | _UIntType __f> | |
| 343 | _LIBCPP_CONSTEXPR const size_t | |
| 344 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size; | |
| 345 | ||
| 346 | template <class _UIntType, | |
| 347 | size_t __w, | |
| 348 | size_t __n, | |
| 349 | size_t __m, | |
| 350 | size_t __r, | |
| 351 | _UIntType __a, | |
| 352 | size_t __u, | |
| 353 | _UIntType __d, | |
| 354 | size_t __s, | |
| 355 | _UIntType __b, | |
| 356 | size_t __t, | |
| 357 | _UIntType __c, | |
| 358 | size_t __l, | |
| 359 | _UIntType __f> | |
| 360 | _LIBCPP_CONSTEXPR const size_t | |
| 361 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size; | |
| 362 | ||
| 363 | template <class _UIntType, | |
| 364 | size_t __w, | |
| 365 | size_t __n, | |
| 366 | size_t __m, | |
| 367 | size_t __r, | |
| 368 | _UIntType __a, | |
| 369 | size_t __u, | |
| 370 | _UIntType __d, | |
| 371 | size_t __s, | |
| 372 | _UIntType __b, | |
| 373 | size_t __t, | |
| 374 | _UIntType __c, | |
| 375 | size_t __l, | |
| 376 | _UIntType __f> | |
| 377 | _LIBCPP_CONSTEXPR const size_t | |
| 378 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits; | |
| 379 | ||
| 380 | template <class _UIntType, | |
| 381 | size_t __w, | |
| 382 | size_t __n, | |
| 383 | size_t __m, | |
| 384 | size_t __r, | |
| 385 | _UIntType __a, | |
| 386 | size_t __u, | |
| 387 | _UIntType __d, | |
| 388 | size_t __s, | |
| 389 | _UIntType __b, | |
| 390 | size_t __t, | |
| 391 | _UIntType __c, | |
| 392 | size_t __l, | |
| 393 | _UIntType __f> | |
| 394 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine< | |
| 395 | _UIntType, | |
| 396 | __w, | |
| 397 | __n, | |
| 398 | __m, | |
| 399 | __r, | |
| 400 | __a, | |
| 401 | __u, | |
| 402 | __d, | |
| 403 | __s, | |
| 404 | __b, | |
| 405 | __t, | |
| 406 | __c, | |
| 407 | __l, | |
| 408 | __f>::result_type | |
| 409 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask; | |
| 410 | ||
| 411 | template <class _UIntType, | |
| 412 | size_t __w, | |
| 413 | size_t __n, | |
| 414 | size_t __m, | |
| 415 | size_t __r, | |
| 416 | _UIntType __a, | |
| 417 | size_t __u, | |
| 418 | _UIntType __d, | |
| 419 | size_t __s, | |
| 420 | _UIntType __b, | |
| 421 | size_t __t, | |
| 422 | _UIntType __c, | |
| 423 | size_t __l, | |
| 424 | _UIntType __f> | |
| 425 | _LIBCPP_CONSTEXPR const size_t | |
| 426 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u; | |
| 427 | ||
| 428 | template <class _UIntType, | |
| 429 | size_t __w, | |
| 430 | size_t __n, | |
| 431 | size_t __m, | |
| 432 | size_t __r, | |
| 433 | _UIntType __a, | |
| 434 | size_t __u, | |
| 435 | _UIntType __d, | |
| 436 | size_t __s, | |
| 437 | _UIntType __b, | |
| 438 | size_t __t, | |
| 439 | _UIntType __c, | |
| 440 | size_t __l, | |
| 441 | _UIntType __f> | |
| 442 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine< | |
| 443 | _UIntType, | |
| 444 | __w, | |
| 445 | __n, | |
| 446 | __m, | |
| 447 | __r, | |
| 448 | __a, | |
| 449 | __u, | |
| 450 | __d, | |
| 451 | __s, | |
| 452 | __b, | |
| 453 | __t, | |
| 454 | __c, | |
| 455 | __l, | |
| 456 | __f>::result_type | |
| 457 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d; | |
| 458 | ||
| 459 | template <class _UIntType, | |
| 460 | size_t __w, | |
| 461 | size_t __n, | |
| 462 | size_t __m, | |
| 463 | size_t __r, | |
| 464 | _UIntType __a, | |
| 465 | size_t __u, | |
| 466 | _UIntType __d, | |
| 467 | size_t __s, | |
| 468 | _UIntType __b, | |
| 469 | size_t __t, | |
| 470 | _UIntType __c, | |
| 471 | size_t __l, | |
| 472 | _UIntType __f> | |
| 473 | _LIBCPP_CONSTEXPR const size_t | |
| 474 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s; | |
| 475 | ||
| 476 | template <class _UIntType, | |
| 477 | size_t __w, | |
| 478 | size_t __n, | |
| 479 | size_t __m, | |
| 480 | size_t __r, | |
| 481 | _UIntType __a, | |
| 482 | size_t __u, | |
| 483 | _UIntType __d, | |
| 484 | size_t __s, | |
| 485 | _UIntType __b, | |
| 486 | size_t __t, | |
| 487 | _UIntType __c, | |
| 488 | size_t __l, | |
| 489 | _UIntType __f> | |
| 490 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine< | |
| 491 | _UIntType, | |
| 492 | __w, | |
| 493 | __n, | |
| 494 | __m, | |
| 495 | __r, | |
| 496 | __a, | |
| 497 | __u, | |
| 498 | __d, | |
| 499 | __s, | |
| 500 | __b, | |
| 501 | __t, | |
| 502 | __c, | |
| 503 | __l, | |
| 504 | __f>::result_type | |
| 505 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b; | |
| 506 | ||
| 507 | template <class _UIntType, | |
| 508 | size_t __w, | |
| 509 | size_t __n, | |
| 510 | size_t __m, | |
| 511 | size_t __r, | |
| 512 | _UIntType __a, | |
| 513 | size_t __u, | |
| 514 | _UIntType __d, | |
| 515 | size_t __s, | |
| 516 | _UIntType __b, | |
| 517 | size_t __t, | |
| 518 | _UIntType __c, | |
| 519 | size_t __l, | |
| 520 | _UIntType __f> | |
| 521 | _LIBCPP_CONSTEXPR const size_t | |
| 522 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t; | |
| 523 | ||
| 524 | template <class _UIntType, | |
| 525 | size_t __w, | |
| 526 | size_t __n, | |
| 527 | size_t __m, | |
| 528 | size_t __r, | |
| 529 | _UIntType __a, | |
| 530 | size_t __u, | |
| 531 | _UIntType __d, | |
| 532 | size_t __s, | |
| 533 | _UIntType __b, | |
| 534 | size_t __t, | |
| 535 | _UIntType __c, | |
| 536 | size_t __l, | |
| 537 | _UIntType __f> | |
| 538 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine< | |
| 539 | _UIntType, | |
| 540 | __w, | |
| 541 | __n, | |
| 542 | __m, | |
| 543 | __r, | |
| 544 | __a, | |
| 545 | __u, | |
| 546 | __d, | |
| 547 | __s, | |
| 548 | __b, | |
| 549 | __t, | |
| 550 | __c, | |
| 551 | __l, | |
| 552 | __f>::result_type | |
| 553 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c; | |
| 554 | ||
| 555 | template <class _UIntType, | |
| 556 | size_t __w, | |
| 557 | size_t __n, | |
| 558 | size_t __m, | |
| 559 | size_t __r, | |
| 560 | _UIntType __a, | |
| 561 | size_t __u, | |
| 562 | _UIntType __d, | |
| 563 | size_t __s, | |
| 564 | _UIntType __b, | |
| 565 | size_t __t, | |
| 566 | _UIntType __c, | |
| 567 | size_t __l, | |
| 568 | _UIntType __f> | |
| 569 | _LIBCPP_CONSTEXPR const size_t | |
| 570 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l; | |
| 571 | ||
| 572 | template <class _UIntType, | |
| 573 | size_t __w, | |
| 574 | size_t __n, | |
| 575 | size_t __m, | |
| 576 | size_t __r, | |
| 577 | _UIntType __a, | |
| 578 | size_t __u, | |
| 579 | _UIntType __d, | |
| 580 | size_t __s, | |
| 581 | _UIntType __b, | |
| 582 | size_t __t, | |
| 583 | _UIntType __c, | |
| 584 | size_t __l, | |
| 585 | _UIntType __f> | |
| 586 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine< | |
| 587 | _UIntType, | |
| 588 | __w, | |
| 589 | __n, | |
| 590 | __m, | |
| 591 | __r, | |
| 592 | __a, | |
| 593 | __u, | |
| 594 | __d, | |
| 595 | __s, | |
| 596 | __b, | |
| 597 | __t, | |
| 598 | __c, | |
| 599 | __l, | |
| 600 | __f>::result_type | |
| 601 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>:: | |
| 602 | initialization_multiplier; | |
| 603 | ||
| 604 | template <class _UIntType, | |
| 605 | size_t __w, | |
| 606 | size_t __n, | |
| 607 | size_t __m, | |
| 608 | size_t __r, | |
| 609 | _UIntType __a, | |
| 610 | size_t __u, | |
| 611 | _UIntType __d, | |
| 612 | size_t __s, | |
| 613 | _UIntType __b, | |
| 614 | size_t __t, | |
| 615 | _UIntType __c, | |
| 616 | size_t __l, | |
| 617 | _UIntType __f> | |
| 618 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine< | |
| 619 | _UIntType, | |
| 620 | __w, | |
| 621 | __n, | |
| 622 | __m, | |
| 623 | __r, | |
| 624 | __a, | |
| 625 | __u, | |
| 626 | __d, | |
| 627 | __s, | |
| 628 | __b, | |
| 629 | __t, | |
| 630 | __c, | |
| 631 | __l, | |
| 632 | __f>::result_type | |
| 633 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed; | |
| 634 | ||
| 635 | 313 | template <class _UIntType, |
| 636 | 314 | size_t __w, |
| 637 | 315 | size_t __n, |
lib/libcxx/include/__random/piecewise_constant_distribution.h+3-1| ... | ... | @@ -11,11 +11,13 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/upper_bound.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__random/is_valid.h> |
| 15 | 16 | #include <__random/uniform_real_distribution.h> |
| 17 | #include <__vector/vector.h> | |
| 18 | #include <initializer_list> | |
| 16 | 19 | #include <iosfwd> |
| 17 | 20 | #include <numeric> |
| 18 | #include <vector> | |
| 19 | 21 | |
| 20 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | 23 | # pragma GCC system_header |
lib/libcxx/include/__random/piecewise_linear_distribution.h+4-1| ... | ... | @@ -11,11 +11,14 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/upper_bound.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/ptrdiff_t.h> | |
| 14 | 15 | #include <__random/is_valid.h> |
| 15 | 16 | #include <__random/uniform_real_distribution.h> |
| 17 | #include <__vector/comparison.h> | |
| 18 | #include <__vector/vector.h> | |
| 16 | 19 | #include <cmath> |
| 20 | #include <initializer_list> | |
| 17 | 21 | #include <iosfwd> |
| 18 | #include <vector> | |
| 19 | 22 | |
| 20 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | 24 | # pragma GCC system_header |
lib/libcxx/include/__random/random_device.h+2-2| ... | ... | @@ -21,7 +21,7 @@ _LIBCPP_PUSH_MACROS |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | #if !defined(_LIBCPP_HAS_NO_RANDOM_DEVICE) | |
| 24 | #if _LIBCPP_HAS_RANDOM_DEVICE | |
| 25 | 25 | |
| 26 | 26 | class _LIBCPP_EXPORTED_FROM_ABI random_device { |
| 27 | 27 | # ifdef _LIBCPP_USING_DEV_RANDOM |
| ... | ... | @@ -72,7 +72,7 @@ public: |
| 72 | 72 | void operator=(const random_device&) = delete; |
| 73 | 73 | }; |
| 74 | 74 | |
| 75 | #endif // !_LIBCPP_HAS_NO_RANDOM_DEVICE | |
| 75 | #endif // _LIBCPP_HAS_RANDOM_DEVICE | |
| 76 | 76 | |
| 77 | 77 | _LIBCPP_END_NAMESPACE_STD |
| 78 | 78 |
lib/libcxx/include/__random/seed_seq.h+3-1| ... | ... | @@ -14,10 +14,12 @@ |
| 14 | 14 | #include <__algorithm/max.h> |
| 15 | 15 | #include <__config> |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__type_traits/enable_if.h> | |
| 18 | #include <__type_traits/is_integral.h> | |
| 17 | 19 | #include <__type_traits/is_unsigned.h> |
| 20 | #include <__vector/vector.h> | |
| 18 | 21 | #include <cstdint> |
| 19 | 22 | #include <initializer_list> |
| 20 | #include <vector> | |
| 21 | 23 | |
| 22 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | 25 | # pragma GCC system_header |
lib/libcxx/include/__random/shuffle_order_engine.h+2-5| ... | ... | @@ -11,12 +11,12 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/equal.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/size_t.h> | |
| 14 | 15 | #include <__random/is_seed_sequence.h> |
| 15 | 16 | #include <__type_traits/enable_if.h> |
| 16 | 17 | #include <__type_traits/integral_constant.h> |
| 17 | 18 | #include <__type_traits/is_convertible.h> |
| 18 | 19 | #include <__utility/move.h> |
| 19 | #include <cstddef> | |
| 20 | 20 | #include <cstdint> |
| 21 | 21 | #include <iosfwd> |
| 22 | 22 | |
| ... | ... | @@ -66,7 +66,7 @@ private: |
| 66 | 66 | |
| 67 | 67 | public: |
| 68 | 68 | // engine characteristics |
| 69 | static _LIBCPP_CONSTEXPR const size_t table_size = __k; | |
| 69 | static inline _LIBCPP_CONSTEXPR const size_t table_size = __k; | |
| 70 | 70 | |
| 71 | 71 | #ifdef _LIBCPP_CXX03_LANG |
| 72 | 72 | static const result_type _Min = _Engine::_Min; |
| ... | ... | @@ -173,9 +173,6 @@ private: |
| 173 | 173 | } |
| 174 | 174 | }; |
| 175 | 175 | |
| 176 | template <class _Engine, size_t __k> | |
| 177 | _LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size; | |
| 178 | ||
| 179 | 176 | template <class _Eng, size_t _Kp> |
| 180 | 177 | _LIBCPP_HIDE_FROM_ABI bool |
| 181 | 178 | operator==(const shuffle_order_engine<_Eng, _Kp>& __x, const shuffle_order_engine<_Eng, _Kp>& __y) { |
lib/libcxx/include/__random/subtract_with_carry_engine.h+6-18| ... | ... | @@ -12,9 +12,10 @@ |
| 12 | 12 | #include <__algorithm/equal.h> |
| 13 | 13 | #include <__algorithm/min.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/size_t.h> | |
| 15 | 16 | #include <__random/is_seed_sequence.h> |
| 16 | 17 | #include <__random/linear_congruential_engine.h> |
| 17 | #include <cstddef> | |
| 18 | #include <__type_traits/enable_if.h> | |
| 18 | 19 | #include <cstdint> |
| 19 | 20 | #include <iosfwd> |
| 20 | 21 | #include <limits> |
| ... | ... | @@ -71,12 +72,12 @@ public: |
| 71 | 72 | static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters"); |
| 72 | 73 | |
| 73 | 74 | // engine characteristics |
| 74 | static _LIBCPP_CONSTEXPR const size_t word_size = __w; | |
| 75 | static _LIBCPP_CONSTEXPR const size_t short_lag = __s; | |
| 76 | static _LIBCPP_CONSTEXPR const size_t long_lag = __r; | |
| 75 | static inline _LIBCPP_CONSTEXPR const size_t word_size = __w; | |
| 76 | static inline _LIBCPP_CONSTEXPR const size_t short_lag = __s; | |
| 77 | static inline _LIBCPP_CONSTEXPR const size_t long_lag = __r; | |
| 77 | 78 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; } |
| 78 | 79 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; } |
| 79 | static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u; | |
| 80 | static inline _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u; | |
| 80 | 81 | |
| 81 | 82 | // constructors and seeding functions |
| 82 | 83 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -129,19 +130,6 @@ private: |
| 129 | 130 | _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>); |
| 130 | 131 | }; |
| 131 | 132 | |
| 132 | template <class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 133 | _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size; | |
| 134 | ||
| 135 | template <class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 136 | _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag; | |
| 137 | ||
| 138 | template <class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 139 | _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag; | |
| 140 | ||
| 141 | template <class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 142 | _LIBCPP_CONSTEXPR const typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::result_type | |
| 143 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed; | |
| 144 | ||
| 145 | 133 | template <class _UIntType, size_t __w, size_t __s, size_t __r> |
| 146 | 134 | void subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, integral_constant<unsigned, 1>) { |
| 147 | 135 | linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> __e(__sd == 0u ? default_seed : __sd); |
lib/libcxx/include/__random/uniform_int_distribution.h+1-1| ... | ... | @@ -11,11 +11,11 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__bit/countl.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/size_t.h> | |
| 14 | 15 | #include <__random/is_valid.h> |
| 15 | 16 | #include <__random/log2.h> |
| 16 | 17 | #include <__type_traits/conditional.h> |
| 17 | 18 | #include <__type_traits/make_unsigned.h> |
| 18 | #include <cstddef> | |
| 19 | 19 | #include <cstdint> |
| 20 | 20 | #include <iosfwd> |
| 21 | 21 | #include <limits> |
lib/libcxx/include/__random/uniform_random_bit_generator.h+1-1| ... | ... | @@ -13,8 +13,8 @@ |
| 13 | 13 | #include <__concepts/invocable.h> |
| 14 | 14 | #include <__concepts/same_as.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__functional/invoke.h> | |
| 17 | 16 | #include <__type_traits/integral_constant.h> |
| 17 | #include <__type_traits/invoke.h> | |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 20 | # pragma GCC system_header |
lib/libcxx/include/__ranges/access.h+1-1| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__concepts/class_or_enum.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/size_t.h> | |
| 15 | 16 | #include <__iterator/concepts.h> |
| 16 | 17 | #include <__iterator/readable_traits.h> |
| 17 | 18 | #include <__ranges/enable_borrowed_range.h> |
| ... | ... | @@ -21,7 +22,6 @@ |
| 21 | 22 | #include <__type_traits/remove_reference.h> |
| 22 | 23 | #include <__utility/auto_cast.h> |
| 23 | 24 | #include <__utility/declval.h> |
| 24 | #include <cstddef> | |
| 25 | 25 | |
| 26 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | 27 | # pragma GCC system_header |
lib/libcxx/include/__ranges/chunk_by_view.h+2-2| ... | ... | @@ -59,7 +59,7 @@ class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS chunk_by_view : public view_interface |
| 59 | 59 | _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Pred> __pred_; |
| 60 | 60 | |
| 61 | 61 | // We cache the result of begin() to allow providing an amortized O(1). |
| 62 | using _Cache = __non_propagating_cache<iterator_t<_View>>; | |
| 62 | using _Cache _LIBCPP_NODEBUG = __non_propagating_cache<iterator_t<_View>>; | |
| 63 | 63 | _Cache __cached_begin_; |
| 64 | 64 | |
| 65 | 65 | class __iterator; |
| ... | ... | @@ -215,7 +215,7 @@ struct __fn { |
| 215 | 215 | requires constructible_from<decay_t<_Pred>, _Pred> |
| 216 | 216 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const |
| 217 | 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 __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred))); | |
| 219 | 219 | } |
| 220 | 220 | }; |
| 221 | 221 | } // namespace __chunk_by |
lib/libcxx/include/__ranges/counted.h+1-1| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__concepts/convertible_to.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/size_t.h> | |
| 15 | 16 | #include <__iterator/concepts.h> |
| 16 | 17 | #include <__iterator/counted_iterator.h> |
| 17 | 18 | #include <__iterator/default_sentinel.h> |
| ... | ... | @@ -22,7 +23,6 @@ |
| 22 | 23 | #include <__type_traits/decay.h> |
| 23 | 24 | #include <__utility/forward.h> |
| 24 | 25 | #include <__utility/move.h> |
| 25 | #include <cstddef> | |
| 26 | 26 | #include <span> |
| 27 | 27 | |
| 28 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__ranges/drop_view.h+4-4| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | #include <__concepts/constructible.h> |
| 16 | 16 | #include <__concepts/convertible_to.h> |
| 17 | 17 | #include <__config> |
| 18 | #include <__cstddef/size_t.h> | |
| 18 | 19 | #include <__functional/bind_back.h> |
| 19 | 20 | #include <__fwd/span.h> |
| 20 | 21 | #include <__fwd/string_view.h> |
| ... | ... | @@ -42,7 +43,6 @@ |
| 42 | 43 | #include <__utility/auto_cast.h> |
| 43 | 44 | #include <__utility/forward.h> |
| 44 | 45 | #include <__utility/move.h> |
| 45 | #include <cstddef> | |
| 46 | 46 | |
| 47 | 47 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 48 | 48 | # pragma GCC system_header |
| ... | ... | @@ -64,7 +64,7 @@ class drop_view : public view_interface<drop_view<_View>> { |
| 64 | 64 | // Note: drop_view<input-range>::begin() is still trivially amortized O(1) because |
| 65 | 65 | // one can't call begin() on it more than once. |
| 66 | 66 | static constexpr bool _UseCache = forward_range<_View> && !(random_access_range<_View> && sized_range<_View>); |
| 67 | using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 67 | using _Cache _LIBCPP_NODEBUG = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 68 | 68 | _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache(); |
| 69 | 69 | range_difference_t<_View> __count_ = 0; |
| 70 | 70 | _View __base_ = _View(); |
| ... | ... | @@ -204,7 +204,7 @@ struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { |
| 204 | 204 | }; |
| 205 | 205 | |
| 206 | 206 | template <class _Tp> |
| 207 | using __passthrough_type_t = typename __passthrough_type<_Tp>::type; | |
| 207 | using __passthrough_type_t _LIBCPP_NODEBUG = typename __passthrough_type<_Tp>::type; | |
| 208 | 208 | |
| 209 | 209 | struct __fn { |
| 210 | 210 | // [range.drop.overview]: the `empty_view` case. |
| ... | ... | @@ -307,7 +307,7 @@ struct __fn { |
| 307 | 307 | requires constructible_from<decay_t<_Np>, _Np> |
| 308 | 308 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Np&& __n) const |
| 309 | 309 | noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) { |
| 310 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); | |
| 310 | return __pipeable(std::__bind_back(*this, std::forward<_Np>(__n))); | |
| 311 | 311 | } |
| 312 | 312 | }; |
| 313 | 313 |
lib/libcxx/include/__ranges/drop_while_view.h+2-2| ... | ... | @@ -90,7 +90,7 @@ private: |
| 90 | 90 | _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Pred> __pred_; |
| 91 | 91 | |
| 92 | 92 | static constexpr bool _UseCache = forward_range<_View>; |
| 93 | using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 93 | using _Cache _LIBCPP_NODEBUG = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 94 | 94 | _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache(); |
| 95 | 95 | }; |
| 96 | 96 | |
| ... | ... | @@ -115,7 +115,7 @@ struct __fn { |
| 115 | 115 | requires constructible_from<decay_t<_Pred>, _Pred> |
| 116 | 116 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const |
| 117 | 117 | noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) { |
| 118 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); | |
| 118 | return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred))); | |
| 119 | 119 | } |
| 120 | 120 | }; |
| 121 | 121 |
lib/libcxx/include/__ranges/elements_view.h+4-4| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <__concepts/derived_from.h> |
| 17 | 17 | #include <__concepts/equality_comparable.h> |
| 18 | 18 | #include <__config> |
| 19 | #include <__fwd/complex.h> | |
| 19 | #include <__fwd/get.h> | |
| 20 | 20 | #include <__iterator/concepts.h> |
| 21 | 21 | #include <__iterator/iterator_traits.h> |
| 22 | 22 | #include <__ranges/access.h> |
| ... | ... | @@ -37,7 +37,7 @@ |
| 37 | 37 | #include <__utility/declval.h> |
| 38 | 38 | #include <__utility/forward.h> |
| 39 | 39 | #include <__utility/move.h> |
| 40 | #include <cstddef> | |
| 40 | #include <tuple> // std::get | |
| 41 | 41 | |
| 42 | 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 43 | 43 | # pragma GCC system_header |
| ... | ... | @@ -171,7 +171,7 @@ class elements_view<_View, _Np>::__iterator |
| 171 | 171 | template <bool> |
| 172 | 172 | friend class __sentinel; |
| 173 | 173 | |
| 174 | using _Base = __maybe_const<_Const, _View>; | |
| 174 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | |
| 175 | 175 | |
| 176 | 176 | iterator_t<_Base> __current_ = iterator_t<_Base>(); |
| 177 | 177 | |
| ... | ... | @@ -335,7 +335,7 @@ template <input_range _View, size_t _Np> |
| 335 | 335 | template <bool _Const> |
| 336 | 336 | class elements_view<_View, _Np>::__sentinel { |
| 337 | 337 | private: |
| 338 | using _Base = __maybe_const<_Const, _View>; | |
| 338 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | |
| 339 | 339 | _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>(); |
| 340 | 340 | |
| 341 | 341 | template <bool> |
lib/libcxx/include/__ranges/empty_view.h+1-1| ... | ... | @@ -11,10 +11,10 @@ |
| 11 | 11 | #define _LIBCPP___RANGES_EMPTY_VIEW_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__cstddef/size_t.h> | |
| 14 | 15 | #include <__ranges/enable_borrowed_range.h> |
| 15 | 16 | #include <__ranges/view_interface.h> |
| 16 | 17 | #include <__type_traits/is_object.h> |
| 17 | #include <cstddef> | |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 20 | # pragma GCC system_header |
lib/libcxx/include/__ranges/filter_view.h+3-3| ... | ... | @@ -61,7 +61,7 @@ class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS filter_view : public view_interface<f |
| 61 | 61 | // We cache the result of begin() to allow providing an amortized O(1) begin() whenever |
| 62 | 62 | // the underlying range is at least a forward_range. |
| 63 | 63 | static constexpr bool _UseCache = forward_range<_View>; |
| 64 | using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 64 | using _Cache _LIBCPP_NODEBUG = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 65 | 65 | _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache(); |
| 66 | 66 | |
| 67 | 67 | class __iterator; |
| ... | ... | @@ -115,7 +115,7 @@ struct __filter_iterator_category {}; |
| 115 | 115 | |
| 116 | 116 | template <forward_range _View> |
| 117 | 117 | struct __filter_iterator_category<_View> { |
| 118 | using _Cat = typename iterator_traits<iterator_t<_View>>::iterator_category; | |
| 118 | using _Cat _LIBCPP_NODEBUG = typename iterator_traits<iterator_t<_View>>::iterator_category; | |
| 119 | 119 | using iterator_category = |
| 120 | 120 | _If<derived_from<_Cat, bidirectional_iterator_tag>, |
| 121 | 121 | bidirectional_iterator_tag, |
| ... | ... | @@ -239,7 +239,7 @@ struct __fn { |
| 239 | 239 | requires constructible_from<decay_t<_Pred>, _Pred> |
| 240 | 240 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const |
| 241 | 241 | noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) { |
| 242 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); | |
| 242 | return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred))); | |
| 243 | 243 | } |
| 244 | 244 | }; |
| 245 | 245 | } // namespace __filter |
lib/libcxx/include/__ranges/iota_view.h+1-1| ... | ... | @@ -68,7 +68,7 @@ struct __get_wider_signed { |
| 68 | 68 | }; |
| 69 | 69 | |
| 70 | 70 | template <class _Start> |
| 71 | using _IotaDiffT = | |
| 71 | using _IotaDiffT _LIBCPP_NODEBUG = | |
| 72 | 72 | typename _If< (!integral<_Start> || sizeof(iter_difference_t<_Start>) > sizeof(_Start)), |
| 73 | 73 | type_identity<iter_difference_t<_Start>>, |
| 74 | 74 | __get_wider_signed<_Start> >::type; |
lib/libcxx/include/__ranges/istream_view.h+2-2| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | #include <__concepts/derived_from.h> |
| 15 | 15 | #include <__concepts/movable.h> |
| 16 | 16 | #include <__config> |
| 17 | #include <__cstddef/ptrdiff_t.h> | |
| 17 | 18 | #include <__fwd/istream.h> |
| 18 | 19 | #include <__fwd/string.h> |
| 19 | 20 | #include <__iterator/default_sentinel.h> |
| ... | ... | @@ -22,7 +23,6 @@ |
| 22 | 23 | #include <__ranges/view_interface.h> |
| 23 | 24 | #include <__type_traits/remove_cvref.h> |
| 24 | 25 | #include <__utility/forward.h> |
| 25 | #include <cstddef> | |
| 26 | 26 | |
| 27 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | 28 | # pragma GCC system_header |
| ... | ... | @@ -99,7 +99,7 @@ private: |
| 99 | 99 | template <class _Val> |
| 100 | 100 | using istream_view = basic_istream_view<_Val, char>; |
| 101 | 101 | |
| 102 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 102 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 103 | 103 | template <class _Val> |
| 104 | 104 | using wistream_view = basic_istream_view<_Val, wchar_t>; |
| 105 | 105 | # endif |
lib/libcxx/include/__ranges/join_view.h+18-17| ... | ... | @@ -55,8 +55,8 @@ struct __join_view_iterator_category {}; |
| 55 | 55 | template <class _View> |
| 56 | 56 | requires is_reference_v<range_reference_t<_View>> && forward_range<_View> && forward_range<range_reference_t<_View>> |
| 57 | 57 | struct __join_view_iterator_category<_View> { |
| 58 | using _OuterC = typename iterator_traits<iterator_t<_View>>::iterator_category; | |
| 59 | using _InnerC = typename iterator_traits<iterator_t<range_reference_t<_View>>>::iterator_category; | |
| 58 | using _OuterC _LIBCPP_NODEBUG = typename iterator_traits<iterator_t<_View>>::iterator_category; | |
| 59 | using _InnerC _LIBCPP_NODEBUG = typename iterator_traits<iterator_t<range_reference_t<_View>>>::iterator_category; | |
| 60 | 60 | |
| 61 | 61 | using iterator_category = |
| 62 | 62 | _If< derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag> && |
| ... | ... | @@ -71,7 +71,7 @@ template <input_range _View> |
| 71 | 71 | requires view<_View> && input_range<range_reference_t<_View>> |
| 72 | 72 | class join_view : public view_interface<join_view<_View>> { |
| 73 | 73 | private: |
| 74 | using _InnerRange = range_reference_t<_View>; | |
| 74 | using _InnerRange _LIBCPP_NODEBUG = range_reference_t<_View>; | |
| 75 | 75 | |
| 76 | 76 | template <bool> |
| 77 | 77 | struct __iterator; |
| ... | ... | @@ -85,11 +85,12 @@ private: |
| 85 | 85 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); |
| 86 | 86 | |
| 87 | 87 | static constexpr bool _UseOuterCache = !forward_range<_View>; |
| 88 | using _OuterCache = _If<_UseOuterCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 88 | using _OuterCache _LIBCPP_NODEBUG = _If<_UseOuterCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 89 | 89 | _LIBCPP_NO_UNIQUE_ADDRESS _OuterCache __outer_; |
| 90 | 90 | |
| 91 | 91 | static constexpr bool _UseInnerCache = !is_reference_v<_InnerRange>; |
| 92 | using _InnerCache = _If<_UseInnerCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>; | |
| 92 | using _InnerCache _LIBCPP_NODEBUG = | |
| 93 | _If<_UseInnerCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>; | |
| 93 | 94 | _LIBCPP_NO_UNIQUE_ADDRESS _InnerCache __inner_; |
| 94 | 95 | |
| 95 | 96 | public: |
| ... | ... | @@ -155,9 +156,9 @@ private: |
| 155 | 156 | template <bool> |
| 156 | 157 | friend struct __sentinel; |
| 157 | 158 | |
| 158 | using _Parent = __maybe_const<_Const, join_view>; | |
| 159 | using _Base = __maybe_const<_Const, _View>; | |
| 160 | sentinel_t<_Base> __end_ = sentinel_t<_Base>(); | |
| 159 | using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, join_view>; | |
| 160 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | |
| 161 | sentinel_t<_Base> __end_ = sentinel_t<_Base>(); | |
| 161 | 162 | |
| 162 | 163 | public: |
| 163 | 164 | _LIBCPP_HIDE_FROM_ABI __sentinel() = default; |
| ... | ... | @@ -190,18 +191,18 @@ struct join_view<_View>::__iterator final : public __join_view_iterator_category |
| 190 | 191 | static constexpr bool __is_join_view_iterator = true; |
| 191 | 192 | |
| 192 | 193 | private: |
| 193 | using _Parent = __maybe_const<_Const, join_view<_View>>; | |
| 194 | using _Base = __maybe_const<_Const, _View>; | |
| 195 | using _Outer = iterator_t<_Base>; | |
| 196 | using _Inner = iterator_t<range_reference_t<_Base>>; | |
| 197 | using _InnerRange = range_reference_t<_View>; | |
| 194 | using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, join_view<_View>>; | |
| 195 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | |
| 196 | using _Outer _LIBCPP_NODEBUG = iterator_t<_Base>; | |
| 197 | using _Inner _LIBCPP_NODEBUG = iterator_t<range_reference_t<_Base>>; | |
| 198 | using _InnerRange _LIBCPP_NODEBUG = range_reference_t<_View>; | |
| 198 | 199 | |
| 199 | 200 | static_assert(!_Const || forward_range<_Base>, "Const can only be true when Base models forward_range."); |
| 200 | 201 | |
| 201 | 202 | static constexpr bool __ref_is_glvalue = is_reference_v<range_reference_t<_Base>>; |
| 202 | 203 | |
| 203 | 204 | static constexpr bool _OuterPresent = forward_range<_Base>; |
| 204 | using _OuterType = _If<_OuterPresent, _Outer, std::__empty>; | |
| 205 | using _OuterType _LIBCPP_NODEBUG = _If<_OuterPresent, _Outer, std::__empty>; | |
| 205 | 206 | _LIBCPP_NO_UNIQUE_ADDRESS _OuterType __outer_ = _OuterType(); |
| 206 | 207 | |
| 207 | 208 | optional<_Inner> __inner_; |
| ... | ... | @@ -377,9 +378,9 @@ template <class _JoinViewIterator> |
| 377 | 378 | __has_random_access_iterator_category<typename _JoinViewIterator::_Outer>::value && |
| 378 | 379 | __has_random_access_iterator_category<typename _JoinViewIterator::_Inner>::value) |
| 379 | 380 | struct __segmented_iterator_traits<_JoinViewIterator> { |
| 380 | using __segment_iterator = | |
| 381 | _LIBCPP_NODEBUG __iterator_with_data<typename _JoinViewIterator::_Outer, typename _JoinViewIterator::_Parent*>; | |
| 382 | using __local_iterator = typename _JoinViewIterator::_Inner; | |
| 381 | using __segment_iterator _LIBCPP_NODEBUG = | |
| 382 | __iterator_with_data<typename _JoinViewIterator::_Outer, typename _JoinViewIterator::_Parent*>; | |
| 383 | using __local_iterator _LIBCPP_NODEBUG = typename _JoinViewIterator::_Inner; | |
| 383 | 384 | |
| 384 | 385 | // TODO: Would it make sense to enable the optimization for other iterator types? |
| 385 | 386 |
lib/libcxx/include/__ranges/lazy_split_view.h+7-6| ... | ... | @@ -72,7 +72,8 @@ class lazy_split_view : public view_interface<lazy_split_view<_View, _Pattern>> |
| 72 | 72 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); |
| 73 | 73 | _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern(); |
| 74 | 74 | |
| 75 | using _MaybeCurrent = _If<!forward_range<_View>, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 75 | using _MaybeCurrent _LIBCPP_NODEBUG = | |
| 76 | _If<!forward_range<_View>, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 76 | 77 | _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent(); |
| 77 | 78 | |
| 78 | 79 | template <bool> |
| ... | ... | @@ -146,11 +147,11 @@ private: |
| 146 | 147 | friend struct __inner_iterator; |
| 147 | 148 | friend __outer_iterator<true>; |
| 148 | 149 | |
| 149 | using _Parent = __maybe_const<_Const, lazy_split_view>; | |
| 150 | using _Base = __maybe_const<_Const, _View>; | |
| 150 | using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, lazy_split_view>; | |
| 151 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | |
| 151 | 152 | |
| 152 | 153 | _Parent* __parent_ = nullptr; |
| 153 | using _MaybeCurrent = _If<forward_range<_View>, iterator_t<_Base>, __empty_cache>; | |
| 154 | using _MaybeCurrent _LIBCPP_NODEBUG = _If<forward_range<_View>, iterator_t<_Base>, __empty_cache>; | |
| 154 | 155 | _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent(); |
| 155 | 156 | bool __trailing_empty_ = false; |
| 156 | 157 | |
| ... | ... | @@ -283,7 +284,7 @@ private: |
| 283 | 284 | template <bool _Const> |
| 284 | 285 | struct __inner_iterator : __inner_iterator_category<__maybe_const<_Const, _View>> { |
| 285 | 286 | private: |
| 286 | using _Base = __maybe_const<_Const, _View>; | |
| 287 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | |
| 287 | 288 | // Workaround for a GCC issue. |
| 288 | 289 | static constexpr bool _OuterConst = _Const; |
| 289 | 290 | __outer_iterator<_Const> __i_ = __outer_iterator<_OuterConst>(); |
| ... | ... | @@ -420,7 +421,7 @@ struct __fn { |
| 420 | 421 | requires constructible_from<decay_t<_Pattern>, _Pattern> |
| 421 | 422 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const |
| 422 | 423 | noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) { |
| 423 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern))); | |
| 424 | return __pipeable(std::__bind_back(*this, std::forward<_Pattern>(__pattern))); | |
| 424 | 425 | } |
| 425 | 426 | }; |
| 426 | 427 | } // namespace __lazy_split_view |
lib/libcxx/include/__ranges/range_adaptor.h+8-10| ... | ... | @@ -19,8 +19,10 @@ |
| 19 | 19 | #include <__functional/invoke.h> |
| 20 | 20 | #include <__ranges/concepts.h> |
| 21 | 21 | #include <__type_traits/decay.h> |
| 22 | #include <__type_traits/invoke.h> | |
| 22 | 23 | #include <__type_traits/is_class.h> |
| 23 | 24 | #include <__type_traits/is_nothrow_constructible.h> |
| 25 | #include <__type_traits/remove_cv.h> | |
| 24 | 26 | #include <__type_traits/remove_cvref.h> |
| 25 | 27 | #include <__utility/forward.h> |
| 26 | 28 | #include <__utility/move.h> |
| ... | ... | @@ -45,15 +47,15 @@ namespace ranges { |
| 45 | 47 | // - `f1 | f2` is an adaptor closure `g` such that `g(x)` is equivalent to `f2(f1(x))` |
| 46 | 48 | template <class _Tp> |
| 47 | 49 | requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>> |
| 48 | struct __range_adaptor_closure; | |
| 50 | struct __range_adaptor_closure {}; | |
| 49 | 51 | |
| 50 | 52 | // Type that wraps an arbitrary function object and makes it into a range adaptor closure, |
| 51 | 53 | // i.e. something that can be called via the `x | f` notation. |
| 52 | 54 | template <class _Fn> |
| 53 | struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_closure_t<_Fn>> { | |
| 54 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) {} | |
| 55 | struct __pipeable : _Fn, __range_adaptor_closure<__pipeable<_Fn>> { | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __pipeable(_Fn&& __f) : _Fn(std::move(__f)) {} | |
| 55 | 57 | }; |
| 56 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t); | |
| 58 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__pipeable); | |
| 57 | 59 | |
| 58 | 60 | template <class _Tp> |
| 59 | 61 | _Tp __derived_from_range_adaptor_closure(__range_adaptor_closure<_Tp>*); |
| ... | ... | @@ -77,17 +79,13 @@ template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure> |
| 77 | 79 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) noexcept( |
| 78 | 80 | is_nothrow_constructible_v<decay_t<_Closure>, _Closure> && |
| 79 | 81 | is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>) { |
| 80 | return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); | |
| 82 | return __pipeable(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); | |
| 81 | 83 | } |
| 82 | 84 | |
| 83 | template <class _Tp> | |
| 84 | requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>> | |
| 85 | struct __range_adaptor_closure {}; | |
| 86 | ||
| 87 | 85 | # if _LIBCPP_STD_VER >= 23 |
| 88 | 86 | template <class _Tp> |
| 89 | 87 | requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>> |
| 90 | class range_adaptor_closure : public __range_adaptor_closure<_Tp> {}; | |
| 88 | class _LIBCPP_NO_SPECIALIZATIONS range_adaptor_closure : public __range_adaptor_closure<_Tp> {}; | |
| 91 | 89 | # endif // _LIBCPP_STD_VER >= 23 |
| 92 | 90 | |
| 93 | 91 | } // namespace ranges |
lib/libcxx/include/__ranges/repeat_view.h+3-2| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | #include <__concepts/same_as.h> |
| 16 | 16 | #include <__concepts/semiregular.h> |
| 17 | 17 | #include <__config> |
| 18 | #include <__cstddef/ptrdiff_t.h> | |
| 18 | 19 | #include <__iterator/concepts.h> |
| 19 | 20 | #include <__iterator/iterator_traits.h> |
| 20 | 21 | #include <__iterator/unreachable_sentinel.h> |
| ... | ... | @@ -60,7 +61,7 @@ struct __repeat_view_iterator_difference<_Tp> { |
| 60 | 61 | }; |
| 61 | 62 | |
| 62 | 63 | template <class _Tp> |
| 63 | using __repeat_view_iterator_difference_t = typename __repeat_view_iterator_difference<_Tp>::type; | |
| 64 | using __repeat_view_iterator_difference_t _LIBCPP_NODEBUG = typename __repeat_view_iterator_difference<_Tp>::type; | |
| 64 | 65 | |
| 65 | 66 | namespace views::__drop { |
| 66 | 67 | struct __fn; |
| ... | ... | @@ -138,7 +139,7 @@ template <move_constructible _Tp, semiregular _Bound> |
| 138 | 139 | class repeat_view<_Tp, _Bound>::__iterator { |
| 139 | 140 | friend class repeat_view; |
| 140 | 141 | |
| 141 | using _IndexT = conditional_t<same_as<_Bound, unreachable_sentinel_t>, ptrdiff_t, _Bound>; | |
| 142 | using _IndexT _LIBCPP_NODEBUG = conditional_t<same_as<_Bound, unreachable_sentinel_t>, ptrdiff_t, _Bound>; | |
| 142 | 143 | |
| 143 | 144 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(const _Tp* __value, _IndexT __bound_sentinel = _IndexT()) |
| 144 | 145 | : __value_(__value), __current_(__bound_sentinel) {} |
lib/libcxx/include/__ranges/reverse_view.h+2-1| ... | ... | @@ -47,7 +47,8 @@ class reverse_view : public view_interface<reverse_view<_View>> { |
| 47 | 47 | // We cache begin() whenever ranges::next is not guaranteed O(1) to provide an |
| 48 | 48 | // amortized O(1) begin() method. |
| 49 | 49 | static constexpr bool _UseCache = !random_access_range<_View> && !common_range<_View>; |
| 50 | using _Cache = _If<_UseCache, __non_propagating_cache<reverse_iterator<iterator_t<_View>>>, __empty_cache>; | |
| 50 | using _Cache _LIBCPP_NODEBUG = | |
| 51 | _If<_UseCache, __non_propagating_cache<reverse_iterator<iterator_t<_View>>>, __empty_cache>; | |
| 51 | 52 | _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache(); |
| 52 | 53 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); |
| 53 | 54 |
lib/libcxx/include/__ranges/single_view.h+2-1| ... | ... | @@ -12,6 +12,8 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__concepts/constructible.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/ptrdiff_t.h> | |
| 16 | #include <__cstddef/size_t.h> | |
| 15 | 17 | #include <__ranges/movable_box.h> |
| 16 | 18 | #include <__ranges/range_adaptor.h> |
| 17 | 19 | #include <__ranges/view_interface.h> |
| ... | ... | @@ -20,7 +22,6 @@ |
| 20 | 22 | #include <__utility/forward.h> |
| 21 | 23 | #include <__utility/in_place.h> |
| 22 | 24 | #include <__utility/move.h> |
| 23 | #include <cstddef> | |
| 24 | 25 | |
| 25 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | 27 | # pragma GCC system_header |
lib/libcxx/include/__ranges/size.h+2-1| ... | ... | @@ -13,6 +13,8 @@ |
| 13 | 13 | #include <__concepts/arithmetic.h> |
| 14 | 14 | #include <__concepts/class_or_enum.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__cstddef/ptrdiff_t.h> | |
| 17 | #include <__cstddef/size_t.h> | |
| 16 | 18 | #include <__iterator/concepts.h> |
| 17 | 19 | #include <__iterator/iterator_traits.h> |
| 18 | 20 | #include <__ranges/access.h> |
| ... | ... | @@ -22,7 +24,6 @@ |
| 22 | 24 | #include <__type_traits/remove_cvref.h> |
| 23 | 25 | #include <__utility/auto_cast.h> |
| 24 | 26 | #include <__utility/declval.h> |
| 25 | #include <cstddef> | |
| 26 | 27 | |
| 27 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | 29 | # pragma GCC system_header |
lib/libcxx/include/__ranges/split_view.h+2-2| ... | ... | @@ -52,7 +52,7 @@ class split_view : public view_interface<split_view<_View, _Pattern>> { |
| 52 | 52 | private: |
| 53 | 53 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); |
| 54 | 54 | _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern(); |
| 55 | using _Cache = __non_propagating_cache<subrange<iterator_t<_View>>>; | |
| 55 | using _Cache _LIBCPP_NODEBUG = __non_propagating_cache<subrange<iterator_t<_View>>>; | |
| 56 | 56 | _Cache __cached_begin_ = _Cache(); |
| 57 | 57 | |
| 58 | 58 | template <class, class> |
| ... | ... | @@ -211,7 +211,7 @@ struct __fn { |
| 211 | 211 | requires constructible_from<decay_t<_Pattern>, _Pattern> |
| 212 | 212 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const |
| 213 | 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 __pipeable(std::__bind_back(*this, std::forward<_Pattern>(__pattern))); | |
| 215 | 215 | } |
| 216 | 216 | }; |
| 217 | 217 | } // namespace __split_view |
lib/libcxx/include/__ranges/subrange.h+3-2| ... | ... | @@ -17,6 +17,7 @@ |
| 17 | 17 | #include <__concepts/derived_from.h> |
| 18 | 18 | #include <__concepts/different_from.h> |
| 19 | 19 | #include <__config> |
| 20 | #include <__cstddef/size_t.h> | |
| 20 | 21 | #include <__fwd/subrange.h> |
| 21 | 22 | #include <__iterator/advance.h> |
| 22 | 23 | #include <__iterator/concepts.h> |
| ... | ... | @@ -33,13 +34,13 @@ |
| 33 | 34 | #include <__tuple/tuple_size.h> |
| 34 | 35 | #include <__type_traits/conditional.h> |
| 35 | 36 | #include <__type_traits/decay.h> |
| 37 | #include <__type_traits/integral_constant.h> | |
| 36 | 38 | #include <__type_traits/is_pointer.h> |
| 37 | 39 | #include <__type_traits/is_reference.h> |
| 38 | 40 | #include <__type_traits/make_unsigned.h> |
| 39 | 41 | #include <__type_traits/remove_const.h> |
| 40 | 42 | #include <__type_traits/remove_pointer.h> |
| 41 | 43 | #include <__utility/move.h> |
| 42 | #include <cstddef> | |
| 43 | 44 | |
| 44 | 45 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 45 | 46 | # pragma GCC system_header |
| ... | ... | @@ -81,7 +82,7 @@ private: |
| 81 | 82 | struct _Empty { |
| 82 | 83 | _LIBCPP_HIDE_FROM_ABI constexpr _Empty(auto) noexcept {} |
| 83 | 84 | }; |
| 84 | using _Size = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>; | |
| 85 | using _Size _LIBCPP_NODEBUG = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>; | |
| 85 | 86 | _LIBCPP_NO_UNIQUE_ADDRESS _Iter __begin_ = _Iter(); |
| 86 | 87 | _LIBCPP_NO_UNIQUE_ADDRESS _Sent __end_ = _Sent(); |
| 87 | 88 | _LIBCPP_NO_UNIQUE_ADDRESS _Size __size_ = 0; |
lib/libcxx/include/__ranges/take_view.h+4-5| ... | ... | @@ -42,7 +42,6 @@ |
| 42 | 42 | #include <__utility/auto_cast.h> |
| 43 | 43 | #include <__utility/forward.h> |
| 44 | 44 | #include <__utility/move.h> |
| 45 | #include <cstddef> | |
| 46 | 45 | |
| 47 | 46 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 48 | 47 | # pragma GCC system_header |
| ... | ... | @@ -162,9 +161,9 @@ public: |
| 162 | 161 | template <view _View> |
| 163 | 162 | template <bool _Const> |
| 164 | 163 | class take_view<_View>::__sentinel { |
| 165 | using _Base = __maybe_const<_Const, _View>; | |
| 164 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | |
| 166 | 165 | template <bool _OtherConst> |
| 167 | using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>; | |
| 166 | using _Iter _LIBCPP_NODEBUG = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>; | |
| 168 | 167 | _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>(); |
| 169 | 168 | |
| 170 | 169 | template <bool> |
| ... | ... | @@ -245,7 +244,7 @@ struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { |
| 245 | 244 | }; |
| 246 | 245 | |
| 247 | 246 | template <class _Tp> |
| 248 | using __passthrough_type_t = typename __passthrough_type<_Tp>::type; | |
| 247 | using __passthrough_type_t _LIBCPP_NODEBUG = typename __passthrough_type<_Tp>::type; | |
| 249 | 248 | |
| 250 | 249 | struct __fn { |
| 251 | 250 | // [range.take.overview]: the `empty_view` case. |
| ... | ... | @@ -347,7 +346,7 @@ struct __fn { |
| 347 | 346 | requires constructible_from<decay_t<_Np>, _Np> |
| 348 | 347 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Np&& __n) const |
| 349 | 348 | noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) { |
| 350 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); | |
| 349 | return __pipeable(std::__bind_back(*this, std::forward<_Np>(__n))); | |
| 351 | 350 | } |
| 352 | 351 | }; |
| 353 | 352 |
lib/libcxx/include/__ranges/take_while_view.h+2-2| ... | ... | @@ -103,7 +103,7 @@ template <view _View, class _Pred> |
| 103 | 103 | requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>> |
| 104 | 104 | template <bool _Const> |
| 105 | 105 | class take_while_view<_View, _Pred>::__sentinel { |
| 106 | using _Base = __maybe_const<_Const, _View>; | |
| 106 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | |
| 107 | 107 | |
| 108 | 108 | sentinel_t<_Base> __end_ = sentinel_t<_Base>(); |
| 109 | 109 | const _Pred* __pred_ = nullptr; |
| ... | ... | @@ -149,7 +149,7 @@ struct __fn { |
| 149 | 149 | requires constructible_from<decay_t<_Pred>, _Pred> |
| 150 | 150 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const |
| 151 | 151 | noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) { |
| 152 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); | |
| 152 | return __pipeable(std::__bind_back(*this, std::forward<_Pred>(__pred))); | |
| 153 | 153 | } |
| 154 | 154 | }; |
| 155 | 155 |
lib/libcxx/include/__ranges/to.h+20-19| ... | ... | @@ -10,15 +10,13 @@ |
| 10 | 10 | #ifndef _LIBCPP___RANGES_TO_H |
| 11 | 11 | #define _LIBCPP___RANGES_TO_H |
| 12 | 12 | |
| 13 | #include <__algorithm/ranges_copy.h> | |
| 14 | 13 | #include <__concepts/constructible.h> |
| 15 | 14 | #include <__concepts/convertible_to.h> |
| 16 | 15 | #include <__concepts/derived_from.h> |
| 17 | 16 | #include <__concepts/same_as.h> |
| 18 | 17 | #include <__config> |
| 18 | #include <__cstddef/ptrdiff_t.h> | |
| 19 | 19 | #include <__functional/bind_back.h> |
| 20 | #include <__iterator/back_insert_iterator.h> | |
| 21 | #include <__iterator/insert_iterator.h> | |
| 22 | 20 | #include <__iterator/iterator_traits.h> |
| 23 | 21 | #include <__ranges/access.h> |
| 24 | 22 | #include <__ranges/concepts.h> |
| ... | ... | @@ -33,7 +31,6 @@ |
| 33 | 31 | #include <__type_traits/type_identity.h> |
| 34 | 32 | #include <__utility/declval.h> |
| 35 | 33 | #include <__utility/forward.h> |
| 36 | #include <cstddef> | |
| 37 | 34 | |
| 38 | 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 39 | 36 | # pragma GCC system_header |
| ... | ... | @@ -54,21 +51,14 @@ constexpr bool __reservable_container = |
| 54 | 51 | }; |
| 55 | 52 | |
| 56 | 53 | template <class _Container, class _Ref> |
| 57 | constexpr bool __container_insertable = requires(_Container& __c, _Ref&& __ref) { | |
| 54 | constexpr bool __container_appendable = requires(_Container& __c, _Ref&& __ref) { | |
| 58 | 55 | requires( |
| 56 | requires { __c.emplace_back(std::forward<_Ref>(__ref)); } || | |
| 59 | 57 | requires { __c.push_back(std::forward<_Ref>(__ref)); } || |
| 58 | requires { __c.emplace(__c.end(), std::forward<_Ref>(__ref)); } || | |
| 60 | 59 | requires { __c.insert(__c.end(), std::forward<_Ref>(__ref)); }); |
| 61 | 60 | }; |
| 62 | 61 | |
| 63 | template <class _Ref, class _Container> | |
| 64 | _LIBCPP_HIDE_FROM_ABI constexpr auto __container_inserter(_Container& __c) { | |
| 65 | if constexpr (requires { __c.push_back(std::declval<_Ref>()); }) { | |
| 66 | return std::back_inserter(__c); | |
| 67 | } else { | |
| 68 | return std::inserter(__c, __c.end()); | |
| 69 | } | |
| 70 | } | |
| 71 | ||
| 72 | 62 | // Note: making this a concept allows short-circuiting the second condition. |
| 73 | 63 | template <class _Container, class _Range> |
| 74 | 64 | concept __try_non_recursive_conversion = |
| ... | ... | @@ -113,14 +103,25 @@ template <class _Container, input_range _Range, class... _Args> |
| 113 | 103 | |
| 114 | 104 | // Case 4 -- default-construct (or construct from the extra arguments) and insert, reserving the size if possible. |
| 115 | 105 | else if constexpr (constructible_from<_Container, _Args...> && |
| 116 | __container_insertable<_Container, range_reference_t<_Range>>) { | |
| 106 | __container_appendable<_Container, range_reference_t<_Range>>) { | |
| 117 | 107 | _Container __result(std::forward<_Args>(__args)...); |
| 118 | 108 | if constexpr (sized_range<_Range> && __reservable_container<_Container>) { |
| 119 | 109 | __result.reserve(static_cast<range_size_t<_Container>>(ranges::size(__range))); |
| 120 | 110 | } |
| 121 | 111 | |
| 122 | ranges::copy(__range, ranges::__container_inserter<range_reference_t<_Range>>(__result)); | |
| 123 | ||
| 112 | for (auto&& __ref : __range) { | |
| 113 | using _Ref = decltype(__ref); | |
| 114 | if constexpr (requires { __result.emplace_back(std::declval<_Ref>()); }) { | |
| 115 | __result.emplace_back(std::forward<_Ref>(__ref)); | |
| 116 | } else if constexpr (requires { __result.push_back(std::declval<_Ref>()); }) { | |
| 117 | __result.push_back(std::forward<_Ref>(__ref)); | |
| 118 | } else if constexpr (requires { __result.emplace(__result.end(), std::declval<_Ref>()); }) { | |
| 119 | __result.emplace(__result.end(), std::forward<_Ref>(__ref)); | |
| 120 | } else { | |
| 121 | static_assert(requires { __result.insert(__result.end(), std::declval<_Ref>()); }); | |
| 122 | __result.insert(__result.end(), std::forward<_Ref>(__ref)); | |
| 123 | } | |
| 124 | } | |
| 124 | 125 | return __result; |
| 125 | 126 | |
| 126 | 127 | } else { |
| ... | ... | @@ -214,7 +215,7 @@ template <class _Container, class... _Args> |
| 214 | 215 | } |
| 215 | 216 | { return ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); }; |
| 216 | 217 | |
| 217 | return __range_adaptor_closure_t(std::__bind_back(__to_func, std::forward<_Args>(__args)...)); | |
| 218 | return __pipeable(std::__bind_back(__to_func, std::forward<_Args>(__args)...)); | |
| 218 | 219 | } |
| 219 | 220 | |
| 220 | 221 | // Range adaptor closure object 2 -- wrapping the `ranges::to` version where `_Container` is a template template |
| ... | ... | @@ -233,7 +234,7 @@ template <template <class...> class _Container, class... _Args> |
| 233 | 234 | }; |
| 234 | 235 | // clang-format on |
| 235 | 236 | |
| 236 | return __range_adaptor_closure_t(std::__bind_back(__to_func, std::forward<_Args>(__args)...)); | |
| 237 | return __pipeable(std::__bind_back(__to_func, std::forward<_Args>(__args)...)); | |
| 237 | 238 | } |
| 238 | 239 | |
| 239 | 240 | } // namespace ranges |
lib/libcxx/include/__ranges/transform_view.h+10-8| ... | ... | @@ -34,6 +34,7 @@ |
| 34 | 34 | #include <__ranges/view_interface.h> |
| 35 | 35 | #include <__type_traits/conditional.h> |
| 36 | 36 | #include <__type_traits/decay.h> |
| 37 | #include <__type_traits/invoke.h> | |
| 37 | 38 | #include <__type_traits/is_nothrow_constructible.h> |
| 38 | 39 | #include <__type_traits/is_object.h> |
| 39 | 40 | #include <__type_traits/is_reference.h> |
| ... | ... | @@ -158,7 +159,7 @@ struct __transform_view_iterator_category_base {}; |
| 158 | 159 | |
| 159 | 160 | template <forward_range _View, class _Fn> |
| 160 | 161 | struct __transform_view_iterator_category_base<_View, _Fn> { |
| 161 | using _Cat = typename iterator_traits<iterator_t<_View>>::iterator_category; | |
| 162 | using _Cat _LIBCPP_NODEBUG = typename iterator_traits<iterator_t<_View>>::iterator_category; | |
| 162 | 163 | |
| 163 | 164 | using iterator_category = |
| 164 | 165 | conditional_t< is_reference_v<invoke_result_t<_Fn&, range_reference_t<_View>>>, |
| ... | ... | @@ -173,10 +174,11 @@ template <input_range _View, copy_constructible _Fn> |
| 173 | 174 | # endif |
| 174 | 175 | requires __transform_view_constraints<_View, _Fn> |
| 175 | 176 | template <bool _Const> |
| 176 | class transform_view<_View, _Fn>::__iterator : public __transform_view_iterator_category_base<_View, _Fn> { | |
| 177 | class transform_view<_View, _Fn>::__iterator | |
| 178 | : public __transform_view_iterator_category_base<_View, __maybe_const<_Const, _Fn>> { | |
| 177 | 179 | |
| 178 | using _Parent = __maybe_const<_Const, transform_view>; | |
| 179 | using _Base = __maybe_const<_Const, _View>; | |
| 180 | using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, transform_view>; | |
| 181 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | |
| 180 | 182 | |
| 181 | 183 | _Parent* __parent_ = nullptr; |
| 182 | 184 | |
| ... | ... | @@ -190,7 +192,7 @@ public: |
| 190 | 192 | iterator_t<_Base> __current_ = iterator_t<_Base>(); |
| 191 | 193 | |
| 192 | 194 | using iterator_concept = typename __transform_view_iterator_concept<_View>::type; |
| 193 | using value_type = remove_cvref_t<invoke_result_t<_Fn&, range_reference_t<_Base>>>; | |
| 195 | using value_type = remove_cvref_t<invoke_result_t<__maybe_const<_Const, _Fn>&, range_reference_t<_Base>>>; | |
| 194 | 196 | using difference_type = range_difference_t<_Base>; |
| 195 | 197 | |
| 196 | 198 | _LIBCPP_HIDE_FROM_ABI __iterator() |
| ... | ... | @@ -336,8 +338,8 @@ template <input_range _View, copy_constructible _Fn> |
| 336 | 338 | requires __transform_view_constraints<_View, _Fn> |
| 337 | 339 | template <bool _Const> |
| 338 | 340 | class transform_view<_View, _Fn>::__sentinel { |
| 339 | using _Parent = __maybe_const<_Const, transform_view>; | |
| 340 | using _Base = __maybe_const<_Const, _View>; | |
| 341 | using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, transform_view>; | |
| 342 | using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>; | |
| 341 | 343 | |
| 342 | 344 | sentinel_t<_Base> __end_ = sentinel_t<_Base>(); |
| 343 | 345 | |
| ... | ... | @@ -396,7 +398,7 @@ struct __fn { |
| 396 | 398 | requires constructible_from<decay_t<_Fn>, _Fn> |
| 397 | 399 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f) const |
| 398 | 400 | noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>) { |
| 399 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Fn>(__f))); | |
| 401 | return __pipeable(std::__bind_back(*this, std::forward<_Fn>(__f))); | |
| 400 | 402 | } |
| 401 | 403 | }; |
| 402 | 404 | } // namespace __transform |
lib/libcxx/include/__ranges/zip_view.h+8-47| ... | ... | @@ -36,7 +36,6 @@ |
| 36 | 36 | #include <__utility/forward.h> |
| 37 | 37 | #include <__utility/integer_sequence.h> |
| 38 | 38 | #include <__utility/move.h> |
| 39 | #include <__utility/pair.h> | |
| 40 | 39 | #include <tuple> |
| 41 | 40 | |
| 42 | 41 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -58,22 +57,11 @@ concept __zip_is_common = |
| 58 | 57 | (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) || |
| 59 | 58 | ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...)); |
| 60 | 59 | |
| 61 | template <typename _Tp, typename _Up> | |
| 62 | auto __tuple_or_pair_test() -> pair<_Tp, _Up>; | |
| 63 | ||
| 64 | template <typename... _Types> | |
| 65 | requires(sizeof...(_Types) != 2) | |
| 66 | auto __tuple_or_pair_test() -> tuple<_Types...>; | |
| 67 | ||
| 68 | template <class... _Types> | |
| 69 | using __tuple_or_pair = decltype(__tuple_or_pair_test<_Types...>()); | |
| 70 | ||
| 71 | 60 | template <class _Fun, class _Tuple> |
| 72 | 61 | _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_transform(_Fun&& __f, _Tuple&& __tuple) { |
| 73 | 62 | return std::apply( |
| 74 | 63 | [&]<class... _Types>(_Types&&... __elements) { |
| 75 | return __tuple_or_pair<invoke_result_t<_Fun&, _Types>...>( | |
| 76 | std::invoke(__f, std::forward<_Types>(__elements))...); | |
| 64 | return tuple<invoke_result_t<_Fun&, _Types>...>(std::invoke(__f, std::forward<_Types>(__elements))...); | |
| 77 | 65 | }, |
| 78 | 66 | std::forward<_Tuple>(__tuple)); |
| 79 | 67 | } |
| ... | ... | @@ -88,7 +76,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __tuple_for_each(_Fun&& __f, _Tuple&& __tup |
| 88 | 76 | } |
| 89 | 77 | |
| 90 | 78 | template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices> |
| 91 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_or_pair< | |
| 79 | _LIBCPP_HIDE_FROM_ABI constexpr tuple< | |
| 92 | 80 | invoke_result_t<_Fun&, |
| 93 | 81 | typename tuple_element<_Indices, remove_cvref_t<_Tuple1>>::type, |
| 94 | 82 | typename tuple_element<_Indices, remove_cvref_t<_Tuple2>>::type>...> |
| ... | ... | @@ -250,10 +238,9 @@ template <input_range... _Views> |
| 250 | 238 | requires(view<_Views> && ...) && (sizeof...(_Views) > 0) |
| 251 | 239 | template <bool _Const> |
| 252 | 240 | class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base<_Const, _Views...> { |
| 253 | __tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current_; | |
| 241 | tuple<iterator_t<__maybe_const<_Const, _Views>>...> __current_; | |
| 254 | 242 | |
| 255 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator( | |
| 256 | __tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current) | |
| 243 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(tuple<iterator_t<__maybe_const<_Const, _Views>>...> __current) | |
| 257 | 244 | : __current_(std::move(__current)) {} |
| 258 | 245 | |
| 259 | 246 | template <bool> |
| ... | ... | @@ -266,7 +253,7 @@ class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base |
| 266 | 253 | |
| 267 | 254 | public: |
| 268 | 255 | using iterator_concept = decltype(__get_zip_view_iterator_tag<_Const, _Views...>()); |
| 269 | using value_type = __tuple_or_pair<range_value_t<__maybe_const<_Const, _Views>>...>; | |
| 256 | using value_type = tuple<range_value_t<__maybe_const<_Const, _Views>>...>; | |
| 270 | 257 | using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>; |
| 271 | 258 | |
| 272 | 259 | _LIBCPP_HIDE_FROM_ABI __iterator() = default; |
| ... | ... | @@ -340,33 +327,8 @@ public: |
| 340 | 327 | } |
| 341 | 328 | } |
| 342 | 329 | |
| 343 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const __iterator& __x, const __iterator& __y) | |
| 344 | requires __zip_all_random_access<_Const, _Views...> | |
| 345 | { | |
| 346 | return __x.__current_ < __y.__current_; | |
| 347 | } | |
| 348 | ||
| 349 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const __iterator& __x, const __iterator& __y) | |
| 350 | requires __zip_all_random_access<_Const, _Views...> | |
| 351 | { | |
| 352 | return __y < __x; | |
| 353 | } | |
| 354 | ||
| 355 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y) | |
| 356 | requires __zip_all_random_access<_Const, _Views...> | |
| 357 | { | |
| 358 | return !(__y < __x); | |
| 359 | } | |
| 360 | ||
| 361 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y) | |
| 362 | requires __zip_all_random_access<_Const, _Views...> | |
| 363 | { | |
| 364 | return !(__x < __y); | |
| 365 | } | |
| 366 | ||
| 367 | 330 | _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) |
| 368 | requires __zip_all_random_access<_Const, _Views...> && | |
| 369 | (three_way_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...) | |
| 331 | requires __zip_all_random_access<_Const, _Views...> | |
| 370 | 332 | { |
| 371 | 333 | return __x.__current_ <=> __y.__current_; |
| 372 | 334 | } |
| ... | ... | @@ -427,10 +389,9 @@ template <input_range... _Views> |
| 427 | 389 | requires(view<_Views> && ...) && (sizeof...(_Views) > 0) |
| 428 | 390 | template <bool _Const> |
| 429 | 391 | class zip_view<_Views...>::__sentinel { |
| 430 | __tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end_; | |
| 392 | tuple<sentinel_t<__maybe_const<_Const, _Views>>...> __end_; | |
| 431 | 393 | |
| 432 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel( | |
| 433 | __tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end) | |
| 394 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(tuple<sentinel_t<__maybe_const<_Const, _Views>>...> __end) | |
| 434 | 395 | : __end_(__end) {} |
| 435 | 396 | |
| 436 | 397 | friend class zip_view<_Views...>; |
lib/libcxx/include/__split_buffer+89-192| ... | ... | @@ -23,7 +23,6 @@ |
| 23 | 23 | #include <__memory/compressed_pair.h> |
| 24 | 24 | #include <__memory/pointer_traits.h> |
| 25 | 25 | #include <__memory/swap_allocator.h> |
| 26 | #include <__type_traits/add_lvalue_reference.h> | |
| 27 | 26 | #include <__type_traits/conditional.h> |
| 28 | 27 | #include <__type_traits/enable_if.h> |
| 29 | 28 | #include <__type_traits/integral_constant.h> |
| ... | ... | @@ -35,7 +34,6 @@ |
| 35 | 34 | #include <__type_traits/remove_reference.h> |
| 36 | 35 | #include <__utility/forward.h> |
| 37 | 36 | #include <__utility/move.h> |
| 38 | #include <cstddef> | |
| 39 | 37 | |
| 40 | 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | 39 | # pragma GCC system_header |
| ... | ... | @@ -47,30 +45,30 @@ _LIBCPP_PUSH_MACROS |
| 47 | 45 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 46 | |
| 49 | 47 | // __split_buffer allocates a contiguous chunk of memory and stores objects in the range [__begin_, __end_). |
| 50 | // It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __end_cap_.first()). That allows | |
| 48 | // It has uninitialized memory in the ranges [__first_, __begin_) and [__end_, __cap_). That allows | |
| 51 | 49 | // it to grow both in the front and back without having to move the data. |
| 52 | 50 | |
| 53 | 51 | template <class _Tp, class _Allocator = allocator<_Tp> > |
| 54 | 52 | struct __split_buffer { |
| 55 | 53 | public: |
| 56 | using value_type = _Tp; | |
| 57 | using allocator_type = _Allocator; | |
| 58 | using __alloc_rr = __libcpp_remove_reference_t<allocator_type>; | |
| 59 | using __alloc_traits = allocator_traits<__alloc_rr>; | |
| 60 | using reference = value_type&; | |
| 61 | using const_reference = const value_type&; | |
| 62 | using size_type = typename __alloc_traits::size_type; | |
| 63 | using difference_type = typename __alloc_traits::difference_type; | |
| 64 | using pointer = typename __alloc_traits::pointer; | |
| 65 | using const_pointer = typename __alloc_traits::const_pointer; | |
| 66 | using iterator = pointer; | |
| 67 | using const_iterator = const_pointer; | |
| 54 | using value_type = _Tp; | |
| 55 | using allocator_type = _Allocator; | |
| 56 | using __alloc_rr _LIBCPP_NODEBUG = __libcpp_remove_reference_t<allocator_type>; | |
| 57 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<__alloc_rr>; | |
| 58 | using reference = value_type&; | |
| 59 | using const_reference = const value_type&; | |
| 60 | using size_type = typename __alloc_traits::size_type; | |
| 61 | using difference_type = typename __alloc_traits::difference_type; | |
| 62 | using pointer = typename __alloc_traits::pointer; | |
| 63 | using const_pointer = typename __alloc_traits::const_pointer; | |
| 64 | using iterator = pointer; | |
| 65 | using const_iterator = const_pointer; | |
| 68 | 66 | |
| 69 | 67 | // A __split_buffer contains the following members which may be trivially relocatable: |
| 70 | 68 | // - pointer: may be trivially relocatable, so it's checked |
| 71 | 69 | // - allocator_type: may be trivially relocatable, so it's checked |
| 72 | 70 | // __split_buffer doesn't have any self-references, so it's trivially relocatable if its members are. |
| 73 | using __trivially_relocatable = __conditional_t< | |
| 71 | using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t< | |
| 74 | 72 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, |
| 75 | 73 | __split_buffer, |
| 76 | 74 | void>; |
| ... | ... | @@ -78,23 +76,20 @@ public: |
| 78 | 76 | pointer __first_; |
| 79 | 77 | pointer __begin_; |
| 80 | 78 | pointer __end_; |
| 81 | __compressed_pair<pointer, allocator_type> __end_cap_; | |
| 82 | ||
| 83 | using __alloc_ref = __add_lvalue_reference_t<allocator_type>; | |
| 84 | using __alloc_const_ref = __add_lvalue_reference_t<allocator_type>; | |
| 79 | _LIBCPP_COMPRESSED_PAIR(pointer, __cap_, allocator_type, __alloc_); | |
| 85 | 80 | |
| 86 | 81 | __split_buffer(const __split_buffer&) = delete; |
| 87 | 82 | __split_buffer& operator=(const __split_buffer&) = delete; |
| 88 | 83 | |
| 89 | 84 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __split_buffer() |
| 90 | 85 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| 91 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __default_init_tag()) {} | |
| 86 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr) {} | |
| 92 | 87 | |
| 93 | 88 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(__alloc_rr& __a) |
| 94 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) {} | |
| 89 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {} | |
| 95 | 90 | |
| 96 | 91 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __split_buffer(const __alloc_rr& __a) |
| 97 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) {} | |
| 92 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __cap_(nullptr), __alloc_(__a) {} | |
| 98 | 93 | |
| 99 | 94 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI |
| 100 | 95 | __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); |
| ... | ... | @@ -111,16 +106,6 @@ public: |
| 111 | 106 | |
| 112 | 107 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~__split_buffer(); |
| 113 | 108 | |
| 114 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __alloc_rr& __alloc() _NOEXCEPT { return __end_cap_.second(); } | |
| 115 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const __alloc_rr& __alloc() const _NOEXCEPT { | |
| 116 | return __end_cap_.second(); | |
| 117 | } | |
| 118 | ||
| 119 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT { return __end_cap_.first(); } | |
| 120 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT { | |
| 121 | return __end_cap_.first(); | |
| 122 | } | |
| 123 | ||
| 124 | 109 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __begin_; } |
| 125 | 110 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __begin_; } |
| 126 | 111 | |
| ... | ... | @@ -136,7 +121,7 @@ public: |
| 136 | 121 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const { return __end_ == __begin_; } |
| 137 | 122 | |
| 138 | 123 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const { |
| 139 | return static_cast<size_type>(__end_cap() - __first_); | |
| 124 | return static_cast<size_type>(__cap_ - __first_); | |
| 140 | 125 | } |
| 141 | 126 | |
| 142 | 127 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __front_spare() const { |
| ... | ... | @@ -144,7 +129,7 @@ public: |
| 144 | 129 | } |
| 145 | 130 | |
| 146 | 131 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __back_spare() const { |
| 147 | return static_cast<size_type>(__end_cap() - __end_); | |
| 132 | return static_cast<size_type>(__cap_ - __end_); | |
| 148 | 133 | } |
| 149 | 134 | |
| 150 | 135 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() { return *__begin_; } |
| ... | ... | @@ -152,13 +137,10 @@ public: |
| 152 | 137 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() { return *(__end_ - 1); } |
| 153 | 138 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const { return *(__end_ - 1); } |
| 154 | 139 | |
| 155 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n); | |
| 156 | 140 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; |
| 157 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(const_reference __x); | |
| 158 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x); | |
| 159 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x); | |
| 160 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x); | |
| 161 | 141 | |
| 142 | template <class... _Args> | |
| 143 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args); | |
| 162 | 144 | template <class... _Args> |
| 163 | 145 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); |
| 164 | 146 | |
| ... | ... | @@ -168,9 +150,6 @@ public: |
| 168 | 150 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n); |
| 169 | 151 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x); |
| 170 | 152 | |
| 171 | template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0> | |
| 172 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(_InputIter __first, _InputIter __last); | |
| 173 | ||
| 174 | 153 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> |
| 175 | 154 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void |
| 176 | 155 | __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); |
| ... | ... | @@ -205,7 +184,7 @@ public: |
| 205 | 184 | private: |
| 206 | 185 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer& __c, true_type) |
| 207 | 186 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { |
| 208 | __alloc() = std::move(__c.__alloc()); | |
| 187 | __alloc_ = std::move(__c.__alloc_); | |
| 209 | 188 | } |
| 210 | 189 | |
| 211 | 190 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {} |
| ... | ... | @@ -234,14 +213,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants |
| 234 | 213 | return false; |
| 235 | 214 | if (__end_ != nullptr) |
| 236 | 215 | return false; |
| 237 | if (__end_cap() != nullptr) | |
| 216 | if (__cap_ != nullptr) | |
| 238 | 217 | return false; |
| 239 | 218 | } else { |
| 240 | 219 | if (__begin_ < __first_) |
| 241 | 220 | return false; |
| 242 | 221 | if (__end_ < __begin_) |
| 243 | 222 | return false; |
| 244 | if (__end_cap() < __end_) | |
| 223 | if (__cap_ < __end_) | |
| 245 | 224 | return false; |
| 246 | 225 | } |
| 247 | 226 | return true; |
| ... | ... | @@ -256,7 +235,7 @@ template <class _Tp, class _Allocator> |
| 256 | 235 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) { |
| 257 | 236 | _ConstructTransaction __tx(&this->__end_, __n); |
| 258 | 237 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { |
| 259 | __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_)); | |
| 238 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_)); | |
| 260 | 239 | } |
| 261 | 240 | } |
| 262 | 241 | |
| ... | ... | @@ -271,29 +250,22 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 271 | 250 | __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { |
| 272 | 251 | _ConstructTransaction __tx(&this->__end_, __n); |
| 273 | 252 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) { |
| 274 | __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_), __x); | |
| 253 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), __x); | |
| 275 | 254 | } |
| 276 | 255 | } |
| 277 | 256 | |
| 278 | template <class _Tp, class _Allocator> | |
| 279 | template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> > | |
| 280 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 281 | __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) { | |
| 282 | __construct_at_end_with_sentinel(__first, __last); | |
| 283 | } | |
| 284 | ||
| 285 | 257 | template <class _Tp, class _Allocator> |
| 286 | 258 | template <class _Iterator, class _Sentinel> |
| 287 | 259 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 288 | 260 | __split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator __first, _Sentinel __last) { |
| 289 | __alloc_rr& __a = this->__alloc(); | |
| 261 | __alloc_rr& __a = __alloc_; | |
| 290 | 262 | for (; __first != __last; ++__first) { |
| 291 | if (__end_ == __end_cap()) { | |
| 292 | size_type __old_cap = __end_cap() - __first_; | |
| 263 | if (__end_ == __cap_) { | |
| 264 | size_type __old_cap = __cap_ - __first_; | |
| 293 | 265 | size_type __new_cap = std::max<size_type>(2 * __old_cap, 8); |
| 294 | 266 | __split_buffer __buf(__new_cap, 0, __a); |
| 295 | 267 | for (pointer __p = __begin_; __p != __end_; ++__p, (void)++__buf.__end_) |
| 296 | __alloc_traits::construct(__buf.__alloc(), std::__to_address(__buf.__end_), std::move(*__p)); | |
| 268 | __alloc_traits::construct(__buf.__alloc_, std::__to_address(__buf.__end_), std::move(*__p)); | |
| 297 | 269 | swap(__buf); |
| 298 | 270 | } |
| 299 | 271 | __alloc_traits::construct(__a, std::__to_address(this->__end_), *__first); |
| ... | ... | @@ -313,7 +285,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 313 | 285 | __split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) { |
| 314 | 286 | _ConstructTransaction __tx(&this->__end_, __n); |
| 315 | 287 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) { |
| 316 | __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_), *__first); | |
| 288 | __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), *__first); | |
| 317 | 289 | } |
| 318 | 290 | } |
| 319 | 291 | |
| ... | ... | @@ -321,7 +293,7 @@ template <class _Tp, class _Allocator> |
| 321 | 293 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void |
| 322 | 294 | __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) { |
| 323 | 295 | while (__begin_ != __new_begin) |
| 324 | __alloc_traits::destroy(__alloc(), std::__to_address(__begin_++)); | |
| 296 | __alloc_traits::destroy(__alloc_, std::__to_address(__begin_++)); | |
| 325 | 297 | } |
| 326 | 298 | |
| 327 | 299 | template <class _Tp, class _Allocator> |
| ... | ... | @@ -334,7 +306,7 @@ template <class _Tp, class _Allocator> |
| 334 | 306 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void |
| 335 | 307 | __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT { |
| 336 | 308 | while (__new_last != __end_) |
| 337 | __alloc_traits::destroy(__alloc(), std::__to_address(--__end_)); | |
| 309 | __alloc_traits::destroy(__alloc_, std::__to_address(--__end_)); | |
| 338 | 310 | } |
| 339 | 311 | |
| 340 | 312 | template <class _Tp, class _Allocator> |
| ... | ... | @@ -346,23 +318,23 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type |
| 346 | 318 | template <class _Tp, class _Allocator> |
| 347 | 319 | _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 348 | 320 | __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a) |
| 349 | : __end_cap_(nullptr, __a) { | |
| 321 | : __cap_(nullptr), __alloc_(__a) { | |
| 350 | 322 | if (__cap == 0) { |
| 351 | 323 | __first_ = nullptr; |
| 352 | 324 | } else { |
| 353 | auto __allocation = std::__allocate_at_least(__alloc(), __cap); | |
| 325 | auto __allocation = std::__allocate_at_least(__alloc_, __cap); | |
| 354 | 326 | __first_ = __allocation.ptr; |
| 355 | 327 | __cap = __allocation.count; |
| 356 | 328 | } |
| 357 | 329 | __begin_ = __end_ = __first_ + __start; |
| 358 | __end_cap() = __first_ + __cap; | |
| 330 | __cap_ = __first_ + __cap; | |
| 359 | 331 | } |
| 360 | 332 | |
| 361 | 333 | template <class _Tp, class _Allocator> |
| 362 | 334 | _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::~__split_buffer() { |
| 363 | 335 | clear(); |
| 364 | 336 | if (__first_) |
| 365 | __alloc_traits::deallocate(__alloc(), __first_, capacity()); | |
| 337 | __alloc_traits::deallocate(__alloc_, __first_, capacity()); | |
| 366 | 338 | } |
| 367 | 339 | |
| 368 | 340 | template <class _Tp, class _Allocator> |
| ... | ... | @@ -371,31 +343,32 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 __split_buffer<_Tp, _Allocator>::__split_buffer(__ |
| 371 | 343 | : __first_(std::move(__c.__first_)), |
| 372 | 344 | __begin_(std::move(__c.__begin_)), |
| 373 | 345 | __end_(std::move(__c.__end_)), |
| 374 | __end_cap_(std::move(__c.__end_cap_)) { | |
| 375 | __c.__first_ = nullptr; | |
| 376 | __c.__begin_ = nullptr; | |
| 377 | __c.__end_ = nullptr; | |
| 378 | __c.__end_cap() = nullptr; | |
| 346 | __cap_(std::move(__c.__cap_)), | |
| 347 | __alloc_(std::move(__c.__alloc_)) { | |
| 348 | __c.__first_ = nullptr; | |
| 349 | __c.__begin_ = nullptr; | |
| 350 | __c.__end_ = nullptr; | |
| 351 | __c.__cap_ = nullptr; | |
| 379 | 352 | } |
| 380 | 353 | |
| 381 | 354 | template <class _Tp, class _Allocator> |
| 382 | 355 | _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 383 | 356 | __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a) |
| 384 | : __end_cap_(nullptr, __a) { | |
| 385 | if (__a == __c.__alloc()) { | |
| 386 | __first_ = __c.__first_; | |
| 387 | __begin_ = __c.__begin_; | |
| 388 | __end_ = __c.__end_; | |
| 389 | __end_cap() = __c.__end_cap(); | |
| 390 | __c.__first_ = nullptr; | |
| 391 | __c.__begin_ = nullptr; | |
| 392 | __c.__end_ = nullptr; | |
| 393 | __c.__end_cap() = nullptr; | |
| 357 | : __cap_(nullptr), __alloc_(__a) { | |
| 358 | if (__a == __c.__alloc_) { | |
| 359 | __first_ = __c.__first_; | |
| 360 | __begin_ = __c.__begin_; | |
| 361 | __end_ = __c.__end_; | |
| 362 | __cap_ = __c.__cap_; | |
| 363 | __c.__first_ = nullptr; | |
| 364 | __c.__begin_ = nullptr; | |
| 365 | __c.__end_ = nullptr; | |
| 366 | __c.__cap_ = nullptr; | |
| 394 | 367 | } else { |
| 395 | auto __allocation = std::__allocate_at_least(__alloc(), __c.size()); | |
| 368 | auto __allocation = std::__allocate_at_least(__alloc_, __c.size()); | |
| 396 | 369 | __first_ = __allocation.ptr; |
| 397 | 370 | __begin_ = __end_ = __first_; |
| 398 | __end_cap() = __first_ + __allocation.count; | |
| 371 | __cap_ = __first_ + __allocation.count; | |
| 399 | 372 | typedef move_iterator<iterator> _Ip; |
| 400 | 373 | __construct_at_end(_Ip(__c.begin()), _Ip(__c.end())); |
| 401 | 374 | } |
| ... | ... | @@ -409,12 +382,12 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) |
| 409 | 382 | !__alloc_traits::propagate_on_container_move_assignment::value) { |
| 410 | 383 | clear(); |
| 411 | 384 | shrink_to_fit(); |
| 412 | __first_ = __c.__first_; | |
| 413 | __begin_ = __c.__begin_; | |
| 414 | __end_ = __c.__end_; | |
| 415 | __end_cap() = __c.__end_cap(); | |
| 385 | __first_ = __c.__first_; | |
| 386 | __begin_ = __c.__begin_; | |
| 387 | __end_ = __c.__end_; | |
| 388 | __cap_ = __c.__cap_; | |
| 416 | 389 | __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); |
| 417 | __c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; | |
| 390 | __c.__first_ = __c.__begin_ = __c.__end_ = __c.__cap_ = nullptr; | |
| 418 | 391 | return *this; |
| 419 | 392 | } |
| 420 | 393 | |
| ... | ... | @@ -424,151 +397,75 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split |
| 424 | 397 | std::swap(__first_, __x.__first_); |
| 425 | 398 | std::swap(__begin_, __x.__begin_); |
| 426 | 399 | std::swap(__end_, __x.__end_); |
| 427 | std::swap(__end_cap(), __x.__end_cap()); | |
| 428 | std::__swap_allocator(__alloc(), __x.__alloc()); | |
| 429 | } | |
| 430 | ||
| 431 | template <class _Tp, class _Allocator> | |
| 432 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::reserve(size_type __n) { | |
| 433 | if (__n < capacity()) { | |
| 434 | __split_buffer<value_type, __alloc_rr&> __t(__n, 0, __alloc()); | |
| 435 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); | |
| 436 | std::swap(__first_, __t.__first_); | |
| 437 | std::swap(__begin_, __t.__begin_); | |
| 438 | std::swap(__end_, __t.__end_); | |
| 439 | std::swap(__end_cap(), __t.__end_cap()); | |
| 440 | } | |
| 400 | std::swap(__cap_, __x.__cap_); | |
| 401 | std::__swap_allocator(__alloc_, __x.__alloc_); | |
| 441 | 402 | } |
| 442 | 403 | |
| 443 | 404 | template <class _Tp, class _Allocator> |
| 444 | 405 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { |
| 445 | 406 | if (capacity() > size()) { |
| 446 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 407 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 447 | 408 | try { |
| 448 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 449 | __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc()); | |
| 450 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); | |
| 451 | __t.__end_ = __t.__begin_ + (__end_ - __begin_); | |
| 452 | std::swap(__first_, __t.__first_); | |
| 453 | std::swap(__begin_, __t.__begin_); | |
| 454 | std::swap(__end_, __t.__end_); | |
| 455 | std::swap(__end_cap(), __t.__end_cap()); | |
| 456 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 409 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 410 | __split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc_); | |
| 411 | if (__t.capacity() < capacity()) { | |
| 412 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); | |
| 413 | __t.__end_ = __t.__begin_ + (__end_ - __begin_); | |
| 414 | std::swap(__first_, __t.__first_); | |
| 415 | std::swap(__begin_, __t.__begin_); | |
| 416 | std::swap(__end_, __t.__end_); | |
| 417 | std::swap(__cap_, __t.__cap_); | |
| 418 | } | |
| 419 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 457 | 420 | } catch (...) { |
| 458 | 421 | } |
| 459 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 422 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 460 | 423 | } |
| 461 | 424 | } |
| 462 | 425 | |
| 463 | 426 | template <class _Tp, class _Allocator> |
| 464 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_front(const_reference __x) { | |
| 465 | if (__begin_ == __first_) { | |
| 466 | if (__end_ < __end_cap()) { | |
| 467 | difference_type __d = __end_cap() - __end_; | |
| 468 | __d = (__d + 1) / 2; | |
| 469 | __begin_ = std::move_backward(__begin_, __end_, __end_ + __d); | |
| 470 | __end_ += __d; | |
| 471 | } else { | |
| 472 | size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); | |
| 473 | __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc()); | |
| 474 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); | |
| 475 | std::swap(__first_, __t.__first_); | |
| 476 | std::swap(__begin_, __t.__begin_); | |
| 477 | std::swap(__end_, __t.__end_); | |
| 478 | std::swap(__end_cap(), __t.__end_cap()); | |
| 479 | } | |
| 480 | } | |
| 481 | __alloc_traits::construct(__alloc(), std::__to_address(__begin_ - 1), __x); | |
| 482 | --__begin_; | |
| 483 | } | |
| 484 | ||
| 485 | template <class _Tp, class _Allocator> | |
| 486 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) { | |
| 427 | template <class... _Args> | |
| 428 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_front(_Args&&... __args) { | |
| 487 | 429 | if (__begin_ == __first_) { |
| 488 | if (__end_ < __end_cap()) { | |
| 489 | difference_type __d = __end_cap() - __end_; | |
| 430 | if (__end_ < __cap_) { | |
| 431 | difference_type __d = __cap_ - __end_; | |
| 490 | 432 | __d = (__d + 1) / 2; |
| 491 | 433 | __begin_ = std::move_backward(__begin_, __end_, __end_ + __d); |
| 492 | 434 | __end_ += __d; |
| 493 | 435 | } else { |
| 494 | size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); | |
| 495 | __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc()); | |
| 436 | size_type __c = std::max<size_type>(2 * static_cast<size_type>(__cap_ - __first_), 1); | |
| 437 | __split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 3) / 4, __alloc_); | |
| 496 | 438 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); |
| 497 | 439 | std::swap(__first_, __t.__first_); |
| 498 | 440 | std::swap(__begin_, __t.__begin_); |
| 499 | 441 | std::swap(__end_, __t.__end_); |
| 500 | std::swap(__end_cap(), __t.__end_cap()); | |
| 442 | std::swap(__cap_, __t.__cap_); | |
| 501 | 443 | } |
| 502 | 444 | } |
| 503 | __alloc_traits::construct(__alloc(), std::__to_address(__begin_ - 1), std::move(__x)); | |
| 445 | __alloc_traits::construct(__alloc_, std::__to_address(__begin_ - 1), std::forward<_Args>(__args)...); | |
| 504 | 446 | --__begin_; |
| 505 | 447 | } |
| 506 | 448 | |
| 507 | template <class _Tp, class _Allocator> | |
| 508 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void | |
| 509 | __split_buffer<_Tp, _Allocator>::push_back(const_reference __x) { | |
| 510 | if (__end_ == __end_cap()) { | |
| 511 | if (__begin_ > __first_) { | |
| 512 | difference_type __d = __begin_ - __first_; | |
| 513 | __d = (__d + 1) / 2; | |
| 514 | __end_ = std::move(__begin_, __end_, __begin_ - __d); | |
| 515 | __begin_ -= __d; | |
| 516 | } else { | |
| 517 | size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); | |
| 518 | __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); | |
| 519 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); | |
| 520 | std::swap(__first_, __t.__first_); | |
| 521 | std::swap(__begin_, __t.__begin_); | |
| 522 | std::swap(__end_, __t.__end_); | |
| 523 | std::swap(__end_cap(), __t.__end_cap()); | |
| 524 | } | |
| 525 | } | |
| 526 | __alloc_traits::construct(__alloc(), std::__to_address(__end_), __x); | |
| 527 | ++__end_; | |
| 528 | } | |
| 529 | ||
| 530 | template <class _Tp, class _Allocator> | |
| 531 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) { | |
| 532 | if (__end_ == __end_cap()) { | |
| 533 | if (__begin_ > __first_) { | |
| 534 | difference_type __d = __begin_ - __first_; | |
| 535 | __d = (__d + 1) / 2; | |
| 536 | __end_ = std::move(__begin_, __end_, __begin_ - __d); | |
| 537 | __begin_ -= __d; | |
| 538 | } else { | |
| 539 | size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); | |
| 540 | __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); | |
| 541 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); | |
| 542 | std::swap(__first_, __t.__first_); | |
| 543 | std::swap(__begin_, __t.__begin_); | |
| 544 | std::swap(__end_, __t.__end_); | |
| 545 | std::swap(__end_cap(), __t.__end_cap()); | |
| 546 | } | |
| 547 | } | |
| 548 | __alloc_traits::construct(__alloc(), std::__to_address(__end_), std::move(__x)); | |
| 549 | ++__end_; | |
| 550 | } | |
| 551 | ||
| 552 | 449 | template <class _Tp, class _Allocator> |
| 553 | 450 | template <class... _Args> |
| 554 | 451 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) { |
| 555 | if (__end_ == __end_cap()) { | |
| 452 | if (__end_ == __cap_) { | |
| 556 | 453 | if (__begin_ > __first_) { |
| 557 | 454 | difference_type __d = __begin_ - __first_; |
| 558 | 455 | __d = (__d + 1) / 2; |
| 559 | 456 | __end_ = std::move(__begin_, __end_, __begin_ - __d); |
| 560 | 457 | __begin_ -= __d; |
| 561 | 458 | } else { |
| 562 | size_type __c = std::max<size_type>(2 * static_cast<size_t>(__end_cap() - __first_), 1); | |
| 563 | __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc()); | |
| 459 | size_type __c = std::max<size_type>(2 * static_cast<size_type>(__cap_ - __first_), 1); | |
| 460 | __split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc_); | |
| 564 | 461 | __t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_)); |
| 565 | 462 | std::swap(__first_, __t.__first_); |
| 566 | 463 | std::swap(__begin_, __t.__begin_); |
| 567 | 464 | std::swap(__end_, __t.__end_); |
| 568 | std::swap(__end_cap(), __t.__end_cap()); | |
| 465 | std::swap(__cap_, __t.__cap_); | |
| 569 | 466 | } |
| 570 | 467 | } |
| 571 | __alloc_traits::construct(__alloc(), std::__to_address(__end_), std::forward<_Args>(__args)...); | |
| 468 | __alloc_traits::construct(__alloc_, std::__to_address(__end_), std::forward<_Args>(__args)...); | |
| 572 | 469 | ++__end_; |
| 573 | 470 | } |
| 574 | 471 |
lib/libcxx/include/__stop_token/atomic_unique_lock.h+4-4| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #ifndef _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H | |
| 11 | #define _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H | |
| 10 | #ifndef _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H | |
| 11 | #define _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H | |
| 12 | 12 | |
| 13 | 13 | #include <__bit/popcount.h> |
| 14 | 14 | #include <__config> |
| ... | ... | @@ -133,8 +133,8 @@ private: |
| 133 | 133 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __set_locked_bit = [](_State __state) { return __state | _LockedBit; }; |
| 134 | 134 | }; |
| 135 | 135 | |
| 136 | #endif // _LIBCPP_STD_VER >= 20 | |
| 136 | #endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 137 | 137 | |
| 138 | 138 | _LIBCPP_END_NAMESPACE_STD |
| 139 | 139 | |
| 140 | #endif // _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H | |
| 140 | #endif // _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H |
lib/libcxx/include/__stop_token/intrusive_shared_ptr.h+1-1| ... | ... | @@ -13,10 +13,10 @@ |
| 13 | 13 | #include <__atomic/atomic.h> |
| 14 | 14 | #include <__atomic/memory_order.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__cstddef/nullptr_t.h> | |
| 16 | 17 | #include <__type_traits/is_reference.h> |
| 17 | 18 | #include <__utility/move.h> |
| 18 | 19 | #include <__utility/swap.h> |
| 19 | #include <cstddef> | |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 22 | # pragma GCC system_header |
lib/libcxx/include/__stop_token/stop_callback.h+3-3| ... | ... | @@ -31,7 +31,7 @@ _LIBCPP_PUSH_MACROS |
| 31 | 31 | |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | #if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 34 | #if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 35 | 35 | |
| 36 | 36 | template <class _Callback> |
| 37 | 37 | class _LIBCPP_AVAILABILITY_SYNC stop_callback : private __stop_callback_base { |
| ... | ... | @@ -93,10 +93,10 @@ private: |
| 93 | 93 | template <class _Callback> |
| 94 | 94 | _LIBCPP_AVAILABILITY_SYNC stop_callback(stop_token, _Callback) -> stop_callback<_Callback>; |
| 95 | 95 | |
| 96 | #endif // _LIBCPP_STD_VER >= 20 | |
| 96 | #endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 97 | 97 | |
| 98 | 98 | _LIBCPP_END_NAMESPACE_STD |
| 99 | 99 | |
| 100 | 100 | _LIBCPP_POP_MACROS |
| 101 | 101 | |
| 102 | #endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 102 | #endif // _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H |
lib/libcxx/include/__stop_token/stop_source.h+3-3| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | #if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 25 | #if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 26 | 26 | |
| 27 | 27 | struct nostopstate_t { |
| 28 | 28 | explicit nostopstate_t() = default; |
| ... | ... | @@ -84,8 +84,8 @@ private: |
| 84 | 84 | __intrusive_shared_ptr<__stop_state> __state_; |
| 85 | 85 | }; |
| 86 | 86 | |
| 87 | #endif // _LIBCPP_STD_VER >= 20 | |
| 87 | #endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 88 | 88 | |
| 89 | 89 | _LIBCPP_END_NAMESPACE_STD |
| 90 | 90 | |
| 91 | #endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 91 | #endif // _LIBCPP___STOP_TOKEN_STOP_SOURCE_H |
lib/libcxx/include/__stop_token/stop_state.h+6-6| ... | ... | @@ -24,10 +24,10 @@ |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 27 | #if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 28 | 28 | |
| 29 | 29 | struct __stop_callback_base : __intrusive_node_base<__stop_callback_base> { |
| 30 | using __callback_fn_t = void(__stop_callback_base*) noexcept; | |
| 30 | using __callback_fn_t _LIBCPP_NODEBUG = void(__stop_callback_base*) noexcept; | |
| 31 | 31 | _LIBCPP_HIDE_FROM_ABI explicit __stop_callback_base(__callback_fn_t* __callback_fn) : __callback_fn_(__callback_fn) {} |
| 32 | 32 | |
| 33 | 33 | _LIBCPP_HIDE_FROM_ABI void __invoke() noexcept { __callback_fn_(this); } |
| ... | ... | @@ -58,9 +58,9 @@ class __stop_state { |
| 58 | 58 | // It is used by __intrusive_shared_ptr, but it is stored here for better layout |
| 59 | 59 | atomic<uint32_t> __ref_count_ = 0; |
| 60 | 60 | |
| 61 | using __state_t = uint32_t; | |
| 62 | using __callback_list_lock = __atomic_unique_lock<__state_t, __callback_list_locked_bit>; | |
| 63 | using __callback_list = __intrusive_list_view<__stop_callback_base>; | |
| 61 | using __state_t _LIBCPP_NODEBUG = uint32_t; | |
| 62 | using __callback_list_lock _LIBCPP_NODEBUG = __atomic_unique_lock<__state_t, __callback_list_locked_bit>; | |
| 63 | using __callback_list _LIBCPP_NODEBUG = __intrusive_list_view<__stop_callback_base>; | |
| 64 | 64 | |
| 65 | 65 | __callback_list __callback_list_; |
| 66 | 66 | __thread_id __requesting_thread_; |
| ... | ... | @@ -229,7 +229,7 @@ struct __intrusive_shared_ptr_traits<__stop_state> { |
| 229 | 229 | } |
| 230 | 230 | }; |
| 231 | 231 | |
| 232 | #endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 232 | #endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 233 | 233 | |
| 234 | 234 | _LIBCPP_END_NAMESPACE_STD |
| 235 | 235 |
lib/libcxx/include/__stop_token/stop_token.h+2-2| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 23 | #if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 24 | 24 | |
| 25 | 25 | class _LIBCPP_AVAILABILITY_SYNC stop_token { |
| 26 | 26 | public: |
| ... | ... | @@ -56,7 +56,7 @@ private: |
| 56 | 56 | _LIBCPP_HIDE_FROM_ABI explicit stop_token(const __intrusive_shared_ptr<__stop_state>& __state) : __state_(__state) {} |
| 57 | 57 | }; |
| 58 | 58 | |
| 59 | #endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 59 | #endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 60 | 60 | |
| 61 | 61 | _LIBCPP_END_NAMESPACE_STD |
| 62 | 62 |
lib/libcxx/include/__string/char_traits.h+7-6| ... | ... | @@ -17,18 +17,19 @@ |
| 17 | 17 | #include <__assert> |
| 18 | 18 | #include <__compare/ordering.h> |
| 19 | 19 | #include <__config> |
| 20 | #include <__cstddef/ptrdiff_t.h> | |
| 20 | 21 | #include <__functional/hash.h> |
| 21 | 22 | #include <__functional/identity.h> |
| 22 | 23 | #include <__iterator/iterator_traits.h> |
| 24 | #include <__std_mbstate_t.h> | |
| 23 | 25 | #include <__string/constexpr_c_functions.h> |
| 24 | 26 | #include <__type_traits/is_constant_evaluated.h> |
| 25 | 27 | #include <__utility/is_pointer_in_range.h> |
| 26 | #include <cstddef> | |
| 27 | 28 | #include <cstdint> |
| 28 | 29 | #include <cstdio> |
| 29 | 30 | #include <iosfwd> |
| 30 | 31 | |
| 31 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 32 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 32 | 33 | # include <cwchar> // for wmemcpy |
| 33 | 34 | #endif |
| 34 | 35 | |
| ... | ... | @@ -233,7 +234,7 @@ struct __char_traits_base { |
| 233 | 234 | |
| 234 | 235 | // char_traits<wchar_t> |
| 235 | 236 | |
| 236 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 237 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 237 | 238 | template <> |
| 238 | 239 | struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> { |
| 239 | 240 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int |
| ... | ... | @@ -254,9 +255,9 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w |
| 254 | 255 | return std::__constexpr_wmemchr(__s, __a, __n); |
| 255 | 256 | } |
| 256 | 257 | }; |
| 257 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 258 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 258 | 259 | |
| 259 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 260 | #if _LIBCPP_HAS_CHAR8_T | |
| 260 | 261 | |
| 261 | 262 | template <> |
| 262 | 263 | struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> |
| ... | ... | @@ -276,7 +277,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> |
| 276 | 277 | } |
| 277 | 278 | }; |
| 278 | 279 | |
| 279 | #endif // _LIBCPP_HAS_NO_CHAR8_T | |
| 280 | #endif // _LIBCPP_HAS_CHAR8_T | |
| 280 | 281 | |
| 281 | 282 | template <> |
| 282 | 283 | struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> |
lib/libcxx/include/__string/constexpr_c_functions.h+7-8| ... | ... | @@ -10,20 +10,23 @@ |
| 10 | 10 | #define _LIBCPP___STRING_CONSTEXPR_C_FUNCTIONS_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__memory/addressof.h> |
| 14 | 15 | #include <__memory/construct_at.h> |
| 15 | 16 | #include <__type_traits/datasizeof.h> |
| 17 | #include <__type_traits/enable_if.h> | |
| 16 | 18 | #include <__type_traits/is_always_bitcastable.h> |
| 17 | 19 | #include <__type_traits/is_assignable.h> |
| 18 | 20 | #include <__type_traits/is_constant_evaluated.h> |
| 19 | 21 | #include <__type_traits/is_constructible.h> |
| 20 | 22 | #include <__type_traits/is_equality_comparable.h> |
| 23 | #include <__type_traits/is_integral.h> | |
| 21 | 24 | #include <__type_traits/is_same.h> |
| 22 | 25 | #include <__type_traits/is_trivially_copyable.h> |
| 23 | 26 | #include <__type_traits/is_trivially_lexicographically_comparable.h> |
| 24 | 27 | #include <__type_traits/remove_cv.h> |
| 28 | #include <__utility/element_count.h> | |
| 25 | 29 | #include <__utility/is_pointer_in_range.h> |
| 26 | #include <cstddef> | |
| 27 | 30 | |
| 28 | 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | 32 | # pragma GCC system_header |
| ... | ... | @@ -31,17 +34,13 @@ |
| 31 | 34 | |
| 32 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 36 | |
| 34 | // Type used to encode that a function takes an integer that represents a number | |
| 35 | // of elements as opposed to a number of bytes. | |
| 36 | enum class __element_count : size_t {}; | |
| 37 | ||
| 38 | 37 | template <class _Tp> |
| 39 | 38 | inline const bool __is_char_type = false; |
| 40 | 39 | |
| 41 | 40 | template <> |
| 42 | 41 | inline const bool __is_char_type<char> = true; |
| 43 | 42 | |
| 44 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 43 | #if _LIBCPP_HAS_CHAR8_T | |
| 45 | 44 | template <> |
| 46 | 45 | inline const bool __is_char_type<char8_t> = true; |
| 47 | 46 | #endif |
| ... | ... | @@ -64,13 +63,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_st |
| 64 | 63 | return __builtin_strlen(reinterpret_cast<const char*>(__str)); |
| 65 | 64 | } |
| 66 | 65 | |
| 67 | // Because of __libcpp_is_trivially_lexicographically_comparable we know that comparing the object representations is | |
| 66 | // Because of __is_trivially_lexicographically_comparable_v we know that comparing the object representations is | |
| 68 | 67 | // equivalent to a std::memcmp. Since we have multiple objects contiguously in memory, we can call memcmp once instead |
| 69 | 68 | // of invoking it on every object individually. |
| 70 | 69 | template <class _Tp, class _Up> |
| 71 | 70 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int |
| 72 | 71 | __constexpr_memcmp(const _Tp* __lhs, const _Up* __rhs, __element_count __n) { |
| 73 | static_assert(__libcpp_is_trivially_lexicographically_comparable<_Tp, _Up>::value, | |
| 72 | static_assert(__is_trivially_lexicographically_comparable_v<_Tp, _Up>, | |
| 74 | 73 | "_Tp and _Up have to be trivially lexicographically comparable"); |
| 75 | 74 | |
| 76 | 75 | auto __count = static_cast<size_t>(__n); |
lib/libcxx/include/__support/xlocale/__nop_locale_mgmt.h+2-4| ... | ... | @@ -15,13 +15,11 @@ |
| 15 | 15 | // Patch over lack of extended locale support |
| 16 | 16 | typedef void* locale_t; |
| 17 | 17 | |
| 18 | inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return NULL; } | |
| 18 | inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return nullptr; } | |
| 19 | 19 | |
| 20 | 20 | inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {} |
| 21 | 21 | |
| 22 | inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return NULL; } | |
| 23 | ||
| 24 | inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return NULL; } | |
| 22 | inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return nullptr; } | |
| 25 | 23 | |
| 26 | 24 | #define LC_COLLATE_MASK (1 << LC_COLLATE) |
| 27 | 25 | #define LC_CTYPE_MASK (1 << LC_CTYPE) |
lib/libcxx/include/__support/xlocale/__posix_l_fallback.h+6-22| ... | ... | @@ -20,29 +20,15 @@ |
| 20 | 20 | #include <string.h> |
| 21 | 21 | #include <time.h> |
| 22 | 22 | |
| 23 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 23 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 24 | 24 | # include <wchar.h> |
| 25 | 25 | # include <wctype.h> |
| 26 | 26 | #endif |
| 27 | 27 | |
| 28 | inline _LIBCPP_HIDE_FROM_ABI int isalnum_l(int __c, locale_t) { return ::isalnum(__c); } | |
| 29 | ||
| 30 | inline _LIBCPP_HIDE_FROM_ABI int isalpha_l(int __c, locale_t) { return ::isalpha(__c); } | |
| 31 | ||
| 32 | inline _LIBCPP_HIDE_FROM_ABI int iscntrl_l(int __c, locale_t) { return ::iscntrl(__c); } | |
| 33 | ||
| 34 | 28 | inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) { return ::isdigit(__c); } |
| 35 | 29 | |
| 36 | inline _LIBCPP_HIDE_FROM_ABI int isgraph_l(int __c, locale_t) { return ::isgraph(__c); } | |
| 37 | ||
| 38 | 30 | inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, locale_t) { return ::islower(__c); } |
| 39 | 31 | |
| 40 | inline _LIBCPP_HIDE_FROM_ABI int isprint_l(int __c, locale_t) { return ::isprint(__c); } | |
| 41 | ||
| 42 | inline _LIBCPP_HIDE_FROM_ABI int ispunct_l(int __c, locale_t) { return ::ispunct(__c); } | |
| 43 | ||
| 44 | inline _LIBCPP_HIDE_FROM_ABI int isspace_l(int __c, locale_t) { return ::isspace(__c); } | |
| 45 | ||
| 46 | 32 | inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, locale_t) { return ::isupper(__c); } |
| 47 | 33 | |
| 48 | 34 | inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) { return ::isxdigit(__c); } |
| ... | ... | @@ -51,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) { return ::toupper |
| 51 | 37 | |
| 52 | 38 | inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) { return ::tolower(__c); } |
| 53 | 39 | |
| 54 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 55 | inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) { return ::iswalnum(__c); } | |
| 40 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 41 | inline _LIBCPP_HIDE_FROM_ABI int iswctype_l(wint_t __c, wctype_t __type, locale_t) { return ::iswctype(__c, __type); } | |
| 56 | 42 | |
| 57 | 43 | inline _LIBCPP_HIDE_FROM_ABI int iswalpha_l(wint_t __c, locale_t) { return ::iswalpha(__c); } |
| 58 | 44 | |
| ... | ... | @@ -62,8 +48,6 @@ inline _LIBCPP_HIDE_FROM_ABI int iswcntrl_l(wint_t __c, locale_t) { return ::isw |
| 62 | 48 | |
| 63 | 49 | inline _LIBCPP_HIDE_FROM_ABI int iswdigit_l(wint_t __c, locale_t) { return ::iswdigit(__c); } |
| 64 | 50 | |
| 65 | inline _LIBCPP_HIDE_FROM_ABI int iswgraph_l(wint_t __c, locale_t) { return ::iswgraph(__c); } | |
| 66 | ||
| 67 | 51 | inline _LIBCPP_HIDE_FROM_ABI int iswlower_l(wint_t __c, locale_t) { return ::iswlower(__c); } |
| 68 | 52 | |
| 69 | 53 | inline _LIBCPP_HIDE_FROM_ABI int iswprint_l(wint_t __c, locale_t) { return ::iswprint(__c); } |
| ... | ... | @@ -79,7 +63,7 @@ inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) { return ::is |
| 79 | 63 | inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) { return ::towupper(__c); } |
| 80 | 64 | |
| 81 | 65 | inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) { return ::towlower(__c); } |
| 82 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 66 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 83 | 67 | |
| 84 | 68 | inline _LIBCPP_HIDE_FROM_ABI int strcoll_l(const char* __s1, const char* __s2, locale_t) { |
| 85 | 69 | return ::strcoll(__s1, __s2); |
| ... | ... | @@ -94,7 +78,7 @@ strftime_l(char* __s, size_t __max, const char* __format, const struct tm* __tm, |
| 94 | 78 | return ::strftime(__s, __max, __format, __tm); |
| 95 | 79 | } |
| 96 | 80 | |
| 97 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 81 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 98 | 82 | inline _LIBCPP_HIDE_FROM_ABI int wcscoll_l(const wchar_t* __ws1, const wchar_t* __ws2, locale_t) { |
| 99 | 83 | return ::wcscoll(__ws1, __ws2); |
| 100 | 84 | } |
| ... | ... | @@ -102,6 +86,6 @@ inline _LIBCPP_HIDE_FROM_ABI int wcscoll_l(const wchar_t* __ws1, const wchar_t* |
| 102 | 86 | inline _LIBCPP_HIDE_FROM_ABI size_t wcsxfrm_l(wchar_t* __dest, const wchar_t* __src, size_t __n, locale_t) { |
| 103 | 87 | return ::wcsxfrm(__dest, __src, __n); |
| 104 | 88 | } |
| 105 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 89 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 106 | 90 | |
| 107 | 91 | #endif // _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H |
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h+1-1| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #include <__config> |
| 19 | 19 | #include <stdlib.h> |
| 20 | 20 | |
| 21 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 21 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 22 | 22 | # include <wchar.h> |
| 23 | 23 | #endif |
| 24 | 24 |
lib/libcxx/include/__system_error/errc.h+1-1| ... | ... | @@ -133,7 +133,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 133 | 133 | // enum class errc |
| 134 | 134 | // |
| 135 | 135 | // LWG3869 deprecates the UNIX STREAMS macros and enum values. |
| 136 | // This makes the code clumbersome: | |
| 136 | // This makes the code cumbersome: | |
| 137 | 137 | // - the enum value is deprecated and should show a diagnostic, |
| 138 | 138 | // - the macro is deprecated and should _not_ show a diagnostic in this |
| 139 | 139 | // context, and |
lib/libcxx/include/__system_error/error_code.h-1| ... | ... | @@ -17,7 +17,6 @@ |
| 17 | 17 | #include <__system_error/errc.h> |
| 18 | 18 | #include <__system_error/error_category.h> |
| 19 | 19 | #include <__system_error/error_condition.h> |
| 20 | #include <cstddef> | |
| 21 | 20 | #include <string> |
| 22 | 21 | |
| 23 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__system_error/error_condition.h-1| ... | ... | @@ -16,7 +16,6 @@ |
| 16 | 16 | #include <__functional/unary_function.h> |
| 17 | 17 | #include <__system_error/errc.h> |
| 18 | 18 | #include <__system_error/error_category.h> |
| 19 | #include <cstddef> | |
| 20 | 19 | #include <string> |
| 21 | 20 | |
| 22 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__system_error/system_error.h+6-3| ... | ... | @@ -39,9 +39,12 @@ public: |
| 39 | 39 | _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg); | |
| 43 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) { | |
| 44 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 42 | // __ev is expected to be an error in the generic_category domain (e.g. from | |
| 43 | // errno, or std::errc::*), not system_category (e.g. from windows syscalls). | |
| 44 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg); | |
| 45 | ||
| 46 | [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) { | |
| 47 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 45 | 48 | throw system_error(__ec, __what_arg); |
| 46 | 49 | #else |
| 47 | 50 | _LIBCPP_VERBOSE_ABORT( |
lib/libcxx/include/__system_error/throw_system_error.h created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 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___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H | |
| 11 | #define _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_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 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg); | |
| 22 | ||
| 23 | _LIBCPP_END_NAMESPACE_STD | |
| 24 | ||
| 25 | #endif // _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H |
lib/libcxx/include/__thread/formatter.h+2-2| ... | ... | @@ -31,7 +31,7 @@ |
| 31 | 31 | |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | # ifndef _LIBCPP_HAS_NO_THREADS | |
| 34 | # if _LIBCPP_HAS_THREADS | |
| 35 | 35 | |
| 36 | 36 | template <__fmt_char_type _CharT> |
| 37 | 37 | struct _LIBCPP_TEMPLATE_VIS formatter<__thread_id, _CharT> { |
| ... | ... | @@ -71,7 +71,7 @@ public: |
| 71 | 71 | __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__right}; |
| 72 | 72 | }; |
| 73 | 73 | |
| 74 | # endif // !_LIBCPP_HAS_NO_THREADS | |
| 74 | # endif // _LIBCPP_HAS_THREADS | |
| 75 | 75 | |
| 76 | 76 | _LIBCPP_END_NAMESPACE_STD |
| 77 | 77 |
lib/libcxx/include/__thread/id.h+2-2| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 25 | #if _LIBCPP_HAS_THREADS | |
| 26 | 26 | class _LIBCPP_EXPORTED_FROM_ABI __thread_id; |
| 27 | 27 | |
| 28 | 28 | namespace this_thread { |
| ... | ... | @@ -114,7 +114,7 @@ inline _LIBCPP_HIDE_FROM_ABI __thread_id get_id() _NOEXCEPT { return __libcpp_th |
| 114 | 114 | |
| 115 | 115 | } // namespace this_thread |
| 116 | 116 | |
| 117 | #endif // !_LIBCPP_HAS_NO_THREADS | |
| 117 | #endif // _LIBCPP_HAS_THREADS | |
| 118 | 118 | |
| 119 | 119 | _LIBCPP_END_NAMESPACE_STD |
| 120 | 120 |
lib/libcxx/include/__thread/jthread.h+5-3| ... | ... | @@ -11,17 +11,19 @@ |
| 11 | 11 | #define _LIBCPP___THREAD_JTHREAD_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/invoke.h> | |
| 15 | 14 | #include <__stop_token/stop_source.h> |
| 16 | 15 | #include <__stop_token/stop_token.h> |
| 16 | #include <__thread/id.h> | |
| 17 | 17 | #include <__thread/support.h> |
| 18 | 18 | #include <__thread/thread.h> |
| 19 | 19 | #include <__type_traits/decay.h> |
| 20 | #include <__type_traits/invoke.h> | |
| 20 | 21 | #include <__type_traits/is_constructible.h> |
| 21 | 22 | #include <__type_traits/is_same.h> |
| 22 | 23 | #include <__type_traits/remove_cvref.h> |
| 23 | 24 | #include <__utility/forward.h> |
| 24 | 25 | #include <__utility/move.h> |
| 26 | #include <__utility/swap.h> | |
| 25 | 27 | |
| 26 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | 29 | # pragma GCC system_header |
| ... | ... | @@ -30,7 +32,7 @@ |
| 30 | 32 | _LIBCPP_PUSH_MACROS |
| 31 | 33 | #include <__undef_macros> |
| 32 | 34 | |
| 33 | #if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) | |
| 35 | #if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 34 | 36 | |
| 35 | 37 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 38 | |
| ... | ... | @@ -127,7 +129,7 @@ private: |
| 127 | 129 | |
| 128 | 130 | _LIBCPP_END_NAMESPACE_STD |
| 129 | 131 | |
| 130 | #endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) | |
| 132 | #endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS | |
| 131 | 133 | |
| 132 | 134 | _LIBCPP_POP_MACROS |
| 133 | 135 |
lib/libcxx/include/__thread/support.h+6-6| ... | ... | @@ -104,20 +104,20 @@ _LIBCPP_END_NAMESPACE_STD |
| 104 | 104 | |
| 105 | 105 | */ |
| 106 | 106 | |
| 107 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 107 | #if _LIBCPP_HAS_THREADS | |
| 108 | 108 | |
| 109 | # if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | |
| 109 | # if _LIBCPP_HAS_THREAD_API_EXTERNAL | |
| 110 | 110 | # include <__thread/support/external.h> |
| 111 | # elif defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | |
| 111 | # elif _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 112 | 112 | # include <__thread/support/pthread.h> |
| 113 | # elif defined(_LIBCPP_HAS_THREAD_API_C11) | |
| 113 | # elif _LIBCPP_HAS_THREAD_API_C11 | |
| 114 | 114 | # include <__thread/support/c11.h> |
| 115 | # elif defined(_LIBCPP_HAS_THREAD_API_WIN32) | |
| 115 | # elif _LIBCPP_HAS_THREAD_API_WIN32 | |
| 116 | 116 | # include <__thread/support/windows.h> |
| 117 | 117 | # else |
| 118 | 118 | # error "No threading API was selected" |
| 119 | 119 | # endif |
| 120 | 120 | |
| 121 | #endif // !_LIBCPP_HAS_NO_THREADS | |
| 121 | #endif // _LIBCPP_HAS_THREADS | |
| 122 | 122 | |
| 123 | 123 | #endif // _LIBCPP___THREAD_SUPPORT_H |
lib/libcxx/include/__thread/support/pthread.h+1-1| ... | ... | @@ -39,7 +39,7 @@ |
| 39 | 39 | |
| 40 | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 41 | |
| 42 | using __libcpp_timespec_t = ::timespec; | |
| 42 | using __libcpp_timespec_t _LIBCPP_NODEBUG = ::timespec; | |
| 43 | 43 | |
| 44 | 44 | // |
| 45 | 45 | // Mutex |
lib/libcxx/include/__thread/this_thread.h+5| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #ifndef _LIBCPP___THREAD_THIS_THREAD_H |
| 11 | 11 | #define _LIBCPP___THREAD_THIS_THREAD_H |
| 12 | 12 | |
| 13 | #include <__chrono/duration.h> | |
| 13 | 14 | #include <__chrono/steady_clock.h> |
| 14 | 15 | #include <__chrono/time_point.h> |
| 15 | 16 | #include <__condition_variable/condition_variable.h> |
| ... | ... | @@ -29,6 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 30 | |
| 30 | 31 | namespace this_thread { |
| 31 | 32 | |
| 33 | #if _LIBCPP_HAS_THREADS | |
| 34 | ||
| 32 | 35 | _LIBCPP_EXPORTED_FROM_ABI void sleep_for(const chrono::nanoseconds& __ns); |
| 33 | 36 | |
| 34 | 37 | template <class _Rep, class _Period> |
| ... | ... | @@ -65,6 +68,8 @@ inline _LIBCPP_HIDE_FROM_ABI void sleep_until(const chrono::time_point<chrono::s |
| 65 | 68 | |
| 66 | 69 | inline _LIBCPP_HIDE_FROM_ABI void yield() _NOEXCEPT { __libcpp_thread_yield(); } |
| 67 | 70 | |
| 71 | #endif // _LIBCPP_HAS_THREADS | |
| 72 | ||
| 68 | 73 | } // namespace this_thread |
| 69 | 74 | |
| 70 | 75 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__thread/thread.h+19-10| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #ifndef _LIBCPP___THREAD_THREAD_H |
| 11 | 11 | #define _LIBCPP___THREAD_THREAD_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__condition_variable/condition_variable.h> |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__exception/terminate.h> |
| ... | ... | @@ -17,13 +18,17 @@ |
| 17 | 18 | #include <__functional/unary_function.h> |
| 18 | 19 | #include <__memory/unique_ptr.h> |
| 19 | 20 | #include <__mutex/mutex.h> |
| 20 | #include <__system_error/system_error.h> | |
| 21 | #include <__system_error/throw_system_error.h> | |
| 21 | 22 | #include <__thread/id.h> |
| 22 | 23 | #include <__thread/support.h> |
| 24 | #include <__type_traits/decay.h> | |
| 25 | #include <__type_traits/enable_if.h> | |
| 26 | #include <__type_traits/is_same.h> | |
| 27 | #include <__type_traits/remove_cvref.h> | |
| 23 | 28 | #include <__utility/forward.h> |
| 24 | 29 | #include <tuple> |
| 25 | 30 | |
| 26 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 31 | #if _LIBCPP_HAS_LOCALIZATION | |
| 27 | 32 | # include <locale> |
| 28 | 33 | # include <sstream> |
| 29 | 34 | #endif |
| ... | ... | @@ -37,6 +42,8 @@ _LIBCPP_PUSH_MACROS |
| 37 | 42 | |
| 38 | 43 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 39 | 44 | |
| 45 | #if _LIBCPP_HAS_THREADS | |
| 46 | ||
| 40 | 47 | template <class _Tp> |
| 41 | 48 | class __thread_specific_ptr; |
| 42 | 49 | class _LIBCPP_EXPORTED_FROM_ABI __thread_struct; |
| ... | ... | @@ -117,7 +124,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> : public __unary_function<__thread |
| 117 | 124 | } |
| 118 | 125 | }; |
| 119 | 126 | |
| 120 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 127 | # if _LIBCPP_HAS_LOCALIZATION | |
| 121 | 128 | template <class _CharT, class _Traits> |
| 122 | 129 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| 123 | 130 | operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) { |
| ... | ... | @@ -142,7 +149,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) { |
| 142 | 149 | __sstr << __id.__id_; |
| 143 | 150 | return __os << __sstr.str(); |
| 144 | 151 | } |
| 145 | #endif // _LIBCPP_HAS_NO_LOCALIZATION | |
| 152 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 146 | 153 | |
| 147 | 154 | class _LIBCPP_EXPORTED_FROM_ABI thread { |
| 148 | 155 | __libcpp_thread_t __t_; |
| ... | ... | @@ -155,13 +162,13 @@ public: |
| 155 | 162 | typedef __libcpp_thread_t native_handle_type; |
| 156 | 163 | |
| 157 | 164 | _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {} |
| 158 | #ifndef _LIBCPP_CXX03_LANG | |
| 165 | # ifndef _LIBCPP_CXX03_LANG | |
| 159 | 166 | template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0> |
| 160 | 167 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args); |
| 161 | #else // _LIBCPP_CXX03_LANG | |
| 168 | # else // _LIBCPP_CXX03_LANG | |
| 162 | 169 | template <class _Fp> |
| 163 | 170 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp __f); |
| 164 | #endif | |
| 171 | # endif | |
| 165 | 172 | ~thread(); |
| 166 | 173 | |
| 167 | 174 | _LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { __t.__t_ = _LIBCPP_NULL_THREAD; } |
| ... | ... | @@ -185,7 +192,7 @@ public: |
| 185 | 192 | static unsigned hardware_concurrency() _NOEXCEPT; |
| 186 | 193 | }; |
| 187 | 194 | |
| 188 | #ifndef _LIBCPP_CXX03_LANG | |
| 195 | # ifndef _LIBCPP_CXX03_LANG | |
| 189 | 196 | |
| 190 | 197 | template <class _TSp, class _Fp, class... _Args, size_t... _Indices> |
| 191 | 198 | inline _LIBCPP_HIDE_FROM_ABI void __thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>) { |
| ... | ... | @@ -215,7 +222,7 @@ thread::thread(_Fp&& __f, _Args&&... __args) { |
| 215 | 222 | __throw_system_error(__ec, "thread constructor failed"); |
| 216 | 223 | } |
| 217 | 224 | |
| 218 | #else // _LIBCPP_CXX03_LANG | |
| 225 | # else // _LIBCPP_CXX03_LANG | |
| 219 | 226 | |
| 220 | 227 | template <class _Fp> |
| 221 | 228 | struct __thread_invoke_pair { |
| ... | ... | @@ -247,10 +254,12 @@ thread::thread(_Fp __f) { |
| 247 | 254 | __throw_system_error(__ec, "thread constructor failed"); |
| 248 | 255 | } |
| 249 | 256 | |
| 250 | #endif // _LIBCPP_CXX03_LANG | |
| 257 | # endif // _LIBCPP_CXX03_LANG | |
| 251 | 258 | |
| 252 | 259 | inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); } |
| 253 | 260 | |
| 261 | #endif // _LIBCPP_HAS_THREADS | |
| 262 | ||
| 254 | 263 | _LIBCPP_END_NAMESPACE_STD |
| 255 | 264 | |
| 256 | 265 | _LIBCPP_POP_MACROS |
lib/libcxx/include/__thread/timed_backoff_policy.h+2-2| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 15 | #if _LIBCPP_HAS_THREADS | |
| 16 | 16 | |
| 17 | 17 | # include <__chrono/duration.h> |
| 18 | 18 | # include <__thread/support.h> |
| ... | ... | @@ -39,6 +39,6 @@ struct __libcpp_timed_backoff_policy { |
| 39 | 39 | |
| 40 | 40 | _LIBCPP_END_NAMESPACE_STD |
| 41 | 41 | |
| 42 | #endif // _LIBCPP_HAS_NO_THREADS | |
| 42 | #endif // _LIBCPP_HAS_THREADS | |
| 43 | 43 | |
| 44 | 44 | #endif // _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H |
lib/libcxx/include/__tree+42-38| ... | ... | @@ -13,7 +13,6 @@ |
| 13 | 13 | #include <__algorithm/min.h> |
| 14 | 14 | #include <__assert> |
| 15 | 15 | #include <__config> |
| 16 | #include <__functional/invoke.h> | |
| 17 | 16 | #include <__iterator/distance.h> |
| 18 | 17 | #include <__iterator/iterator_traits.h> |
| 19 | 18 | #include <__iterator/next.h> |
| ... | ... | @@ -24,12 +23,12 @@ |
| 24 | 23 | #include <__memory/swap_allocator.h> |
| 25 | 24 | #include <__memory/unique_ptr.h> |
| 26 | 25 | #include <__type_traits/can_extract_key.h> |
| 27 | #include <__type_traits/conditional.h> | |
| 26 | #include <__type_traits/enable_if.h> | |
| 27 | #include <__type_traits/invoke.h> | |
| 28 | 28 | #include <__type_traits/is_const.h> |
| 29 | 29 | #include <__type_traits/is_constructible.h> |
| 30 | 30 | #include <__type_traits/is_nothrow_assignable.h> |
| 31 | 31 | #include <__type_traits/is_nothrow_constructible.h> |
| 32 | #include <__type_traits/is_pointer.h> | |
| 33 | 32 | #include <__type_traits/is_same.h> |
| 34 | 33 | #include <__type_traits/is_swappable.h> |
| 35 | 34 | #include <__type_traits/remove_const_ref.h> |
| ... | ... | @@ -566,11 +565,18 @@ struct __tree_node_base_types { |
| 566 | 565 | |
| 567 | 566 | typedef __tree_end_node<__node_base_pointer> __end_node_type; |
| 568 | 567 | typedef __rebind_pointer_t<_VoidPtr, __end_node_type> __end_node_pointer; |
| 569 | #if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB) | |
| 570 | 568 | typedef __end_node_pointer __parent_pointer; |
| 571 | #else | |
| 572 | typedef __conditional_t< is_pointer<__end_node_pointer>::value, __end_node_pointer, __node_base_pointer> | |
| 573 | __parent_pointer; | |
| 569 | ||
| 570 | // TODO(LLVM 22): Remove this check | |
| 571 | #ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB | |
| 572 | static_assert(sizeof(__node_base_pointer) == sizeof(__end_node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) == | |
| 573 | _LIBCPP_ALIGNOF(__end_node_pointer), | |
| 574 | "It looks like you are using std::__tree (an implementation detail for (multi)map/set) with a fancy " | |
| 575 | "pointer type that thas a different representation depending on whether it points to a __tree base " | |
| 576 | "pointer or a __tree node pointer (both of which are implementation details of the standard library). " | |
| 577 | "This means that your ABI is being broken between LLVM 19 and LLVM 20. If you don't care about your " | |
| 578 | "ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to silence this " | |
| 579 | "diagnostic."); | |
| 574 | 580 | #endif |
| 575 | 581 | |
| 576 | 582 | private: |
| ... | ... | @@ -605,12 +611,7 @@ public: |
| 605 | 611 | typedef _Tp __node_value_type; |
| 606 | 612 | typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer; |
| 607 | 613 | typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer; |
| 608 | #if defined(_LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB) | |
| 609 | 614 | typedef typename __base::__end_node_pointer __iter_pointer; |
| 610 | #else | |
| 611 | typedef __conditional_t< is_pointer<__node_pointer>::value, typename __base::__end_node_pointer, __node_pointer> | |
| 612 | __iter_pointer; | |
| 613 | #endif | |
| 614 | 615 | |
| 615 | 616 | private: |
| 616 | 617 | static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const"); |
| ... | ... | @@ -875,7 +876,7 @@ private: |
| 875 | 876 | |
| 876 | 877 | template <class _Tp, class _Compare> |
| 877 | 878 | #ifndef _LIBCPP_CXX03_LANG |
| 878 | _LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value, | |
| 879 | _LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Compare const&, _Tp const&, _Tp const&>, | |
| 879 | 880 | "the specified comparator type does not provide a viable const call operator") |
| 880 | 881 | #endif |
| 881 | 882 | int __diagnose_non_const_comparator(); |
| ... | ... | @@ -932,21 +933,21 @@ private: |
| 932 | 933 | |
| 933 | 934 | private: |
| 934 | 935 | __iter_pointer __begin_node_; |
| 935 | __compressed_pair<__end_node_t, __node_allocator> __pair1_; | |
| 936 | __compressed_pair<size_type, value_compare> __pair3_; | |
| 936 | _LIBCPP_COMPRESSED_PAIR(__end_node_t, __end_node_, __node_allocator, __node_alloc_); | |
| 937 | _LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_); | |
| 937 | 938 | |
| 938 | 939 | public: |
| 939 | 940 | _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() _NOEXCEPT { |
| 940 | return static_cast<__iter_pointer>(pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first())); | |
| 941 | return static_cast<__iter_pointer>(pointer_traits<__end_node_ptr>::pointer_to(__end_node_)); | |
| 941 | 942 | } |
| 942 | 943 | _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() const _NOEXCEPT { |
| 943 | 944 | return static_cast<__iter_pointer>( |
| 944 | pointer_traits<__end_node_ptr>::pointer_to(const_cast<__end_node_t&>(__pair1_.first()))); | |
| 945 | pointer_traits<__end_node_ptr>::pointer_to(const_cast<__end_node_t&>(__end_node_))); | |
| 945 | 946 | } |
| 946 | _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __pair1_.second(); } | |
| 947 | _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; } | |
| 947 | 948 | |
| 948 | 949 | private: |
| 949 | _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __pair1_.second(); } | |
| 950 | _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; } | |
| 950 | 951 | _LIBCPP_HIDE_FROM_ABI __iter_pointer& __begin_node() _NOEXCEPT { return __begin_node_; } |
| 951 | 952 | _LIBCPP_HIDE_FROM_ABI const __iter_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; } |
| 952 | 953 | |
| ... | ... | @@ -954,12 +955,12 @@ public: |
| 954 | 955 | _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); } |
| 955 | 956 | |
| 956 | 957 | private: |
| 957 | _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __pair3_.first(); } | |
| 958 | _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; } | |
| 958 | 959 | |
| 959 | 960 | public: |
| 960 | _LIBCPP_HIDE_FROM_ABI const size_type& size() const _NOEXCEPT { return __pair3_.first(); } | |
| 961 | _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __pair3_.second(); } | |
| 962 | _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __pair3_.second(); } | |
| 961 | _LIBCPP_HIDE_FROM_ABI const size_type& size() const _NOEXCEPT { return __size_; } | |
| 962 | _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __value_comp_; } | |
| 963 | _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __value_comp_; } | |
| 963 | 964 | |
| 964 | 965 | public: |
| 965 | 966 | _LIBCPP_HIDE_FROM_ABI __node_pointer __root() const _NOEXCEPT { |
| ... | ... | @@ -1324,21 +1325,19 @@ private: |
| 1324 | 1325 | template <class _Tp, class _Compare, class _Allocator> |
| 1325 | 1326 | __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_( |
| 1326 | 1327 | is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value) |
| 1327 | : __pair3_(0, __comp) { | |
| 1328 | : __size_(0), __value_comp_(__comp) { | |
| 1328 | 1329 | __begin_node() = __end_node(); |
| 1329 | 1330 | } |
| 1330 | 1331 | |
| 1331 | 1332 | template <class _Tp, class _Compare, class _Allocator> |
| 1332 | 1333 | __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) |
| 1333 | : __begin_node_(__iter_pointer()), | |
| 1334 | __pair1_(__default_init_tag(), __node_allocator(__a)), | |
| 1335 | __pair3_(0, __default_init_tag()) { | |
| 1334 | : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0) { | |
| 1336 | 1335 | __begin_node() = __end_node(); |
| 1337 | 1336 | } |
| 1338 | 1337 | |
| 1339 | 1338 | template <class _Tp, class _Compare, class _Allocator> |
| 1340 | 1339 | __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) |
| 1341 | : __begin_node_(__iter_pointer()), __pair1_(__default_init_tag(), __node_allocator(__a)), __pair3_(0, __comp) { | |
| 1340 | : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) { | |
| 1342 | 1341 | __begin_node() = __end_node(); |
| 1343 | 1342 | } |
| 1344 | 1343 | |
| ... | ... | @@ -1437,8 +1436,9 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _ |
| 1437 | 1436 | template <class _Tp, class _Compare, class _Allocator> |
| 1438 | 1437 | __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) |
| 1439 | 1438 | : __begin_node_(__iter_pointer()), |
| 1440 | __pair1_(__default_init_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())), | |
| 1441 | __pair3_(0, __t.value_comp()) { | |
| 1439 | __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())), | |
| 1440 | __size_(0), | |
| 1441 | __value_comp_(__t.value_comp()) { | |
| 1442 | 1442 | __begin_node() = __end_node(); |
| 1443 | 1443 | } |
| 1444 | 1444 | |
| ... | ... | @@ -1446,8 +1446,10 @@ template <class _Tp, class _Compare, class _Allocator> |
| 1446 | 1446 | __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_( |
| 1447 | 1447 | is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value) |
| 1448 | 1448 | : __begin_node_(std::move(__t.__begin_node_)), |
| 1449 | __pair1_(std::move(__t.__pair1_)), | |
| 1450 | __pair3_(std::move(__t.__pair3_)) { | |
| 1449 | __end_node_(std::move(__t.__end_node_)), | |
| 1450 | __node_alloc_(std::move(__t.__node_alloc_)), | |
| 1451 | __size_(__t.__size_), | |
| 1452 | __value_comp_(std::move(__t.__value_comp_)) { | |
| 1451 | 1453 | if (size() == 0) |
| 1452 | 1454 | __begin_node() = __end_node(); |
| 1453 | 1455 | else { |
| ... | ... | @@ -1460,7 +1462,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_( |
| 1460 | 1462 | |
| 1461 | 1463 | template <class _Tp, class _Compare, class _Allocator> |
| 1462 | 1464 | __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a) |
| 1463 | : __pair1_(__default_init_tag(), __node_allocator(__a)), __pair3_(0, std::move(__t.value_comp())) { | |
| 1465 | : __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(std::move(__t.value_comp())) { | |
| 1464 | 1466 | if (__a == __t.__alloc()) { |
| 1465 | 1467 | if (__t.size() == 0) |
| 1466 | 1468 | __begin_node() = __end_node(); |
| ... | ... | @@ -1482,10 +1484,11 @@ template <class _Tp, class _Compare, class _Allocator> |
| 1482 | 1484 | void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type) |
| 1483 | 1485 | _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value) { |
| 1484 | 1486 | destroy(static_cast<__node_pointer>(__end_node()->__left_)); |
| 1485 | __begin_node_ = __t.__begin_node_; | |
| 1486 | __pair1_.first() = __t.__pair1_.first(); | |
| 1487 | __begin_node_ = __t.__begin_node_; | |
| 1488 | __end_node_ = __t.__end_node_; | |
| 1487 | 1489 | __move_assign_alloc(__t); |
| 1488 | __pair3_ = std::move(__t.__pair3_); | |
| 1490 | __size_ = __t.__size_; | |
| 1491 | __value_comp_ = std::move(__t.__value_comp_); | |
| 1489 | 1492 | if (size() == 0) |
| 1490 | 1493 | __begin_node() = __end_node(); |
| 1491 | 1494 | else { |
| ... | ... | @@ -1554,9 +1557,10 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) |
| 1554 | 1557 | { |
| 1555 | 1558 | using std::swap; |
| 1556 | 1559 | swap(__begin_node_, __t.__begin_node_); |
| 1557 | swap(__pair1_.first(), __t.__pair1_.first()); | |
| 1560 | swap(__end_node_, __t.__end_node_); | |
| 1558 | 1561 | std::__swap_allocator(__node_alloc(), __t.__node_alloc()); |
| 1559 | __pair3_.swap(__t.__pair3_); | |
| 1562 | swap(__size_, __t.__size_); | |
| 1563 | swap(__value_comp_, __t.__value_comp_); | |
| 1560 | 1564 | if (size() == 0) |
| 1561 | 1565 | __begin_node() = __end_node(); |
| 1562 | 1566 | else |
lib/libcxx/include/__tuple/find_index.h+1-1| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___TUPLE_FIND_INDEX_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/is_same.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
lib/libcxx/include/__tuple/make_tuple_types.h+9-9| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__fwd/array.h> |
| 14 | 15 | #include <__fwd/tuple.h> |
| 15 | 16 | #include <__tuple/tuple_element.h> |
| ... | ... | @@ -17,9 +18,8 @@ |
| 17 | 18 | #include <__tuple/tuple_size.h> |
| 18 | 19 | #include <__tuple/tuple_types.h> |
| 19 | 20 | #include <__type_traits/copy_cvref.h> |
| 20 | #include <__type_traits/remove_cv.h> | |
| 21 | #include <__type_traits/remove_cvref.h> | |
| 21 | 22 | #include <__type_traits/remove_reference.h> |
| 22 | #include <cstddef> | |
| 23 | 23 | |
| 24 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | 25 | # pragma GCC system_header |
| ... | ... | @@ -47,9 +47,9 @@ struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> { |
| 47 | 47 | template <class _Vt, size_t _Np, size_t... _Idx> |
| 48 | 48 | struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> { |
| 49 | 49 | template <size_t> |
| 50 | using __value_type = _Vt; | |
| 50 | using __value_type _LIBCPP_NODEBUG = _Vt; | |
| 51 | 51 | template <class _Tp> |
| 52 | using __apply_quals = __tuple_types<__copy_cvref_t<_Tp, __value_type<_Idx>>...>; | |
| 52 | using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__copy_cvref_t<_Tp, __value_type<_Idx>>...>; | |
| 53 | 53 | }; |
| 54 | 54 | |
| 55 | 55 | template <class _Tp, |
| ... | ... | @@ -58,19 +58,19 @@ template <class _Tp, |
| 58 | 58 | bool _SameSize = (_Ep == tuple_size<__libcpp_remove_reference_t<_Tp> >::value)> |
| 59 | 59 | struct __make_tuple_types { |
| 60 | 60 | static_assert(_Sp <= _Ep, "__make_tuple_types input error"); |
| 61 | using _RawTp = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >; | |
| 62 | using _Maker = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>; | |
| 63 | using type = typename _Maker::template __apply_quals<_Tp>; | |
| 61 | using _RawTp _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>; | |
| 62 | using _Maker _LIBCPP_NODEBUG = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>; | |
| 63 | using type = typename _Maker::template __apply_quals<_Tp>; | |
| 64 | 64 | }; |
| 65 | 65 | |
| 66 | 66 | template <class... _Types, size_t _Ep> |
| 67 | 67 | struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> { |
| 68 | typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type; | |
| 68 | using type _LIBCPP_NODEBUG = __tuple_types<_Types...>; | |
| 69 | 69 | }; |
| 70 | 70 | |
| 71 | 71 | template <class... _Types, size_t _Ep> |
| 72 | 72 | struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> { |
| 73 | typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type; | |
| 73 | using type _LIBCPP_NODEBUG = __tuple_types<_Types...>; | |
| 74 | 74 | }; |
| 75 | 75 | |
| 76 | 76 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__tuple/sfinae_helpers.h+3-3| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___TUPLE_SFINAE_HELPERS_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__fwd/tuple.h> |
| 14 | 15 | #include <__tuple/make_tuple_types.h> |
| 15 | 16 | #include <__tuple/tuple_element.h> |
| ... | ... | @@ -23,7 +24,6 @@ |
| 23 | 24 | #include <__type_traits/is_same.h> |
| 24 | 25 | #include <__type_traits/remove_cvref.h> |
| 25 | 26 | #include <__type_traits/remove_reference.h> |
| 26 | #include <cstddef> | |
| 27 | 27 | |
| 28 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | 29 | # pragma GCC system_header |
| ... | ... | @@ -41,7 +41,7 @@ struct __tuple_sfinae_base { |
| 41 | 41 | static auto __do_test(...) -> false_type; |
| 42 | 42 | |
| 43 | 43 | template <class _FromArgs, class _ToArgs> |
| 44 | using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{})); | |
| 44 | using __constructible _LIBCPP_NODEBUG = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{})); | |
| 45 | 45 | }; |
| 46 | 46 | |
| 47 | 47 | // __tuple_constructible |
| ... | ... | @@ -59,7 +59,7 @@ struct __tuple_constructible<_Tp, _Up, true, true> |
| 59 | 59 | |
| 60 | 60 | template <size_t _Ip, class... _Tp> |
| 61 | 61 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > { |
| 62 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; | |
| 62 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, __tuple_types<_Tp...> >::type; | |
| 63 | 63 | }; |
| 64 | 64 | |
| 65 | 65 | struct _LIBCPP_EXPORTED_FROM_ABI __check_tuple_constructor_fail { |
lib/libcxx/include/__tuple/tuple_element.h+5-5| ... | ... | @@ -10,9 +10,9 @@ |
| 10 | 10 | #define _LIBCPP___TUPLE_TUPLE_ELEMENT_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__tuple/tuple_indices.h> |
| 14 | 15 | #include <__tuple/tuple_types.h> |
| 15 | #include <cstddef> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | # pragma GCC system_header |
| ... | ... | @@ -25,17 +25,17 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element; |
| 25 | 25 | |
| 26 | 26 | template <size_t _Ip, class _Tp> |
| 27 | 27 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> { |
| 28 | typedef _LIBCPP_NODEBUG const typename tuple_element<_Ip, _Tp>::type type; | |
| 28 | using type _LIBCPP_NODEBUG = const typename tuple_element<_Ip, _Tp>::type; | |
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | 31 | template <size_t _Ip, class _Tp> |
| 32 | 32 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> { |
| 33 | typedef _LIBCPP_NODEBUG volatile typename tuple_element<_Ip, _Tp>::type type; | |
| 33 | using type _LIBCPP_NODEBUG = volatile typename tuple_element<_Ip, _Tp>::type; | |
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | 36 | template <size_t _Ip, class _Tp> |
| 37 | 37 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> { |
| 38 | typedef _LIBCPP_NODEBUG const volatile typename tuple_element<_Ip, _Tp>::type type; | |
| 38 | using type _LIBCPP_NODEBUG = const volatile typename tuple_element<_Ip, _Tp>::type; | |
| 39 | 39 | }; |
| 40 | 40 | |
| 41 | 41 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -43,7 +43,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> { |
| 43 | 43 | template <size_t _Ip, class... _Types> |
| 44 | 44 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > { |
| 45 | 45 | static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range"); |
| 46 | typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type; | |
| 46 | using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>; | |
| 47 | 47 | }; |
| 48 | 48 | |
| 49 | 49 | # if _LIBCPP_STD_VER >= 14 |
lib/libcxx/include/__tuple/tuple_indices.h+1-1| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__utility/integer_sequence.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
lib/libcxx/include/__tuple/tuple_like_ext.h+1-1| ... | ... | @@ -10,12 +10,12 @@ |
| 10 | 10 | #define _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__fwd/array.h> |
| 14 | 15 | #include <__fwd/pair.h> |
| 15 | 16 | #include <__fwd/tuple.h> |
| 16 | 17 | #include <__tuple/tuple_types.h> |
| 17 | 18 | #include <__type_traits/integral_constant.h> |
| 18 | #include <cstddef> | |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | 21 | # pragma GCC system_header |
lib/libcxx/include/__tuple/tuple_like_no_subrange.h+1-1| ... | ... | @@ -10,13 +10,13 @@ |
| 10 | 10 | #define _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__fwd/array.h> |
| 14 | 15 | #include <__fwd/complex.h> |
| 15 | 16 | #include <__fwd/pair.h> |
| 16 | 17 | #include <__fwd/tuple.h> |
| 17 | 18 | #include <__tuple/tuple_size.h> |
| 18 | 19 | #include <__type_traits/remove_cvref.h> |
| 19 | #include <cstddef> | |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 22 | # pragma GCC system_header |
lib/libcxx/include/__tuple/tuple_size.h+4-2| ... | ... | @@ -10,11 +10,13 @@ |
| 10 | 10 | #define _LIBCPP___TUPLE_TUPLE_SIZE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__fwd/tuple.h> |
| 14 | 15 | #include <__tuple/tuple_types.h> |
| 16 | #include <__type_traits/enable_if.h> | |
| 17 | #include <__type_traits/integral_constant.h> | |
| 15 | 18 | #include <__type_traits/is_const.h> |
| 16 | 19 | #include <__type_traits/is_volatile.h> |
| 17 | #include <cstddef> | |
| 18 | 20 | |
| 19 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 22 | # pragma GCC system_header |
| ... | ... | @@ -27,7 +29,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size; |
| 27 | 29 | |
| 28 | 30 | #if !defined(_LIBCPP_CXX03_LANG) |
| 29 | 31 | template <class _Tp, class...> |
| 30 | using __enable_if_tuple_size_imp = _Tp; | |
| 32 | using __enable_if_tuple_size_imp _LIBCPP_NODEBUG = _Tp; | |
| 31 | 33 | |
| 32 | 34 | template <class _Tp> |
| 33 | 35 | struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< const _Tp, |
lib/libcxx/include/__type_traits/add_const.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_ADD_CONST_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_CONST_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> | |
| 21 | struct _LIBCPP_TEMPLATE_VIS add_const { | |
| 22 | typedef _LIBCPP_NODEBUG const _Tp type; | |
| 23 | }; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER >= 14 | |
| 26 | template <class _Tp> | |
| 27 | using add_const_t = typename add_const<_Tp>::type; | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_ADD_CONST_H |
lib/libcxx/include/__type_traits/add_cv.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_ADD_CV_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_CV_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> | |
| 21 | struct _LIBCPP_TEMPLATE_VIS add_cv { | |
| 22 | typedef _LIBCPP_NODEBUG const volatile _Tp type; | |
| 23 | }; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER >= 14 | |
| 26 | template <class _Tp> | |
| 27 | using add_cv_t = typename add_cv<_Tp>::type; | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H |
lib/libcxx/include/__type_traits/add_cv_quals.h created+52| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ADD_CV_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_CV_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> | |
| 21 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_const { | |
| 22 | using type _LIBCPP_NODEBUG = const _Tp; | |
| 23 | }; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER >= 14 | |
| 26 | template <class _Tp> | |
| 27 | using add_const_t = typename add_const<_Tp>::type; | |
| 28 | #endif | |
| 29 | ||
| 30 | template <class _Tp> | |
| 31 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_cv { | |
| 32 | using type _LIBCPP_NODEBUG = const volatile _Tp; | |
| 33 | }; | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER >= 14 | |
| 36 | template <class _Tp> | |
| 37 | using add_cv_t = typename add_cv<_Tp>::type; | |
| 38 | #endif | |
| 39 | ||
| 40 | template <class _Tp> | |
| 41 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_volatile { | |
| 42 | using type _LIBCPP_NODEBUG = volatile _Tp; | |
| 43 | }; | |
| 44 | ||
| 45 | #if _LIBCPP_STD_VER >= 14 | |
| 46 | template <class _Tp> | |
| 47 | using add_volatile_t = typename add_volatile<_Tp>::type; | |
| 48 | #endif | |
| 49 | ||
| 50 | _LIBCPP_END_NAMESPACE_STD | |
| 51 | ||
| 52 | #endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H |
lib/libcxx/include/__type_traits/add_lvalue_reference.h+4-4| ... | ... | @@ -21,17 +21,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | #if __has_builtin(__add_lvalue_reference) |
| 22 | 22 | |
| 23 | 23 | template <class _Tp> |
| 24 | using __add_lvalue_reference_t = __add_lvalue_reference(_Tp); | |
| 24 | using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp); | |
| 25 | 25 | |
| 26 | 26 | #else |
| 27 | 27 | |
| 28 | 28 | template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value> |
| 29 | 29 | struct __add_lvalue_reference_impl { |
| 30 | typedef _LIBCPP_NODEBUG _Tp type; | |
| 30 | using type _LIBCPP_NODEBUG = _Tp; | |
| 31 | 31 | }; |
| 32 | 32 | template <class _Tp > |
| 33 | 33 | struct __add_lvalue_reference_impl<_Tp, true> { |
| 34 | typedef _LIBCPP_NODEBUG _Tp& type; | |
| 34 | using type _LIBCPP_NODEBUG = _Tp&; | |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | template <class _Tp> |
| ... | ... | @@ -40,7 +40,7 @@ using __add_lvalue_reference_t = typename __add_lvalue_reference_impl<_Tp>::type |
| 40 | 40 | #endif // __has_builtin(__add_lvalue_reference) |
| 41 | 41 | |
| 42 | 42 | template <class _Tp> |
| 43 | struct add_lvalue_reference { | |
| 43 | struct _LIBCPP_NO_SPECIALIZATIONS add_lvalue_reference { | |
| 44 | 44 | using type _LIBCPP_NODEBUG = __add_lvalue_reference_t<_Tp>; |
| 45 | 45 | }; |
| 46 | 46 |
lib/libcxx/include/__type_traits/add_pointer.h+4-4| ... | ... | @@ -23,16 +23,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | #if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer) |
| 24 | 24 | |
| 25 | 25 | template <class _Tp> |
| 26 | using __add_pointer_t = __add_pointer(_Tp); | |
| 26 | using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp); | |
| 27 | 27 | |
| 28 | 28 | #else |
| 29 | 29 | template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value || is_void<_Tp>::value> |
| 30 | 30 | struct __add_pointer_impl { |
| 31 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp>* type; | |
| 31 | using type _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>*; | |
| 32 | 32 | }; |
| 33 | 33 | template <class _Tp> |
| 34 | 34 | struct __add_pointer_impl<_Tp, false> { |
| 35 | typedef _LIBCPP_NODEBUG _Tp type; | |
| 35 | using type _LIBCPP_NODEBUG = _Tp; | |
| 36 | 36 | }; |
| 37 | 37 | |
| 38 | 38 | template <class _Tp> |
| ... | ... | @@ -41,7 +41,7 @@ using __add_pointer_t = typename __add_pointer_impl<_Tp>::type; |
| 41 | 41 | #endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer) |
| 42 | 42 | |
| 43 | 43 | template <class _Tp> |
| 44 | struct add_pointer { | |
| 44 | struct _LIBCPP_NO_SPECIALIZATIONS add_pointer { | |
| 45 | 45 | using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>; |
| 46 | 46 | }; |
| 47 | 47 |
lib/libcxx/include/__type_traits/add_rvalue_reference.h+4-4| ... | ... | @@ -21,17 +21,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | #if __has_builtin(__add_rvalue_reference) |
| 22 | 22 | |
| 23 | 23 | template <class _Tp> |
| 24 | using __add_rvalue_reference_t = __add_rvalue_reference(_Tp); | |
| 24 | using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp); | |
| 25 | 25 | |
| 26 | 26 | #else |
| 27 | 27 | |
| 28 | 28 | template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value> |
| 29 | 29 | struct __add_rvalue_reference_impl { |
| 30 | typedef _LIBCPP_NODEBUG _Tp type; | |
| 30 | using type _LIBCPP_NODEBUG = _Tp; | |
| 31 | 31 | }; |
| 32 | 32 | template <class _Tp > |
| 33 | 33 | struct __add_rvalue_reference_impl<_Tp, true> { |
| 34 | typedef _LIBCPP_NODEBUG _Tp&& type; | |
| 34 | using type _LIBCPP_NODEBUG = _Tp&&; | |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | template <class _Tp> |
| ... | ... | @@ -40,7 +40,7 @@ using __add_rvalue_reference_t = typename __add_rvalue_reference_impl<_Tp>::type |
| 40 | 40 | #endif // __has_builtin(__add_rvalue_reference) |
| 41 | 41 | |
| 42 | 42 | template <class _Tp> |
| 43 | struct add_rvalue_reference { | |
| 43 | struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference { | |
| 44 | 44 | using type = __add_rvalue_reference_t<_Tp>; |
| 45 | 45 | }; |
| 46 | 46 |
lib/libcxx/include/__type_traits/add_volatile.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_ADD_VOLATILE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> | |
| 21 | struct _LIBCPP_TEMPLATE_VIS add_volatile { | |
| 22 | typedef _LIBCPP_NODEBUG volatile _Tp type; | |
| 23 | }; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER >= 14 | |
| 26 | template <class _Tp> | |
| 27 | using add_volatile_t = typename add_volatile<_Tp>::type; | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H |
lib/libcxx/include/__type_traits/aligned_storage.h+21-71| ... | ... | @@ -10,11 +10,9 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__type_traits/conditional.h> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | 14 | #include <__type_traits/integral_constant.h> |
| 15 | #include <__type_traits/nat.h> | |
| 16 | 15 | #include <__type_traits/type_list.h> |
| 17 | #include <cstddef> | |
| 18 | 16 | |
| 19 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 18 | # pragma GCC system_header |
| ... | ... | @@ -35,42 +33,23 @@ struct __struct_double4 { |
| 35 | 33 | double __lx[4]; |
| 36 | 34 | }; |
| 37 | 35 | |
| 38 | // clang-format off | |
| 39 | typedef __type_list<__align_type<unsigned char>, | |
| 40 | __type_list<__align_type<unsigned short>, | |
| 41 | __type_list<__align_type<unsigned int>, | |
| 42 | __type_list<__align_type<unsigned long>, | |
| 43 | __type_list<__align_type<unsigned long long>, | |
| 44 | __type_list<__align_type<double>, | |
| 45 | __type_list<__align_type<long double>, | |
| 46 | __type_list<__align_type<__struct_double>, | |
| 47 | __type_list<__align_type<__struct_double4>, | |
| 48 | __type_list<__align_type<int*>, | |
| 49 | __nat | |
| 50 | > > > > > > > > > > __all_types; | |
| 51 | // clang-format on | |
| 52 | ||
| 53 | template <size_t _Align> | |
| 54 | struct _ALIGNAS(_Align) __fallback_overaligned {}; | |
| 55 | ||
| 56 | template <class _TL, size_t _Align> | |
| 57 | struct __find_pod; | |
| 58 | ||
| 59 | template <class _Hp, size_t _Align> | |
| 60 | struct __find_pod<__type_list<_Hp, __nat>, _Align> { | |
| 61 | typedef __conditional_t<_Align == _Hp::value, typename _Hp::type, __fallback_overaligned<_Align> > type; | |
| 62 | }; | |
| 63 | ||
| 64 | template <class _Hp, class _Tp, size_t _Align> | |
| 65 | struct __find_pod<__type_list<_Hp, _Tp>, _Align> { | |
| 66 | typedef __conditional_t<_Align == _Hp::value, typename _Hp::type, typename __find_pod<_Tp, _Align>::type> type; | |
| 67 | }; | |
| 36 | using __all_types _LIBCPP_NODEBUG = | |
| 37 | __type_list<__align_type<unsigned char>, | |
| 38 | __align_type<unsigned short>, | |
| 39 | __align_type<unsigned int>, | |
| 40 | __align_type<unsigned long>, | |
| 41 | __align_type<unsigned long long>, | |
| 42 | __align_type<double>, | |
| 43 | __align_type<long double>, | |
| 44 | __align_type<__struct_double>, | |
| 45 | __align_type<__struct_double4>, | |
| 46 | __align_type<int*> >; | |
| 68 | 47 | |
| 69 | 48 | template <class _TL, size_t _Len> |
| 70 | 49 | struct __find_max_align; |
| 71 | 50 | |
| 72 | template <class _Hp, size_t _Len> | |
| 73 | struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; | |
| 51 | template <class _Head, size_t _Len> | |
| 52 | struct __find_max_align<__type_list<_Head>, _Len> : public integral_constant<size_t, _Head::value> {}; | |
| 74 | 53 | |
| 75 | 54 | template <size_t _Len, size_t _A1, size_t _A2> |
| 76 | 55 | struct __select_align { |
| ... | ... | @@ -82,15 +61,15 @@ public: |
| 82 | 61 | static const size_t value = _Len < __max ? __min : __max; |
| 83 | 62 | }; |
| 84 | 63 | |
| 85 | template <class _Hp, class _Tp, size_t _Len> | |
| 86 | struct __find_max_align<__type_list<_Hp, _Tp>, _Len> | |
| 87 | : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; | |
| 64 | template <class _Head, class... _Tail, size_t _Len> | |
| 65 | struct __find_max_align<__type_list<_Head, _Tail...>, _Len> | |
| 66 | : public integral_constant< | |
| 67 | size_t, | |
| 68 | __select_align<_Len, _Head::value, __find_max_align<__type_list<_Tail...>, _Len>::value>::value> {}; | |
| 88 | 69 | |
| 89 | 70 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> |
| 90 | struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage { | |
| 91 | typedef typename __find_pod<__all_types, _Align>::type _Aligner; | |
| 92 | union type { | |
| 93 | _Aligner __align; | |
| 71 | struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS aligned_storage { | |
| 72 | union _ALIGNAS(_Align) type { | |
| 94 | 73 | unsigned char __data[(_Len + _Align - 1) / _Align * _Align]; |
| 95 | 74 | }; |
| 96 | 75 | }; |
| ... | ... | @@ -104,35 +83,6 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 104 | 83 | |
| 105 | 84 | #endif |
| 106 | 85 | |
| 107 | #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ | |
| 108 | template <size_t _Len> \ | |
| 109 | struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n> { \ | |
| 110 | struct _ALIGNAS(n) type { \ | |
| 111 | unsigned char __lx[(_Len + n - 1) / n * n]; \ | |
| 112 | }; \ | |
| 113 | } | |
| 114 | ||
| 115 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); | |
| 116 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); | |
| 117 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); | |
| 118 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); | |
| 119 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); | |
| 120 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); | |
| 121 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); | |
| 122 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); | |
| 123 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); | |
| 124 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); | |
| 125 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); | |
| 126 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); | |
| 127 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); | |
| 128 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); | |
| 129 | // PE/COFF does not support alignment beyond 8192 (=0x2000) | |
| 130 | #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 131 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); | |
| 132 | #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 133 | ||
| 134 | #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION | |
| 135 | ||
| 136 | 86 | _LIBCPP_END_NAMESPACE_STD |
| 137 | 87 | |
| 138 | 88 | #endif // _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H |
lib/libcxx/include/__type_traits/aligned_union.h+2-3| ... | ... | @@ -10,9 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/aligned_storage.h> |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <cstddef> | |
| 16 | 15 | |
| 17 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 17 | # pragma GCC system_header |
| ... | ... | @@ -34,7 +33,7 @@ struct __static_max<_I0, _I1, _In...> { |
| 34 | 33 | }; |
| 35 | 34 | |
| 36 | 35 | template <size_t _Len, class _Type0, class... _Types> |
| 37 | struct _LIBCPP_DEPRECATED_IN_CXX23 aligned_union { | |
| 36 | struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_NO_SPECIALIZATIONS aligned_union { | |
| 38 | 37 | static const size_t alignment_value = |
| 39 | 38 | __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; |
| 40 | 39 | static const size_t __len = __static_max<_Len, sizeof(_Type0), sizeof(_Types)...>::value; |
lib/libcxx/include/__type_traits/alignment_of.h+4-3| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/integral_constant.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
| ... | ... | @@ -20,11 +20,12 @@ |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | 22 | template <class _Tp> |
| 23 | struct _LIBCPP_TEMPLATE_VIS alignment_of : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; | |
| 23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS alignment_of | |
| 24 | : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; | |
| 24 | 25 | |
| 25 | 26 | #if _LIBCPP_STD_VER >= 17 |
| 26 | 27 | template <class _Tp> |
| 27 | inline constexpr size_t alignment_of_v = _LIBCPP_ALIGNOF(_Tp); | |
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t alignment_of_v = _LIBCPP_ALIGNOF(_Tp); | |
| 28 | 29 | #endif |
| 29 | 30 | |
| 30 | 31 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/common_reference.h+10-11| ... | ... | @@ -15,7 +15,6 @@ |
| 15 | 15 | #include <__type_traits/copy_cvref.h> |
| 16 | 16 | #include <__type_traits/is_convertible.h> |
| 17 | 17 | #include <__type_traits/is_reference.h> |
| 18 | #include <__type_traits/remove_cv.h> | |
| 19 | 18 | #include <__type_traits/remove_cvref.h> |
| 20 | 19 | #include <__type_traits/remove_reference.h> |
| 21 | 20 | #include <__utility/declval.h> |
| ... | ... | @@ -30,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 29 | #if _LIBCPP_STD_VER >= 20 |
| 31 | 30 | // Let COND_RES(X, Y) be: |
| 32 | 31 | template <class _Xp, class _Yp> |
| 33 | using __cond_res = decltype(false ? std::declval<_Xp (&)()>()() : std::declval<_Yp (&)()>()()); | |
| 32 | using __cond_res _LIBCPP_NODEBUG = decltype(false ? std::declval<_Xp (&)()>()() : std::declval<_Yp (&)()>()()); | |
| 34 | 33 | |
| 35 | 34 | // Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U` |
| 36 | 35 | // with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type |
| ... | ... | @@ -39,7 +38,7 @@ using __cond_res = decltype(false ? std::declval<_Xp (&)()>()() : std::declval<_ |
| 39 | 38 | template <class _Tp> |
| 40 | 39 | struct __xref { |
| 41 | 40 | template <class _Up> |
| 42 | using __apply = __copy_cvref_t<_Tp, _Up>; | |
| 41 | using __apply _LIBCPP_NODEBUG = __copy_cvref_t<_Tp, _Up>; | |
| 43 | 42 | }; |
| 44 | 43 | |
| 45 | 44 | // Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>, |
| ... | ... | @@ -48,10 +47,10 @@ template <class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = |
| 48 | 47 | struct __common_ref; |
| 49 | 48 | |
| 50 | 49 | template <class _Xp, class _Yp> |
| 51 | using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type; | |
| 50 | using __common_ref_t _LIBCPP_NODEBUG = typename __common_ref<_Xp, _Yp>::__type; | |
| 52 | 51 | |
| 53 | 52 | template <class _Xp, class _Yp> |
| 54 | using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>; | |
| 53 | using __cv_cond_res _LIBCPP_NODEBUG = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>; | |
| 55 | 54 | |
| 56 | 55 | // If A and B are both lvalue reference types, COMMON-REF(A, B) is |
| 57 | 56 | // COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type. |
| ... | ... | @@ -61,13 +60,13 @@ template <class _Ap, class _Bp, class _Xp, class _Yp> |
| 61 | 60 | requires { typename __cv_cond_res<_Xp, _Yp>; } && |
| 62 | 61 | is_reference_v<__cv_cond_res<_Xp, _Yp>> |
| 63 | 62 | struct __common_ref<_Ap&, _Bp&, _Xp, _Yp> { |
| 64 | using __type = __cv_cond_res<_Xp, _Yp>; | |
| 63 | using __type _LIBCPP_NODEBUG = __cv_cond_res<_Xp, _Yp>; | |
| 65 | 64 | }; |
| 66 | 65 | // clang-format on |
| 67 | 66 | |
| 68 | 67 | // Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ... |
| 69 | 68 | template <class _Xp, class _Yp> |
| 70 | using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&; | |
| 69 | using __common_ref_C _LIBCPP_NODEBUG = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&; | |
| 71 | 70 | |
| 72 | 71 | // .... If A and B are both rvalue reference types, C is well-formed, and |
| 73 | 72 | // is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C. |
| ... | ... | @@ -78,13 +77,13 @@ template <class _Ap, class _Bp, class _Xp, class _Yp> |
| 78 | 77 | is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> && |
| 79 | 78 | is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>> |
| 80 | 79 | struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp> { |
| 81 | using __type = __common_ref_C<_Xp, _Yp>; | |
| 80 | using __type _LIBCPP_NODEBUG = __common_ref_C<_Xp, _Yp>; | |
| 82 | 81 | }; |
| 83 | 82 | // clang-format on |
| 84 | 83 | |
| 85 | 84 | // Otherwise, let D be COMMON-REF(const X&, Y&). ... |
| 86 | 85 | template <class _Tp, class _Up> |
| 87 | using __common_ref_D = __common_ref_t<const _Tp&, _Up&>; | |
| 86 | using __common_ref_D _LIBCPP_NODEBUG = __common_ref_t<const _Tp&, _Up&>; | |
| 88 | 87 | |
| 89 | 88 | // ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and |
| 90 | 89 | // is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D. |
| ... | ... | @@ -94,7 +93,7 @@ template <class _Ap, class _Bp, class _Xp, class _Yp> |
| 94 | 93 | requires { typename __common_ref_D<_Xp, _Yp>; } && |
| 95 | 94 | is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>> |
| 96 | 95 | struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp> { |
| 97 | using __type = __common_ref_D<_Xp, _Yp>; | |
| 96 | using __type _LIBCPP_NODEBUG = __common_ref_D<_Xp, _Yp>; | |
| 98 | 97 | }; |
| 99 | 98 | // clang-format on |
| 100 | 99 | |
| ... | ... | @@ -150,7 +149,7 @@ template <class, class, template <class> class, template <class> class> |
| 150 | 149 | struct basic_common_reference {}; |
| 151 | 150 | |
| 152 | 151 | template <class _Tp, class _Up> |
| 153 | using __basic_common_reference_t = | |
| 152 | using __basic_common_reference_t _LIBCPP_NODEBUG = | |
| 154 | 153 | typename basic_common_reference<remove_cvref_t<_Tp>, |
| 155 | 154 | remove_cvref_t<_Up>, |
| 156 | 155 | __xref<_Tp>::template __apply, |
lib/libcxx/include/__type_traits/common_type.h+21-5| ... | ... | @@ -14,8 +14,10 @@ |
| 14 | 14 | #include <__type_traits/decay.h> |
| 15 | 15 | #include <__type_traits/is_same.h> |
| 16 | 16 | #include <__type_traits/remove_cvref.h> |
| 17 | #include <__type_traits/type_identity.h> | |
| 17 | 18 | #include <__type_traits/void_t.h> |
| 18 | 19 | #include <__utility/declval.h> |
| 20 | #include <__utility/empty.h> | |
| 19 | 21 | |
| 20 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | 23 | # pragma GCC system_header |
| ... | ... | @@ -23,10 +25,22 @@ |
| 23 | 25 | |
| 24 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 27 | |
| 26 | #if _LIBCPP_STD_VER >= 20 | |
| 28 | #if __has_builtin(__builtin_common_type) | |
| 29 | ||
| 30 | template <class... _Args> | |
| 31 | struct common_type; | |
| 32 | ||
| 33 | template <class... _Args> | |
| 34 | using __common_type_t _LIBCPP_NODEBUG = typename common_type<_Args...>::type; | |
| 35 | ||
| 36 | template <class... _Args> | |
| 37 | struct common_type : __builtin_common_type<__common_type_t, __type_identity, __empty, _Args...> {}; | |
| 38 | ||
| 39 | #else | |
| 40 | # if _LIBCPP_STD_VER >= 20 | |
| 27 | 41 | // Let COND_RES(X, Y) be: |
| 28 | 42 | template <class _Tp, class _Up> |
| 29 | using __cond_type = decltype(false ? std::declval<_Tp>() : std::declval<_Up>()); | |
| 43 | using __cond_type _LIBCPP_NODEBUG = decltype(false ? std::declval<_Tp>() : std::declval<_Up>()); | |
| 30 | 44 | |
| 31 | 45 | template <class _Tp, class _Up, class = void> |
| 32 | 46 | struct __common_type3 {}; |
| ... | ... | @@ -39,15 +53,15 @@ struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> { |
| 39 | 53 | |
| 40 | 54 | template <class _Tp, class _Up, class = void> |
| 41 | 55 | struct __common_type2_imp : __common_type3<_Tp, _Up> {}; |
| 42 | #else | |
| 56 | # else | |
| 43 | 57 | template <class _Tp, class _Up, class = void> |
| 44 | 58 | struct __common_type2_imp {}; |
| 45 | #endif | |
| 59 | # endif | |
| 46 | 60 | |
| 47 | 61 | // sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..." |
| 48 | 62 | template <class _Tp, class _Up> |
| 49 | 63 | struct __common_type2_imp<_Tp, _Up, __void_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())> > { |
| 50 | typedef _LIBCPP_NODEBUG __decay_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())> type; | |
| 64 | using type _LIBCPP_NODEBUG = __decay_t<decltype(true ? std::declval<_Tp>() : std::declval<_Up>())>; | |
| 51 | 65 | }; |
| 52 | 66 | |
| 53 | 67 | template <class, class = void> |
| ... | ... | @@ -92,6 +106,8 @@ template <class _Tp, class _Up, class _Vp, class... _Rest> |
| 92 | 106 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp, _Rest...> |
| 93 | 107 | : __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...> > {}; |
| 94 | 108 | |
| 109 | #endif | |
| 110 | ||
| 95 | 111 | #if _LIBCPP_STD_VER >= 14 |
| 96 | 112 | template <class... _Tp> |
| 97 | 113 | using common_type_t = typename common_type<_Tp...>::type; |
lib/libcxx/include/__type_traits/conditional.h+7-1| ... | ... | @@ -36,13 +36,19 @@ template <bool _Cond, class _IfRes, class _ElseRes> |
| 36 | 36 | using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>; |
| 37 | 37 | |
| 38 | 38 | template <bool _Bp, class _If, class _Then> |
| 39 | struct _LIBCPP_TEMPLATE_VIS conditional { | |
| 39 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS conditional { | |
| 40 | 40 | using type _LIBCPP_NODEBUG = _If; |
| 41 | 41 | }; |
| 42 | ||
| 43 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 44 | #if __has_warning("-Winvalid-specialization") | |
| 45 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | |
| 46 | #endif | |
| 42 | 47 | template <class _If, class _Then> |
| 43 | 48 | struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> { |
| 44 | 49 | using type _LIBCPP_NODEBUG = _Then; |
| 45 | 50 | }; |
| 51 | _LIBCPP_DIAGNOSTIC_POP | |
| 46 | 52 | |
| 47 | 53 | #if _LIBCPP_STD_VER >= 14 |
| 48 | 54 | template <bool _Bp, class _IfRes, class _ElseRes> |
lib/libcxx/include/__type_traits/conjunction.h+8-3| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | 24 | template <class...> |
| 25 | using __expand_to_true = true_type; | |
| 25 | using __expand_to_true _LIBCPP_NODEBUG = true_type; | |
| 26 | 26 | |
| 27 | 27 | template <class... _Pred> |
| 28 | 28 | __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int); |
| ... | ... | @@ -47,16 +47,21 @@ struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)... |
| 47 | 47 | #if _LIBCPP_STD_VER >= 17 |
| 48 | 48 | |
| 49 | 49 | template <class...> |
| 50 | struct conjunction : true_type {}; | |
| 50 | struct _LIBCPP_NO_SPECIALIZATIONS conjunction : true_type {}; | |
| 51 | 51 | |
| 52 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 53 | # if __has_warning("-Winvalid-specialization") | |
| 54 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | |
| 55 | # endif | |
| 52 | 56 | template <class _Arg> |
| 53 | 57 | struct conjunction<_Arg> : _Arg {}; |
| 54 | 58 | |
| 55 | 59 | template <class _Arg, class... _Args> |
| 56 | 60 | struct conjunction<_Arg, _Args...> : conditional_t<!bool(_Arg::value), _Arg, conjunction<_Args...>> {}; |
| 61 | _LIBCPP_DIAGNOSTIC_POP | |
| 57 | 62 | |
| 58 | 63 | template <class... _Args> |
| 59 | inline constexpr bool conjunction_v = conjunction<_Args...>::value; | |
| 64 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool conjunction_v = conjunction<_Args...>::value; | |
| 60 | 65 | |
| 61 | 66 | #endif // _LIBCPP_STD_VER >= 17 |
| 62 | 67 |
lib/libcxx/include/__type_traits/container_traits.h created+43| ... | ... | @@ -0,0 +1,43 @@ |
| 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___TYPE_TRAITS_CONTAINER_TRAITS_H | |
| 11 | #define _LIBCPP___TYPE_TRAITS_CONTAINER_TRAITS_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 | // // __container_traits is a general purpose utility containing traits describing various containers operations. | |
| 22 | // It currently only has one trait: `__emplacement_has_strong_exception_safety_guarantee`, but it's | |
| 23 | // intended to be extended in the future. | |
| 24 | // | |
| 25 | // These traits should only be used for optimization or QoI purposes. In particular, since this is a libc++ internal | |
| 26 | // mechanism, no user-defined containers should be expected to specialize these traits (in fact it would be illegal for | |
| 27 | // them to do so). Hence, when using these traits to implement something, make sure that a container that fails to | |
| 28 | // specialize these traits does not result in non-conforming code. | |
| 29 | // | |
| 30 | // When a trait is nonsensical for a type, this class still provides a fallback value for that trait. | |
| 31 | // For example, `std::array` does not support `insert` or `emplace`, so | |
| 32 | // `__emplacement_has_strong_exception_safety_guarantee` is false for such types. | |
| 33 | template <class _Container> | |
| 34 | struct __container_traits { | |
| 35 | // A trait that tells whether a single element insertion/emplacement via member function | |
| 36 | // `insert(...)` or `emplace(...)` has strong exception guarantee, that is, if the function | |
| 37 | // exits via an exception, the original container is unaffected | |
| 38 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = false; | |
| 39 | }; | |
| 40 | ||
| 41 | _LIBCPP_END_NAMESPACE_STD | |
| 42 | ||
| 43 | #endif // _LIBCPP___TYPE_TRAITS_CONTAINER_TRAITS_H |
lib/libcxx/include/__type_traits/copy_cv.h+5-5| ... | ... | @@ -22,29 +22,29 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | template <class _From> |
| 23 | 23 | struct __copy_cv { |
| 24 | 24 | template <class _To> |
| 25 | using __apply = _To; | |
| 25 | using __apply _LIBCPP_NODEBUG = _To; | |
| 26 | 26 | }; |
| 27 | 27 | |
| 28 | 28 | template <class _From> |
| 29 | 29 | struct __copy_cv<const _From> { |
| 30 | 30 | template <class _To> |
| 31 | using __apply = const _To; | |
| 31 | using __apply _LIBCPP_NODEBUG = const _To; | |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | 34 | template <class _From> |
| 35 | 35 | struct __copy_cv<volatile _From> { |
| 36 | 36 | template <class _To> |
| 37 | using __apply = volatile _To; | |
| 37 | using __apply _LIBCPP_NODEBUG = volatile _To; | |
| 38 | 38 | }; |
| 39 | 39 | |
| 40 | 40 | template <class _From> |
| 41 | 41 | struct __copy_cv<const volatile _From> { |
| 42 | 42 | template <class _To> |
| 43 | using __apply = const volatile _To; | |
| 43 | using __apply _LIBCPP_NODEBUG = const volatile _To; | |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | template <class _From, class _To> |
| 47 | using __copy_cv_t = typename __copy_cv<_From>::template __apply<_To>; | |
| 47 | using __copy_cv_t _LIBCPP_NODEBUG = typename __copy_cv<_From>::template __apply<_To>; | |
| 48 | 48 | |
| 49 | 49 | _LIBCPP_END_NAMESPACE_STD |
| 50 | 50 |
lib/libcxx/include/__type_traits/copy_cvref.h+12-9| ... | ... | @@ -20,23 +20,26 @@ |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | template <class _From, class _To> | |
| 23 | template <class _From> | |
| 24 | 24 | struct __copy_cvref { |
| 25 | using type = __copy_cv_t<_From, _To>; | |
| 25 | template <class _To> | |
| 26 | using __apply _LIBCPP_NODEBUG = __copy_cv_t<_From, _To>; | |
| 26 | 27 | }; |
| 27 | 28 | |
| 28 | template <class _From, class _To> | |
| 29 | struct __copy_cvref<_From&, _To> { | |
| 30 | using type = __add_lvalue_reference_t<__copy_cv_t<_From, _To> >; | |
| 29 | template <class _From> | |
| 30 | struct __copy_cvref<_From&> { | |
| 31 | template <class _To> | |
| 32 | using __apply _LIBCPP_NODEBUG = __add_lvalue_reference_t<__copy_cv_t<_From, _To> >; | |
| 31 | 33 | }; |
| 32 | 34 | |
| 33 | template <class _From, class _To> | |
| 34 | struct __copy_cvref<_From&&, _To> { | |
| 35 | using type = __add_rvalue_reference_t<__copy_cv_t<_From, _To> >; | |
| 35 | template <class _From> | |
| 36 | struct __copy_cvref<_From&&> { | |
| 37 | template <class _To> | |
| 38 | using __apply _LIBCPP_NODEBUG = __add_rvalue_reference_t<__copy_cv_t<_From, _To> >; | |
| 36 | 39 | }; |
| 37 | 40 | |
| 38 | 41 | template <class _From, class _To> |
| 39 | using __copy_cvref_t = typename __copy_cvref<_From, _To>::type; | |
| 42 | using __copy_cvref_t _LIBCPP_NODEBUG = typename __copy_cvref<_From>::template __apply<_To>; | |
| 40 | 43 | |
| 41 | 44 | _LIBCPP_END_NAMESPACE_STD |
| 42 | 45 |
lib/libcxx/include/__type_traits/datasizeof.h+8-23| ... | ... | @@ -10,9 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_DATASIZEOF_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__type_traits/is_class.h> | |
| 14 | #include <__type_traits/is_final.h> | |
| 15 | #include <cstddef> | |
| 13 | #include <__cstddef/size_t.h> | |
| 16 | 14 | |
| 17 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 16 | # pragma GCC system_header |
| ... | ... | @@ -26,39 +24,26 @@ |
| 26 | 24 | |
| 27 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 26 | |
| 29 | #if __has_keyword(__datasizeof) || __has_extension(datasizeof) | |
| 27 | // TODO: Enable this again once #94816 is fixed. | |
| 28 | #if (__has_keyword(__datasizeof) || __has_extension(datasizeof)) && 0 | |
| 30 | 29 | template <class _Tp> |
| 31 | 30 | inline const size_t __datasizeof_v = __datasizeof(_Tp); |
| 32 | 31 | #else |
| 33 | // NOLINTNEXTLINE(readability-redundant-preprocessor) This is https://llvm.org/PR64825 | |
| 34 | # if __has_cpp_attribute(__no_unique_address__) | |
| 35 | 32 | template <class _Tp> |
| 36 | 33 | struct _FirstPaddingByte { |
| 37 | [[__no_unique_address__]] _Tp __v_; | |
| 34 | _LIBCPP_NO_UNIQUE_ADDRESS _Tp __v_; | |
| 38 | 35 | char __first_padding_byte_; |
| 39 | 36 | }; |
| 40 | # else | |
| 41 | template <class _Tp, bool = __libcpp_is_final<_Tp>::value || !is_class<_Tp>::value> | |
| 42 | struct _FirstPaddingByte : _Tp { | |
| 43 | char __first_padding_byte_; | |
| 44 | }; | |
| 45 | ||
| 46 | template <class _Tp> | |
| 47 | struct _FirstPaddingByte<_Tp, true> { | |
| 48 | _Tp __v_; | |
| 49 | char __first_padding_byte_; | |
| 50 | }; | |
| 51 | # endif // __has_cpp_attribute(__no_unique_address__) | |
| 52 | 37 | |
| 53 | // _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow | |
| 54 | // the use as an extension. | |
| 38 | // _FirstPaddingByte<> is sometimes non-standard layout. | |
| 39 | // It is conditionally-supported to use __builtin_offsetof in that case, but GCC and Clang allow it. | |
| 55 | 40 | _LIBCPP_DIAGNOSTIC_PUSH |
| 56 | 41 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof") |
| 57 | 42 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Winvalid-offsetof") |
| 58 | 43 | template <class _Tp> |
| 59 | inline const size_t __datasizeof_v = offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_); | |
| 44 | inline const size_t __datasizeof_v = __builtin_offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_); | |
| 60 | 45 | _LIBCPP_DIAGNOSTIC_POP |
| 61 | #endif // __has_extension(datasizeof) | |
| 46 | #endif // __has_extension(datasizeof) | |
| 62 | 47 | |
| 63 | 48 | _LIBCPP_END_NAMESPACE_STD |
| 64 | 49 |
lib/libcxx/include/__type_traits/decay.h+6-7| ... | ... | @@ -30,33 +30,32 @@ template <class _Tp> |
| 30 | 30 | using __decay_t _LIBCPP_NODEBUG = __decay(_Tp); |
| 31 | 31 | |
| 32 | 32 | template <class _Tp> |
| 33 | struct decay { | |
| 33 | struct _LIBCPP_NO_SPECIALIZATIONS decay { | |
| 34 | 34 | using type _LIBCPP_NODEBUG = __decay_t<_Tp>; |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | #else |
| 38 | 38 | template <class _Up, bool> |
| 39 | 39 | struct __decay { |
| 40 | typedef _LIBCPP_NODEBUG __remove_cv_t<_Up> type; | |
| 40 | using type _LIBCPP_NODEBUG = __remove_cv_t<_Up>; | |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | 43 | template <class _Up> |
| 44 | 44 | struct __decay<_Up, true> { |
| 45 | 45 | public: |
| 46 | typedef _LIBCPP_NODEBUG | |
| 46 | using type _LIBCPP_NODEBUG = | |
| 47 | 47 | __conditional_t<is_array<_Up>::value, |
| 48 | 48 | __add_pointer_t<__remove_extent_t<_Up> >, |
| 49 | __conditional_t<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> > > | |
| 50 | type; | |
| 49 | __conditional_t<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> > >; | |
| 51 | 50 | }; |
| 52 | 51 | |
| 53 | 52 | template <class _Tp> |
| 54 | 53 | struct _LIBCPP_TEMPLATE_VIS decay { |
| 55 | 54 | private: |
| 56 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up; | |
| 55 | using _Up _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>; | |
| 57 | 56 | |
| 58 | 57 | public: |
| 59 | typedef _LIBCPP_NODEBUG typename __decay<_Up, __libcpp_is_referenceable<_Up>::value>::type type; | |
| 58 | using type _LIBCPP_NODEBUG = typename __decay<_Up, __libcpp_is_referenceable<_Up>::value>::type; | |
| 60 | 59 | }; |
| 61 | 60 | |
| 62 | 61 | template <class _Tp> |
lib/libcxx/include/__type_traits/desugars_to.h+18-1| ... | ... | @@ -17,11 +17,28 @@ |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | // Tags to represent the canonical operations | |
| 20 | // Tags to represent the canonical operations. | |
| 21 | ||
| 22 | // syntactically, the operation is equivalent to calling `a == b` | |
| 21 | 23 | struct __equal_tag {}; |
| 24 | ||
| 25 | // syntactically, the operation is equivalent to calling `a + b` | |
| 22 | 26 | struct __plus_tag {}; |
| 27 | ||
| 28 | // syntactically, the operation is equivalent to calling `a < b` | |
| 23 | 29 | struct __less_tag {}; |
| 24 | 30 | |
| 31 | // syntactically, the operation is equivalent to calling `a > b` | |
| 32 | struct __greater_tag {}; | |
| 33 | ||
| 34 | // syntactically, the operation is equivalent to calling `a < b`, and these expressions | |
| 35 | // have to be true for any `a` and `b`: | |
| 36 | // - `(a < b) == (b > a)` | |
| 37 | // - `(!(a < b) && !(b < a)) == (a == b)` | |
| 38 | // For example, this is satisfied for std::less on integral types, but also for ranges::less on all types due to | |
| 39 | // additional semantic requirements on that operation. | |
| 40 | struct __totally_ordered_less_tag {}; | |
| 41 | ||
| 25 | 42 | // This class template is used to determine whether an operation "desugars" |
| 26 | 43 | // (or boils down) to a given canonical operation. |
| 27 | 44 | // |
lib/libcxx/include/__type_traits/detected_or.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_DETECTED_OR_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_DETECTED_OR_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/void_t.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Default, class _Void, template <class...> class _Op, class... _Args> | |
| 22 | struct __detector { | |
| 23 | using type _LIBCPP_NODEBUG = _Default; | |
| 24 | }; | |
| 25 | ||
| 26 | template <class _Default, template <class...> class _Op, class... _Args> | |
| 27 | struct __detector<_Default, __void_t<_Op<_Args...> >, _Op, _Args...> { | |
| 28 | using type _LIBCPP_NODEBUG = _Op<_Args...>; | |
| 29 | }; | |
| 30 | ||
| 31 | template <class _Default, template <class...> class _Op, class... _Args> | |
| 32 | using __detected_or_t _LIBCPP_NODEBUG = typename __detector<_Default, void, _Op, _Args...>::type; | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_DETECTED_OR_H |
lib/libcxx/include/__type_traits/disjunction.h+3-3| ... | ... | @@ -31,7 +31,7 @@ struct _OrImpl<true> { |
| 31 | 31 | template <> |
| 32 | 32 | struct _OrImpl<false> { |
| 33 | 33 | template <class _Res, class...> |
| 34 | using _Result = _Res; | |
| 34 | using _Result _LIBCPP_NODEBUG = _Res; | |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | 37 | // _Or always performs lazy evaluation of its arguments. |
| ... | ... | @@ -46,10 +46,10 @@ using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _R |
| 46 | 46 | #if _LIBCPP_STD_VER >= 17 |
| 47 | 47 | |
| 48 | 48 | template <class... _Args> |
| 49 | struct disjunction : _Or<_Args...> {}; | |
| 49 | struct _LIBCPP_NO_SPECIALIZATIONS disjunction : _Or<_Args...> {}; | |
| 50 | 50 | |
| 51 | 51 | template <class... _Args> |
| 52 | inline constexpr bool disjunction_v = _Or<_Args...>::value; | |
| 52 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool disjunction_v = _Or<_Args...>::value; | |
| 53 | 53 | |
| 54 | 54 | #endif // _LIBCPP_STD_VER >= 17 |
| 55 | 55 |
lib/libcxx/include/__type_traits/enable_if.h+7-1| ... | ... | @@ -18,11 +18,17 @@ |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | 20 | template <bool, class _Tp = void> |
| 21 | struct _LIBCPP_TEMPLATE_VIS enable_if {}; | |
| 21 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS enable_if{}; | |
| 22 | ||
| 23 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 24 | #if __has_warning("-Winvalid-specialization") | |
| 25 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | |
| 26 | #endif | |
| 22 | 27 | template <class _Tp> |
| 23 | 28 | struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> { |
| 24 | 29 | typedef _Tp type; |
| 25 | 30 | }; |
| 31 | _LIBCPP_DIAGNOSTIC_POP | |
| 26 | 32 | |
| 27 | 33 | template <bool _Bp, class _Tp = void> |
| 28 | 34 | using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type; |
lib/libcxx/include/__type_traits/extent.h+3-3| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_EXTENT_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/integral_constant.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
| ... | ... | @@ -22,11 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | #if __has_builtin(__array_extent) |
| 23 | 23 | |
| 24 | 24 | template <class _Tp, size_t _Dim = 0> |
| 25 | struct _LIBCPP_TEMPLATE_VIS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {}; | |
| 25 | struct _LIBCPP_NO_SPECIALIZATIONS _LIBCPP_TEMPLATE_VIS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {}; | |
| 26 | 26 | |
| 27 | 27 | # if _LIBCPP_STD_VER >= 17 |
| 28 | 28 | template <class _Tp, unsigned _Ip = 0> |
| 29 | inline constexpr size_t extent_v = __array_extent(_Tp, _Ip); | |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t extent_v = __array_extent(_Tp, _Ip); | |
| 30 | 30 | # endif |
| 31 | 31 | |
| 32 | 32 | #else // __has_builtin(__array_extent) |
lib/libcxx/include/__type_traits/has_unique_object_representation.h+3-2| ... | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | #if _LIBCPP_STD_VER >= 17 |
| 23 | 23 | |
| 24 | 24 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations | |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS has_unique_object_representations | |
| 26 | 26 | // TODO: We work around a Clang and GCC bug in __has_unique_object_representations by using remove_all_extents |
| 27 | 27 | // even though it should not be necessary. This was reported to the compilers: |
| 28 | 28 | // - Clang: https://github.com/llvm/llvm-project/issues/95311 |
| ... | ... | @@ -31,7 +31,8 @@ struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations |
| 31 | 31 | : public integral_constant<bool, __has_unique_object_representations(remove_all_extents_t<_Tp>)> {}; |
| 32 | 32 | |
| 33 | 33 | template <class _Tp> |
| 34 | inline constexpr bool has_unique_object_representations_v = __has_unique_object_representations(_Tp); | |
| 34 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool has_unique_object_representations_v = | |
| 35 | __has_unique_object_representations(_Tp); | |
| 35 | 36 | |
| 36 | 37 | #endif |
| 37 | 38 |
lib/libcxx/include/__type_traits/has_virtual_destructor.h+3-2| ... | ... | @@ -19,11 +19,12 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS has_virtual_destructor | |
| 23 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; | |
| 23 | 24 | |
| 24 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 26 | template <class _Tp> |
| 26 | inline constexpr bool has_virtual_destructor_v = __has_virtual_destructor(_Tp); | |
| 27 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool has_virtual_destructor_v = __has_virtual_destructor(_Tp); | |
| 27 | 28 | #endif |
| 28 | 29 | |
| 29 | 30 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/integral_constant.h+2-5| ... | ... | @@ -18,8 +18,8 @@ |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | 20 | template <class _Tp, _Tp __v> |
| 21 | struct _LIBCPP_TEMPLATE_VIS integral_constant { | |
| 22 | static _LIBCPP_CONSTEXPR const _Tp value = __v; | |
| 21 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS integral_constant { | |
| 22 | static inline _LIBCPP_CONSTEXPR const _Tp value = __v; | |
| 23 | 23 | typedef _Tp value_type; |
| 24 | 24 | typedef integral_constant type; |
| 25 | 25 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT { return value; } |
| ... | ... | @@ -28,9 +28,6 @@ struct _LIBCPP_TEMPLATE_VIS integral_constant { |
| 28 | 28 | #endif |
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | template <class _Tp, _Tp __v> | |
| 32 | _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; | |
| 33 | ||
| 34 | 31 | typedef integral_constant<bool, true> true_type; |
| 35 | 32 | typedef integral_constant<bool, false> false_type; |
| 36 | 33 |
lib/libcxx/include/__type_traits/invoke.h+75-25| ... | ... | @@ -29,6 +29,36 @@ |
| 29 | 29 | # pragma GCC system_header |
| 30 | 30 | #endif |
| 31 | 31 | |
| 32 | // This file defines the following libc++-internal API (back-ported to C++03): | |
| 33 | // | |
| 34 | // template <class... Args> | |
| 35 | // decltype(auto) __invoke(Args&&... args) noexcept(noexcept(std::invoke(std::forward<Args>(args...)))) { | |
| 36 | // return std::invoke(std::forward<Args>(args)...); | |
| 37 | // } | |
| 38 | // | |
| 39 | // template <class Ret, class... Args> | |
| 40 | // Ret __invoke_r(Args&&... args) { | |
| 41 | // return std::invoke_r(std::forward<Args>(args)...); | |
| 42 | // } | |
| 43 | // | |
| 44 | // template <class Ret, class Func, class... Args> | |
| 45 | // inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>; | |
| 46 | // | |
| 47 | // template <class Func, class... Args> | |
| 48 | // struct __is_invocable : is_invocable<Func, Args...> {}; | |
| 49 | // | |
| 50 | // template <class Func, class... Args> | |
| 51 | // inline const bool __is_invocable_v = is_invocable_v<Func, Args...>; | |
| 52 | // | |
| 53 | // template <class Func, class... Args> | |
| 54 | // inline const bool __is_nothrow_invocable_v = is_nothrow_invocable_v<Func, Args...>; | |
| 55 | // | |
| 56 | // template <class Func, class... Args> | |
| 57 | // struct __invoke_result : invoke_result {}; | |
| 58 | // | |
| 59 | // template <class Func, class... Args> | |
| 60 | // using __invoke_result_t = invoke_result_t<Func, Args...>; | |
| 61 | ||
| 32 | 62 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 63 | |
| 34 | 64 | template <class _DecayedFp> |
| ... | ... | @@ -44,12 +74,12 @@ template <class _Fp, |
| 44 | 74 | class _DecayFp = __decay_t<_Fp>, |
| 45 | 75 | class _DecayA0 = __decay_t<_A0>, |
| 46 | 76 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
| 47 | using __enable_if_bullet1 = | |
| 77 | using __enable_if_bullet1 _LIBCPP_NODEBUG = | |
| 48 | 78 | __enable_if_t<is_member_function_pointer<_DecayFp>::value && |
| 49 | 79 | (is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value)>; |
| 50 | 80 | |
| 51 | 81 | template <class _Fp, class _A0, class _DecayFp = __decay_t<_Fp>, class _DecayA0 = __decay_t<_A0> > |
| 52 | using __enable_if_bullet2 = | |
| 82 | using __enable_if_bullet2 _LIBCPP_NODEBUG = | |
| 53 | 83 | __enable_if_t<is_member_function_pointer<_DecayFp>::value && __is_reference_wrapper<_DecayA0>::value>; |
| 54 | 84 | |
| 55 | 85 | template <class _Fp, |
| ... | ... | @@ -57,7 +87,7 @@ template <class _Fp, |
| 57 | 87 | class _DecayFp = __decay_t<_Fp>, |
| 58 | 88 | class _DecayA0 = __decay_t<_A0>, |
| 59 | 89 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
| 60 | using __enable_if_bullet3 = | |
| 90 | using __enable_if_bullet3 _LIBCPP_NODEBUG = | |
| 61 | 91 | __enable_if_t<is_member_function_pointer<_DecayFp>::value && |
| 62 | 92 | !(is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value) && |
| 63 | 93 | !__is_reference_wrapper<_DecayA0>::value>; |
| ... | ... | @@ -67,12 +97,12 @@ template <class _Fp, |
| 67 | 97 | class _DecayFp = __decay_t<_Fp>, |
| 68 | 98 | class _DecayA0 = __decay_t<_A0>, |
| 69 | 99 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
| 70 | using __enable_if_bullet4 = | |
| 100 | using __enable_if_bullet4 _LIBCPP_NODEBUG = | |
| 71 | 101 | __enable_if_t<is_member_object_pointer<_DecayFp>::value && |
| 72 | 102 | (is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value)>; |
| 73 | 103 | |
| 74 | 104 | template <class _Fp, class _A0, class _DecayFp = __decay_t<_Fp>, class _DecayA0 = __decay_t<_A0> > |
| 75 | using __enable_if_bullet5 = | |
| 105 | using __enable_if_bullet5 _LIBCPP_NODEBUG = | |
| 76 | 106 | __enable_if_t<is_member_object_pointer<_DecayFp>::value && __is_reference_wrapper<_DecayA0>::value>; |
| 77 | 107 | |
| 78 | 108 | template <class _Fp, |
| ... | ... | @@ -80,7 +110,7 @@ template <class _Fp, |
| 80 | 110 | class _DecayFp = __decay_t<_Fp>, |
| 81 | 111 | class _DecayA0 = __decay_t<_A0>, |
| 82 | 112 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> |
| 83 | using __enable_if_bullet6 = | |
| 113 | using __enable_if_bullet6 _LIBCPP_NODEBUG = | |
| 84 | 114 | __enable_if_t<is_member_object_pointer<_DecayFp>::value && |
| 85 | 115 | !(is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value) && |
| 86 | 116 | !__is_reference_wrapper<_DecayA0>::value>; |
| ... | ... | @@ -159,7 +189,7 @@ struct __invokable_r { |
| 159 | 189 | |
| 160 | 190 | // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void, |
| 161 | 191 | // or incomplete array types as required by the standard. |
| 162 | using _Result = decltype(__try_call<_Fp, _Args...>(0)); | |
| 192 | using _Result _LIBCPP_NODEBUG = decltype(__try_call<_Fp, _Args...>(0)); | |
| 163 | 193 | |
| 164 | 194 | using type = __conditional_t<_IsNotSame<_Result, __nat>::value, |
| 165 | 195 | __conditional_t<is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >, |
| ... | ... | @@ -167,7 +197,7 @@ struct __invokable_r { |
| 167 | 197 | static const bool value = type::value; |
| 168 | 198 | }; |
| 169 | 199 | template <class _Fp, class... _Args> |
| 170 | using __invokable = __invokable_r<void, _Fp, _Args...>; | |
| 200 | using __is_invocable _LIBCPP_NODEBUG = __invokable_r<void, _Fp, _Args...>; | |
| 171 | 201 | |
| 172 | 202 | template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class... _Args> |
| 173 | 203 | struct __nothrow_invokable_r_imp { |
| ... | ... | @@ -199,15 +229,12 @@ struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> { |
| 199 | 229 | }; |
| 200 | 230 | |
| 201 | 231 | template <class _Ret, class _Fp, class... _Args> |
| 202 | using __nothrow_invokable_r = | |
| 232 | using __nothrow_invokable_r _LIBCPP_NODEBUG = | |
| 203 | 233 | __nothrow_invokable_r_imp<__invokable_r<_Ret, _Fp, _Args...>::value, is_void<_Ret>::value, _Ret, _Fp, _Args...>; |
| 204 | 234 | |
| 205 | 235 | template <class _Fp, class... _Args> |
| 206 | using __nothrow_invokable = __nothrow_invokable_r_imp<__invokable<_Fp, _Args...>::value, true, void, _Fp, _Args...>; | |
| 207 | ||
| 208 | template <class _Fp, class... _Args> | |
| 209 | struct __invoke_of | |
| 210 | : public enable_if<__invokable<_Fp, _Args...>::value, typename __invokable_r<void, _Fp, _Args...>::_Result> {}; | |
| 236 | using __nothrow_invokable _LIBCPP_NODEBUG = | |
| 237 | __nothrow_invokable_r_imp<__is_invocable<_Fp, _Args...>::value, true, void, _Fp, _Args...>; | |
| 211 | 238 | |
| 212 | 239 | template <class _Ret, bool = is_void<_Ret>::value> |
| 213 | 240 | struct __invoke_void_return_wrapper { |
| ... | ... | @@ -225,40 +252,63 @@ struct __invoke_void_return_wrapper<_Ret, true> { |
| 225 | 252 | } |
| 226 | 253 | }; |
| 227 | 254 | |
| 255 | template <class _Func, class... _Args> | |
| 256 | inline const bool __is_invocable_v = __is_invocable<_Func, _Args...>::value; | |
| 257 | ||
| 258 | template <class _Ret, class _Func, class... _Args> | |
| 259 | inline const bool __is_invocable_r_v = __invokable_r<_Ret, _Func, _Args...>::value; | |
| 260 | ||
| 261 | template <class _Func, class... _Args> | |
| 262 | inline const bool __is_nothrow_invocable_v = __nothrow_invokable<_Func, _Args...>::value; | |
| 263 | ||
| 264 | template <class _Func, class... _Args> | |
| 265 | struct __invoke_result | |
| 266 | : enable_if<__is_invocable_v<_Func, _Args...>, typename __invokable_r<void, _Func, _Args...>::_Result> {}; | |
| 267 | ||
| 268 | template <class _Func, class... _Args> | |
| 269 | using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Func, _Args...>::type; | |
| 270 | ||
| 271 | template <class _Ret, class... _Args> | |
| 272 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... __args) { | |
| 273 | return __invoke_void_return_wrapper<_Ret>::__call(std::forward<_Args>(__args)...); | |
| 274 | } | |
| 275 | ||
| 228 | 276 | #if _LIBCPP_STD_VER >= 17 |
| 229 | 277 | |
| 230 | 278 | // is_invocable |
| 231 | 279 | |
| 232 | 280 | template <class _Fn, class... _Args> |
| 233 | struct _LIBCPP_TEMPLATE_VIS is_invocable : integral_constant<bool, __invokable<_Fn, _Args...>::value> {}; | |
| 281 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_invocable : bool_constant<__is_invocable_v<_Fn, _Args...>> {}; | |
| 234 | 282 | |
| 235 | 283 | template <class _Ret, class _Fn, class... _Args> |
| 236 | struct _LIBCPP_TEMPLATE_VIS is_invocable_r : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {}; | |
| 284 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_invocable_r | |
| 285 | : bool_constant<__is_invocable_r_v<_Ret, _Fn, _Args...>> {}; | |
| 237 | 286 | |
| 238 | 287 | template <class _Fn, class... _Args> |
| 239 | inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; | |
| 288 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_v = __is_invocable_v<_Fn, _Args...>; | |
| 240 | 289 | |
| 241 | 290 | template <class _Ret, class _Fn, class... _Args> |
| 242 | inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 291 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_r_v = __is_invocable_r_v<_Ret, _Fn, _Args...>; | |
| 243 | 292 | |
| 244 | 293 | // is_nothrow_invocable |
| 245 | 294 | |
| 246 | 295 | template <class _Fn, class... _Args> |
| 247 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> { | |
| 248 | }; | |
| 296 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable | |
| 297 | : bool_constant<__nothrow_invokable<_Fn, _Args...>::value> {}; | |
| 249 | 298 | |
| 250 | 299 | template <class _Ret, class _Fn, class... _Args> |
| 251 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r | |
| 252 | : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {}; | |
| 300 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable_r | |
| 301 | : bool_constant<__nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {}; | |
| 253 | 302 | |
| 254 | 303 | template <class _Fn, class... _Args> |
| 255 | inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value; | |
| 304 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value; | |
| 256 | 305 | |
| 257 | 306 | template <class _Ret, class _Fn, class... _Args> |
| 258 | inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 307 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_r_v = | |
| 308 | is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 259 | 309 | |
| 260 | 310 | template <class _Fn, class... _Args> |
| 261 | struct _LIBCPP_TEMPLATE_VIS invoke_result : __invoke_of<_Fn, _Args...> {}; | |
| 311 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS invoke_result : __invoke_result<_Fn, _Args...> {}; | |
| 262 | 312 | |
| 263 | 313 | template <class _Fn, class... _Args> |
| 264 | 314 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; |
lib/libcxx/include/__type_traits/is_abstract.h+3-2| ... | ... | @@ -19,11 +19,12 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_abstract : public integral_constant<bool, __is_abstract(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_abstract | |
| 23 | : public integral_constant<bool, __is_abstract(_Tp)> {}; | |
| 23 | 24 | |
| 24 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 26 | template <class _Tp> |
| 26 | inline constexpr bool is_abstract_v = __is_abstract(_Tp); | |
| 27 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_abstract_v = __is_abstract(_Tp); | |
| 27 | 28 | #endif |
| 28 | 29 | |
| 29 | 30 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_aggregate.h+3-2| ... | ... | @@ -21,10 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | #if _LIBCPP_STD_VER >= 17 |
| 22 | 22 | |
| 23 | 23 | template <class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {}; | |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_aggregate | |
| 25 | : public integral_constant<bool, __is_aggregate(_Tp)> {}; | |
| 25 | 26 | |
| 26 | 27 | template <class _Tp> |
| 27 | inline constexpr bool is_aggregate_v = __is_aggregate(_Tp); | |
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_aggregate_v = __is_aggregate(_Tp); | |
| 28 | 29 | |
| 29 | 30 | #endif // _LIBCPP_STD_VER >= 17 |
| 30 | 31 |
lib/libcxx/include/__type_traits/is_allocator.h+1-1| ... | ... | @@ -10,10 +10,10 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_IS_ALLOCATOR_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/integral_constant.h> |
| 14 | 15 | #include <__type_traits/void_t.h> |
| 15 | 16 | #include <__utility/declval.h> |
| 16 | #include <cstddef> | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | # pragma GCC system_header |
lib/libcxx/include/__type_traits/is_always_bitcastable.h+2-4| ... | ... | @@ -10,9 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_IS_ALWAYS_BITCASTABLE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | 13 | #include <__type_traits/is_integral.h> |
| 15 | #include <__type_traits/is_object.h> | |
| 16 | 14 | #include <__type_traits/is_same.h> |
| 17 | 15 | #include <__type_traits/is_trivially_copyable.h> |
| 18 | 16 | #include <__type_traits/remove_cv.h> |
| ... | ... | @@ -31,8 +29,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 29 | // considered bit-castable. |
| 32 | 30 | template <class _From, class _To> |
| 33 | 31 | struct __is_always_bitcastable { |
| 34 | using _UnqualFrom = __remove_cv_t<_From>; | |
| 35 | using _UnqualTo = __remove_cv_t<_To>; | |
| 32 | using _UnqualFrom _LIBCPP_NODEBUG = __remove_cv_t<_From>; | |
| 33 | using _UnqualTo _LIBCPP_NODEBUG = __remove_cv_t<_To>; | |
| 36 | 34 | |
| 37 | 35 | // clang-format off |
| 38 | 36 | static const bool value = |
lib/libcxx/include/__type_traits/is_arithmetic.h+2-2| ... | ... | @@ -21,12 +21,12 @@ |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_arithmetic | |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_arithmetic | |
| 25 | 25 | : public integral_constant<bool, is_integral<_Tp>::value || is_floating_point<_Tp>::value> {}; |
| 26 | 26 | |
| 27 | 27 | #if _LIBCPP_STD_VER >= 17 |
| 28 | 28 | template <class _Tp> |
| 29 | inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; | |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; | |
| 30 | 30 | #endif |
| 31 | 31 | |
| 32 | 32 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_array.h+3-3| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/integral_constant.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
| ... | ... | @@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | (!defined(_LIBCPP_COMPILER_CLANG_BASED) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1900)) |
| 24 | 24 | |
| 25 | 25 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> {}; | |
| 26 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_array : _BoolConstant<__is_array(_Tp)> {}; | |
| 27 | 27 | |
| 28 | 28 | # if _LIBCPP_STD_VER >= 17 |
| 29 | 29 | template <class _Tp> |
| 30 | inline constexpr bool is_array_v = __is_array(_Tp); | |
| 30 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_array_v = __is_array(_Tp); | |
| 31 | 31 | # endif |
| 32 | 32 | |
| 33 | 33 | #else |
lib/libcxx/include/__type_traits/is_assignable.h+6-6| ... | ... | @@ -21,30 +21,30 @@ |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class _Tp, class _Up> |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> {}; | |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> {}; | |
| 25 | 25 | |
| 26 | 26 | #if _LIBCPP_STD_VER >= 17 |
| 27 | 27 | template <class _Tp, class _Arg> |
| 28 | inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg); | |
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg); | |
| 29 | 29 | #endif |
| 30 | 30 | |
| 31 | 31 | template <class _Tp> |
| 32 | struct _LIBCPP_TEMPLATE_VIS is_copy_assignable | |
| 32 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_copy_assignable | |
| 33 | 33 | : public integral_constant<bool, |
| 34 | 34 | __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; |
| 35 | 35 | |
| 36 | 36 | #if _LIBCPP_STD_VER >= 17 |
| 37 | 37 | template <class _Tp> |
| 38 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; | |
| 38 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; | |
| 39 | 39 | #endif |
| 40 | 40 | |
| 41 | 41 | template <class _Tp> |
| 42 | struct _LIBCPP_TEMPLATE_VIS is_move_assignable | |
| 42 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_move_assignable | |
| 43 | 43 | : public integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {}; |
| 44 | 44 | |
| 45 | 45 | #if _LIBCPP_STD_VER >= 17 |
| 46 | 46 | template <class _Tp> |
| 47 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; | |
| 47 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; | |
| 48 | 48 | #endif |
| 49 | 49 | |
| 50 | 50 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_base_of.h+16-2| ... | ... | @@ -19,11 +19,25 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Bp, class _Dp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_base_of : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_base_of | |
| 23 | : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; | |
| 23 | 24 | |
| 24 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 26 | template <class _Bp, class _Dp> |
| 26 | inline constexpr bool is_base_of_v = __is_base_of(_Bp, _Dp); | |
| 27 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_base_of_v = __is_base_of(_Bp, _Dp); | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER >= 26 | |
| 31 | # if __has_builtin(__builtin_is_virtual_base_of) | |
| 32 | ||
| 33 | template <class _Base, class _Derived> | |
| 34 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_virtual_base_of | |
| 35 | : public bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)> {}; | |
| 36 | ||
| 37 | template <class _Base, class _Derived> | |
| 38 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived); | |
| 39 | ||
| 40 | # endif | |
| 27 | 41 | #endif |
| 28 | 42 | |
| 29 | 43 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_bounded_array.h+11-5| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/integral_constant.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
| ... | ... | @@ -20,19 +20,25 @@ |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | 22 | template <class> |
| 23 | struct _LIBCPP_TEMPLATE_VIS __libcpp_is_bounded_array : false_type {}; | |
| 23 | inline const bool __is_bounded_array_v = false; | |
| 24 | 24 | template <class _Tp, size_t _Np> |
| 25 | struct _LIBCPP_TEMPLATE_VIS __libcpp_is_bounded_array<_Tp[_Np]> : true_type {}; | |
| 25 | inline const bool __is_bounded_array_v<_Tp[_Np]> = true; | |
| 26 | 26 | |
| 27 | 27 | #if _LIBCPP_STD_VER >= 20 |
| 28 | 28 | |
| 29 | 29 | template <class> |
| 30 | struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {}; | |
| 30 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : false_type {}; | |
| 31 | ||
| 32 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 33 | # if __has_warning("-Winvalid-specialization") | |
| 34 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | |
| 35 | # endif | |
| 31 | 36 | template <class _Tp, size_t _Np> |
| 32 | 37 | struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {}; |
| 38 | _LIBCPP_DIAGNOSTIC_POP | |
| 33 | 39 | |
| 34 | 40 | template <class _Tp> |
| 35 | inline constexpr bool is_bounded_array_v = is_bounded_array<_Tp>::value; | |
| 41 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = is_bounded_array<_Tp>::value; | |
| 36 | 42 | |
| 37 | 43 | #endif |
| 38 | 44 |
lib/libcxx/include/__type_traits/is_char_like_type.h+1-1| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class _CharT> |
| 24 | using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >; | |
| 24 | using _IsCharLikeType _LIBCPP_NODEBUG = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >; | |
| 25 | 25 | |
| 26 | 26 | _LIBCPP_END_NAMESPACE_STD |
| 27 | 27 |
lib/libcxx/include/__type_traits/is_class.h+2-2| ... | ... | @@ -19,11 +19,11 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_class : public integral_constant<bool, __is_class(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_class : public integral_constant<bool, __is_class(_Tp)> {}; | |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | template <class _Tp> |
| 26 | inline constexpr bool is_class_v = __is_class(_Tp); | |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_class_v = __is_class(_Tp); | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_compound.h+2-2| ... | ... | @@ -22,11 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | #if __has_builtin(__is_compound) |
| 23 | 23 | |
| 24 | 24 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> {}; | |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_compound : _BoolConstant<__is_compound(_Tp)> {}; | |
| 26 | 26 | |
| 27 | 27 | # if _LIBCPP_STD_VER >= 17 |
| 28 | 28 | template <class _Tp> |
| 29 | inline constexpr bool is_compound_v = __is_compound(_Tp); | |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_compound_v = __is_compound(_Tp); | |
| 30 | 30 | # endif |
| 31 | 31 | |
| 32 | 32 | #else // __has_builtin(__is_compound) |
lib/libcxx/include/__type_traits/is_const.h+2-2| ... | ... | @@ -21,11 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | #if __has_builtin(__is_const) |
| 22 | 22 | |
| 23 | 23 | template <class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> {}; | |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_const : _BoolConstant<__is_const(_Tp)> {}; | |
| 25 | 25 | |
| 26 | 26 | # if _LIBCPP_STD_VER >= 17 |
| 27 | 27 | template <class _Tp> |
| 28 | inline constexpr bool is_const_v = __is_const(_Tp); | |
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_const_v = __is_const(_Tp); | |
| 29 | 29 | # endif |
| 30 | 30 | |
| 31 | 31 | #else |
lib/libcxx/include/__type_traits/is_constructible.h+10-8| ... | ... | @@ -21,37 +21,39 @@ |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class _Tp, class... _Args> |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_constructible : public integral_constant<bool, __is_constructible(_Tp, _Args...)> {}; | |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_constructible | |
| 25 | : public integral_constant<bool, __is_constructible(_Tp, _Args...)> {}; | |
| 25 | 26 | |
| 26 | 27 | #if _LIBCPP_STD_VER >= 17 |
| 27 | 28 | template <class _Tp, class... _Args> |
| 28 | inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...); | |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...); | |
| 29 | 30 | #endif |
| 30 | 31 | |
| 31 | 32 | template <class _Tp> |
| 32 | struct _LIBCPP_TEMPLATE_VIS is_copy_constructible | |
| 33 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_copy_constructible | |
| 33 | 34 | : public integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; |
| 34 | 35 | |
| 35 | 36 | #if _LIBCPP_STD_VER >= 17 |
| 36 | 37 | template <class _Tp> |
| 37 | inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; | |
| 38 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; | |
| 38 | 39 | #endif |
| 39 | 40 | |
| 40 | 41 | template <class _Tp> |
| 41 | struct _LIBCPP_TEMPLATE_VIS is_move_constructible | |
| 42 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_move_constructible | |
| 42 | 43 | : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; |
| 43 | 44 | |
| 44 | 45 | #if _LIBCPP_STD_VER >= 17 |
| 45 | 46 | template <class _Tp> |
| 46 | inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; | |
| 47 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; | |
| 47 | 48 | #endif |
| 48 | 49 | |
| 49 | 50 | template <class _Tp> |
| 50 | struct _LIBCPP_TEMPLATE_VIS is_default_constructible : public integral_constant<bool, __is_constructible(_Tp)> {}; | |
| 51 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_default_constructible | |
| 52 | : public integral_constant<bool, __is_constructible(_Tp)> {}; | |
| 51 | 53 | |
| 52 | 54 | #if _LIBCPP_STD_VER >= 17 |
| 53 | 55 | template <class _Tp> |
| 54 | inline constexpr bool is_default_constructible_v = __is_constructible(_Tp); | |
| 56 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_default_constructible_v = __is_constructible(_Tp); | |
| 55 | 57 | #endif |
| 56 | 58 | |
| 57 | 59 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_convertible.h+3-2| ... | ... | @@ -19,11 +19,12 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _T1, class _T2> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_convertible : public integral_constant<bool, __is_convertible(_T1, _T2)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_convertible | |
| 23 | : public integral_constant<bool, __is_convertible(_T1, _T2)> {}; | |
| 23 | 24 | |
| 24 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 26 | template <class _From, class _To> |
| 26 | inline constexpr bool is_convertible_v = __is_convertible(_From, _To); | |
| 27 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_convertible_v = __is_convertible(_From, _To); | |
| 27 | 28 | #endif |
| 28 | 29 | |
| 29 | 30 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_destructible.h+2-2| ... | ... | @@ -25,11 +25,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | #if __has_builtin(__is_destructible) |
| 26 | 26 | |
| 27 | 27 | template <class _Tp> |
| 28 | struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> {}; | |
| 28 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_destructible : _BoolConstant<__is_destructible(_Tp)> {}; | |
| 29 | 29 | |
| 30 | 30 | # if _LIBCPP_STD_VER >= 17 |
| 31 | 31 | template <class _Tp> |
| 32 | inline constexpr bool is_destructible_v = __is_destructible(_Tp); | |
| 32 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_destructible_v = __is_destructible(_Tp); | |
| 33 | 33 | # endif |
| 34 | 34 | |
| 35 | 35 | #else // __has_builtin(__is_destructible) |
lib/libcxx/include/__type_traits/is_empty.h+2-2| ... | ... | @@ -19,11 +19,11 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_empty : public integral_constant<bool, __is_empty(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_empty : public integral_constant<bool, __is_empty(_Tp)> {}; | |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | template <class _Tp> |
| 26 | inline constexpr bool is_empty_v = __is_empty(_Tp); | |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_empty_v = __is_empty(_Tp); | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_enum.h+4-4| ... | ... | @@ -19,20 +19,20 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_enum : public integral_constant<bool, __is_enum(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_enum : public integral_constant<bool, __is_enum(_Tp)> {}; | |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | template <class _Tp> |
| 26 | inline constexpr bool is_enum_v = __is_enum(_Tp); | |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_enum_v = __is_enum(_Tp); | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | #if _LIBCPP_STD_VER >= 23 |
| 30 | 30 | |
| 31 | 31 | template <class _Tp> |
| 32 | struct _LIBCPP_TEMPLATE_VIS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {}; | |
| 32 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {}; | |
| 33 | 33 | |
| 34 | 34 | template <class _Tp> |
| 35 | inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp); | |
| 35 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp); | |
| 36 | 36 | |
| 37 | 37 | #endif // _LIBCPP_STD_VER >= 23 |
| 38 | 38 |
lib/libcxx/include/__type_traits/is_equality_comparable.h+1-1| ... | ... | @@ -80,7 +80,7 @@ struct __libcpp_is_trivially_equality_comparable_impl<_Tp*, _Up*> |
| 80 | 80 | }; |
| 81 | 81 | |
| 82 | 82 | template <class _Tp, class _Up> |
| 83 | using __libcpp_is_trivially_equality_comparable = | |
| 83 | using __libcpp_is_trivially_equality_comparable _LIBCPP_NODEBUG = | |
| 84 | 84 | __libcpp_is_trivially_equality_comparable_impl<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >; |
| 85 | 85 | |
| 86 | 86 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_execution_policy.h+2-2| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class> |
| 24 | inline constexpr bool is_execution_policy_v = false; | |
| 24 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_execution_policy_v = false; | |
| 25 | 25 | |
| 26 | 26 | template <class> |
| 27 | 27 | inline constexpr bool __is_unsequenced_execution_policy_impl = false; |
| ... | ... | @@ -50,7 +50,7 @@ __remove_parallel_policy(const _ExecutionPolicy& = _ExecutionPolicy{execution::_ |
| 50 | 50 | // Removes the "parallel" part of an execution policy. |
| 51 | 51 | // For example, turns par_unseq into unseq, and par into seq. |
| 52 | 52 | template <class _ExecutionPolicy> |
| 53 | using __remove_parallel_policy_t = decltype(std::__remove_parallel_policy<_ExecutionPolicy>()); | |
| 53 | using __remove_parallel_policy_t _LIBCPP_NODEBUG = decltype(std::__remove_parallel_policy<_ExecutionPolicy>()); | |
| 54 | 54 | |
| 55 | 55 | _LIBCPP_END_NAMESPACE_STD |
| 56 | 56 |
lib/libcxx/include/__type_traits/is_final.h+2-2| ... | ... | @@ -23,12 +23,12 @@ struct _LIBCPP_TEMPLATE_VIS __libcpp_is_final : public integral_constant<bool, _ |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 14 |
| 25 | 25 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_final : public integral_constant<bool, __is_final(_Tp)> {}; | |
| 26 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_final : public integral_constant<bool, __is_final(_Tp)> {}; | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | #if _LIBCPP_STD_VER >= 17 |
| 30 | 30 | template <class _Tp> |
| 31 | inline constexpr bool is_final_v = __is_final(_Tp); | |
| 31 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_final_v = __is_final(_Tp); | |
| 32 | 32 | #endif |
| 33 | 33 | |
| 34 | 34 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_floating_point.h+3-2| ... | ... | @@ -27,11 +27,12 @@ template <> struct __libcpp_is_floating_point<long double> : public tru |
| 27 | 27 | // clang-format on |
| 28 | 28 | |
| 29 | 29 | template <class _Tp> |
| 30 | struct _LIBCPP_TEMPLATE_VIS is_floating_point : public __libcpp_is_floating_point<__remove_cv_t<_Tp> > {}; | |
| 30 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_floating_point | |
| 31 | : public __libcpp_is_floating_point<__remove_cv_t<_Tp> > {}; | |
| 31 | 32 | |
| 32 | 33 | #if _LIBCPP_STD_VER >= 17 |
| 33 | 34 | template <class _Tp> |
| 34 | inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; | |
| 35 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; | |
| 35 | 36 | #endif |
| 36 | 37 | |
| 37 | 38 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_function.h+2-2| ... | ... | @@ -19,11 +19,11 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_function : integral_constant<bool, __is_function(_Tp)> {}; | |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | template <class _Tp> |
| 26 | inline constexpr bool is_function_v = __is_function(_Tp); | |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_function_v = __is_function(_Tp); | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_fundamental.h+2-2| ... | ... | @@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | #if __has_builtin(__is_fundamental) |
| 24 | 24 | |
| 25 | 25 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> {}; | |
| 26 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> {}; | |
| 27 | 27 | |
| 28 | 28 | # if _LIBCPP_STD_VER >= 17 |
| 29 | 29 | template <class _Tp> |
| 30 | inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); | |
| 30 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); | |
| 31 | 31 | # endif |
| 32 | 32 | |
| 33 | 33 | #else // __has_builtin(__is_fundamental) |
lib/libcxx/include/__type_traits/is_implicit_lifetime.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_IMPLICIT_LIFETIME_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_IMPLICIT_LIFETIME_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER >= 23 | |
| 22 | # if __has_builtin(__builtin_is_implicit_lifetime) | |
| 23 | ||
| 24 | template <class _Tp> | |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_implicit_lifetime | |
| 26 | : public bool_constant<__builtin_is_implicit_lifetime(_Tp)> {}; | |
| 27 | ||
| 28 | template <class _Tp> | |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_implicit_lifetime_v = __builtin_is_implicit_lifetime(_Tp); | |
| 30 | ||
| 31 | # endif | |
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_IMPLICIT_LIFETIME_H |
lib/libcxx/include/__type_traits/is_integral.h+5-5| ... | ... | @@ -25,10 +25,10 @@ template <> struct __libcpp_is_integral<bool> { enum { va |
| 25 | 25 | template <> struct __libcpp_is_integral<char> { enum { value = 1 }; }; |
| 26 | 26 | template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; }; |
| 27 | 27 | template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; }; |
| 28 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 28 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 29 | 29 | template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; }; |
| 30 | 30 | #endif |
| 31 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 31 | #if _LIBCPP_HAS_CHAR8_T | |
| 32 | 32 | template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; }; |
| 33 | 33 | #endif |
| 34 | 34 | template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; }; |
| ... | ... | @@ -41,7 +41,7 @@ template <> struct __libcpp_is_integral<long> { enum { va |
| 41 | 41 | template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; }; |
| 42 | 42 | template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; }; |
| 43 | 43 | template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; }; |
| 44 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 44 | #if _LIBCPP_HAS_INT128 | |
| 45 | 45 | template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; }; |
| 46 | 46 | template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; }; |
| 47 | 47 | #endif |
| ... | ... | @@ -50,11 +50,11 @@ template <> struct __libcpp_is_integral<__uint128_t> { enum { va |
| 50 | 50 | #if __has_builtin(__is_integral) |
| 51 | 51 | |
| 52 | 52 | template <class _Tp> |
| 53 | struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> {}; | |
| 53 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_integral : _BoolConstant<__is_integral(_Tp)> {}; | |
| 54 | 54 | |
| 55 | 55 | # if _LIBCPP_STD_VER >= 17 |
| 56 | 56 | template <class _Tp> |
| 57 | inline constexpr bool is_integral_v = __is_integral(_Tp); | |
| 57 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_integral_v = __is_integral(_Tp); | |
| 58 | 58 | # endif |
| 59 | 59 | |
| 60 | 60 | #else |
lib/libcxx/include/__type_traits/is_literal_type.h+3-3| ... | ... | @@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) |
| 22 | 22 | template <class _Tp> |
| 23 | struct _LIBCPP_TEMPLATE_VIS | |
| 24 | _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type : public integral_constant<bool, __is_literal_type(_Tp)> {}; | |
| 23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS is_literal_type | |
| 24 | : public integral_constant<bool, __is_literal_type(_Tp)> {}; | |
| 25 | 25 | |
| 26 | 26 | # if _LIBCPP_STD_VER >= 17 |
| 27 | 27 | template <class _Tp> |
| 28 | _LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = __is_literal_type(_Tp); | |
| 28 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_literal_type_v = __is_literal_type(_Tp); | |
| 29 | 29 | # endif // _LIBCPP_STD_VER >= 17 |
| 30 | 30 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) |
| 31 | 31 |
lib/libcxx/include/__type_traits/is_member_pointer.h+10-8| ... | ... | @@ -19,24 +19,26 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {}; | |
| 23 | 23 | |
| 24 | 24 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {}; | |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_object_pointer | |
| 26 | : _BoolConstant<__is_member_object_pointer(_Tp)> {}; | |
| 26 | 27 | |
| 27 | 28 | template <class _Tp> |
| 28 | struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {}; | |
| 29 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_function_pointer | |
| 30 | : _BoolConstant<__is_member_function_pointer(_Tp)> {}; | |
| 29 | 31 | |
| 30 | # if _LIBCPP_STD_VER >= 17 | |
| 32 | #if _LIBCPP_STD_VER >= 17 | |
| 31 | 33 | template <class _Tp> |
| 32 | inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); | |
| 34 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); | |
| 33 | 35 | |
| 34 | 36 | template <class _Tp> |
| 35 | inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); | |
| 37 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); | |
| 36 | 38 | |
| 37 | 39 | template <class _Tp> |
| 38 | inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); | |
| 39 | # endif | |
| 40 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); | |
| 41 | #endif | |
| 40 | 42 | |
| 41 | 43 | _LIBCPP_END_NAMESPACE_STD |
| 42 | 44 |
lib/libcxx/include/__type_traits/is_nothrow_assignable.h+7-7| ... | ... | @@ -21,34 +21,34 @@ |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class _Tp, class _Arg> |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> { | |
| 25 | }; | |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_assignable | |
| 25 | : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {}; | |
| 26 | 26 | |
| 27 | 27 | #if _LIBCPP_STD_VER >= 17 |
| 28 | 28 | template <class _Tp, class _Arg> |
| 29 | inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg); | |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg); | |
| 30 | 30 | #endif |
| 31 | 31 | |
| 32 | 32 | template <class _Tp> |
| 33 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable | |
| 33 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_assignable | |
| 34 | 34 | : public integral_constant< |
| 35 | 35 | bool, |
| 36 | 36 | __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; |
| 37 | 37 | |
| 38 | 38 | #if _LIBCPP_STD_VER >= 17 |
| 39 | 39 | template <class _Tp> |
| 40 | inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; | |
| 40 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; | |
| 41 | 41 | #endif |
| 42 | 42 | |
| 43 | 43 | template <class _Tp> |
| 44 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable | |
| 44 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_assignable | |
| 45 | 45 | : public integral_constant<bool, |
| 46 | 46 | __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> { |
| 47 | 47 | }; |
| 48 | 48 | |
| 49 | 49 | #if _LIBCPP_STD_VER >= 17 |
| 50 | 50 | template <class _Tp> |
| 51 | inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; | |
| 51 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; | |
| 52 | 52 | #endif |
| 53 | 53 | |
| 54 | 54 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_nothrow_constructible.h+11-8| ... | ... | @@ -21,39 +21,42 @@ |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template < class _Tp, class... _Args> |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible | |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_constructible | |
| 25 | 25 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {}; |
| 26 | 26 | |
| 27 | 27 | #if _LIBCPP_STD_VER >= 17 |
| 28 | 28 | template <class _Tp, class... _Args> |
| 29 | inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value; | |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_constructible_v = | |
| 30 | is_nothrow_constructible<_Tp, _Args...>::value; | |
| 30 | 31 | #endif |
| 31 | 32 | |
| 32 | 33 | template <class _Tp> |
| 33 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible | |
| 34 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_constructible | |
| 34 | 35 | : public integral_constant< bool, __is_nothrow_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; |
| 35 | 36 | |
| 36 | 37 | #if _LIBCPP_STD_VER >= 17 |
| 37 | 38 | template <class _Tp> |
| 38 | inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; | |
| 39 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_constructible_v = | |
| 40 | is_nothrow_copy_constructible<_Tp>::value; | |
| 39 | 41 | #endif |
| 40 | 42 | |
| 41 | 43 | template <class _Tp> |
| 42 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible | |
| 44 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_constructible | |
| 43 | 45 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; |
| 44 | 46 | |
| 45 | 47 | #if _LIBCPP_STD_VER >= 17 |
| 46 | 48 | template <class _Tp> |
| 47 | inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; | |
| 49 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_move_constructible_v = | |
| 50 | is_nothrow_move_constructible<_Tp>::value; | |
| 48 | 51 | #endif |
| 49 | 52 | |
| 50 | 53 | template <class _Tp> |
| 51 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible | |
| 54 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_default_constructible | |
| 52 | 55 | : public integral_constant<bool, __is_nothrow_constructible(_Tp)> {}; |
| 53 | 56 | |
| 54 | 57 | #if _LIBCPP_STD_VER >= 17 |
| 55 | 58 | template <class _Tp> |
| 56 | inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp); | |
| 59 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp); | |
| 57 | 60 | #endif |
| 58 | 61 | |
| 59 | 62 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_nothrow_convertible.h+2-2| ... | ... | @@ -29,10 +29,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | # if __has_builtin(__is_nothrow_convertible) |
| 30 | 30 | |
| 31 | 31 | template <class _Tp, class _Up> |
| 32 | struct is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {}; | |
| 32 | struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {}; | |
| 33 | 33 | |
| 34 | 34 | template <class _Tp, class _Up> |
| 35 | inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up); | |
| 35 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up); | |
| 36 | 36 | |
| 37 | 37 | # else // __has_builtin(__is_nothrow_convertible) |
| 38 | 38 |
lib/libcxx/include/__type_traits/is_nothrow_destructible.h+4-3| ... | ... | @@ -10,10 +10,10 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/integral_constant.h> |
| 14 | 15 | #include <__type_traits/is_destructible.h> |
| 15 | 16 | #include <__utility/declval.h> |
| 16 | #include <cstddef> | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | # pragma GCC system_header |
| ... | ... | @@ -24,7 +24,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | #if __has_builtin(__is_nothrow_destructible) |
| 25 | 25 | |
| 26 | 26 | template <class _Tp> |
| 27 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible : integral_constant<bool, __is_nothrow_destructible(_Tp)> {}; | |
| 27 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_destructible | |
| 28 | : integral_constant<bool, __is_nothrow_destructible(_Tp)> {}; | |
| 28 | 29 | |
| 29 | 30 | #else |
| 30 | 31 | |
| ... | ... | @@ -55,7 +56,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> : public true_type {} |
| 55 | 56 | |
| 56 | 57 | #if _LIBCPP_STD_VER >= 17 |
| 57 | 58 | template <class _Tp> |
| 58 | inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value; | |
| 59 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value; | |
| 59 | 60 | #endif |
| 60 | 61 | |
| 61 | 62 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_null_pointer.h+4-3| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/nullptr_t.h> | |
| 13 | 14 | #include <__type_traits/integral_constant.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
| ... | ... | @@ -24,11 +24,12 @@ inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t); |
| 24 | 24 | |
| 25 | 25 | #if _LIBCPP_STD_VER >= 14 |
| 26 | 26 | template <class _Tp> |
| 27 | struct _LIBCPP_TEMPLATE_VIS is_null_pointer : integral_constant<bool, __is_null_pointer_v<_Tp>> {}; | |
| 27 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_null_pointer | |
| 28 | : integral_constant<bool, __is_null_pointer_v<_Tp>> {}; | |
| 28 | 29 | |
| 29 | 30 | # if _LIBCPP_STD_VER >= 17 |
| 30 | 31 | template <class _Tp> |
| 31 | inline constexpr bool is_null_pointer_v = __is_null_pointer_v<_Tp>; | |
| 32 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_null_pointer_v = __is_null_pointer_v<_Tp>; | |
| 32 | 33 | # endif |
| 33 | 34 | #endif // _LIBCPP_STD_VER >= 14 |
| 34 | 35 |
lib/libcxx/include/__type_traits/is_object.h+2-2| ... | ... | @@ -19,11 +19,11 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_object : _BoolConstant<__is_object(_Tp)> {}; | |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | template <class _Tp> |
| 26 | inline constexpr bool is_object_v = __is_object(_Tp); | |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_object_v = __is_object(_Tp); | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_pod.h+2-2| ... | ... | @@ -19,11 +19,11 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_pod : public integral_constant<bool, __is_pod(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant<bool, __is_pod(_Tp)> {}; | |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | template <class _Tp> |
| 26 | inline constexpr bool is_pod_v = __is_pod(_Tp); | |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp); | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_pointer.h+3-3| ... | ... | @@ -22,11 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | #if __has_builtin(__is_pointer) |
| 23 | 23 | |
| 24 | 24 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> {}; | |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pointer : _BoolConstant<__is_pointer(_Tp)> {}; | |
| 26 | 26 | |
| 27 | 27 | # if _LIBCPP_STD_VER >= 17 |
| 28 | 28 | template <class _Tp> |
| 29 | inline constexpr bool is_pointer_v = __is_pointer(_Tp); | |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pointer_v = __is_pointer(_Tp); | |
| 30 | 30 | # endif |
| 31 | 31 | |
| 32 | 32 | #else // __has_builtin(__is_pointer) |
| ... | ... | @@ -40,7 +40,7 @@ template <class _Tp> |
| 40 | 40 | struct __libcpp_remove_objc_qualifiers { |
| 41 | 41 | typedef _Tp type; |
| 42 | 42 | }; |
| 43 | # if defined(_LIBCPP_HAS_OBJC_ARC) | |
| 43 | # if _LIBCPP_HAS_OBJC_ARC | |
| 44 | 44 | // clang-format off |
| 45 | 45 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; }; |
| 46 | 46 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; }; |
lib/libcxx/include/__type_traits/is_polymorphic.h+3-2| ... | ... | @@ -19,11 +19,12 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_polymorphic : public integral_constant<bool, __is_polymorphic(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_polymorphic | |
| 23 | : public integral_constant<bool, __is_polymorphic(_Tp)> {}; | |
| 23 | 24 | |
| 24 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 26 | template <class _Tp> |
| 26 | inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp); | |
| 27 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp); | |
| 27 | 28 | #endif |
| 28 | 29 | |
| 29 | 30 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_primary_template.h+3-2| ... | ... | @@ -21,10 +21,11 @@ |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class _Tp> |
| 24 | using __test_for_primary_template = __enable_if_t<_IsSame<_Tp, typename _Tp::__primary_template>::value>; | |
| 24 | using __test_for_primary_template _LIBCPP_NODEBUG = | |
| 25 | __enable_if_t<_IsSame<_Tp, typename _Tp::__primary_template>::value>; | |
| 25 | 26 | |
| 26 | 27 | template <class _Tp> |
| 27 | using __is_primary_template = _IsValidExpansion<__test_for_primary_template, _Tp>; | |
| 28 | using __is_primary_template _LIBCPP_NODEBUG = _IsValidExpansion<__test_for_primary_template, _Tp>; | |
| 28 | 29 | |
| 29 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 30 | 31 |
lib/libcxx/include/__type_traits/is_reference.h+8-6| ... | ... | @@ -19,26 +19,28 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_reference : _BoolConstant<__is_reference(_Tp)> {}; | |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | template <class _Tp> |
| 26 | inline constexpr bool is_reference_v = __is_reference(_Tp); | |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_reference_v = __is_reference(_Tp); | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | #if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) |
| 30 | 30 | |
| 31 | 31 | template <class _Tp> |
| 32 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {}; | |
| 32 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { | |
| 33 | }; | |
| 33 | 34 | |
| 34 | 35 | template <class _Tp> |
| 35 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {}; | |
| 36 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { | |
| 37 | }; | |
| 36 | 38 | |
| 37 | 39 | # if _LIBCPP_STD_VER >= 17 |
| 38 | 40 | template <class _Tp> |
| 39 | inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); | |
| 41 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); | |
| 40 | 42 | template <class _Tp> |
| 41 | inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); | |
| 43 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); | |
| 42 | 44 | # endif |
| 43 | 45 | |
| 44 | 46 | #else // __has_builtin(__is_lvalue_reference) |
lib/libcxx/include/__type_traits/is_same.h+4-4| ... | ... | @@ -19,11 +19,11 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp, class _Up> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_same : _BoolConstant<__is_same(_Tp, _Up)> {}; | |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | template <class _Tp, class _Up> |
| 26 | inline constexpr bool is_same_v = __is_same(_Tp, _Up); | |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_same_v = __is_same(_Tp, _Up); | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | // _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types: |
| ... | ... | @@ -34,10 +34,10 @@ inline constexpr bool is_same_v = __is_same(_Tp, _Up); |
| 34 | 34 | // (such as in a dependent return type). |
| 35 | 35 | |
| 36 | 36 | template <class _Tp, class _Up> |
| 37 | using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>; | |
| 37 | using _IsSame _LIBCPP_NODEBUG = _BoolConstant<__is_same(_Tp, _Up)>; | |
| 38 | 38 | |
| 39 | 39 | template <class _Tp, class _Up> |
| 40 | using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>; | |
| 40 | using _IsNotSame _LIBCPP_NODEBUG = _BoolConstant<!__is_same(_Tp, _Up)>; | |
| 41 | 41 | |
| 42 | 42 | _LIBCPP_END_NAMESPACE_STD |
| 43 | 43 |
lib/libcxx/include/__type_traits/is_scalar.h+3-3| ... | ... | @@ -26,18 +26,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | #if __has_builtin(__is_scalar) |
| 27 | 27 | |
| 28 | 28 | template <class _Tp> |
| 29 | struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> {}; | |
| 29 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_scalar : _BoolConstant<__is_scalar(_Tp)> {}; | |
| 30 | 30 | |
| 31 | 31 | # if _LIBCPP_STD_VER >= 17 |
| 32 | 32 | template <class _Tp> |
| 33 | inline constexpr bool is_scalar_v = __is_scalar(_Tp); | |
| 33 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scalar_v = __is_scalar(_Tp); | |
| 34 | 34 | # endif |
| 35 | 35 | |
| 36 | 36 | #else // __has_builtin(__is_scalar) |
| 37 | 37 | |
| 38 | 38 | template <class _Tp> |
| 39 | 39 | struct __is_block : false_type {}; |
| 40 | # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) | |
| 40 | # if _LIBCPP_HAS_EXTENSION_BLOCKS | |
| 41 | 41 | template <class _Rp, class... _Args> |
| 42 | 42 | struct __is_block<_Rp (^)(_Args...)> : true_type {}; |
| 43 | 43 | # endif |
lib/libcxx/include/__type_traits/is_signed.h+2-2| ... | ... | @@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | #if __has_builtin(__is_signed) |
| 24 | 24 | |
| 25 | 25 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> {}; | |
| 26 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_signed : _BoolConstant<__is_signed(_Tp)> {}; | |
| 27 | 27 | |
| 28 | 28 | # if _LIBCPP_STD_VER >= 17 |
| 29 | 29 | template <class _Tp> |
| 30 | inline constexpr bool is_signed_v = __is_signed(_Tp); | |
| 30 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_signed_v = __is_signed(_Tp); | |
| 31 | 31 | # endif |
| 32 | 32 | |
| 33 | 33 | #else // __has_builtin(__is_signed) |
lib/libcxx/include/__type_traits/is_signed_integer.h+1-1| ... | ... | @@ -25,7 +25,7 @@ template <> struct __libcpp_is_signed_integer<signed short> : publi |
| 25 | 25 | template <> struct __libcpp_is_signed_integer<signed int> : public true_type {}; |
| 26 | 26 | template <> struct __libcpp_is_signed_integer<signed long> : public true_type {}; |
| 27 | 27 | template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {}; |
| 28 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 28 | #if _LIBCPP_HAS_INT128 | |
| 29 | 29 | template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {}; |
| 30 | 30 | #endif |
| 31 | 31 | // clang-format on |
lib/libcxx/include/__type_traits/is_standard_layout.h+3-2| ... | ... | @@ -19,11 +19,12 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_standard_layout : public integral_constant<bool, __is_standard_layout(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_standard_layout | |
| 23 | : public integral_constant<bool, __is_standard_layout(_Tp)> {}; | |
| 23 | 24 | |
| 24 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 26 | template <class _Tp> |
| 26 | inline constexpr bool is_standard_layout_v = __is_standard_layout(_Tp); | |
| 27 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_standard_layout_v = __is_standard_layout(_Tp); | |
| 27 | 28 | #endif |
| 28 | 29 | |
| 29 | 30 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_swappable.h+16-11| ... | ... | @@ -10,15 +10,16 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_IS_SWAPPABLE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/add_lvalue_reference.h> |
| 14 | 15 | #include <__type_traits/enable_if.h> |
| 16 | #include <__type_traits/integral_constant.h> | |
| 15 | 17 | #include <__type_traits/is_assignable.h> |
| 16 | 18 | #include <__type_traits/is_constructible.h> |
| 17 | 19 | #include <__type_traits/is_nothrow_assignable.h> |
| 18 | 20 | #include <__type_traits/is_nothrow_constructible.h> |
| 19 | 21 | #include <__type_traits/void_t.h> |
| 20 | 22 | #include <__utility/declval.h> |
| 21 | #include <cstddef> | |
| 22 | 23 | |
| 23 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | 25 | # pragma GCC system_header |
| ... | ... | @@ -40,10 +41,11 @@ inline const bool __is_nothrow_swappable_v = __is_nothrow_swappable_with_v<_Tp&, |
| 40 | 41 | |
| 41 | 42 | #ifndef _LIBCPP_CXX03_LANG |
| 42 | 43 | template <class _Tp> |
| 43 | using __swap_result_t = __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>; | |
| 44 | using __swap_result_t _LIBCPP_NODEBUG = | |
| 45 | __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>; | |
| 44 | 46 | #else |
| 45 | 47 | template <class> |
| 46 | using __swap_result_t = void; | |
| 48 | using __swap_result_t _LIBCPP_NODEBUG = void; | |
| 47 | 49 | #endif |
| 48 | 50 | |
| 49 | 51 | template <class _Tp> |
| ... | ... | @@ -72,30 +74,33 @@ inline const bool __is_nothrow_swappable_with_v<_Tp, _Up, true> = |
| 72 | 74 | #if _LIBCPP_STD_VER >= 17 |
| 73 | 75 | |
| 74 | 76 | template <class _Tp, class _Up> |
| 75 | inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>; | |
| 77 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>; | |
| 76 | 78 | |
| 77 | 79 | template <class _Tp, class _Up> |
| 78 | struct _LIBCPP_TEMPLATE_VIS is_swappable_with : bool_constant<is_swappable_with_v<_Tp, _Up>> {}; | |
| 80 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_swappable_with | |
| 81 | : bool_constant<is_swappable_with_v<_Tp, _Up>> {}; | |
| 79 | 82 | |
| 80 | 83 | template <class _Tp> |
| 81 | inline constexpr bool is_swappable_v = | |
| 84 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_v = | |
| 82 | 85 | is_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>; |
| 83 | 86 | |
| 84 | 87 | template <class _Tp> |
| 85 | struct _LIBCPP_TEMPLATE_VIS is_swappable : bool_constant<is_swappable_v<_Tp>> {}; | |
| 88 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_swappable : bool_constant<is_swappable_v<_Tp>> {}; | |
| 86 | 89 | |
| 87 | 90 | template <class _Tp, class _Up> |
| 88 | inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>; | |
| 91 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>; | |
| 89 | 92 | |
| 90 | 93 | template <class _Tp, class _Up> |
| 91 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {}; | |
| 94 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable_with | |
| 95 | : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {}; | |
| 92 | 96 | |
| 93 | 97 | template <class _Tp> |
| 94 | inline constexpr bool is_nothrow_swappable_v = | |
| 98 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_v = | |
| 95 | 99 | is_nothrow_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>; |
| 96 | 100 | |
| 97 | 101 | template <class _Tp> |
| 98 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable : bool_constant<is_nothrow_swappable_v<_Tp>> {}; | |
| 102 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable | |
| 103 | : bool_constant<is_nothrow_swappable_v<_Tp>> {}; | |
| 99 | 104 | |
| 100 | 105 | #endif // _LIBCPP_STD_VER >= 17 |
| 101 | 106 |
lib/libcxx/include/__type_traits/is_trivial.h+3-2| ... | ... | @@ -19,11 +19,12 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_trivial : public integral_constant<bool, __is_trivial(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivial : public integral_constant<bool, __is_trivial(_Tp)> { | |
| 23 | }; | |
| 23 | 24 | |
| 24 | 25 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 26 | template <class _Tp> |
| 26 | inline constexpr bool is_trivial_v = __is_trivial(_Tp); | |
| 27 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivial_v = __is_trivial(_Tp); | |
| 27 | 28 | #endif |
| 28 | 29 | |
| 29 | 30 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_trivially_assignable.h+9-7| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | 13 | #include <__type_traits/add_lvalue_reference.h> |
| 15 | 14 | #include <__type_traits/add_rvalue_reference.h> |
| 16 | 15 | #include <__type_traits/integral_constant.h> |
| ... | ... | @@ -22,33 +21,36 @@ |
| 22 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 22 | |
| 24 | 23 | template <class _Tp, class _Arg> |
| 25 | struct is_trivially_assignable : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> {}; | |
| 24 | struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_assignable | |
| 25 | : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> {}; | |
| 26 | 26 | |
| 27 | 27 | #if _LIBCPP_STD_VER >= 17 |
| 28 | 28 | template <class _Tp, class _Arg> |
| 29 | inline constexpr bool is_trivially_assignable_v = __is_trivially_assignable(_Tp, _Arg); | |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_assignable_v = __is_trivially_assignable(_Tp, _Arg); | |
| 30 | 30 | #endif |
| 31 | 31 | |
| 32 | 32 | template <class _Tp> |
| 33 | struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable | |
| 33 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_assignable | |
| 34 | 34 | : public integral_constant< |
| 35 | 35 | bool, |
| 36 | 36 | __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {}; |
| 37 | 37 | |
| 38 | 38 | #if _LIBCPP_STD_VER >= 17 |
| 39 | 39 | template <class _Tp> |
| 40 | inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value; | |
| 40 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_assignable_v = | |
| 41 | is_trivially_copy_assignable<_Tp>::value; | |
| 41 | 42 | #endif |
| 42 | 43 | |
| 43 | 44 | template <class _Tp> |
| 44 | struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable | |
| 45 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_assignable | |
| 45 | 46 | : public integral_constant< |
| 46 | 47 | bool, |
| 47 | 48 | __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {}; |
| 48 | 49 | |
| 49 | 50 | #if _LIBCPP_STD_VER >= 17 |
| 50 | 51 | template <class _Tp> |
| 51 | inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value; | |
| 52 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_move_assignable_v = | |
| 53 | is_trivially_move_assignable<_Tp>::value; | |
| 52 | 54 | #endif |
| 53 | 55 | |
| 54 | 56 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_trivially_constructible.h+12-8| ... | ... | @@ -21,39 +21,43 @@ |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class _Tp, class... _Args> |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible | |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_constructible | |
| 25 | 25 | : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> {}; |
| 26 | 26 | |
| 27 | 27 | #if _LIBCPP_STD_VER >= 17 |
| 28 | 28 | template <class _Tp, class... _Args> |
| 29 | inline constexpr bool is_trivially_constructible_v = __is_trivially_constructible(_Tp, _Args...); | |
| 29 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_constructible_v = | |
| 30 | __is_trivially_constructible(_Tp, _Args...); | |
| 30 | 31 | #endif |
| 31 | 32 | |
| 32 | 33 | template <class _Tp> |
| 33 | struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible | |
| 34 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_constructible | |
| 34 | 35 | : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {}; |
| 35 | 36 | |
| 36 | 37 | #if _LIBCPP_STD_VER >= 17 |
| 37 | 38 | template <class _Tp> |
| 38 | inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value; | |
| 39 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_constructible_v = | |
| 40 | is_trivially_copy_constructible<_Tp>::value; | |
| 39 | 41 | #endif |
| 40 | 42 | |
| 41 | 43 | template <class _Tp> |
| 42 | struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible | |
| 44 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_constructible | |
| 43 | 45 | : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {}; |
| 44 | 46 | |
| 45 | 47 | #if _LIBCPP_STD_VER >= 17 |
| 46 | 48 | template <class _Tp> |
| 47 | inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value; | |
| 49 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_move_constructible_v = | |
| 50 | is_trivially_move_constructible<_Tp>::value; | |
| 48 | 51 | #endif |
| 49 | 52 | |
| 50 | 53 | template <class _Tp> |
| 51 | struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible | |
| 54 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_default_constructible | |
| 52 | 55 | : public integral_constant<bool, __is_trivially_constructible(_Tp)> {}; |
| 53 | 56 | |
| 54 | 57 | #if _LIBCPP_STD_VER >= 17 |
| 55 | 58 | template <class _Tp> |
| 56 | inline constexpr bool is_trivially_default_constructible_v = __is_trivially_constructible(_Tp); | |
| 59 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_default_constructible_v = | |
| 60 | __is_trivially_constructible(_Tp); | |
| 57 | 61 | #endif |
| 58 | 62 | |
| 59 | 63 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_trivially_copyable.h+4-5| ... | ... | @@ -20,17 +20,16 @@ |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | 22 | template <class _Tp> |
| 23 | struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable : public integral_constant<bool, __is_trivially_copyable(_Tp)> {}; | |
| 23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copyable | |
| 24 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> {}; | |
| 24 | 25 | |
| 25 | 26 | #if _LIBCPP_STD_VER >= 17 |
| 26 | 27 | template <class _Tp> |
| 27 | inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp); | |
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp); | |
| 28 | 29 | #endif |
| 29 | 30 | |
| 30 | #if _LIBCPP_STD_VER >= 20 | |
| 31 | 31 | template <class _Tp> |
| 32 | inline constexpr bool __is_cheap_to_copy = is_trivially_copyable_v<_Tp> && sizeof(_Tp) <= sizeof(std::intmax_t); | |
| 33 | #endif | |
| 32 | inline const bool __is_cheap_to_copy = __is_trivially_copyable(_Tp) && sizeof(_Tp) <= sizeof(std::intmax_t); | |
| 34 | 33 | |
| 35 | 34 | _LIBCPP_END_NAMESPACE_STD |
| 36 | 35 |
lib/libcxx/include/__type_traits/is_trivially_destructible.h+2-2| ... | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | #if __has_builtin(__is_trivially_destructible) |
| 23 | 23 | |
| 24 | 24 | template <class _Tp> |
| 25 | struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible | |
| 25 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_destructible | |
| 26 | 26 | : public integral_constant<bool, __is_trivially_destructible(_Tp)> {}; |
| 27 | 27 | |
| 28 | 28 | #elif __has_builtin(__has_trivial_destructor) |
| ... | ... | @@ -39,7 +39,7 @@ struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible |
| 39 | 39 | |
| 40 | 40 | #if _LIBCPP_STD_VER >= 17 |
| 41 | 41 | template <class _Tp> |
| 42 | inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value; | |
| 42 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value; | |
| 43 | 43 | #endif |
| 44 | 44 | |
| 45 | 45 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_trivially_lexicographically_comparable.h+15-5| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_LEXICOGRAPHICALLY_COMPARABLE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__fwd/byte.h> | |
| 13 | 14 | #include <__type_traits/integral_constant.h> |
| 14 | 15 | #include <__type_traits/is_same.h> |
| 15 | 16 | #include <__type_traits/is_unsigned.h> |
| ... | ... | @@ -40,13 +41,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | 41 | // unsigned integer types with sizeof(T) > 1: depending on the endianness, the LSB might be the first byte to be |
| 41 | 42 | // compared. This means that when comparing unsigned(129) and unsigned(2) |
| 42 | 43 | // using memcmp(), the result would be that 2 > 129. |
| 43 | // TODO: Do we want to enable this on big-endian systems? | |
| 44 | ||
| 45 | template <class _Tp> | |
| 46 | inline const bool __is_std_byte_v = false; | |
| 47 | ||
| 48 | #if _LIBCPP_STD_VER >= 17 | |
| 49 | template <> | |
| 50 | inline const bool __is_std_byte_v<byte> = true; | |
| 51 | #endif | |
| 44 | 52 | |
| 45 | 53 | template <class _Tp, class _Up> |
| 46 | struct __libcpp_is_trivially_lexicographically_comparable | |
| 47 | : integral_constant<bool, | |
| 48 | is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value && sizeof(_Tp) == 1 && | |
| 49 | is_unsigned<_Tp>::value> {}; | |
| 54 | inline const bool __is_trivially_lexicographically_comparable_v = | |
| 55 | is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value && | |
| 56 | #ifdef _LIBCPP_LITTLE_ENDIAN | |
| 57 | sizeof(_Tp) == 1 && | |
| 58 | #endif | |
| 59 | (is_unsigned<_Tp>::value || __is_std_byte_v<_Tp>); | |
| 50 | 60 | |
| 51 | 61 | _LIBCPP_END_NAMESPACE_STD |
| 52 | 62 |
lib/libcxx/include/__type_traits/is_trivially_relocatable.h+5-3| ... | ... | @@ -11,7 +11,6 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__type_traits/enable_if.h> |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | 14 | #include <__type_traits/is_same.h> |
| 16 | 15 | #include <__type_traits/is_trivially_copyable.h> |
| 17 | 16 | |
| ... | ... | @@ -23,8 +22,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 22 | |
| 24 | 23 | // A type is trivially relocatable if a move construct + destroy of the original object is equivalent to |
| 25 | 24 | // `memcpy(dst, src, sizeof(T))`. |
| 26 | ||
| 27 | #if __has_builtin(__is_trivially_relocatable) | |
| 25 | // | |
| 26 | // Note that we don't use the __is_trivially_relocatable Clang builtin right now because it does not | |
| 27 | // implement the semantics of any current or future trivial relocation proposal and it can lead to | |
| 28 | // incorrect optimizations on some platforms (Windows) and supported compilers (AppleClang). | |
| 29 | #if __has_builtin(__is_trivially_relocatable) && 0 | |
| 28 | 30 | template <class _Tp, class = void> |
| 29 | 31 | struct __libcpp_is_trivially_relocatable : integral_constant<bool, __is_trivially_relocatable(_Tp)> {}; |
| 30 | 32 | #else |
lib/libcxx/include/__type_traits/is_unbounded_array.h+10-4| ... | ... | @@ -19,19 +19,25 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class> |
| 22 | struct _LIBCPP_TEMPLATE_VIS __libcpp_is_unbounded_array : false_type {}; | |
| 22 | inline const bool __is_unbounded_array_v = false; | |
| 23 | 23 | template <class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS __libcpp_is_unbounded_array<_Tp[]> : true_type {}; | |
| 24 | inline const bool __is_unbounded_array_v<_Tp[]> = true; | |
| 25 | 25 | |
| 26 | 26 | #if _LIBCPP_STD_VER >= 20 |
| 27 | 27 | |
| 28 | 28 | template <class> |
| 29 | struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {}; | |
| 29 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_unbounded_array : false_type {}; | |
| 30 | ||
| 31 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 32 | # if __has_warning("-Winvalid-specialization") | |
| 33 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | |
| 34 | # endif | |
| 30 | 35 | template <class _Tp> |
| 31 | 36 | struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {}; |
| 37 | _LIBCPP_DIAGNOSTIC_POP | |
| 32 | 38 | |
| 33 | 39 | template <class _Tp> |
| 34 | inline constexpr bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; | |
| 40 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; | |
| 35 | 41 | |
| 36 | 42 | #endif |
| 37 | 43 |
lib/libcxx/include/__type_traits/is_union.h+2-2| ... | ... | @@ -19,11 +19,11 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_union : public integral_constant<bool, __is_union(_Tp)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_union : public integral_constant<bool, __is_union(_Tp)> {}; | |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | template <class _Tp> |
| 26 | inline constexpr bool is_union_v = __is_union(_Tp); | |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_union_v = __is_union(_Tp); | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/is_unsigned.h+2-2| ... | ... | @@ -23,11 +23,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | #if __has_builtin(__is_unsigned) |
| 24 | 24 | |
| 25 | 25 | template <class _Tp> |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> {}; | |
| 26 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> {}; | |
| 27 | 27 | |
| 28 | 28 | # if _LIBCPP_STD_VER >= 17 |
| 29 | 29 | template <class _Tp> |
| 30 | inline constexpr bool is_unsigned_v = __is_unsigned(_Tp); | |
| 30 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unsigned_v = __is_unsigned(_Tp); | |
| 31 | 31 | # endif |
| 32 | 32 | |
| 33 | 33 | #else // __has_builtin(__is_unsigned) |
lib/libcxx/include/__type_traits/is_unsigned_integer.h+1-1| ... | ... | @@ -25,7 +25,7 @@ template <> struct __libcpp_is_unsigned_integer<unsigned short> : p |
| 25 | 25 | template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {}; |
| 26 | 26 | template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {}; |
| 27 | 27 | template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {}; |
| 28 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 28 | #if _LIBCPP_HAS_INT128 | |
| 29 | 29 | template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {}; |
| 30 | 30 | #endif |
| 31 | 31 | // clang-format on |
lib/libcxx/include/__type_traits/is_void.h+4-4| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {}; | |
| 22 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {}; | |
| 23 | 23 | |
| 24 | # if _LIBCPP_STD_VER >= 17 | |
| 24 | #if _LIBCPP_STD_VER >= 17 | |
| 25 | 25 | template <class _Tp> |
| 26 | inline constexpr bool is_void_v = __is_same(__remove_cv(_Tp), void); | |
| 27 | # endif | |
| 26 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_void_v = __is_same(__remove_cv(_Tp), void); | |
| 27 | #endif | |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_END_NAMESPACE_STD |
| 30 | 30 |
lib/libcxx/include/__type_traits/is_volatile.h+2-2| ... | ... | @@ -21,11 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | #if __has_builtin(__is_volatile) |
| 22 | 22 | |
| 23 | 23 | template <class _Tp> |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> {}; | |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_volatile : _BoolConstant<__is_volatile(_Tp)> {}; | |
| 25 | 25 | |
| 26 | 26 | # if _LIBCPP_STD_VER >= 17 |
| 27 | 27 | template <class _Tp> |
| 28 | inline constexpr bool is_volatile_v = __is_volatile(_Tp); | |
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_volatile_v = __is_volatile(_Tp); | |
| 29 | 29 | # endif |
| 30 | 30 | |
| 31 | 31 | #else |
lib/libcxx/include/__type_traits/make_32_64_or_128_bit.h+2-2| ... | ... | @@ -31,11 +31,11 @@ template <class _Tp> |
| 31 | 31 | requires(is_signed_v<_Tp> || is_unsigned_v<_Tp> || is_same_v<_Tp, char>) |
| 32 | 32 | #endif |
| 33 | 33 | // clang-format off |
| 34 | using __make_32_64_or_128_bit_t = | |
| 34 | using __make_32_64_or_128_bit_t _LIBCPP_NODEBUG = | |
| 35 | 35 | __copy_unsigned_t<_Tp, |
| 36 | 36 | __conditional_t<sizeof(_Tp) <= sizeof(int32_t), int32_t, |
| 37 | 37 | __conditional_t<sizeof(_Tp) <= sizeof(int64_t), int64_t, |
| 38 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 38 | #if _LIBCPP_HAS_INT128 | |
| 39 | 39 | __conditional_t<sizeof(_Tp) <= sizeof(__int128_t), __int128_t, |
| 40 | 40 | /* else */ void> |
| 41 | 41 | #else |
lib/libcxx/include/__type_traits/make_const_lvalue_ref.h+1-1| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _Tp> |
| 22 | using __make_const_lvalue_ref = const __libcpp_remove_reference_t<_Tp>&; | |
| 22 | using __make_const_lvalue_ref _LIBCPP_NODEBUG = const __libcpp_remove_reference_t<_Tp>&; | |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_END_NAMESPACE_STD |
| 25 | 25 |
lib/libcxx/include/__type_traits/make_signed.h+13-18| ... | ... | @@ -13,7 +13,6 @@ |
| 13 | 13 | #include <__type_traits/copy_cv.h> |
| 14 | 14 | #include <__type_traits/is_enum.h> |
| 15 | 15 | #include <__type_traits/is_integral.h> |
| 16 | #include <__type_traits/nat.h> | |
| 17 | 16 | #include <__type_traits/remove_cv.h> |
| 18 | 17 | #include <__type_traits/type_list.h> |
| 19 | 18 | |
| ... | ... | @@ -26,24 +25,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 25 | #if __has_builtin(__make_signed) |
| 27 | 26 | |
| 28 | 27 | template <class _Tp> |
| 29 | using __make_signed_t = __make_signed(_Tp); | |
| 28 | using __make_signed_t _LIBCPP_NODEBUG = __make_signed(_Tp); | |
| 30 | 29 | |
| 31 | 30 | #else |
| 32 | // clang-format off | |
| 33 | typedef __type_list<signed char, | |
| 34 | __type_list<signed short, | |
| 35 | __type_list<signed int, | |
| 36 | __type_list<signed long, | |
| 37 | __type_list<signed long long, | |
| 38 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 39 | __type_list<__int128_t, | |
| 40 | # endif | |
| 41 | __nat | |
| 42 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 43 | > | |
| 31 | using __signed_types = | |
| 32 | __type_list<signed char, | |
| 33 | signed short, | |
| 34 | signed int, | |
| 35 | signed long, | |
| 36 | signed long long | |
| 37 | # if _LIBCPP_HAS_INT128 | |
| 38 | , | |
| 39 | __int128_t | |
| 44 | 40 | # endif |
| 45 | > > > > > __signed_types; | |
| 46 | // clang-format on | |
| 41 | >; | |
| 47 | 42 | |
| 48 | 43 | template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> |
| 49 | 44 | struct __make_signed{}; |
| ... | ... | @@ -63,7 +58,7 @@ template <> struct __make_signed< signed long, true> {typedef long ty |
| 63 | 58 | template <> struct __make_signed<unsigned long, true> {typedef long type;}; |
| 64 | 59 | template <> struct __make_signed< signed long long, true> {typedef long long type;}; |
| 65 | 60 | template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; |
| 66 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 61 | # if _LIBCPP_HAS_INT128 | |
| 67 | 62 | template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; |
| 68 | 63 | template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; |
| 69 | 64 | # endif |
| ... | ... | @@ -75,7 +70,7 @@ using __make_signed_t = __copy_cv_t<_Tp, typename __make_signed<__remove_cv_t<_T |
| 75 | 70 | #endif // __has_builtin(__make_signed) |
| 76 | 71 | |
| 77 | 72 | template <class _Tp> |
| 78 | struct make_signed { | |
| 73 | struct _LIBCPP_NO_SPECIALIZATIONS make_signed { | |
| 79 | 74 | using type _LIBCPP_NODEBUG = __make_signed_t<_Tp>; |
| 80 | 75 | }; |
| 81 | 76 |
lib/libcxx/include/__type_traits/make_unsigned.h+15-22| ... | ... | @@ -15,7 +15,6 @@ |
| 15 | 15 | #include <__type_traits/is_enum.h> |
| 16 | 16 | #include <__type_traits/is_integral.h> |
| 17 | 17 | #include <__type_traits/is_unsigned.h> |
| 18 | #include <__type_traits/nat.h> | |
| 19 | 18 | #include <__type_traits/remove_cv.h> |
| 20 | 19 | #include <__type_traits/type_list.h> |
| 21 | 20 | |
| ... | ... | @@ -28,24 +27,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 27 | #if __has_builtin(__make_unsigned) |
| 29 | 28 | |
| 30 | 29 | template <class _Tp> |
| 31 | using __make_unsigned_t = __make_unsigned(_Tp); | |
| 30 | using __make_unsigned_t _LIBCPP_NODEBUG = __make_unsigned(_Tp); | |
| 32 | 31 | |
| 33 | 32 | #else |
| 34 | // clang-format off | |
| 35 | typedef __type_list<unsigned char, | |
| 36 | __type_list<unsigned short, | |
| 37 | __type_list<unsigned int, | |
| 38 | __type_list<unsigned long, | |
| 39 | __type_list<unsigned long long, | |
| 40 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 41 | __type_list<__uint128_t, | |
| 42 | # endif | |
| 43 | __nat | |
| 44 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 45 | > | |
| 33 | using __unsigned_types = | |
| 34 | __type_list<unsigned char, | |
| 35 | unsigned short, | |
| 36 | unsigned int, | |
| 37 | unsigned long, | |
| 38 | unsigned long long | |
| 39 | # if _LIBCPP_HAS_INT128 | |
| 40 | , | |
| 41 | __uint128_t | |
| 46 | 42 | # endif |
| 47 | > > > > > __unsigned_types; | |
| 48 | // clang-format on | |
| 43 | >; | |
| 49 | 44 | |
| 50 | 45 | template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> |
| 51 | 46 | struct __make_unsigned{}; |
| ... | ... | @@ -65,7 +60,7 @@ template <> struct __make_unsigned< signed long, true> {typedef unsigned l |
| 65 | 60 | template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; |
| 66 | 61 | template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; |
| 67 | 62 | template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; |
| 68 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 63 | # if _LIBCPP_HAS_INT128 | |
| 69 | 64 | template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; |
| 70 | 65 | template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; |
| 71 | 66 | # endif |
| ... | ... | @@ -77,7 +72,7 @@ using __make_unsigned_t = __copy_cv_t<_Tp, typename __make_unsigned<__remove_cv_ |
| 77 | 72 | #endif // __has_builtin(__make_unsigned) |
| 78 | 73 | |
| 79 | 74 | template <class _Tp> |
| 80 | struct make_unsigned { | |
| 75 | struct _LIBCPP_NO_SPECIALIZATIONS make_unsigned { | |
| 81 | 76 | using type _LIBCPP_NODEBUG = __make_unsigned_t<_Tp>; |
| 82 | 77 | }; |
| 83 | 78 | |
| ... | ... | @@ -86,15 +81,13 @@ template <class _Tp> |
| 86 | 81 | using make_unsigned_t = __make_unsigned_t<_Tp>; |
| 87 | 82 | #endif |
| 88 | 83 | |
| 89 | #ifndef _LIBCPP_CXX03_LANG | |
| 90 | 84 | template <class _Tp> |
| 91 | _LIBCPP_HIDE_FROM_ABI constexpr __make_unsigned_t<_Tp> __to_unsigned_like(_Tp __x) noexcept { | |
| 85 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __make_unsigned_t<_Tp> __to_unsigned_like(_Tp __x) _NOEXCEPT { | |
| 92 | 86 | return static_cast<__make_unsigned_t<_Tp> >(__x); |
| 93 | 87 | } |
| 94 | #endif | |
| 95 | 88 | |
| 96 | 89 | template <class _Tp, class _Up> |
| 97 | using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, __make_unsigned_t<_Up>, _Up>; | |
| 90 | using __copy_unsigned_t _LIBCPP_NODEBUG = __conditional_t<is_unsigned<_Tp>::value, __make_unsigned_t<_Up>, _Up>; | |
| 98 | 91 | |
| 99 | 92 | _LIBCPP_END_NAMESPACE_STD |
| 100 | 93 |
lib/libcxx/include/__type_traits/maybe_const.h+1-1| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <bool _Const, class _Tp> |
| 22 | using __maybe_const = __conditional_t<_Const, const _Tp, _Tp>; | |
| 22 | using __maybe_const _LIBCPP_NODEBUG = __conditional_t<_Const, const _Tp, _Tp>; | |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_END_NAMESPACE_STD |
| 25 | 25 |
lib/libcxx/include/__type_traits/negation.h+2-2| ... | ... | @@ -23,9 +23,9 @@ struct _Not : _BoolConstant<!_Pred::value> {}; |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER >= 17 |
| 25 | 25 | template <class _Tp> |
| 26 | struct negation : _Not<_Tp> {}; | |
| 26 | struct _LIBCPP_NO_SPECIALIZATIONS negation : _Not<_Tp> {}; | |
| 27 | 27 | template <class _Tp> |
| 28 | inline constexpr bool negation_v = !_Tp::value; | |
| 28 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool negation_v = !_Tp::value; | |
| 29 | 29 | #endif // _LIBCPP_STD_VER >= 17 |
| 30 | 30 | |
| 31 | 31 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/noexcept_move_assign_container.h deleted-37| ... | ... | @@ -1,37 +0,0 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__memory/allocator_traits.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <__type_traits/is_nothrow_assignable.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 <typename _Alloc, typename _Traits = allocator_traits<_Alloc> > | |
| 24 | struct __noexcept_move_assign_container | |
| 25 | : public integral_constant<bool, | |
| 26 | _Traits::propagate_on_container_move_assignment::value | |
| 27 | #if _LIBCPP_STD_VER >= 17 | |
| 28 | || _Traits::is_always_equal::value | |
| 29 | #else | |
| 30 | && is_nothrow_move_assignable<_Alloc>::value | |
| 31 | #endif | |
| 32 | > { | |
| 33 | }; | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP___TYPE_TRAITS_NOEXCEPT_MOVE_ASSIGN_CONTAINER_H |
lib/libcxx/include/__type_traits/promote.h+2-83| ... | ... | @@ -13,20 +13,12 @@ |
| 13 | 13 | #include <__type_traits/integral_constant.h> |
| 14 | 14 | #include <__type_traits/is_arithmetic.h> |
| 15 | 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 | |
| 20 | ||
| 21 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 17 | # pragma GCC system_header |
| 23 | 18 | #endif |
| 24 | 19 | |
| 25 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 21 | |
| 27 | // TODO(LLVM-20): Remove this workaround | |
| 28 | #if !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER != 1700 | |
| 29 | ||
| 30 | 22 | template <class... _Args> |
| 31 | 23 | class __promote { |
| 32 | 24 | static_assert((is_arithmetic<_Args>::value && ...)); |
| ... | ... | @@ -39,10 +31,10 @@ class __promote { |
| 39 | 31 | static double __test(unsigned long); |
| 40 | 32 | static double __test(long long); |
| 41 | 33 | static double __test(unsigned long long); |
| 42 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 34 | #if _LIBCPP_HAS_INT128 | |
| 43 | 35 | static double __test(__int128_t); |
| 44 | 36 | static double __test(__uint128_t); |
| 45 | # endif | |
| 37 | #endif | |
| 46 | 38 | static double __test(double); |
| 47 | 39 | static long double __test(long double); |
| 48 | 40 | |
| ... | ... | @@ -50,79 +42,6 @@ public: |
| 50 | 42 | using type = decltype((__test(_Args()) + ...)); |
| 51 | 43 | }; |
| 52 | 44 | |
| 53 | #else | |
| 54 | ||
| 55 | template <class _Tp> | |
| 56 | struct __numeric_type { | |
| 57 | static void __test(...); | |
| 58 | static float __test(float); | |
| 59 | static double __test(char); | |
| 60 | static double __test(int); | |
| 61 | static double __test(unsigned); | |
| 62 | static double __test(long); | |
| 63 | static double __test(unsigned long); | |
| 64 | static double __test(long long); | |
| 65 | static double __test(unsigned long long); | |
| 66 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 67 | static double __test(__int128_t); | |
| 68 | static double __test(__uint128_t); | |
| 69 | # endif | |
| 70 | static double __test(double); | |
| 71 | static long double __test(long double); | |
| 72 | ||
| 73 | typedef decltype(__test(std::declval<_Tp>())) type; | |
| 74 | static const bool value = _IsNotSame<type, void>::value; | |
| 75 | }; | |
| 76 | ||
| 77 | template <> | |
| 78 | struct __numeric_type<void> { | |
| 79 | static const bool value = true; | |
| 80 | }; | |
| 81 | ||
| 82 | template <class _A1, | |
| 83 | class _A2 = void, | |
| 84 | class _A3 = void, | |
| 85 | bool = __numeric_type<_A1>::value && __numeric_type<_A2>::value && __numeric_type<_A3>::value> | |
| 86 | class __promote_imp { | |
| 87 | public: | |
| 88 | static const bool value = false; | |
| 89 | }; | |
| 90 | ||
| 91 | template <class _A1, class _A2, class _A3> | |
| 92 | class __promote_imp<_A1, _A2, _A3, true> { | |
| 93 | private: | |
| 94 | typedef typename __promote_imp<_A1>::type __type1; | |
| 95 | typedef typename __promote_imp<_A2>::type __type2; | |
| 96 | typedef typename __promote_imp<_A3>::type __type3; | |
| 97 | ||
| 98 | public: | |
| 99 | typedef decltype(__type1() + __type2() + __type3()) type; | |
| 100 | static const bool value = true; | |
| 101 | }; | |
| 102 | ||
| 103 | template <class _A1, class _A2> | |
| 104 | class __promote_imp<_A1, _A2, void, true> { | |
| 105 | private: | |
| 106 | typedef typename __promote_imp<_A1>::type __type1; | |
| 107 | typedef typename __promote_imp<_A2>::type __type2; | |
| 108 | ||
| 109 | public: | |
| 110 | typedef decltype(__type1() + __type2()) type; | |
| 111 | static const bool value = true; | |
| 112 | }; | |
| 113 | ||
| 114 | template <class _A1> | |
| 115 | class __promote_imp<_A1, void, void, true> { | |
| 116 | public: | |
| 117 | typedef typename __numeric_type<_A1>::type type; | |
| 118 | static const bool value = true; | |
| 119 | }; | |
| 120 | ||
| 121 | template <class _A1, class _A2 = void, class _A3 = void> | |
| 122 | class __promote : public __promote_imp<_A1, _A2, _A3> {}; | |
| 123 | ||
| 124 | #endif // !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 1700 | |
| 125 | ||
| 126 | 45 | _LIBCPP_END_NAMESPACE_STD |
| 127 | 46 | |
| 128 | 47 | #endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H |
lib/libcxx/include/__type_traits/rank.h+9-3| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_RANK_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/integral_constant.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
| ... | ... | @@ -28,17 +28,23 @@ struct rank : integral_constant<size_t, __array_rank(_Tp)> {}; |
| 28 | 28 | #else |
| 29 | 29 | |
| 30 | 30 | template <class _Tp> |
| 31 | struct _LIBCPP_TEMPLATE_VIS rank : public integral_constant<size_t, 0> {}; | |
| 31 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS rank : public integral_constant<size_t, 0> {}; | |
| 32 | ||
| 33 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 34 | # if __has_warning("-Winvalid-specialization") | |
| 35 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | |
| 36 | # endif | |
| 32 | 37 | template <class _Tp> |
| 33 | 38 | struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> : public integral_constant<size_t, rank<_Tp>::value + 1> {}; |
| 34 | 39 | template <class _Tp, size_t _Np> |
| 35 | 40 | struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {}; |
| 41 | _LIBCPP_DIAGNOSTIC_POP | |
| 36 | 42 | |
| 37 | 43 | #endif // __has_builtin(__array_rank) |
| 38 | 44 | |
| 39 | 45 | #if _LIBCPP_STD_VER >= 17 |
| 40 | 46 | template <class _Tp> |
| 41 | inline constexpr size_t rank_v = rank<_Tp>::value; | |
| 47 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t rank_v = rank<_Tp>::value; | |
| 42 | 48 | #endif |
| 43 | 49 | |
| 44 | 50 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/remove_all_extents.h+3-3| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 16 | # pragma GCC system_header |
| ... | ... | @@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | #if __has_builtin(__remove_all_extents) |
| 22 | 22 | template <class _Tp> |
| 23 | struct remove_all_extents { | |
| 23 | struct _LIBCPP_NO_SPECIALIZATIONS remove_all_extents { | |
| 24 | 24 | using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp); |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | 27 | template <class _Tp> |
| 28 | using __remove_all_extents_t = __remove_all_extents(_Tp); | |
| 28 | using __remove_all_extents_t _LIBCPP_NODEBUG = __remove_all_extents(_Tp); | |
| 29 | 29 | #else |
| 30 | 30 | template <class _Tp> |
| 31 | 31 | struct _LIBCPP_TEMPLATE_VIS remove_all_extents { |
lib/libcxx/include/__type_traits/remove_const.h+2-2| ... | ... | @@ -19,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | 20 | #if __has_builtin(__remove_const) |
| 21 | 21 | template <class _Tp> |
| 22 | struct remove_const { | |
| 22 | struct _LIBCPP_NO_SPECIALIZATIONS remove_const { | |
| 23 | 23 | using type _LIBCPP_NODEBUG = __remove_const(_Tp); |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | 26 | template <class _Tp> |
| 27 | using __remove_const_t = __remove_const(_Tp); | |
| 27 | using __remove_const_t _LIBCPP_NODEBUG = __remove_const(_Tp); | |
| 28 | 28 | #else |
| 29 | 29 | template <class _Tp> |
| 30 | 30 | struct _LIBCPP_TEMPLATE_VIS remove_const { |
lib/libcxx/include/__type_traits/remove_const_ref.h+1-1| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | 22 | template <class _Tp> |
| 23 | using __remove_const_ref_t = __remove_const_t<__libcpp_remove_reference_t<_Tp> >; | |
| 23 | using __remove_const_ref_t _LIBCPP_NODEBUG = __remove_const_t<__libcpp_remove_reference_t<_Tp> >; | |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_END_NAMESPACE_STD |
| 26 | 26 |
lib/libcxx/include/__type_traits/remove_cv.h+5-12| ... | ... | @@ -10,8 +10,6 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_CV_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__type_traits/remove_const.h> | |
| 14 | #include <__type_traits/remove_volatile.h> | |
| 15 | 13 | |
| 16 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 15 | # pragma GCC system_header |
| ... | ... | @@ -19,23 +17,18 @@ |
| 19 | 17 | |
| 20 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 19 | |
| 22 | #if __has_builtin(__remove_cv) && !defined(_LIBCPP_COMPILER_GCC) | |
| 23 | 20 | template <class _Tp> |
| 24 | struct remove_cv { | |
| 21 | struct _LIBCPP_NO_SPECIALIZATIONS remove_cv { | |
| 25 | 22 | using type _LIBCPP_NODEBUG = __remove_cv(_Tp); |
| 26 | 23 | }; |
| 27 | 24 | |
| 25 | #if defined(_LIBCPP_COMPILER_GCC) | |
| 28 | 26 | template <class _Tp> |
| 29 | using __remove_cv_t = __remove_cv(_Tp); | |
| 27 | using __remove_cv_t _LIBCPP_NODEBUG = typename remove_cv<_Tp>::type; | |
| 30 | 28 | #else |
| 31 | 29 | template <class _Tp> |
| 32 | struct _LIBCPP_TEMPLATE_VIS remove_cv { | |
| 33 | typedef __remove_volatile_t<__remove_const_t<_Tp> > type; | |
| 34 | }; | |
| 35 | ||
| 36 | template <class _Tp> | |
| 37 | using __remove_cv_t = __remove_volatile_t<__remove_const_t<_Tp> >; | |
| 38 | #endif // __has_builtin(__remove_cv) | |
| 30 | using __remove_cv_t _LIBCPP_NODEBUG = __remove_cv(_Tp); | |
| 31 | #endif | |
| 39 | 32 | |
| 40 | 33 | #if _LIBCPP_STD_VER >= 14 |
| 41 | 34 | template <class _Tp> |
lib/libcxx/include/__type_traits/remove_cvref.h+11-8| ... | ... | @@ -11,8 +11,6 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__type_traits/is_same.h> |
| 14 | #include <__type_traits/remove_cv.h> | |
| 15 | #include <__type_traits/remove_reference.h> | |
| 16 | 14 | |
| 17 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 16 | # pragma GCC system_header |
| ... | ... | @@ -20,21 +18,26 @@ |
| 20 | 18 | |
| 21 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 20 | |
| 23 | #if __has_builtin(__remove_cvref) && !defined(_LIBCPP_COMPILER_GCC) | |
| 21 | #if defined(_LIBCPP_COMPILER_GCC) | |
| 24 | 22 | template <class _Tp> |
| 25 | using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp); | |
| 23 | struct __remove_cvref_gcc { | |
| 24 | using type = __remove_cvref(_Tp); | |
| 25 | }; | |
| 26 | ||
| 27 | template <class _Tp> | |
| 28 | using __remove_cvref_t _LIBCPP_NODEBUG = typename __remove_cvref_gcc<_Tp>::type; | |
| 26 | 29 | #else |
| 27 | 30 | template <class _Tp> |
| 28 | using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cv_t<__libcpp_remove_reference_t<_Tp> >; | |
| 31 | using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp); | |
| 29 | 32 | #endif // __has_builtin(__remove_cvref) |
| 30 | 33 | |
| 31 | 34 | template <class _Tp, class _Up> |
| 32 | struct __is_same_uncvref : _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> > {}; | |
| 35 | using __is_same_uncvref _LIBCPP_NODEBUG = _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> >; | |
| 33 | 36 | |
| 34 | 37 | #if _LIBCPP_STD_VER >= 20 |
| 35 | 38 | template <class _Tp> |
| 36 | struct remove_cvref { | |
| 37 | using type _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>; | |
| 39 | struct _LIBCPP_NO_SPECIALIZATIONS remove_cvref { | |
| 40 | using type _LIBCPP_NODEBUG = __remove_cvref(_Tp); | |
| 38 | 41 | }; |
| 39 | 42 | |
| 40 | 43 | template <class _Tp> |
lib/libcxx/include/__type_traits/remove_extent.h+3-3| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 16 | # pragma GCC system_header |
| ... | ... | @@ -20,12 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | #if __has_builtin(__remove_extent) |
| 22 | 22 | template <class _Tp> |
| 23 | struct remove_extent { | |
| 23 | struct _LIBCPP_NO_SPECIALIZATIONS remove_extent { | |
| 24 | 24 | using type _LIBCPP_NODEBUG = __remove_extent(_Tp); |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | 27 | template <class _Tp> |
| 28 | using __remove_extent_t = __remove_extent(_Tp); | |
| 28 | using __remove_extent_t _LIBCPP_NODEBUG = __remove_extent(_Tp); | |
| 29 | 29 | #else |
| 30 | 30 | template <class _Tp> |
| 31 | 31 | struct _LIBCPP_TEMPLATE_VIS remove_extent { |
lib/libcxx/include/__type_traits/remove_pointer.h+8-8| ... | ... | @@ -19,24 +19,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer) |
| 21 | 21 | template <class _Tp> |
| 22 | struct remove_pointer { | |
| 22 | struct _LIBCPP_NO_SPECIALIZATIONS remove_pointer { | |
| 23 | 23 | using type _LIBCPP_NODEBUG = __remove_pointer(_Tp); |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | 26 | # ifdef _LIBCPP_COMPILER_GCC |
| 27 | 27 | template <class _Tp> |
| 28 | using __remove_pointer_t = typename remove_pointer<_Tp>::type; | |
| 28 | using __remove_pointer_t _LIBCPP_NODEBUG = typename remove_pointer<_Tp>::type; | |
| 29 | 29 | # else |
| 30 | 30 | template <class _Tp> |
| 31 | using __remove_pointer_t = __remove_pointer(_Tp); | |
| 31 | using __remove_pointer_t _LIBCPP_NODEBUG = __remove_pointer(_Tp); | |
| 32 | 32 | # endif |
| 33 | 33 | #else |
| 34 | 34 | // clang-format off |
| 35 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 36 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 37 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 38 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 39 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 35 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {using type _LIBCPP_NODEBUG = _Tp;}; | |
| 36 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {using type _LIBCPP_NODEBUG = _Tp;}; | |
| 37 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {using type _LIBCPP_NODEBUG = _Tp;}; | |
| 38 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {using type _LIBCPP_NODEBUG = _Tp;}; | |
| 39 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {using type _LIBCPP_NODEBUG = _Tp;}; | |
| 40 | 40 | // clang-format on |
| 41 | 41 | |
| 42 | 42 | template <class _Tp> |
lib/libcxx/include/__type_traits/remove_reference.h+2-2| ... | ... | @@ -19,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | 20 | #if __has_builtin(__remove_reference_t) |
| 21 | 21 | template <class _Tp> |
| 22 | struct remove_reference { | |
| 22 | struct _LIBCPP_NO_SPECIALIZATIONS remove_reference { | |
| 23 | 23 | using type _LIBCPP_NODEBUG = __remove_reference_t(_Tp); |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | 26 | template <class _Tp> |
| 27 | using __libcpp_remove_reference_t = __remove_reference_t(_Tp); | |
| 27 | using __libcpp_remove_reference_t _LIBCPP_NODEBUG = __remove_reference_t(_Tp); | |
| 28 | 28 | #elif __has_builtin(__remove_reference) |
| 29 | 29 | template <class _Tp> |
| 30 | 30 | struct remove_reference { |
lib/libcxx/include/__type_traits/remove_volatile.h+2-2| ... | ... | @@ -19,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | 20 | #if __has_builtin(__remove_volatile) |
| 21 | 21 | template <class _Tp> |
| 22 | struct remove_volatile { | |
| 22 | struct _LIBCPP_NO_SPECIALIZATIONS remove_volatile { | |
| 23 | 23 | using type _LIBCPP_NODEBUG = __remove_volatile(_Tp); |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | 26 | template <class _Tp> |
| 27 | using __remove_volatile_t = __remove_volatile(_Tp); | |
| 27 | using __remove_volatile_t _LIBCPP_NODEBUG = __remove_volatile(_Tp); | |
| 28 | 28 | #else |
| 29 | 29 | template <class _Tp> |
| 30 | 30 | struct _LIBCPP_TEMPLATE_VIS remove_volatile { |
lib/libcxx/include/__type_traits/result_of.h+8-3| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_RESULT_OF_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__functional/invoke.h> | |
| 13 | #include <__type_traits/invoke.h> | |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 16 | # pragma GCC system_header |
| ... | ... | @@ -22,10 +22,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) |
| 24 | 24 | template <class _Callable> |
| 25 | class _LIBCPP_DEPRECATED_IN_CXX17 result_of; | |
| 25 | struct _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS result_of; | |
| 26 | 26 | |
| 27 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 28 | #if __has_warning("-Winvalid-specialization") | |
| 29 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | |
| 30 | #endif | |
| 27 | 31 | template <class _Fp, class... _Args> |
| 28 | class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : public __invoke_of<_Fp, _Args...> {}; | |
| 32 | struct _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : __invoke_result<_Fp, _Args...> {}; | |
| 33 | _LIBCPP_DIAGNOSTIC_POP | |
| 29 | 34 | |
| 30 | 35 | # if _LIBCPP_STD_VER >= 14 |
| 31 | 36 | template <class _Tp> |
lib/libcxx/include/__type_traits/type_identity.h+1-1| ... | ... | @@ -27,7 +27,7 @@ using __type_identity_t _LIBCPP_NODEBUG = typename __type_identity<_Tp>::type; |
| 27 | 27 | |
| 28 | 28 | #if _LIBCPP_STD_VER >= 20 |
| 29 | 29 | template <class _Tp> |
| 30 | struct type_identity { | |
| 30 | struct _LIBCPP_NO_SPECIALIZATIONS type_identity { | |
| 31 | 31 | typedef _Tp type; |
| 32 | 32 | }; |
| 33 | 33 | template <class _Tp> |
lib/libcxx/include/__type_traits/type_list.h+17-12| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 16 | # pragma GCC system_header |
| ... | ... | @@ -18,23 +18,28 @@ |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | template <class _Hp, class _Tp> | |
| 22 | struct __type_list { | |
| 23 | typedef _Hp _Head; | |
| 24 | typedef _Tp _Tail; | |
| 21 | template <class... _Types> | |
| 22 | struct __type_list {}; | |
| 23 | ||
| 24 | template <class> | |
| 25 | struct __type_list_head; | |
| 26 | ||
| 27 | template <class _Head, class... _Tail> | |
| 28 | struct __type_list_head<__type_list<_Head, _Tail...> > { | |
| 29 | using type _LIBCPP_NODEBUG = _Head; | |
| 25 | 30 | }; |
| 26 | 31 | |
| 27 | template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> | |
| 32 | template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename __type_list_head<_TypeList>::type)> | |
| 28 | 33 | struct __find_first; |
| 29 | 34 | |
| 30 | template <class _Hp, class _Tp, size_t _Size> | |
| 31 | struct __find_first<__type_list<_Hp, _Tp>, _Size, true> { | |
| 32 | typedef _LIBCPP_NODEBUG _Hp type; | |
| 35 | template <class _Head, class... _Tail, size_t _Size> | |
| 36 | struct __find_first<__type_list<_Head, _Tail...>, _Size, true> { | |
| 37 | using type _LIBCPP_NODEBUG = _Head; | |
| 33 | 38 | }; |
| 34 | 39 | |
| 35 | template <class _Hp, class _Tp, size_t _Size> | |
| 36 | struct __find_first<__type_list<_Hp, _Tp>, _Size, false> { | |
| 37 | typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type; | |
| 40 | template <class _Head, class... _Tail, size_t _Size> | |
| 41 | struct __find_first<__type_list<_Head, _Tail...>, _Size, false> { | |
| 42 | using type _LIBCPP_NODEBUG = typename __find_first<__type_list<_Tail...>, _Size>::type; | |
| 38 | 43 | }; |
| 39 | 44 | |
| 40 | 45 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__type_traits/underlying_type.h+1-1| ... | ... | @@ -30,7 +30,7 @@ struct __underlying_type_impl<_Tp, true> { |
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | 32 | template <class _Tp> |
| 33 | struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {}; | |
| 33 | struct _LIBCPP_NO_SPECIALIZATIONS underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {}; | |
| 34 | 34 | |
| 35 | 35 | #if _LIBCPP_STD_VER >= 14 |
| 36 | 36 | template <class _Tp> |
lib/libcxx/include/__type_traits/unwrap_ref.h+8-15| ... | ... | @@ -21,38 +21,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | 22 | template <class _Tp> |
| 23 | 23 | struct __unwrap_reference { |
| 24 | typedef _LIBCPP_NODEBUG _Tp type; | |
| 24 | using type _LIBCPP_NODEBUG = _Tp; | |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | 27 | template <class _Tp> |
| 28 | 28 | struct __unwrap_reference<reference_wrapper<_Tp> > { |
| 29 | typedef _LIBCPP_NODEBUG _Tp& type; | |
| 29 | using type _LIBCPP_NODEBUG = _Tp&; | |
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | template <class _Tp> | |
| 33 | using __unwrap_ref_decay_t _LIBCPP_NODEBUG = typename __unwrap_reference<__decay_t<_Tp> >::type; | |
| 34 | ||
| 32 | 35 | #if _LIBCPP_STD_VER >= 20 |
| 33 | 36 | template <class _Tp> |
| 34 | struct unwrap_reference : __unwrap_reference<_Tp> {}; | |
| 37 | struct _LIBCPP_NO_SPECIALIZATIONS unwrap_reference : __unwrap_reference<_Tp> {}; | |
| 35 | 38 | |
| 36 | 39 | template <class _Tp> |
| 37 | 40 | using unwrap_reference_t = typename unwrap_reference<_Tp>::type; |
| 38 | 41 | |
| 39 | 42 | template <class _Tp> |
| 40 | struct unwrap_ref_decay : unwrap_reference<__decay_t<_Tp> > {}; | |
| 43 | struct _LIBCPP_NO_SPECIALIZATIONS unwrap_ref_decay : unwrap_reference<__decay_t<_Tp> > {}; | |
| 41 | 44 | |
| 42 | 45 | template <class _Tp> |
| 43 | using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; | |
| 46 | using unwrap_ref_decay_t = __unwrap_ref_decay_t<_Tp>; | |
| 44 | 47 | #endif // _LIBCPP_STD_VER >= 20 |
| 45 | 48 | |
| 46 | template <class _Tp> | |
| 47 | struct __unwrap_ref_decay | |
| 48 | #if _LIBCPP_STD_VER >= 20 | |
| 49 | : unwrap_ref_decay<_Tp> | |
| 50 | #else | |
| 51 | : __unwrap_reference<__decay_t<_Tp> > | |
| 52 | #endif | |
| 53 | { | |
| 54 | }; | |
| 55 | ||
| 56 | 49 | _LIBCPP_END_NAMESPACE_STD |
| 57 | 50 | |
| 58 | 51 | #endif // _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H |
lib/libcxx/include/__type_traits/void_t.h+1-1| ... | ... | @@ -23,7 +23,7 @@ using void_t = void; |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | template <class...> |
| 26 | using __void_t = void; | |
| 26 | using __void_t _LIBCPP_NODEBUG = void; | |
| 27 | 27 | |
| 28 | 28 | _LIBCPP_END_NAMESPACE_STD |
| 29 | 29 |
lib/libcxx/include/__utility/as_const.h+1-4| ... | ... | @@ -10,9 +10,6 @@ |
| 10 | 10 | #define _LIBCPP___UTILITY_AS_CONST_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | #include <__utility/forward.h> | |
| 15 | #include <__utility/move.h> | |
| 16 | 13 | |
| 17 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 15 | # pragma GCC system_header |
| ... | ... | @@ -22,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | #if _LIBCPP_STD_VER >= 17 |
| 24 | 21 | template <class _Tp> |
| 25 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { | |
| 22 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& as_const(_Tp& __t) noexcept { | |
| 26 | 23 | return __t; |
| 27 | 24 | } |
| 28 | 25 |
lib/libcxx/include/__utility/convert_to_integral.h+1-1| ... | ... | @@ -42,7 +42,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long long __convert_to_integral(_ |
| 42 | 42 | return __val; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 45 | #if _LIBCPP_HAS_INT128 | |
| 46 | 46 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __int128_t __convert_to_integral(__int128_t __val) { return __val; } |
| 47 | 47 | |
| 48 | 48 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __uint128_t __convert_to_integral(__uint128_t __val) { return __val; } |
lib/libcxx/include/__utility/element_count.h created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_ELEMENT_COUNT_H | |
| 10 | #define _LIBCPP___UTILITY_ELEMENT_COUNT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | // Type used to encode that a function takes an integer that represents a number | |
| 22 | // of elements as opposed to a number of bytes. | |
| 23 | enum class __element_count : size_t {}; | |
| 24 | ||
| 25 | _LIBCPP_END_NAMESPACE_STD | |
| 26 | ||
| 27 | #endif // _LIBCPP___UTILITY_ELEMENT_COUNT_H |
lib/libcxx/include/__utility/exception_guard.h+9-9| ... | ... | @@ -44,7 +44,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 44 | 44 | // less common, especially one that tries to catch an exception through -fno-exceptions code. |
| 45 | 45 | // |
| 46 | 46 | // __exception_guard can help greatly simplify code that would normally be cluttered by |
| 47 | // `#if _LIBCPP_HAS_NO_EXCEPTIONS`. For example: | |
| 47 | // `#if _LIBCPP_HAS_EXCEPTIONS`. For example: | |
| 48 | 48 | // |
| 49 | 49 | // template <class Iterator, class Size, class OutputIterator> |
| 50 | 50 | // Iterator uninitialized_copy_n(Iterator iter, Size n, OutputIterator out) { |
| ... | ... | @@ -96,10 +96,10 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_exceptions); |
| 96 | 96 | template <class _Rollback> |
| 97 | 97 | struct __exception_guard_noexceptions { |
| 98 | 98 | __exception_guard_noexceptions() = delete; |
| 99 | _LIBCPP_HIDE_FROM_ABI | |
| 100 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG explicit __exception_guard_noexceptions(_Rollback) {} | |
| 99 | _LIBCPP_NODEBUG _LIBCPP_HIDE_FROM_ABI | |
| 100 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __exception_guard_noexceptions(_Rollback) {} | |
| 101 | 101 | |
| 102 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG | |
| 102 | _LIBCPP_NODEBUG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 103 | 103 | __exception_guard_noexceptions(__exception_guard_noexceptions&& __other) |
| 104 | 104 | _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value) |
| 105 | 105 | : __completed_(__other.__completed_) { |
| ... | ... | @@ -110,11 +110,11 @@ struct __exception_guard_noexceptions { |
| 110 | 110 | __exception_guard_noexceptions& operator=(__exception_guard_noexceptions const&) = delete; |
| 111 | 111 | __exception_guard_noexceptions& operator=(__exception_guard_noexceptions&&) = delete; |
| 112 | 112 | |
| 113 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG void __complete() _NOEXCEPT { | |
| 113 | _LIBCPP_NODEBUG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __complete() _NOEXCEPT { | |
| 114 | 114 | __completed_ = true; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG ~__exception_guard_noexceptions() { | |
| 117 | _LIBCPP_NODEBUG _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__exception_guard_noexceptions() { | |
| 118 | 118 | _LIBCPP_ASSERT_INTERNAL(__completed_, "__exception_guard not completed with exceptions disabled"); |
| 119 | 119 | } |
| 120 | 120 | |
| ... | ... | @@ -124,12 +124,12 @@ private: |
| 124 | 124 | |
| 125 | 125 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_noexceptions); |
| 126 | 126 | |
| 127 | #ifdef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 127 | #if !_LIBCPP_HAS_EXCEPTIONS | |
| 128 | 128 | template <class _Rollback> |
| 129 | using __exception_guard = __exception_guard_noexceptions<_Rollback>; | |
| 129 | using __exception_guard _LIBCPP_NODEBUG = __exception_guard_noexceptions<_Rollback>; | |
| 130 | 130 | #else |
| 131 | 131 | template <class _Rollback> |
| 132 | using __exception_guard = __exception_guard_exceptions<_Rollback>; | |
| 132 | using __exception_guard _LIBCPP_NODEBUG = __exception_guard_exceptions<_Rollback>; | |
| 133 | 133 | #endif |
| 134 | 134 | |
| 135 | 135 | template <class _Rollback> |
lib/libcxx/include/__utility/forward.h+2-2| ... | ... | @@ -21,13 +21,13 @@ |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class _Tp> |
| 24 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& | |
| 24 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& | |
| 25 | 25 | forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>& __t) _NOEXCEPT { |
| 26 | 26 | return static_cast<_Tp&&>(__t); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | template <class _Tp> |
| 30 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& | |
| 30 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& | |
| 31 | 31 | forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>&& __t) _NOEXCEPT { |
| 32 | 32 | static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue"); |
| 33 | 33 | return static_cast<_Tp&&>(__t); |
lib/libcxx/include/__utility/forward_like.h+20-3| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__type_traits/conditional.h> |
| 15 | #include <__type_traits/is_base_of.h> | |
| 15 | 16 | #include <__type_traits/is_const.h> |
| 16 | 17 | #include <__type_traits/is_reference.h> |
| 17 | 18 | #include <__type_traits/remove_reference.h> |
| ... | ... | @@ -25,13 +26,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 26 | #if _LIBCPP_STD_VER >= 23 |
| 26 | 27 | |
| 27 | 28 | template <class _Ap, class _Bp> |
| 28 | using _CopyConst = _If<is_const_v<_Ap>, const _Bp, _Bp>; | |
| 29 | using _CopyConst _LIBCPP_NODEBUG = _If<is_const_v<_Ap>, const _Bp, _Bp>; | |
| 29 | 30 | |
| 30 | 31 | template <class _Ap, class _Bp> |
| 31 | using _OverrideRef = _If<is_rvalue_reference_v<_Ap>, remove_reference_t<_Bp>&&, _Bp&>; | |
| 32 | using _OverrideRef _LIBCPP_NODEBUG = _If<is_rvalue_reference_v<_Ap>, remove_reference_t<_Bp>&&, _Bp&>; | |
| 32 | 33 | |
| 33 | 34 | template <class _Ap, class _Bp> |
| 34 | using _ForwardLike = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>; | |
| 35 | using _ForwardLike _LIBCPP_NODEBUG = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>; | |
| 35 | 36 | |
| 36 | 37 | template <class _Tp, class _Up> |
| 37 | 38 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto |
| ... | ... | @@ -39,6 +40,22 @@ forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up |
| 39 | 40 | return static_cast<_ForwardLike<_Tp, _Up>>(__ux); |
| 40 | 41 | } |
| 41 | 42 | |
| 43 | // This function is used for `deducing this` cases where you want to make sure the operation is performed on the class | |
| 44 | // itself and not on a derived class. For example | |
| 45 | // struct S { | |
| 46 | // template <class Self> | |
| 47 | // void func(Self&& self) { | |
| 48 | // // This will always call `do_something` of S instead of any class derived from S. | |
| 49 | // std::__forward_as<Self, S>(self).do_something(); | |
| 50 | // } | |
| 51 | // }; | |
| 52 | template <class _Tp, class _As, class _Up> | |
| 53 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _ForwardLike<_Tp, _As> | |
| 54 | __forward_as(_LIBCPP_LIFETIMEBOUND _Up&& __val) noexcept { | |
| 55 | static_assert(is_base_of_v<_As, remove_reference_t<_Up>>); | |
| 56 | return static_cast<_ForwardLike<_Tp, _As>>(__val); | |
| 57 | } | |
| 58 | ||
| 42 | 59 | #endif // _LIBCPP_STD_VER >= 23 |
| 43 | 60 | |
| 44 | 61 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__utility/in_place.h+4-3| ... | ... | @@ -10,8 +10,9 @@ |
| 10 | 10 | #define _LIBCPP___UTILITY_IN_PLACE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 13 | 15 | #include <__type_traits/remove_cvref.h> |
| 14 | #include <cstddef> | |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 18 | # pragma GCC system_header |
| ... | ... | @@ -46,7 +47,7 @@ template <class _Tp> |
| 46 | 47 | struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {}; |
| 47 | 48 | |
| 48 | 49 | template <class _Tp> |
| 49 | using __is_inplace_type = __is_inplace_type_imp<__remove_cvref_t<_Tp>>; | |
| 50 | using __is_inplace_type _LIBCPP_NODEBUG = __is_inplace_type_imp<__remove_cvref_t<_Tp>>; | |
| 50 | 51 | |
| 51 | 52 | template <class _Tp> |
| 52 | 53 | struct __is_inplace_index_imp : false_type {}; |
| ... | ... | @@ -54,7 +55,7 @@ template <size_t _Idx> |
| 54 | 55 | struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {}; |
| 55 | 56 | |
| 56 | 57 | template <class _Tp> |
| 57 | using __is_inplace_index = __is_inplace_index_imp<__remove_cvref_t<_Tp>>; | |
| 58 | using __is_inplace_index _LIBCPP_NODEBUG = __is_inplace_index_imp<__remove_cvref_t<_Tp>>; | |
| 58 | 59 | |
| 59 | 60 | #endif // _LIBCPP_STD_VER >= 17 |
| 60 | 61 |
lib/libcxx/include/__utility/integer_sequence.h+5-5| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___UTILITY_INTEGER_SEQUENCE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 13 | 14 | #include <__type_traits/is_integral.h> |
| 14 | #include <cstddef> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | # pragma GCC system_header |
| ... | ... | @@ -25,19 +25,19 @@ struct __tuple_indices; |
| 25 | 25 | template <class _IdxType, _IdxType... _Values> |
| 26 | 26 | struct __integer_sequence { |
| 27 | 27 | template <template <class _OIdxType, _OIdxType...> class _ToIndexSeq, class _ToIndexType> |
| 28 | using __convert = _ToIndexSeq<_ToIndexType, _Values...>; | |
| 28 | using __convert _LIBCPP_NODEBUG = _ToIndexSeq<_ToIndexType, _Values...>; | |
| 29 | 29 | |
| 30 | 30 | template <size_t _Sp> |
| 31 | using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>; | |
| 31 | using __to_tuple_indices _LIBCPP_NODEBUG = __tuple_indices<(_Values + _Sp)...>; | |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | 34 | #if __has_builtin(__make_integer_seq) |
| 35 | 35 | template <size_t _Ep, size_t _Sp> |
| 36 | using __make_indices_imp = | |
| 36 | using __make_indices_imp _LIBCPP_NODEBUG = | |
| 37 | 37 | typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template __to_tuple_indices<_Sp>; |
| 38 | 38 | #elif __has_builtin(__integer_pack) |
| 39 | 39 | template <size_t _Ep, size_t _Sp> |
| 40 | using __make_indices_imp = | |
| 40 | using __make_indices_imp _LIBCPP_NODEBUG = | |
| 41 | 41 | typename __integer_sequence<size_t, __integer_pack(_Ep - _Sp)...>::template __to_tuple_indices<_Sp>; |
| 42 | 42 | #else |
| 43 | 43 | # error "No known way to get an integer pack from the compiler" |
lib/libcxx/include/__utility/is_pointer_in_range.h+8| ... | ... | @@ -57,6 +57,14 @@ __is_pointer_in_range(const _Tp* __begin, const _Tp* __end, const _Up* __ptr) { |
| 57 | 57 | reinterpret_cast<const char*>(__ptr) < reinterpret_cast<const char*>(__end); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | template <class _Tp, class _Up> | |
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool | |
| 62 | __is_overlapping_range(const _Tp* __begin, const _Tp* __end, const _Up* __begin2) { | |
| 63 | auto __size = __end - __begin; | |
| 64 | auto __end2 = __begin2 + __size; | |
| 65 | return std::__is_pointer_in_range(__begin, __end, __begin2) || std::__is_pointer_in_range(__begin2, __end2, __begin); | |
| 66 | } | |
| 67 | ||
| 60 | 68 | _LIBCPP_END_NAMESPACE_STD |
| 61 | 69 | |
| 62 | 70 | #endif // _LIBCPP___UTILITY_IS_POINTER_IN_RANGE_H |
lib/libcxx/include/__utility/move.h+4-4| ... | ... | @@ -26,18 +26,18 @@ _LIBCPP_PUSH_MACROS |
| 26 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | |
| 28 | 28 | template <class _Tp> |
| 29 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&& | |
| 29 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&& | |
| 30 | 30 | move(_LIBCPP_LIFETIMEBOUND _Tp&& __t) _NOEXCEPT { |
| 31 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up; | |
| 31 | using _Up _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>; | |
| 32 | 32 | return static_cast<_Up&&>(__t); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | template <class _Tp> |
| 36 | using __move_if_noexcept_result_t = | |
| 36 | using __move_if_noexcept_result_t _LIBCPP_NODEBUG = | |
| 37 | 37 | __conditional_t<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, _Tp&&>; |
| 38 | 38 | |
| 39 | 39 | template <class _Tp> |
| 40 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp> | |
| 40 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp> | |
| 41 | 41 | move_if_noexcept(_LIBCPP_LIFETIMEBOUND _Tp& __x) _NOEXCEPT { |
| 42 | 42 | return std::move(__x); |
| 43 | 43 | } |
lib/libcxx/include/__utility/no_destroy.h+1-1| ... | ... | @@ -10,9 +10,9 @@ |
| 10 | 10 | #define _LIBCPP___UTILITY_NO_DESTROY_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__new/placement_new_delete.h> | |
| 13 | 14 | #include <__type_traits/is_constant_evaluated.h> |
| 14 | 15 | #include <__utility/forward.h> |
| 15 | #include <new> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | # pragma GCC system_header |
lib/libcxx/include/__utility/pair.h+11-51| ... | ... | @@ -13,11 +13,10 @@ |
| 13 | 13 | #include <__compare/synth_three_way.h> |
| 14 | 14 | #include <__concepts/different_from.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__cstddef/size_t.h> | |
| 16 | 17 | #include <__fwd/array.h> |
| 17 | 18 | #include <__fwd/pair.h> |
| 18 | 19 | #include <__fwd/tuple.h> |
| 19 | #include <__tuple/sfinae_helpers.h> | |
| 20 | #include <__tuple/tuple_element.h> | |
| 21 | 20 | #include <__tuple/tuple_indices.h> |
| 22 | 21 | #include <__tuple/tuple_like_no_subrange.h> |
| 23 | 22 | #include <__tuple/tuple_size.h> |
| ... | ... | @@ -25,6 +24,7 @@ |
| 25 | 24 | #include <__type_traits/common_type.h> |
| 26 | 25 | #include <__type_traits/conditional.h> |
| 27 | 26 | #include <__type_traits/decay.h> |
| 27 | #include <__type_traits/enable_if.h> | |
| 28 | 28 | #include <__type_traits/integral_constant.h> |
| 29 | 29 | #include <__type_traits/is_assignable.h> |
| 30 | 30 | #include <__type_traits/is_constructible.h> |
| ... | ... | @@ -32,7 +32,6 @@ |
| 32 | 32 | #include <__type_traits/is_implicitly_default_constructible.h> |
| 33 | 33 | #include <__type_traits/is_nothrow_assignable.h> |
| 34 | 34 | #include <__type_traits/is_nothrow_constructible.h> |
| 35 | #include <__type_traits/is_reference.h> | |
| 36 | 35 | #include <__type_traits/is_same.h> |
| 37 | 36 | #include <__type_traits/is_swappable.h> |
| 38 | 37 | #include <__type_traits/is_trivially_relocatable.h> |
| ... | ... | @@ -43,7 +42,6 @@ |
| 43 | 42 | #include <__utility/forward.h> |
| 44 | 43 | #include <__utility/move.h> |
| 45 | 44 | #include <__utility/piecewise_construct.h> |
| 46 | #include <cstddef> | |
| 47 | 45 | |
| 48 | 46 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 49 | 47 | # pragma GCC system_header |
| ... | ... | @@ -73,7 +71,7 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 73 | 71 | _T1 first; |
| 74 | 72 | _T2 second; |
| 75 | 73 | |
| 76 | using __trivially_relocatable = | |
| 74 | using __trivially_relocatable _LIBCPP_NODEBUG = | |
| 77 | 75 | __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value, |
| 78 | 76 | pair, |
| 79 | 77 | void>; |
| ... | ... | @@ -81,38 +79,6 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 81 | 79 | _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default; |
| 82 | 80 | _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default; |
| 83 | 81 | |
| 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 | ||
| 116 | 82 | #ifdef _LIBCPP_CXX03_LANG |
| 117 | 83 | _LIBCPP_HIDE_FROM_ABI pair() : first(), second() {} |
| 118 | 84 | |
| ... | ... | @@ -164,8 +130,7 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 164 | 130 | }; |
| 165 | 131 | |
| 166 | 132 | template <bool _MaybeEnable> |
| 167 | using _CheckArgsDep _LIBCPP_NODEBUG = | |
| 168 | typename conditional< _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type; | |
| 133 | using _CheckArgsDep _LIBCPP_NODEBUG = __conditional_t<_MaybeEnable, _CheckArgs, void>; | |
| 169 | 134 | |
| 170 | 135 | template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_default(), int> = 0> |
| 171 | 136 | explicit(!_CheckArgsDep<_Dummy>::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept( |
| ... | ... | @@ -258,8 +223,7 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 258 | 223 | typename __make_tuple_indices<sizeof...(_Args2) >::type()) {} |
| 259 | 224 | |
| 260 | 225 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& |
| 261 | operator=(__conditional_t<!__has_defaulted_members::value && is_copy_assignable<first_type>::value && | |
| 262 | is_copy_assignable<second_type>::value, | |
| 226 | operator=(__conditional_t<is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value, | |
| 263 | 227 | pair, |
| 264 | 228 | __nat> const& __p) noexcept(is_nothrow_copy_assignable<first_type>::value && |
| 265 | 229 | is_nothrow_copy_assignable<second_type>::value) { |
| ... | ... | @@ -268,12 +232,10 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 268 | 232 | return *this; |
| 269 | 233 | } |
| 270 | 234 | |
| 271 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& | |
| 272 | operator=(__conditional_t<!__has_defaulted_members::value && is_move_assignable<first_type>::value && | |
| 273 | is_move_assignable<second_type>::value, | |
| 274 | pair, | |
| 275 | __nat>&& __p) noexcept(is_nothrow_move_assignable<first_type>::value && | |
| 276 | is_nothrow_move_assignable<second_type>::value) { | |
| 235 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=( | |
| 236 | __conditional_t<is_move_assignable<first_type>::value && is_move_assignable<second_type>::value, pair, __nat>&& | |
| 237 | __p) noexcept(is_nothrow_move_assignable<first_type>::value && | |
| 238 | is_nothrow_move_assignable<second_type>::value) { | |
| 277 | 239 | first = std::forward<first_type>(__p.first); |
| 278 | 240 | second = std::forward<second_type>(__p.second); |
| 279 | 241 | return *this; |
| ... | ... | @@ -570,11 +532,9 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x |
| 570 | 532 | #endif |
| 571 | 533 | |
| 572 | 534 | template <class _T1, class _T2> |
| 573 | inline _LIBCPP_HIDE_FROM_ABI | |
| 574 | _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type> | |
| 535 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> > | |
| 575 | 536 | make_pair(_T1&& __t1, _T2&& __t2) { |
| 576 | return pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>( | |
| 577 | std::forward<_T1>(__t1), std::forward<_T2>(__t2)); | |
| 537 | return pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >(std::forward<_T1>(__t1), std::forward<_T2>(__t2)); | |
| 578 | 538 | } |
| 579 | 539 | |
| 580 | 540 | template <class _T1, class _T2> |
lib/libcxx/include/__utility/priority_tag.h+1-1| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___UTILITY_PRIORITY_TAG_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <cstddef> | |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 16 | # pragma GCC system_header |
lib/libcxx/include/__utility/scope_guard.h created+56| ... | ... | @@ -0,0 +1,56 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___UTILITY_SCOPE_GUARD_H | |
| 11 | #define _LIBCPP___UTILITY_SCOPE_GUARD_H | |
| 12 | ||
| 13 | #include <__assert> | |
| 14 | #include <__config> | |
| 15 | #include <__utility/move.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | template <class _Func> | |
| 27 | class __scope_guard { | |
| 28 | _Func __func_; | |
| 29 | ||
| 30 | public: | |
| 31 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __scope_guard(_Func __func) : __func_(std::move(__func)) {} | |
| 32 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__scope_guard() { __func_(); } | |
| 33 | ||
| 34 | __scope_guard(const __scope_guard&) = delete; | |
| 35 | __scope_guard& operator=(const __scope_guard&) = delete; | |
| 36 | __scope_guard& operator=(__scope_guard&&) = delete; | |
| 37 | ||
| 38 | // C++14 doesn't have mandatory RVO, so we have to provide a declaration even though no compiler will ever generate | |
| 39 | // a call to the move constructor. | |
| 40 | #if _LIBCPP_STD_VER <= 14 | |
| 41 | __scope_guard(__scope_guard&&); | |
| 42 | #else | |
| 43 | __scope_guard(__scope_guard&&) = delete; | |
| 44 | #endif | |
| 45 | }; | |
| 46 | ||
| 47 | template <class _Func> | |
| 48 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __scope_guard<_Func> __make_scope_guard(_Func __func) { | |
| 49 | return __scope_guard<_Func>(std::move(__func)); | |
| 50 | } | |
| 51 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 53 | ||
| 54 | _LIBCPP_POP_MACROS | |
| 55 | ||
| 56 | #endif // _LIBCPP___UTILITY_SCOPE_GUARD_H |
lib/libcxx/include/__utility/small_buffer.h+6-4| ... | ... | @@ -10,14 +10,16 @@ |
| 10 | 10 | #define _LIBCPP___UTILITY_SMALL_BUFFER_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/byte.h> | |
| 14 | #include <__cstddef/size_t.h> | |
| 13 | 15 | #include <__memory/construct_at.h> |
| 16 | #include <__new/allocate.h> | |
| 17 | #include <__new/launder.h> | |
| 14 | 18 | #include <__type_traits/decay.h> |
| 15 | 19 | #include <__type_traits/is_trivially_constructible.h> |
| 16 | 20 | #include <__type_traits/is_trivially_destructible.h> |
| 17 | 21 | #include <__utility/exception_guard.h> |
| 18 | 22 | #include <__utility/forward.h> |
| 19 | #include <cstddef> | |
| 20 | #include <new> | |
| 21 | 23 | |
| 22 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | 25 | # pragma GCC system_header |
| ... | ... | @@ -66,7 +68,7 @@ public: |
| 66 | 68 | if constexpr (__fits_in_buffer<_Stored>) { |
| 67 | 69 | return std::launder(reinterpret_cast<_Stored*>(__buffer_)); |
| 68 | 70 | } else { |
| 69 | byte* __allocation = static_cast<byte*>(::operator new[](sizeof(_Stored), align_val_t{alignof(_Stored)})); | |
| 71 | byte* __allocation = reinterpret_cast<byte*>(std::__libcpp_allocate<_Stored>(__element_count(1))); | |
| 70 | 72 | std::construct_at(reinterpret_cast<byte**>(__buffer_), __allocation); |
| 71 | 73 | return std::launder(reinterpret_cast<_Stored*>(__allocation)); |
| 72 | 74 | } |
| ... | ... | @@ -75,7 +77,7 @@ public: |
| 75 | 77 | template <class _Stored> |
| 76 | 78 | _LIBCPP_HIDE_FROM_ABI void __dealloc() noexcept { |
| 77 | 79 | if constexpr (!__fits_in_buffer<_Stored>) |
| 78 | ::operator delete[](*reinterpret_cast<void**>(__buffer_), sizeof(_Stored), align_val_t{alignof(_Stored)}); | |
| 80 | std::__libcpp_deallocate<_Stored>(__get<_Stored>(), __element_count(1)); | |
| 79 | 81 | } |
| 80 | 82 | |
| 81 | 83 | template <class _Stored, class... _Args> |
lib/libcxx/include/__utility/swap.h+5-3| ... | ... | @@ -10,6 +10,8 @@ |
| 10 | 10 | #define _LIBCPP___UTILITY_SWAP_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__cstddef/size_t.h> | |
| 14 | #include <__type_traits/enable_if.h> | |
| 13 | 15 | #include <__type_traits/is_assignable.h> |
| 14 | 16 | #include <__type_traits/is_constructible.h> |
| 15 | 17 | #include <__type_traits/is_nothrow_assignable.h> |
| ... | ... | @@ -17,7 +19,6 @@ |
| 17 | 19 | #include <__type_traits/is_swappable.h> |
| 18 | 20 | #include <__utility/declval.h> |
| 19 | 21 | #include <__utility/move.h> |
| 20 | #include <cstddef> | |
| 21 | 22 | |
| 22 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | 24 | # pragma GCC system_header |
| ... | ... | @@ -30,10 +31,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 31 | |
| 31 | 32 | #ifndef _LIBCPP_CXX03_LANG |
| 32 | 33 | template <class _Tp> |
| 33 | using __swap_result_t = __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>; | |
| 34 | using __swap_result_t _LIBCPP_NODEBUG = | |
| 35 | __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>; | |
| 34 | 36 | #else |
| 35 | 37 | template <class> |
| 36 | using __swap_result_t = void; | |
| 38 | using __swap_result_t _LIBCPP_NODEBUG = void; | |
| 37 | 39 | #endif |
| 38 | 40 | |
| 39 | 41 | template <class _Tp> |
lib/libcxx/include/__utility/unreachable.h+1-1| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() { | |
| 21 | [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() { | |
| 22 | 22 | _LIBCPP_ASSERT_INTERNAL(false, "std::unreachable() was reached"); |
| 23 | 23 | __builtin_unreachable(); |
| 24 | 24 | } |
lib/libcxx/include/__variant/monostate.h+1-1| ... | ... | @@ -12,8 +12,8 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__compare/ordering.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__cstddef/size_t.h> | |
| 15 | 16 | #include <__functional/hash.h> |
| 16 | #include <cstddef> | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | # pragma GCC system_header |
lib/libcxx/include/__vector/comparison.h created+71| ... | ... | @@ -0,0 +1,71 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___VECTOR_COMPARISON_H | |
| 10 | #define _LIBCPP___VECTOR_COMPARISON_H | |
| 11 | ||
| 12 | #include <__algorithm/equal.h> | |
| 13 | #include <__algorithm/lexicographical_compare.h> | |
| 14 | #include <__algorithm/lexicographical_compare_three_way.h> | |
| 15 | #include <__compare/synth_three_way.h> | |
| 16 | #include <__config> | |
| 17 | #include <__fwd/vector.h> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | template <class _Tp, class _Allocator> | |
| 26 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI bool | |
| 27 | operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 28 | const typename vector<_Tp, _Allocator>::size_type __sz = __x.size(); | |
| 29 | return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); | |
| 30 | } | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER <= 17 | |
| 33 | ||
| 34 | template <class _Tp, class _Allocator> | |
| 35 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 36 | return !(__x == __y); | |
| 37 | } | |
| 38 | ||
| 39 | template <class _Tp, class _Allocator> | |
| 40 | inline _LIBCPP_HIDE_FROM_ABI bool operator<(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 41 | return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); | |
| 42 | } | |
| 43 | ||
| 44 | template <class _Tp, class _Allocator> | |
| 45 | inline _LIBCPP_HIDE_FROM_ABI bool operator>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 46 | return __y < __x; | |
| 47 | } | |
| 48 | ||
| 49 | template <class _Tp, class _Allocator> | |
| 50 | inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 51 | return !(__x < __y); | |
| 52 | } | |
| 53 | ||
| 54 | template <class _Tp, class _Allocator> | |
| 55 | inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 56 | return !(__y < __x); | |
| 57 | } | |
| 58 | ||
| 59 | #else // _LIBCPP_STD_VER <= 17 | |
| 60 | ||
| 61 | template <class _Tp, class _Allocator> | |
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> | |
| 63 | operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 64 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | |
| 65 | } | |
| 66 | ||
| 67 | #endif // _LIBCPP_STD_VER <= 17 | |
| 68 | ||
| 69 | _LIBCPP_END_NAMESPACE_STD | |
| 70 | ||
| 71 | #endif // _LIBCPP___VECTOR_COMPARISON_H |
lib/libcxx/include/__vector/container_traits.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___VECTOR_CONTAINER_TRAITS_H | |
| 10 | #define _LIBCPP___VECTOR_CONTAINER_TRAITS_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__fwd/vector.h> | |
| 14 | #include <__memory/allocator_traits.h> | |
| 15 | #include <__type_traits/container_traits.h> | |
| 16 | #include <__type_traits/disjunction.h> | |
| 17 | #include <__type_traits/is_nothrow_constructible.h> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | template <class _Tp, class _Allocator> | |
| 26 | struct __container_traits<vector<_Tp, _Allocator> > { | |
| 27 | // http://eel.is/c++draft/vector.modifiers#2 | |
| 28 | // If an exception is thrown other than by the copy constructor, move constructor, assignment operator, or move | |
| 29 | // assignment operator of T or by any InputIterator operation, there are no effects. If an exception is thrown while | |
| 30 | // inserting a single element at the end and T is Cpp17CopyInsertable or is_nothrow_move_constructible_v<T> is true, | |
| 31 | // there are no effects. Otherwise, if an exception is thrown by the move constructor of a non-Cpp17CopyInsertable T, | |
| 32 | // the effects are unspecified. | |
| 33 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | |
| 34 | _Or<is_nothrow_move_constructible<_Tp>, __is_cpp17_copy_insertable<_Allocator> >::value; | |
| 35 | }; | |
| 36 | ||
| 37 | _LIBCPP_END_NAMESPACE_STD | |
| 38 | ||
| 39 | #endif // _LIBCPP___VECTOR_CONTAINER_TRAITS_H |
lib/libcxx/include/__vector/erase.h created+50| ... | ... | @@ -0,0 +1,50 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___VECTOR_ERASE_H | |
| 10 | #define _LIBCPP___VECTOR_ERASE_H | |
| 11 | ||
| 12 | #include <__algorithm/remove.h> | |
| 13 | #include <__algorithm/remove_if.h> | |
| 14 | #include <__config> | |
| 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_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER >= 20 | |
| 25 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 27 | ||
| 28 | template <class _Tp, class _Allocator, class _Up> | |
| 29 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type | |
| 30 | erase(vector<_Tp, _Allocator>& __c, const _Up& __v) { | |
| 31 | auto __old_size = __c.size(); | |
| 32 | __c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end()); | |
| 33 | return __old_size - __c.size(); | |
| 34 | } | |
| 35 | ||
| 36 | template <class _Tp, class _Allocator, class _Predicate> | |
| 37 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type | |
| 38 | erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) { | |
| 39 | auto __old_size = __c.size(); | |
| 40 | __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end()); | |
| 41 | return __old_size - __c.size(); | |
| 42 | } | |
| 43 | ||
| 44 | _LIBCPP_END_NAMESPACE_STD | |
| 45 | ||
| 46 | #endif // _LIBCPP_STD_VER >= 20 | |
| 47 | ||
| 48 | _LIBCPP_POP_MACROS | |
| 49 | ||
| 50 | #endif // _LIBCPP___VECTOR_ERASE_H |
lib/libcxx/include/__vector/pmr.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___VECTOR_PMR_H | |
| 10 | #define _LIBCPP___VECTOR_PMR_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__fwd/vector.h> | |
| 14 | #include <__memory_resource/polymorphic_allocator.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 | namespace pmr { | |
| 25 | template <class _ValueT> | |
| 26 | using vector _LIBCPP_AVAILABILITY_PMR = std::vector<_ValueT, polymorphic_allocator<_ValueT>>; | |
| 27 | } // namespace pmr | |
| 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | |
| 30 | ||
| 31 | #endif | |
| 32 | ||
| 33 | #endif // _LIBCPP___VECTOR_PMR_H |
lib/libcxx/include/__vector/swap.h created+29| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___VECTOR_SWAP_H | |
| 10 | #define _LIBCPP___VECTOR_SWAP_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__fwd/vector.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> | |
| 22 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void | |
| 23 | swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | |
| 24 | __x.swap(__y); | |
| 25 | } | |
| 26 | ||
| 27 | _LIBCPP_END_NAMESPACE_STD | |
| 28 | ||
| 29 | #endif // _LIBCPP___VECTOR_SWAP_H |
lib/libcxx/include/__vector/vector.h created+1416| ... | ... | @@ -0,0 +1,1416 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___VECTOR_VECTOR_H | |
| 10 | #define _LIBCPP___VECTOR_VECTOR_H | |
| 11 | ||
| 12 | #include <__algorithm/copy.h> | |
| 13 | #include <__algorithm/copy_n.h> | |
| 14 | #include <__algorithm/fill_n.h> | |
| 15 | #include <__algorithm/max.h> | |
| 16 | #include <__algorithm/min.h> | |
| 17 | #include <__algorithm/move.h> | |
| 18 | #include <__algorithm/move_backward.h> | |
| 19 | #include <__algorithm/ranges_copy_n.h> | |
| 20 | #include <__algorithm/rotate.h> | |
| 21 | #include <__assert> | |
| 22 | #include <__config> | |
| 23 | #include <__debug_utils/sanitizers.h> | |
| 24 | #include <__format/enable_insertable.h> | |
| 25 | #include <__fwd/vector.h> | |
| 26 | #include <__iterator/advance.h> | |
| 27 | #include <__iterator/bounded_iter.h> | |
| 28 | #include <__iterator/concepts.h> | |
| 29 | #include <__iterator/distance.h> | |
| 30 | #include <__iterator/iterator_traits.h> | |
| 31 | #include <__iterator/move_iterator.h> | |
| 32 | #include <__iterator/next.h> | |
| 33 | #include <__iterator/reverse_iterator.h> | |
| 34 | #include <__iterator/wrap_iter.h> | |
| 35 | #include <__memory/addressof.h> | |
| 36 | #include <__memory/allocate_at_least.h> | |
| 37 | #include <__memory/allocator.h> | |
| 38 | #include <__memory/allocator_traits.h> | |
| 39 | #include <__memory/compressed_pair.h> | |
| 40 | #include <__memory/noexcept_move_assign_container.h> | |
| 41 | #include <__memory/pointer_traits.h> | |
| 42 | #include <__memory/swap_allocator.h> | |
| 43 | #include <__memory/temp_value.h> | |
| 44 | #include <__memory/uninitialized_algorithms.h> | |
| 45 | #include <__ranges/access.h> | |
| 46 | #include <__ranges/concepts.h> | |
| 47 | #include <__ranges/container_compatible_range.h> | |
| 48 | #include <__ranges/from_range.h> | |
| 49 | #include <__split_buffer> | |
| 50 | #include <__type_traits/conditional.h> | |
| 51 | #include <__type_traits/enable_if.h> | |
| 52 | #include <__type_traits/is_allocator.h> | |
| 53 | #include <__type_traits/is_constant_evaluated.h> | |
| 54 | #include <__type_traits/is_constructible.h> | |
| 55 | #include <__type_traits/is_nothrow_assignable.h> | |
| 56 | #include <__type_traits/is_nothrow_constructible.h> | |
| 57 | #include <__type_traits/is_pointer.h> | |
| 58 | #include <__type_traits/is_same.h> | |
| 59 | #include <__type_traits/is_trivially_relocatable.h> | |
| 60 | #include <__type_traits/type_identity.h> | |
| 61 | #include <__utility/exception_guard.h> | |
| 62 | #include <__utility/forward.h> | |
| 63 | #include <__utility/is_pointer_in_range.h> | |
| 64 | #include <__utility/move.h> | |
| 65 | #include <__utility/pair.h> | |
| 66 | #include <__utility/swap.h> | |
| 67 | #include <initializer_list> | |
| 68 | #include <limits> | |
| 69 | #include <stdexcept> | |
| 70 | ||
| 71 | // These headers define parts of vectors definition, since they define ADL functions or class specializations. | |
| 72 | #include <__vector/comparison.h> | |
| 73 | #include <__vector/container_traits.h> | |
| 74 | #include <__vector/swap.h> | |
| 75 | ||
| 76 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 77 | # pragma GCC system_header | |
| 78 | #endif | |
| 79 | ||
| 80 | _LIBCPP_PUSH_MACROS | |
| 81 | #include <__undef_macros> | |
| 82 | ||
| 83 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 84 | ||
| 85 | template <class _Tp, class _Allocator /* = allocator<_Tp> */> | |
| 86 | class _LIBCPP_TEMPLATE_VIS vector { | |
| 87 | private: | |
| 88 | typedef allocator<_Tp> __default_allocator_type; | |
| 89 | ||
| 90 | public: | |
| 91 | // | |
| 92 | // Types | |
| 93 | // | |
| 94 | typedef vector __self; | |
| 95 | typedef _Tp value_type; | |
| 96 | typedef _Allocator allocator_type; | |
| 97 | typedef allocator_traits<allocator_type> __alloc_traits; | |
| 98 | typedef value_type& reference; | |
| 99 | typedef const value_type& const_reference; | |
| 100 | typedef typename __alloc_traits::size_type size_type; | |
| 101 | typedef typename __alloc_traits::difference_type difference_type; | |
| 102 | typedef typename __alloc_traits::pointer pointer; | |
| 103 | typedef typename __alloc_traits::const_pointer const_pointer; | |
| 104 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | |
| 105 | // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's | |
| 106 | // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is | |
| 107 | // considered contiguous. | |
| 108 | typedef __bounded_iter<__wrap_iter<pointer> > iterator; | |
| 109 | typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator; | |
| 110 | #else | |
| 111 | typedef __wrap_iter<pointer> iterator; | |
| 112 | typedef __wrap_iter<const_pointer> const_iterator; | |
| 113 | #endif | |
| 114 | typedef std::reverse_iterator<iterator> reverse_iterator; | |
| 115 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 116 | ||
| 117 | // A vector containers the following members which may be trivially relocatable: | |
| 118 | // - pointer: may be trivially relocatable, so it's checked | |
| 119 | // - allocator_type: may be trivially relocatable, so it's checked | |
| 120 | // vector doesn't contain any self-references, so it's trivially relocatable if its members are. | |
| 121 | using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t< | |
| 122 | __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, | |
| 123 | vector, | |
| 124 | void>; | |
| 125 | ||
| 126 | static_assert(__check_valid_allocator<allocator_type>::value, ""); | |
| 127 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, | |
| 128 | "Allocator::value_type must be same type as value_type"); | |
| 129 | ||
| 130 | // | |
| 131 | // [vector.cons], construct/copy/destroy | |
| 132 | // | |
| 133 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector() | |
| 134 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) {} | |
| 135 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a) | |
| 136 | #if _LIBCPP_STD_VER <= 14 | |
| 137 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) | |
| 138 | #else | |
| 139 | noexcept | |
| 140 | #endif | |
| 141 | : __alloc_(__a) { | |
| 142 | } | |
| 143 | ||
| 144 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n) { | |
| 145 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 146 | if (__n > 0) { | |
| 147 | __vallocate(__n); | |
| 148 | __construct_at_end(__n); | |
| 149 | } | |
| 150 | __guard.__complete(); | |
| 151 | } | |
| 152 | ||
| 153 | #if _LIBCPP_STD_VER >= 14 | |
| 154 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a) | |
| 155 | : __alloc_(__a) { | |
| 156 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 157 | if (__n > 0) { | |
| 158 | __vallocate(__n); | |
| 159 | __construct_at_end(__n); | |
| 160 | } | |
| 161 | __guard.__complete(); | |
| 162 | } | |
| 163 | #endif | |
| 164 | ||
| 165 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x) { | |
| 166 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 167 | if (__n > 0) { | |
| 168 | __vallocate(__n); | |
| 169 | __construct_at_end(__n, __x); | |
| 170 | } | |
| 171 | __guard.__complete(); | |
| 172 | } | |
| 173 | ||
| 174 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> | |
| 175 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 176 | vector(size_type __n, const value_type& __x, const allocator_type& __a) | |
| 177 | : __alloc_(__a) { | |
| 178 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 179 | if (__n > 0) { | |
| 180 | __vallocate(__n); | |
| 181 | __construct_at_end(__n, __x); | |
| 182 | } | |
| 183 | __guard.__complete(); | |
| 184 | } | |
| 185 | ||
| 186 | template <class _InputIterator, | |
| 187 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 188 | is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, | |
| 189 | int> = 0> | |
| 190 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last) { | |
| 191 | __init_with_sentinel(__first, __last); | |
| 192 | } | |
| 193 | ||
| 194 | template <class _InputIterator, | |
| 195 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 196 | is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, | |
| 197 | int> = 0> | |
| 198 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 199 | vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a) | |
| 200 | : __alloc_(__a) { | |
| 201 | __init_with_sentinel(__first, __last); | |
| 202 | } | |
| 203 | ||
| 204 | template < | |
| 205 | class _ForwardIterator, | |
| 206 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 207 | is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 208 | int> = 0> | |
| 209 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last) { | |
| 210 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | |
| 211 | __init_with_size(__first, __last, __n); | |
| 212 | } | |
| 213 | ||
| 214 | template < | |
| 215 | class _ForwardIterator, | |
| 216 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 217 | is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 218 | int> = 0> | |
| 219 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 220 | vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a) | |
| 221 | : __alloc_(__a) { | |
| 222 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | |
| 223 | __init_with_size(__first, __last, __n); | |
| 224 | } | |
| 225 | ||
| 226 | #if _LIBCPP_STD_VER >= 23 | |
| 227 | template <_ContainerCompatibleRange<_Tp> _Range> | |
| 228 | _LIBCPP_HIDE_FROM_ABI constexpr vector( | |
| 229 | from_range_t, _Range&& __range, const allocator_type& __alloc = allocator_type()) | |
| 230 | : __alloc_(__alloc) { | |
| 231 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 232 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 233 | __init_with_size(ranges::begin(__range), ranges::end(__range), __n); | |
| 234 | ||
| 235 | } else { | |
| 236 | __init_with_sentinel(ranges::begin(__range), ranges::end(__range)); | |
| 237 | } | |
| 238 | } | |
| 239 | #endif | |
| 240 | ||
| 241 | private: | |
| 242 | class __destroy_vector { | |
| 243 | public: | |
| 244 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {} | |
| 245 | ||
| 246 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() { | |
| 247 | if (__vec_.__begin_ != nullptr) { | |
| 248 | __vec_.clear(); | |
| 249 | __vec_.__annotate_delete(); | |
| 250 | __alloc_traits::deallocate(__vec_.__alloc_, __vec_.__begin_, __vec_.capacity()); | |
| 251 | } | |
| 252 | } | |
| 253 | ||
| 254 | private: | |
| 255 | vector& __vec_; | |
| 256 | }; | |
| 257 | ||
| 258 | public: | |
| 259 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector (*this)(); } | |
| 260 | ||
| 261 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x) | |
| 262 | : __alloc_(__alloc_traits::select_on_container_copy_construction(__x.__alloc_)) { | |
| 263 | __init_with_size(__x.__begin_, __x.__end_, __x.size()); | |
| 264 | } | |
| 265 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 266 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | |
| 267 | : __alloc_(__a) { | |
| 268 | __init_with_size(__x.__begin_, __x.__end_, __x.size()); | |
| 269 | } | |
| 270 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(const vector& __x); | |
| 271 | ||
| 272 | #ifndef _LIBCPP_CXX03_LANG | |
| 273 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(initializer_list<value_type> __il) { | |
| 274 | __init_with_size(__il.begin(), __il.end(), __il.size()); | |
| 275 | } | |
| 276 | ||
| 277 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 278 | vector(initializer_list<value_type> __il, const allocator_type& __a) | |
| 279 | : __alloc_(__a) { | |
| 280 | __init_with_size(__il.begin(), __il.end(), __il.size()); | |
| 281 | } | |
| 282 | ||
| 283 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(initializer_list<value_type> __il) { | |
| 284 | assign(__il.begin(), __il.end()); | |
| 285 | return *this; | |
| 286 | } | |
| 287 | #endif // !_LIBCPP_CXX03_LANG | |
| 288 | ||
| 289 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(vector&& __x) | |
| 290 | #if _LIBCPP_STD_VER >= 17 | |
| 291 | noexcept; | |
| 292 | #else | |
| 293 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | |
| 294 | #endif | |
| 295 | ||
| 296 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 297 | vector(vector&& __x, const __type_identity_t<allocator_type>& __a); | |
| 298 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(vector&& __x) | |
| 299 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { | |
| 300 | __move_assign(__x, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); | |
| 301 | return *this; | |
| 302 | } | |
| 303 | ||
| 304 | template <class _InputIterator, | |
| 305 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 306 | is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, | |
| 307 | int> = 0> | |
| 308 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_InputIterator __first, _InputIterator __last) { | |
| 309 | __assign_with_sentinel(__first, __last); | |
| 310 | } | |
| 311 | template < | |
| 312 | class _ForwardIterator, | |
| 313 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 314 | is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 315 | int> = 0> | |
| 316 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last) { | |
| 317 | __assign_with_size(__first, __last, std::distance(__first, __last)); | |
| 318 | } | |
| 319 | ||
| 320 | #if _LIBCPP_STD_VER >= 23 | |
| 321 | template <_ContainerCompatibleRange<_Tp> _Range> | |
| 322 | _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) { | |
| 323 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 324 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 325 | __assign_with_size(ranges::begin(__range), ranges::end(__range), __n); | |
| 326 | ||
| 327 | } else { | |
| 328 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); | |
| 329 | } | |
| 330 | } | |
| 331 | #endif | |
| 332 | ||
| 333 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const_reference __u); | |
| 334 | ||
| 335 | #ifndef _LIBCPP_CXX03_LANG | |
| 336 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { | |
| 337 | assign(__il.begin(), __il.end()); | |
| 338 | } | |
| 339 | #endif | |
| 340 | ||
| 341 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { | |
| 342 | return this->__alloc_; | |
| 343 | } | |
| 344 | ||
| 345 | // | |
| 346 | // Iterators | |
| 347 | // | |
| 348 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { | |
| 349 | return __make_iter(__add_alignment_assumption(this->__begin_)); | |
| 350 | } | |
| 351 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { | |
| 352 | return __make_iter(__add_alignment_assumption(this->__begin_)); | |
| 353 | } | |
| 354 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { | |
| 355 | return __make_iter(__add_alignment_assumption(this->__end_)); | |
| 356 | } | |
| 357 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { | |
| 358 | return __make_iter(__add_alignment_assumption(this->__end_)); | |
| 359 | } | |
| 360 | ||
| 361 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { | |
| 362 | return reverse_iterator(end()); | |
| 363 | } | |
| 364 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { | |
| 365 | return const_reverse_iterator(end()); | |
| 366 | } | |
| 367 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { | |
| 368 | return reverse_iterator(begin()); | |
| 369 | } | |
| 370 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | |
| 371 | return const_reverse_iterator(begin()); | |
| 372 | } | |
| 373 | ||
| 374 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } | |
| 375 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } | |
| 376 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { | |
| 377 | return rbegin(); | |
| 378 | } | |
| 379 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | |
| 380 | ||
| 381 | // | |
| 382 | // [vector.capacity], capacity | |
| 383 | // | |
| 384 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { | |
| 385 | return static_cast<size_type>(this->__end_ - this->__begin_); | |
| 386 | } | |
| 387 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT { | |
| 388 | return static_cast<size_type>(this->__cap_ - this->__begin_); | |
| 389 | } | |
| 390 | [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { | |
| 391 | return this->__begin_ == this->__end_; | |
| 392 | } | |
| 393 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { | |
| 394 | return std::min<size_type>(__alloc_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max()); | |
| 395 | } | |
| 396 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n); | |
| 397 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; | |
| 398 | ||
| 399 | // | |
| 400 | // element access | |
| 401 | // | |
| 402 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT { | |
| 403 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds"); | |
| 404 | return this->__begin_[__n]; | |
| 405 | } | |
| 406 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT { | |
| 407 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds"); | |
| 408 | return this->__begin_[__n]; | |
| 409 | } | |
| 410 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n) { | |
| 411 | if (__n >= size()) | |
| 412 | this->__throw_out_of_range(); | |
| 413 | return this->__begin_[__n]; | |
| 414 | } | |
| 415 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const { | |
| 416 | if (__n >= size()) | |
| 417 | this->__throw_out_of_range(); | |
| 418 | return this->__begin_[__n]; | |
| 419 | } | |
| 420 | ||
| 421 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT { | |
| 422 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector"); | |
| 423 | return *this->__begin_; | |
| 424 | } | |
| 425 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT { | |
| 426 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector"); | |
| 427 | return *this->__begin_; | |
| 428 | } | |
| 429 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT { | |
| 430 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector"); | |
| 431 | return *(this->__end_ - 1); | |
| 432 | } | |
| 433 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { | |
| 434 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector"); | |
| 435 | return *(this->__end_ - 1); | |
| 436 | } | |
| 437 | ||
| 438 | // | |
| 439 | // [vector.data], data access | |
| 440 | // | |
| 441 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT { | |
| 442 | return std::__to_address(this->__begin_); | |
| 443 | } | |
| 444 | ||
| 445 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT { | |
| 446 | return std::__to_address(this->__begin_); | |
| 447 | } | |
| 448 | ||
| 449 | // | |
| 450 | // [vector.modifiers], modifiers | |
| 451 | // | |
| 452 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x) { emplace_back(__x); } | |
| 453 | ||
| 454 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x) { emplace_back(std::move(__x)); } | |
| 455 | ||
| 456 | template <class... _Args> | |
| 457 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 458 | #if _LIBCPP_STD_VER >= 17 | |
| 459 | reference | |
| 460 | emplace_back(_Args&&... __args); | |
| 461 | #else | |
| 462 | void | |
| 463 | emplace_back(_Args&&... __args); | |
| 464 | #endif | |
| 465 | ||
| 466 | #if _LIBCPP_STD_VER >= 23 | |
| 467 | template <_ContainerCompatibleRange<_Tp> _Range> | |
| 468 | _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) { | |
| 469 | insert_range(end(), std::forward<_Range>(__range)); | |
| 470 | } | |
| 471 | #endif | |
| 472 | ||
| 473 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() { | |
| 474 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector::pop_back called on an empty vector"); | |
| 475 | this->__destruct_at_end(this->__end_ - 1); | |
| 476 | } | |
| 477 | ||
| 478 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x); | |
| 479 | ||
| 480 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x); | |
| 481 | template <class... _Args> | |
| 482 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args); | |
| 483 | ||
| 484 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 485 | insert(const_iterator __position, size_type __n, const_reference __x); | |
| 486 | ||
| 487 | template <class _InputIterator, | |
| 488 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 489 | is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value, | |
| 490 | int> = 0> | |
| 491 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 492 | insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { | |
| 493 | return __insert_with_sentinel(__position, __first, __last); | |
| 494 | } | |
| 495 | ||
| 496 | template < | |
| 497 | class _ForwardIterator, | |
| 498 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 499 | is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 500 | int> = 0> | |
| 501 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 502 | insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) { | |
| 503 | return __insert_with_size(__position, __first, __last, std::distance(__first, __last)); | |
| 504 | } | |
| 505 | ||
| 506 | #if _LIBCPP_STD_VER >= 23 | |
| 507 | template <_ContainerCompatibleRange<_Tp> _Range> | |
| 508 | _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) { | |
| 509 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 510 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 511 | return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n); | |
| 512 | ||
| 513 | } else { | |
| 514 | return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); | |
| 515 | } | |
| 516 | } | |
| 517 | #endif | |
| 518 | ||
| 519 | #ifndef _LIBCPP_CXX03_LANG | |
| 520 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 521 | insert(const_iterator __position, initializer_list<value_type> __il) { | |
| 522 | return insert(__position, __il.begin(), __il.end()); | |
| 523 | } | |
| 524 | #endif | |
| 525 | ||
| 526 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position); | |
| 527 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last); | |
| 528 | ||
| 529 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { | |
| 530 | size_type __old_size = size(); | |
| 531 | __base_destruct_at_end(this->__begin_); | |
| 532 | __annotate_shrink(__old_size); | |
| 533 | } | |
| 534 | ||
| 535 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz); | |
| 536 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz, const_reference __x); | |
| 537 | ||
| 538 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(vector&) | |
| 539 | #if _LIBCPP_STD_VER >= 14 | |
| 540 | _NOEXCEPT; | |
| 541 | #else | |
| 542 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); | |
| 543 | #endif | |
| 544 | ||
| 545 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; | |
| 546 | ||
| 547 | private: | |
| 548 | pointer __begin_ = nullptr; | |
| 549 | pointer __end_ = nullptr; | |
| 550 | _LIBCPP_COMPRESSED_PAIR(pointer, __cap_ = nullptr, allocator_type, __alloc_); | |
| 551 | ||
| 552 | // Allocate space for __n objects | |
| 553 | // throws length_error if __n > max_size() | |
| 554 | // throws (probably bad_alloc) if memory run out | |
| 555 | // Precondition: __begin_ == __end_ == __cap_ == nullptr | |
| 556 | // Precondition: __n > 0 | |
| 557 | // Postcondition: capacity() >= __n | |
| 558 | // Postcondition: size() == 0 | |
| 559 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { | |
| 560 | if (__n > max_size()) | |
| 561 | __throw_length_error(); | |
| 562 | auto __allocation = std::__allocate_at_least(this->__alloc_, __n); | |
| 563 | __begin_ = __allocation.ptr; | |
| 564 | __end_ = __allocation.ptr; | |
| 565 | __cap_ = __begin_ + __allocation.count; | |
| 566 | __annotate_new(0); | |
| 567 | } | |
| 568 | ||
| 569 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vdeallocate() _NOEXCEPT; | |
| 570 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __recommend(size_type __new_size) const; | |
| 571 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n); | |
| 572 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x); | |
| 573 | ||
| 574 | template <class _InputIterator, class _Sentinel> | |
| 575 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 576 | __init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) { | |
| 577 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 578 | ||
| 579 | if (__n > 0) { | |
| 580 | __vallocate(__n); | |
| 581 | __construct_at_end(std::move(__first), std::move(__last), __n); | |
| 582 | } | |
| 583 | ||
| 584 | __guard.__complete(); | |
| 585 | } | |
| 586 | ||
| 587 | template <class _InputIterator, class _Sentinel> | |
| 588 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 589 | __init_with_sentinel(_InputIterator __first, _Sentinel __last) { | |
| 590 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 591 | ||
| 592 | for (; __first != __last; ++__first) | |
| 593 | emplace_back(*__first); | |
| 594 | ||
| 595 | __guard.__complete(); | |
| 596 | } | |
| 597 | ||
| 598 | template <class _Iterator, class _Sentinel> | |
| 599 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last); | |
| 600 | ||
| 601 | // The `_Iterator` in `*_with_size` functions can be input-only only if called from `*_range` (since C++23). | |
| 602 | // Otherwise, `_Iterator` is a forward iterator. | |
| 603 | ||
| 604 | template <class _Iterator, class _Sentinel> | |
| 605 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 606 | __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n); | |
| 607 | ||
| 608 | template <class _InputIterator, class _Sentinel> | |
| 609 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 610 | __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last); | |
| 611 | ||
| 612 | template <class _Iterator, class _Sentinel> | |
| 613 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 614 | __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n); | |
| 615 | ||
| 616 | template <class _InputIterator, class _Sentinel> | |
| 617 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 618 | __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n); | |
| 619 | ||
| 620 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n); | |
| 621 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x); | |
| 622 | ||
| 623 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT { | |
| 624 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | |
| 625 | // Bound the iterator according to the capacity, rather than the size. | |
| 626 | // | |
| 627 | // Vector guarantees that iterators stay valid as long as no reallocation occurs even if new elements are inserted | |
| 628 | // into the container; for these cases, we need to make sure that the newly-inserted elements can be accessed | |
| 629 | // through the bounded iterator without failing checks. The downside is that the bounded iterator won't catch | |
| 630 | // access that is logically out-of-bounds, i.e., goes beyond the size, but is still within the capacity. With the | |
| 631 | // current implementation, there is no connection between a bounded iterator and its associated container, so we | |
| 632 | // don't have a way to update existing valid iterators when the container is resized and thus have to go with | |
| 633 | // a laxer approach. | |
| 634 | return std::__make_bounded_iter( | |
| 635 | std::__wrap_iter<pointer>(__p), | |
| 636 | std::__wrap_iter<pointer>(this->__begin_), | |
| 637 | std::__wrap_iter<pointer>(this->__cap_)); | |
| 638 | #else | |
| 639 | return iterator(__p); | |
| 640 | #endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | |
| 641 | } | |
| 642 | ||
| 643 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT { | |
| 644 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | |
| 645 | // Bound the iterator according to the capacity, rather than the size. | |
| 646 | return std::__make_bounded_iter( | |
| 647 | std::__wrap_iter<const_pointer>(__p), | |
| 648 | std::__wrap_iter<const_pointer>(this->__begin_), | |
| 649 | std::__wrap_iter<const_pointer>(this->__cap_)); | |
| 650 | #else | |
| 651 | return const_iterator(__p); | |
| 652 | #endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | |
| 653 | } | |
| 654 | ||
| 655 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 656 | __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); | |
| 657 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer | |
| 658 | __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p); | |
| 659 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 660 | __move_range(pointer __from_s, pointer __from_e, pointer __to); | |
| 661 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type) | |
| 662 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | |
| 663 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, false_type) | |
| 664 | _NOEXCEPT_(__alloc_traits::is_always_equal::value); | |
| 665 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last) _NOEXCEPT { | |
| 666 | size_type __old_size = size(); | |
| 667 | __base_destruct_at_end(__new_last); | |
| 668 | __annotate_shrink(__old_size); | |
| 669 | } | |
| 670 | ||
| 671 | template <class... _Args> | |
| 672 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __emplace_back_slow_path(_Args&&... __args); | |
| 673 | ||
| 674 | // The following functions are no-ops outside of AddressSanitizer mode. | |
| 675 | // We call annotations for every allocator, unless explicitly disabled. | |
| 676 | // | |
| 677 | // To disable annotations for a particular allocator, change value of | |
| 678 | // __asan_annotate_container_with_allocator to false. | |
| 679 | // For more details, see the "Using libc++" documentation page or | |
| 680 | // the documentation for __sanitizer_annotate_contiguous_container. | |
| 681 | ||
| 682 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 683 | __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const { | |
| 684 | std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity(), __old_mid, __new_mid); | |
| 685 | } | |
| 686 | ||
| 687 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { | |
| 688 | (void)__current_size; | |
| 689 | #if _LIBCPP_HAS_ASAN | |
| 690 | __annotate_contiguous_container(data() + capacity(), data() + __current_size); | |
| 691 | #endif | |
| 692 | } | |
| 693 | ||
| 694 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT { | |
| 695 | #if _LIBCPP_HAS_ASAN | |
| 696 | __annotate_contiguous_container(data() + size(), data() + capacity()); | |
| 697 | #endif | |
| 698 | } | |
| 699 | ||
| 700 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT { | |
| 701 | (void)__n; | |
| 702 | #if _LIBCPP_HAS_ASAN | |
| 703 | __annotate_contiguous_container(data() + size(), data() + size() + __n); | |
| 704 | #endif | |
| 705 | } | |
| 706 | ||
| 707 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT { | |
| 708 | (void)__old_size; | |
| 709 | #if _LIBCPP_HAS_ASAN | |
| 710 | __annotate_contiguous_container(data() + __old_size, data() + size()); | |
| 711 | #endif | |
| 712 | } | |
| 713 | ||
| 714 | struct _ConstructTransaction { | |
| 715 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n) | |
| 716 | : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { | |
| 717 | #if _LIBCPP_HAS_ASAN | |
| 718 | __v_.__annotate_increase(__n); | |
| 719 | #endif | |
| 720 | } | |
| 721 | ||
| 722 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { | |
| 723 | __v_.__end_ = __pos_; | |
| 724 | #if _LIBCPP_HAS_ASAN | |
| 725 | if (__pos_ != __new_end_) { | |
| 726 | __v_.__annotate_shrink(__new_end_ - __v_.__begin_); | |
| 727 | } | |
| 728 | #endif | |
| 729 | } | |
| 730 | ||
| 731 | vector& __v_; | |
| 732 | pointer __pos_; | |
| 733 | const_pointer const __new_end_; | |
| 734 | ||
| 735 | _ConstructTransaction(_ConstructTransaction const&) = delete; | |
| 736 | _ConstructTransaction& operator=(_ConstructTransaction const&) = delete; | |
| 737 | }; | |
| 738 | ||
| 739 | template <class... _Args> | |
| 740 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_one_at_end(_Args&&... __args) { | |
| 741 | _ConstructTransaction __tx(*this, 1); | |
| 742 | __alloc_traits::construct(this->__alloc_, std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...); | |
| 743 | ++__tx.__pos_; | |
| 744 | } | |
| 745 | ||
| 746 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT { | |
| 747 | pointer __soon_to_be_end = this->__end_; | |
| 748 | while (__new_last != __soon_to_be_end) | |
| 749 | __alloc_traits::destroy(this->__alloc_, std::__to_address(--__soon_to_be_end)); | |
| 750 | this->__end_ = __new_last; | |
| 751 | } | |
| 752 | ||
| 753 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c) { | |
| 754 | __copy_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_copy_assignment::value>()); | |
| 755 | } | |
| 756 | ||
| 757 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c) | |
| 758 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value || | |
| 759 | is_nothrow_move_assignable<allocator_type>::value) { | |
| 760 | __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); | |
| 761 | } | |
| 762 | ||
| 763 | [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_length_error() { std::__throw_length_error("vector"); } | |
| 764 | ||
| 765 | [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_out_of_range() { std::__throw_out_of_range("vector"); } | |
| 766 | ||
| 767 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c, true_type) { | |
| 768 | if (this->__alloc_ != __c.__alloc_) { | |
| 769 | clear(); | |
| 770 | __annotate_delete(); | |
| 771 | __alloc_traits::deallocate(this->__alloc_, this->__begin_, capacity()); | |
| 772 | this->__begin_ = this->__end_ = this->__cap_ = nullptr; | |
| 773 | } | |
| 774 | this->__alloc_ = __c.__alloc_; | |
| 775 | } | |
| 776 | ||
| 777 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector&, false_type) {} | |
| 778 | ||
| 779 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c, true_type) | |
| 780 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | |
| 781 | this->__alloc_ = std::move(__c.__alloc_); | |
| 782 | } | |
| 783 | ||
| 784 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector&, false_type) _NOEXCEPT {} | |
| 785 | ||
| 786 | template <class _Ptr = pointer, __enable_if_t<is_pointer<_Ptr>::value, int> = 0> | |
| 787 | static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI pointer | |
| 788 | __add_alignment_assumption(_Ptr __p) _NOEXCEPT { | |
| 789 | if (!__libcpp_is_constant_evaluated()) { | |
| 790 | return static_cast<pointer>(__builtin_assume_aligned(__p, _LIBCPP_ALIGNOF(decltype(*__p)))); | |
| 791 | } | |
| 792 | return __p; | |
| 793 | } | |
| 794 | ||
| 795 | template <class _Ptr = pointer, __enable_if_t<!is_pointer<_Ptr>::value, int> = 0> | |
| 796 | static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI pointer | |
| 797 | __add_alignment_assumption(_Ptr __p) _NOEXCEPT { | |
| 798 | return __p; | |
| 799 | } | |
| 800 | }; | |
| 801 | ||
| 802 | #if _LIBCPP_STD_VER >= 17 | |
| 803 | template <class _InputIterator, | |
| 804 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, | |
| 805 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | |
| 806 | class = enable_if_t<__is_allocator<_Alloc>::value> > | |
| 807 | vector(_InputIterator, _InputIterator) -> vector<__iter_value_type<_InputIterator>, _Alloc>; | |
| 808 | ||
| 809 | template <class _InputIterator, | |
| 810 | class _Alloc, | |
| 811 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | |
| 812 | class = enable_if_t<__is_allocator<_Alloc>::value> > | |
| 813 | vector(_InputIterator, _InputIterator, _Alloc) -> vector<__iter_value_type<_InputIterator>, _Alloc>; | |
| 814 | #endif | |
| 815 | ||
| 816 | #if _LIBCPP_STD_VER >= 23 | |
| 817 | template <ranges::input_range _Range, | |
| 818 | class _Alloc = allocator<ranges::range_value_t<_Range>>, | |
| 819 | class = enable_if_t<__is_allocator<_Alloc>::value> > | |
| 820 | vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>; | |
| 821 | #endif | |
| 822 | ||
| 823 | // __swap_out_circular_buffer relocates the objects in [__begin_, __end_) into the front of __v and swaps the buffers of | |
| 824 | // *this and __v. It is assumed that __v provides space for exactly (__end_ - __begin_) objects in the front. This | |
| 825 | // function has a strong exception guarantee. | |
| 826 | template <class _Tp, class _Allocator> | |
| 827 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 828 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) { | |
| 829 | __annotate_delete(); | |
| 830 | auto __new_begin = __v.__begin_ - (__end_ - __begin_); | |
| 831 | std::__uninitialized_allocator_relocate( | |
| 832 | this->__alloc_, std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin)); | |
| 833 | __v.__begin_ = __new_begin; | |
| 834 | __end_ = __begin_; // All the objects have been destroyed by relocating them. | |
| 835 | std::swap(this->__begin_, __v.__begin_); | |
| 836 | std::swap(this->__end_, __v.__end_); | |
| 837 | std::swap(this->__cap_, __v.__cap_); | |
| 838 | __v.__first_ = __v.__begin_; | |
| 839 | __annotate_new(size()); | |
| 840 | } | |
| 841 | ||
| 842 | // __swap_out_circular_buffer relocates the objects in [__begin_, __p) into the front of __v, the objects in | |
| 843 | // [__p, __end_) into the back of __v and swaps the buffers of *this and __v. It is assumed that __v provides space for | |
| 844 | // exactly (__p - __begin_) objects in the front and space for at least (__end_ - __p) objects in the back. This | |
| 845 | // function has a strong exception guarantee if __begin_ == __p || __end_ == __p. | |
| 846 | template <class _Tp, class _Allocator> | |
| 847 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer | |
| 848 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) { | |
| 849 | __annotate_delete(); | |
| 850 | pointer __ret = __v.__begin_; | |
| 851 | ||
| 852 | // Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_) | |
| 853 | // in case something in [__begin_, __p) throws. | |
| 854 | std::__uninitialized_allocator_relocate( | |
| 855 | this->__alloc_, std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.__end_)); | |
| 856 | __v.__end_ += (__end_ - __p); | |
| 857 | __end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them. | |
| 858 | auto __new_begin = __v.__begin_ - (__p - __begin_); | |
| 859 | ||
| 860 | std::__uninitialized_allocator_relocate( | |
| 861 | this->__alloc_, std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin)); | |
| 862 | __v.__begin_ = __new_begin; | |
| 863 | __end_ = __begin_; // All the objects have been destroyed by relocating them. | |
| 864 | ||
| 865 | std::swap(this->__begin_, __v.__begin_); | |
| 866 | std::swap(this->__end_, __v.__end_); | |
| 867 | std::swap(this->__cap_, __v.__cap_); | |
| 868 | __v.__first_ = __v.__begin_; | |
| 869 | __annotate_new(size()); | |
| 870 | return __ret; | |
| 871 | } | |
| 872 | ||
| 873 | template <class _Tp, class _Allocator> | |
| 874 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT { | |
| 875 | if (this->__begin_ != nullptr) { | |
| 876 | clear(); | |
| 877 | __annotate_delete(); | |
| 878 | __alloc_traits::deallocate(this->__alloc_, this->__begin_, capacity()); | |
| 879 | this->__begin_ = this->__end_ = this->__cap_ = nullptr; | |
| 880 | } | |
| 881 | } | |
| 882 | ||
| 883 | // Precondition: __new_size > capacity() | |
| 884 | template <class _Tp, class _Allocator> | |
| 885 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type | |
| 886 | vector<_Tp, _Allocator>::__recommend(size_type __new_size) const { | |
| 887 | const size_type __ms = max_size(); | |
| 888 | if (__new_size > __ms) | |
| 889 | this->__throw_length_error(); | |
| 890 | const size_type __cap = capacity(); | |
| 891 | if (__cap >= __ms / 2) | |
| 892 | return __ms; | |
| 893 | return std::max<size_type>(2 * __cap, __new_size); | |
| 894 | } | |
| 895 | ||
| 896 | // Default constructs __n objects starting at __end_ | |
| 897 | // throws if construction throws | |
| 898 | // Precondition: __n > 0 | |
| 899 | // Precondition: size() + __n <= capacity() | |
| 900 | // Postcondition: size() == size() + __n | |
| 901 | template <class _Tp, class _Allocator> | |
| 902 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__construct_at_end(size_type __n) { | |
| 903 | _ConstructTransaction __tx(*this, __n); | |
| 904 | const_pointer __new_end = __tx.__new_end_; | |
| 905 | for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) { | |
| 906 | __alloc_traits::construct(this->__alloc_, std::__to_address(__pos)); | |
| 907 | } | |
| 908 | } | |
| 909 | ||
| 910 | // Copy constructs __n objects starting at __end_ from __x | |
| 911 | // throws if construction throws | |
| 912 | // Precondition: __n > 0 | |
| 913 | // Precondition: size() + __n <= capacity() | |
| 914 | // Postcondition: size() == old size() + __n | |
| 915 | // Postcondition: [i] == __x for all i in [size() - __n, __n) | |
| 916 | template <class _Tp, class _Allocator> | |
| 917 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void | |
| 918 | vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { | |
| 919 | _ConstructTransaction __tx(*this, __n); | |
| 920 | const_pointer __new_end = __tx.__new_end_; | |
| 921 | for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) { | |
| 922 | __alloc_traits::construct(this->__alloc_, std::__to_address(__pos), __x); | |
| 923 | } | |
| 924 | } | |
| 925 | ||
| 926 | template <class _Tp, class _Allocator> | |
| 927 | template <class _InputIterator, class _Sentinel> | |
| 928 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 929 | vector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) { | |
| 930 | _ConstructTransaction __tx(*this, __n); | |
| 931 | __tx.__pos_ = std::__uninitialized_allocator_copy(this->__alloc_, std::move(__first), std::move(__last), __tx.__pos_); | |
| 932 | } | |
| 933 | ||
| 934 | // Default constructs __n objects starting at __end_ | |
| 935 | // throws if construction throws | |
| 936 | // Postcondition: size() == size() + __n | |
| 937 | // Exception safety: strong. | |
| 938 | template <class _Tp, class _Allocator> | |
| 939 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n) { | |
| 940 | if (static_cast<size_type>(this->__cap_ - this->__end_) >= __n) | |
| 941 | this->__construct_at_end(__n); | |
| 942 | else { | |
| 943 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), this->__alloc_); | |
| 944 | __v.__construct_at_end(__n); | |
| 945 | __swap_out_circular_buffer(__v); | |
| 946 | } | |
| 947 | } | |
| 948 | ||
| 949 | // Default constructs __n objects starting at __end_ | |
| 950 | // throws if construction throws | |
| 951 | // Postcondition: size() == size() + __n | |
| 952 | // Exception safety: strong. | |
| 953 | template <class _Tp, class _Allocator> | |
| 954 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) { | |
| 955 | if (static_cast<size_type>(this->__cap_ - this->__end_) >= __n) | |
| 956 | this->__construct_at_end(__n, __x); | |
| 957 | else { | |
| 958 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), this->__alloc_); | |
| 959 | __v.__construct_at_end(__n, __x); | |
| 960 | __swap_out_circular_buffer(__v); | |
| 961 | } | |
| 962 | } | |
| 963 | ||
| 964 | template <class _Tp, class _Allocator> | |
| 965 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x) | |
| 966 | #if _LIBCPP_STD_VER >= 17 | |
| 967 | noexcept | |
| 968 | #else | |
| 969 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | |
| 970 | #endif | |
| 971 | : __alloc_(std::move(__x.__alloc_)) { | |
| 972 | this->__begin_ = __x.__begin_; | |
| 973 | this->__end_ = __x.__end_; | |
| 974 | this->__cap_ = __x.__cap_; | |
| 975 | __x.__begin_ = __x.__end_ = __x.__cap_ = nullptr; | |
| 976 | } | |
| 977 | ||
| 978 | template <class _Tp, class _Allocator> | |
| 979 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI | |
| 980 | vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a) | |
| 981 | : __alloc_(__a) { | |
| 982 | if (__a == __x.__alloc_) { | |
| 983 | this->__begin_ = __x.__begin_; | |
| 984 | this->__end_ = __x.__end_; | |
| 985 | this->__cap_ = __x.__cap_; | |
| 986 | __x.__begin_ = __x.__end_ = __x.__cap_ = nullptr; | |
| 987 | } else { | |
| 988 | typedef move_iterator<iterator> _Ip; | |
| 989 | __init_with_size(_Ip(__x.begin()), _Ip(__x.end()), __x.size()); | |
| 990 | } | |
| 991 | } | |
| 992 | ||
| 993 | template <class _Tp, class _Allocator> | |
| 994 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) | |
| 995 | _NOEXCEPT_(__alloc_traits::is_always_equal::value) { | |
| 996 | if (this->__alloc_ != __c.__alloc_) { | |
| 997 | typedef move_iterator<iterator> _Ip; | |
| 998 | assign(_Ip(__c.begin()), _Ip(__c.end())); | |
| 999 | } else | |
| 1000 | __move_assign(__c, true_type()); | |
| 1001 | } | |
| 1002 | ||
| 1003 | template <class _Tp, class _Allocator> | |
| 1004 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) | |
| 1005 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | |
| 1006 | __vdeallocate(); | |
| 1007 | __move_assign_alloc(__c); // this can throw | |
| 1008 | this->__begin_ = __c.__begin_; | |
| 1009 | this->__end_ = __c.__end_; | |
| 1010 | this->__cap_ = __c.__cap_; | |
| 1011 | __c.__begin_ = __c.__end_ = __c.__cap_ = nullptr; | |
| 1012 | } | |
| 1013 | ||
| 1014 | template <class _Tp, class _Allocator> | |
| 1015 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>& | |
| 1016 | vector<_Tp, _Allocator>::operator=(const vector& __x) { | |
| 1017 | if (this != std::addressof(__x)) { | |
| 1018 | __copy_assign_alloc(__x); | |
| 1019 | assign(__x.__begin_, __x.__end_); | |
| 1020 | } | |
| 1021 | return *this; | |
| 1022 | } | |
| 1023 | ||
| 1024 | template <class _Tp, class _Allocator> | |
| 1025 | template <class _Iterator, class _Sentinel> | |
| 1026 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 1027 | vector<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) { | |
| 1028 | pointer __cur = __begin_; | |
| 1029 | for (; __first != __last && __cur != __end_; ++__first, (void)++__cur) | |
| 1030 | *__cur = *__first; | |
| 1031 | if (__cur != __end_) { | |
| 1032 | __destruct_at_end(__cur); | |
| 1033 | } else { | |
| 1034 | for (; __first != __last; ++__first) | |
| 1035 | emplace_back(*__first); | |
| 1036 | } | |
| 1037 | } | |
| 1038 | ||
| 1039 | template <class _Tp, class _Allocator> | |
| 1040 | template <class _Iterator, class _Sentinel> | |
| 1041 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 1042 | vector<_Tp, _Allocator>::__assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n) { | |
| 1043 | size_type __new_size = static_cast<size_type>(__n); | |
| 1044 | if (__new_size <= capacity()) { | |
| 1045 | if (__new_size > size()) { | |
| 1046 | #if _LIBCPP_STD_VER >= 23 | |
| 1047 | auto __mid = ranges::copy_n(std::move(__first), size(), this->__begin_).in; | |
| 1048 | __construct_at_end(std::move(__mid), std::move(__last), __new_size - size()); | |
| 1049 | #else | |
| 1050 | _Iterator __mid = std::next(__first, size()); | |
| 1051 | std::copy(__first, __mid, this->__begin_); | |
| 1052 | __construct_at_end(__mid, __last, __new_size - size()); | |
| 1053 | #endif | |
| 1054 | } else { | |
| 1055 | pointer __m = std::__copy(std::move(__first), __last, this->__begin_).second; | |
| 1056 | this->__destruct_at_end(__m); | |
| 1057 | } | |
| 1058 | } else { | |
| 1059 | __vdeallocate(); | |
| 1060 | __vallocate(__recommend(__new_size)); | |
| 1061 | __construct_at_end(std::move(__first), std::move(__last), __new_size); | |
| 1062 | } | |
| 1063 | } | |
| 1064 | ||
| 1065 | template <class _Tp, class _Allocator> | |
| 1066 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) { | |
| 1067 | if (__n <= capacity()) { | |
| 1068 | size_type __s = size(); | |
| 1069 | std::fill_n(this->__begin_, std::min(__n, __s), __u); | |
| 1070 | if (__n > __s) | |
| 1071 | __construct_at_end(__n - __s, __u); | |
| 1072 | else | |
| 1073 | this->__destruct_at_end(this->__begin_ + __n); | |
| 1074 | } else { | |
| 1075 | __vdeallocate(); | |
| 1076 | __vallocate(__recommend(static_cast<size_type>(__n))); | |
| 1077 | __construct_at_end(__n, __u); | |
| 1078 | } | |
| 1079 | } | |
| 1080 | ||
| 1081 | template <class _Tp, class _Allocator> | |
| 1082 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __n) { | |
| 1083 | if (__n > capacity()) { | |
| 1084 | if (__n > max_size()) | |
| 1085 | this->__throw_length_error(); | |
| 1086 | __split_buffer<value_type, allocator_type&> __v(__n, size(), this->__alloc_); | |
| 1087 | __swap_out_circular_buffer(__v); | |
| 1088 | } | |
| 1089 | } | |
| 1090 | ||
| 1091 | template <class _Tp, class _Allocator> | |
| 1092 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { | |
| 1093 | if (capacity() > size()) { | |
| 1094 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 1095 | try { | |
| 1096 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1097 | __split_buffer<value_type, allocator_type&> __v(size(), size(), this->__alloc_); | |
| 1098 | // The Standard mandates shrink_to_fit() does not increase the capacity. | |
| 1099 | // With equal capacity keep the existing buffer. This avoids extra work | |
| 1100 | // due to swapping the elements. | |
| 1101 | if (__v.capacity() < capacity()) | |
| 1102 | __swap_out_circular_buffer(__v); | |
| 1103 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 1104 | } catch (...) { | |
| 1105 | } | |
| 1106 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1107 | } | |
| 1108 | } | |
| 1109 | ||
| 1110 | template <class _Tp, class _Allocator> | |
| 1111 | template <class... _Args> | |
| 1112 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer | |
| 1113 | vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) { | |
| 1114 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), this->__alloc_); | |
| 1115 | // __v.emplace_back(std::forward<_Args>(__args)...); | |
| 1116 | __alloc_traits::construct(this->__alloc_, std::__to_address(__v.__end_), std::forward<_Args>(__args)...); | |
| 1117 | __v.__end_++; | |
| 1118 | __swap_out_circular_buffer(__v); | |
| 1119 | return this->__end_; | |
| 1120 | } | |
| 1121 | ||
| 1122 | template <class _Tp, class _Allocator> | |
| 1123 | template <class... _Args> | |
| 1124 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline | |
| 1125 | #if _LIBCPP_STD_VER >= 17 | |
| 1126 | typename vector<_Tp, _Allocator>::reference | |
| 1127 | #else | |
| 1128 | void | |
| 1129 | #endif | |
| 1130 | vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { | |
| 1131 | pointer __end = this->__end_; | |
| 1132 | if (__end < this->__cap_) { | |
| 1133 | __construct_one_at_end(std::forward<_Args>(__args)...); | |
| 1134 | ++__end; | |
| 1135 | } else { | |
| 1136 | __end = __emplace_back_slow_path(std::forward<_Args>(__args)...); | |
| 1137 | } | |
| 1138 | this->__end_ = __end; | |
| 1139 | #if _LIBCPP_STD_VER >= 17 | |
| 1140 | return *(__end - 1); | |
| 1141 | #endif | |
| 1142 | } | |
| 1143 | ||
| 1144 | template <class _Tp, class _Allocator> | |
| 1145 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator | |
| 1146 | vector<_Tp, _Allocator>::erase(const_iterator __position) { | |
| 1147 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 1148 | __position != end(), "vector::erase(iterator) called with a non-dereferenceable iterator"); | |
| 1149 | difference_type __ps = __position - cbegin(); | |
| 1150 | pointer __p = this->__begin_ + __ps; | |
| 1151 | this->__destruct_at_end(std::move(__p + 1, this->__end_, __p)); | |
| 1152 | return __make_iter(__p); | |
| 1153 | } | |
| 1154 | ||
| 1155 | template <class _Tp, class _Allocator> | |
| 1156 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1157 | vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) { | |
| 1158 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "vector::erase(first, last) called with invalid range"); | |
| 1159 | pointer __p = this->__begin_ + (__first - begin()); | |
| 1160 | if (__first != __last) { | |
| 1161 | this->__destruct_at_end(std::move(__p + (__last - __first), this->__end_, __p)); | |
| 1162 | } | |
| 1163 | return __make_iter(__p); | |
| 1164 | } | |
| 1165 | ||
| 1166 | template <class _Tp, class _Allocator> | |
| 1167 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 1168 | vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) { | |
| 1169 | pointer __old_last = this->__end_; | |
| 1170 | difference_type __n = __old_last - __to; | |
| 1171 | { | |
| 1172 | pointer __i = __from_s + __n; | |
| 1173 | _ConstructTransaction __tx(*this, __from_e - __i); | |
| 1174 | for (pointer __pos = __tx.__pos_; __i < __from_e; ++__i, (void)++__pos, __tx.__pos_ = __pos) { | |
| 1175 | __alloc_traits::construct(this->__alloc_, std::__to_address(__pos), std::move(*__i)); | |
| 1176 | } | |
| 1177 | } | |
| 1178 | std::move_backward(__from_s, __from_s + __n, __old_last); | |
| 1179 | } | |
| 1180 | ||
| 1181 | template <class _Tp, class _Allocator> | |
| 1182 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1183 | vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) { | |
| 1184 | pointer __p = this->__begin_ + (__position - begin()); | |
| 1185 | if (this->__end_ < this->__cap_) { | |
| 1186 | if (__p == this->__end_) { | |
| 1187 | __construct_one_at_end(__x); | |
| 1188 | } else { | |
| 1189 | __move_range(__p, this->__end_, __p + 1); | |
| 1190 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); | |
| 1191 | if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x))) | |
| 1192 | ++__xr; | |
| 1193 | *__p = *__xr; | |
| 1194 | } | |
| 1195 | } else { | |
| 1196 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_); | |
| 1197 | __v.emplace_back(__x); | |
| 1198 | __p = __swap_out_circular_buffer(__v, __p); | |
| 1199 | } | |
| 1200 | return __make_iter(__p); | |
| 1201 | } | |
| 1202 | ||
| 1203 | template <class _Tp, class _Allocator> | |
| 1204 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1205 | vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { | |
| 1206 | pointer __p = this->__begin_ + (__position - begin()); | |
| 1207 | if (this->__end_ < this->__cap_) { | |
| 1208 | if (__p == this->__end_) { | |
| 1209 | __construct_one_at_end(std::move(__x)); | |
| 1210 | } else { | |
| 1211 | __move_range(__p, this->__end_, __p + 1); | |
| 1212 | *__p = std::move(__x); | |
| 1213 | } | |
| 1214 | } else { | |
| 1215 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_); | |
| 1216 | __v.emplace_back(std::move(__x)); | |
| 1217 | __p = __swap_out_circular_buffer(__v, __p); | |
| 1218 | } | |
| 1219 | return __make_iter(__p); | |
| 1220 | } | |
| 1221 | ||
| 1222 | template <class _Tp, class _Allocator> | |
| 1223 | template <class... _Args> | |
| 1224 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1225 | vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { | |
| 1226 | pointer __p = this->__begin_ + (__position - begin()); | |
| 1227 | if (this->__end_ < this->__cap_) { | |
| 1228 | if (__p == this->__end_) { | |
| 1229 | __construct_one_at_end(std::forward<_Args>(__args)...); | |
| 1230 | } else { | |
| 1231 | __temp_value<value_type, _Allocator> __tmp(this->__alloc_, std::forward<_Args>(__args)...); | |
| 1232 | __move_range(__p, this->__end_, __p + 1); | |
| 1233 | *__p = std::move(__tmp.get()); | |
| 1234 | } | |
| 1235 | } else { | |
| 1236 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_); | |
| 1237 | __v.emplace_back(std::forward<_Args>(__args)...); | |
| 1238 | __p = __swap_out_circular_buffer(__v, __p); | |
| 1239 | } | |
| 1240 | return __make_iter(__p); | |
| 1241 | } | |
| 1242 | ||
| 1243 | template <class _Tp, class _Allocator> | |
| 1244 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1245 | vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) { | |
| 1246 | pointer __p = this->__begin_ + (__position - begin()); | |
| 1247 | if (__n > 0) { | |
| 1248 | // We can't compare unrelated pointers inside constant expressions | |
| 1249 | if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__cap_ - this->__end_)) { | |
| 1250 | size_type __old_n = __n; | |
| 1251 | pointer __old_last = this->__end_; | |
| 1252 | if (__n > static_cast<size_type>(this->__end_ - __p)) { | |
| 1253 | size_type __cx = __n - (this->__end_ - __p); | |
| 1254 | __construct_at_end(__cx, __x); | |
| 1255 | __n -= __cx; | |
| 1256 | } | |
| 1257 | if (__n > 0) { | |
| 1258 | __move_range(__p, __old_last, __p + __old_n); | |
| 1259 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); | |
| 1260 | if (__p <= __xr && __xr < this->__end_) | |
| 1261 | __xr += __old_n; | |
| 1262 | std::fill_n(__p, __n, *__xr); | |
| 1263 | } | |
| 1264 | } else { | |
| 1265 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_); | |
| 1266 | __v.__construct_at_end(__n, __x); | |
| 1267 | __p = __swap_out_circular_buffer(__v, __p); | |
| 1268 | } | |
| 1269 | } | |
| 1270 | return __make_iter(__p); | |
| 1271 | } | |
| 1272 | ||
| 1273 | template <class _Tp, class _Allocator> | |
| 1274 | template <class _InputIterator, class _Sentinel> | |
| 1275 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator | |
| 1276 | vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) { | |
| 1277 | difference_type __off = __position - begin(); | |
| 1278 | pointer __p = this->__begin_ + __off; | |
| 1279 | pointer __old_last = this->__end_; | |
| 1280 | for (; this->__end_ != this->__cap_ && __first != __last; ++__first) | |
| 1281 | __construct_one_at_end(*__first); | |
| 1282 | ||
| 1283 | if (__first == __last) | |
| 1284 | (void)std::rotate(__p, __old_last, this->__end_); | |
| 1285 | else { | |
| 1286 | __split_buffer<value_type, allocator_type&> __v(__alloc_); | |
| 1287 | auto __guard = std::__make_exception_guard( | |
| 1288 | _AllocatorDestroyRangeReverse<allocator_type, pointer>(__alloc_, __old_last, this->__end_)); | |
| 1289 | __v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last)); | |
| 1290 | __split_buffer<value_type, allocator_type&> __merged( | |
| 1291 | __recommend(size() + __v.size()), __off, __alloc_); // has `__off` positions available at the front | |
| 1292 | std::__uninitialized_allocator_relocate( | |
| 1293 | __alloc_, std::__to_address(__old_last), std::__to_address(this->__end_), std::__to_address(__merged.__end_)); | |
| 1294 | __guard.__complete(); // Release the guard once objects in [__old_last_, __end_) have been successfully relocated. | |
| 1295 | __merged.__end_ += this->__end_ - __old_last; | |
| 1296 | this->__end_ = __old_last; | |
| 1297 | std::__uninitialized_allocator_relocate( | |
| 1298 | __alloc_, std::__to_address(__v.__begin_), std::__to_address(__v.__end_), std::__to_address(__merged.__end_)); | |
| 1299 | __merged.__end_ += __v.size(); | |
| 1300 | __v.__end_ = __v.__begin_; | |
| 1301 | __p = __swap_out_circular_buffer(__merged, __p); | |
| 1302 | } | |
| 1303 | return __make_iter(__p); | |
| 1304 | } | |
| 1305 | ||
| 1306 | template <class _Tp, class _Allocator> | |
| 1307 | template <class _Iterator, class _Sentinel> | |
| 1308 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator | |
| 1309 | vector<_Tp, _Allocator>::__insert_with_size( | |
| 1310 | const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n) { | |
| 1311 | pointer __p = this->__begin_ + (__position - begin()); | |
| 1312 | if (__n > 0) { | |
| 1313 | if (__n <= this->__cap_ - this->__end_) { | |
| 1314 | pointer __old_last = this->__end_; | |
| 1315 | difference_type __dx = this->__end_ - __p; | |
| 1316 | if (__n > __dx) { | |
| 1317 | #if _LIBCPP_STD_VER >= 23 | |
| 1318 | if constexpr (!forward_iterator<_Iterator>) { | |
| 1319 | __construct_at_end(std::move(__first), std::move(__last), __n); | |
| 1320 | std::rotate(__p, __old_last, this->__end_); | |
| 1321 | } else | |
| 1322 | #endif | |
| 1323 | { | |
| 1324 | _Iterator __m = std::next(__first, __dx); | |
| 1325 | __construct_at_end(__m, __last, __n - __dx); | |
| 1326 | if (__dx > 0) { | |
| 1327 | __move_range(__p, __old_last, __p + __n); | |
| 1328 | std::copy(__first, __m, __p); | |
| 1329 | } | |
| 1330 | } | |
| 1331 | } else { | |
| 1332 | __move_range(__p, __old_last, __p + __n); | |
| 1333 | #if _LIBCPP_STD_VER >= 23 | |
| 1334 | if constexpr (!forward_iterator<_Iterator>) { | |
| 1335 | ranges::copy_n(std::move(__first), __n, __p); | |
| 1336 | } else | |
| 1337 | #endif | |
| 1338 | { | |
| 1339 | std::copy_n(__first, __n, __p); | |
| 1340 | } | |
| 1341 | } | |
| 1342 | } else { | |
| 1343 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_); | |
| 1344 | __v.__construct_at_end_with_size(std::move(__first), __n); | |
| 1345 | __p = __swap_out_circular_buffer(__v, __p); | |
| 1346 | } | |
| 1347 | } | |
| 1348 | return __make_iter(__p); | |
| 1349 | } | |
| 1350 | ||
| 1351 | template <class _Tp, class _Allocator> | |
| 1352 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz) { | |
| 1353 | size_type __cs = size(); | |
| 1354 | if (__cs < __sz) | |
| 1355 | this->__append(__sz - __cs); | |
| 1356 | else if (__cs > __sz) | |
| 1357 | this->__destruct_at_end(this->__begin_ + __sz); | |
| 1358 | } | |
| 1359 | ||
| 1360 | template <class _Tp, class _Allocator> | |
| 1361 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) { | |
| 1362 | size_type __cs = size(); | |
| 1363 | if (__cs < __sz) | |
| 1364 | this->__append(__sz - __cs, __x); | |
| 1365 | else if (__cs > __sz) | |
| 1366 | this->__destruct_at_end(this->__begin_ + __sz); | |
| 1367 | } | |
| 1368 | ||
| 1369 | template <class _Tp, class _Allocator> | |
| 1370 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x) | |
| 1371 | #if _LIBCPP_STD_VER >= 14 | |
| 1372 | _NOEXCEPT | |
| 1373 | #else | |
| 1374 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) | |
| 1375 | #endif | |
| 1376 | { | |
| 1377 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( | |
| 1378 | __alloc_traits::propagate_on_container_swap::value || this->__alloc_ == __x.__alloc_, | |
| 1379 | "vector::swap: Either propagate_on_container_swap must be true" | |
| 1380 | " or the allocators must compare equal"); | |
| 1381 | std::swap(this->__begin_, __x.__begin_); | |
| 1382 | std::swap(this->__end_, __x.__end_); | |
| 1383 | std::swap(this->__cap_, __x.__cap_); | |
| 1384 | std::__swap_allocator(this->__alloc_, __x.__alloc_); | |
| 1385 | } | |
| 1386 | ||
| 1387 | template <class _Tp, class _Allocator> | |
| 1388 | _LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<_Tp, _Allocator>::__invariants() const { | |
| 1389 | if (this->__begin_ == nullptr) { | |
| 1390 | if (this->__end_ != nullptr || this->__cap_ != nullptr) | |
| 1391 | return false; | |
| 1392 | } else { | |
| 1393 | if (this->__begin_ > this->__end_) | |
| 1394 | return false; | |
| 1395 | if (this->__begin_ == this->__cap_) | |
| 1396 | return false; | |
| 1397 | if (this->__end_ > this->__cap_) | |
| 1398 | return false; | |
| 1399 | } | |
| 1400 | return true; | |
| 1401 | } | |
| 1402 | ||
| 1403 | #if _LIBCPP_STD_VER >= 20 | |
| 1404 | template <> | |
| 1405 | inline constexpr bool __format::__enable_insertable<vector<char>> = true; | |
| 1406 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1407 | template <> | |
| 1408 | inline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true; | |
| 1409 | # endif | |
| 1410 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1411 | ||
| 1412 | _LIBCPP_END_NAMESPACE_STD | |
| 1413 | ||
| 1414 | _LIBCPP_POP_MACROS | |
| 1415 | ||
| 1416 | #endif // _LIBCPP___VECTOR_VECTOR_H |
lib/libcxx/include/__vector/vector_bool.h created+1131| ... | ... | @@ -0,0 +1,1131 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___VECTOR_VECTOR_BOOL_H | |
| 10 | #define _LIBCPP___VECTOR_VECTOR_BOOL_H | |
| 11 | ||
| 12 | #include <__algorithm/copy.h> | |
| 13 | #include <__algorithm/fill_n.h> | |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 15 | #include <__algorithm/max.h> | |
| 16 | #include <__assert> | |
| 17 | #include <__bit_reference> | |
| 18 | #include <__config> | |
| 19 | #include <__functional/unary_function.h> | |
| 20 | #include <__fwd/bit_reference.h> | |
| 21 | #include <__fwd/functional.h> | |
| 22 | #include <__fwd/vector.h> | |
| 23 | #include <__iterator/distance.h> | |
| 24 | #include <__iterator/iterator_traits.h> | |
| 25 | #include <__iterator/reverse_iterator.h> | |
| 26 | #include <__memory/addressof.h> | |
| 27 | #include <__memory/allocate_at_least.h> | |
| 28 | #include <__memory/allocator.h> | |
| 29 | #include <__memory/allocator_traits.h> | |
| 30 | #include <__memory/compressed_pair.h> | |
| 31 | #include <__memory/construct_at.h> | |
| 32 | #include <__memory/noexcept_move_assign_container.h> | |
| 33 | #include <__memory/pointer_traits.h> | |
| 34 | #include <__memory/swap_allocator.h> | |
| 35 | #include <__ranges/access.h> | |
| 36 | #include <__ranges/concepts.h> | |
| 37 | #include <__ranges/container_compatible_range.h> | |
| 38 | #include <__ranges/from_range.h> | |
| 39 | #include <__type_traits/enable_if.h> | |
| 40 | #include <__type_traits/is_constant_evaluated.h> | |
| 41 | #include <__type_traits/is_nothrow_assignable.h> | |
| 42 | #include <__type_traits/is_nothrow_constructible.h> | |
| 43 | #include <__type_traits/type_identity.h> | |
| 44 | #include <__utility/exception_guard.h> | |
| 45 | #include <__utility/forward.h> | |
| 46 | #include <__utility/move.h> | |
| 47 | #include <__utility/swap.h> | |
| 48 | #include <climits> | |
| 49 | #include <initializer_list> | |
| 50 | #include <limits> | |
| 51 | #include <stdexcept> | |
| 52 | ||
| 53 | // These headers define parts of vectors definition, since they define ADL functions or class specializations. | |
| 54 | #include <__vector/comparison.h> | |
| 55 | #include <__vector/container_traits.h> | |
| 56 | #include <__vector/swap.h> | |
| 57 | ||
| 58 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 59 | # pragma GCC system_header | |
| 60 | #endif | |
| 61 | ||
| 62 | _LIBCPP_PUSH_MACROS | |
| 63 | #include <__undef_macros> | |
| 64 | ||
| 65 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 66 | ||
| 67 | template <class _Allocator> | |
| 68 | struct hash<vector<bool, _Allocator> >; | |
| 69 | ||
| 70 | template <class _Allocator> | |
| 71 | struct __has_storage_type<vector<bool, _Allocator> > { | |
| 72 | static const bool value = true; | |
| 73 | }; | |
| 74 | ||
| 75 | template <class _Allocator> | |
| 76 | class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> { | |
| 77 | public: | |
| 78 | typedef vector __self; | |
| 79 | typedef bool value_type; | |
| 80 | typedef _Allocator allocator_type; | |
| 81 | typedef allocator_traits<allocator_type> __alloc_traits; | |
| 82 | typedef typename __alloc_traits::size_type size_type; | |
| 83 | typedef typename __alloc_traits::difference_type difference_type; | |
| 84 | typedef size_type __storage_type; | |
| 85 | typedef __bit_iterator<vector, false> pointer; | |
| 86 | typedef __bit_iterator<vector, true> const_pointer; | |
| 87 | typedef pointer iterator; | |
| 88 | typedef const_pointer const_iterator; | |
| 89 | typedef std::reverse_iterator<iterator> reverse_iterator; | |
| 90 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 91 | ||
| 92 | private: | |
| 93 | typedef __rebind_alloc<__alloc_traits, __storage_type> __storage_allocator; | |
| 94 | typedef allocator_traits<__storage_allocator> __storage_traits; | |
| 95 | typedef typename __storage_traits::pointer __storage_pointer; | |
| 96 | typedef typename __storage_traits::const_pointer __const_storage_pointer; | |
| 97 | ||
| 98 | __storage_pointer __begin_; | |
| 99 | size_type __size_; | |
| 100 | _LIBCPP_COMPRESSED_PAIR(size_type, __cap_, __storage_allocator, __alloc_); | |
| 101 | ||
| 102 | public: | |
| 103 | typedef __bit_reference<vector> reference; | |
| 104 | #ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | |
| 105 | using const_reference = bool; | |
| 106 | #else | |
| 107 | typedef __bit_const_reference<vector> const_reference; | |
| 108 | #endif | |
| 109 | ||
| 110 | private: | |
| 111 | static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); | |
| 112 | ||
| 113 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type | |
| 114 | __internal_cap_to_external(size_type __n) _NOEXCEPT { | |
| 115 | return __n * __bits_per_word; | |
| 116 | } | |
| 117 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type | |
| 118 | __external_cap_to_internal(size_type __n) _NOEXCEPT { | |
| 119 | return __n > 0 ? (__n - 1) / __bits_per_word + 1 : size_type(0); | |
| 120 | } | |
| 121 | ||
| 122 | public: | |
| 123 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector() | |
| 124 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); | |
| 125 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(const allocator_type& __a) | |
| 127 | #if _LIBCPP_STD_VER <= 14 | |
| 128 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); | |
| 129 | #else | |
| 130 | _NOEXCEPT; | |
| 131 | #endif | |
| 132 | ||
| 133 | private: | |
| 134 | class __destroy_vector { | |
| 135 | public: | |
| 136 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {} | |
| 137 | ||
| 138 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() { | |
| 139 | if (__vec_.__begin_ != nullptr) | |
| 140 | __storage_traits::deallocate(__vec_.__alloc_, __vec_.__begin_, __vec_.__cap_); | |
| 141 | } | |
| 142 | ||
| 143 | private: | |
| 144 | vector& __vec_; | |
| 145 | }; | |
| 146 | ||
| 147 | public: | |
| 148 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector() { __destroy_vector (*this)(); } | |
| 149 | ||
| 150 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n); | |
| 151 | #if _LIBCPP_STD_VER >= 14 | |
| 152 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n, const allocator_type& __a); | |
| 153 | #endif | |
| 154 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v); | |
| 155 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 156 | vector(size_type __n, const value_type& __v, const allocator_type& __a); | |
| 157 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | |
| 158 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last); | |
| 159 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | |
| 160 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 161 | vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a); | |
| 162 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | |
| 163 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last); | |
| 164 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | |
| 165 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 166 | vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a); | |
| 167 | ||
| 168 | #if _LIBCPP_STD_VER >= 23 | |
| 169 | template <_ContainerCompatibleRange<bool> _Range> | |
| 170 | _LIBCPP_HIDE_FROM_ABI constexpr vector(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) | |
| 171 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { | |
| 172 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 173 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 174 | __init_with_size(ranges::begin(__range), ranges::end(__range), __n); | |
| 175 | ||
| 176 | } else { | |
| 177 | __init_with_sentinel(ranges::begin(__range), ranges::end(__range)); | |
| 178 | } | |
| 179 | } | |
| 180 | #endif | |
| 181 | ||
| 182 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v); | |
| 183 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v, const allocator_type& __a); | |
| 184 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(const vector& __v); | |
| 185 | ||
| 186 | #ifndef _LIBCPP_CXX03_LANG | |
| 187 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il); | |
| 188 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 189 | vector(initializer_list<value_type> __il, const allocator_type& __a); | |
| 190 | ||
| 191 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(initializer_list<value_type> __il) { | |
| 192 | assign(__il.begin(), __il.end()); | |
| 193 | return *this; | |
| 194 | } | |
| 195 | ||
| 196 | #endif // !_LIBCPP_CXX03_LANG | |
| 197 | ||
| 198 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(vector&& __v) | |
| 199 | #if _LIBCPP_STD_VER >= 17 | |
| 200 | noexcept; | |
| 201 | #else | |
| 202 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | |
| 203 | #endif | |
| 204 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 205 | vector(vector&& __v, const __type_identity_t<allocator_type>& __a); | |
| 206 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(vector&& __v) | |
| 207 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value); | |
| 208 | ||
| 209 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | |
| 210 | void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last); | |
| 211 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | |
| 212 | void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_ForwardIterator __first, _ForwardIterator __last); | |
| 213 | ||
| 214 | #if _LIBCPP_STD_VER >= 23 | |
| 215 | template <_ContainerCompatibleRange<bool> _Range> | |
| 216 | _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) { | |
| 217 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 218 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 219 | __assign_with_size(ranges::begin(__range), ranges::end(__range), __n); | |
| 220 | ||
| 221 | } else { | |
| 222 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); | |
| 223 | } | |
| 224 | } | |
| 225 | #endif | |
| 226 | ||
| 227 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(size_type __n, const value_type& __x); | |
| 228 | ||
| 229 | #ifndef _LIBCPP_CXX03_LANG | |
| 230 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(initializer_list<value_type> __il) { | |
| 231 | assign(__il.begin(), __il.end()); | |
| 232 | } | |
| 233 | #endif | |
| 234 | ||
| 235 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT { | |
| 236 | return allocator_type(this->__alloc_); | |
| 237 | } | |
| 238 | ||
| 239 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT; | |
| 240 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT { | |
| 241 | return __internal_cap_to_external(__cap_); | |
| 242 | } | |
| 243 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { return __size_; } | |
| 244 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { | |
| 245 | return __size_ == 0; | |
| 246 | } | |
| 247 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n); | |
| 248 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT; | |
| 249 | ||
| 250 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { return __make_iter(0); } | |
| 251 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT { return __make_iter(0); } | |
| 252 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT { return __make_iter(__size_); } | |
| 253 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT { | |
| 254 | return __make_iter(__size_); | |
| 255 | } | |
| 256 | ||
| 257 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT { | |
| 258 | return reverse_iterator(end()); | |
| 259 | } | |
| 260 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rbegin() const _NOEXCEPT { | |
| 261 | return const_reverse_iterator(end()); | |
| 262 | } | |
| 263 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rend() _NOEXCEPT { | |
| 264 | return reverse_iterator(begin()); | |
| 265 | } | |
| 266 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rend() const _NOEXCEPT { | |
| 267 | return const_reverse_iterator(begin()); | |
| 268 | } | |
| 269 | ||
| 270 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cbegin() const _NOEXCEPT { return __make_iter(0); } | |
| 271 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cend() const _NOEXCEPT { | |
| 272 | return __make_iter(__size_); | |
| 273 | } | |
| 274 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crbegin() const _NOEXCEPT { | |
| 275 | return rbegin(); | |
| 276 | } | |
| 277 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | |
| 278 | ||
| 279 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __n) { | |
| 280 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector<bool>::operator[] index out of bounds"); | |
| 281 | return __make_ref(__n); | |
| 282 | } | |
| 283 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __n) const { | |
| 284 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector<bool>::operator[] index out of bounds"); | |
| 285 | return __make_ref(__n); | |
| 286 | } | |
| 287 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference at(size_type __n); | |
| 288 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference at(size_type __n) const; | |
| 289 | ||
| 290 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() { | |
| 291 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::front() called on an empty vector"); | |
| 292 | return __make_ref(0); | |
| 293 | } | |
| 294 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const { | |
| 295 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::front() called on an empty vector"); | |
| 296 | return __make_ref(0); | |
| 297 | } | |
| 298 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() { | |
| 299 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::back() called on an empty vector"); | |
| 300 | return __make_ref(__size_ - 1); | |
| 301 | } | |
| 302 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const { | |
| 303 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::back() called on an empty vector"); | |
| 304 | return __make_ref(__size_ - 1); | |
| 305 | } | |
| 306 | ||
| 307 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(const value_type& __x); | |
| 308 | #if _LIBCPP_STD_VER >= 14 | |
| 309 | template <class... _Args> | |
| 310 | # if _LIBCPP_STD_VER >= 17 | |
| 311 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference emplace_back(_Args&&... __args) | |
| 312 | # else | |
| 313 | _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args) | |
| 314 | # endif | |
| 315 | { | |
| 316 | push_back(value_type(std::forward<_Args>(__args)...)); | |
| 317 | # if _LIBCPP_STD_VER >= 17 | |
| 318 | return this->back(); | |
| 319 | # endif | |
| 320 | } | |
| 321 | #endif | |
| 322 | ||
| 323 | #if _LIBCPP_STD_VER >= 23 | |
| 324 | template <_ContainerCompatibleRange<bool> _Range> | |
| 325 | _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) { | |
| 326 | insert_range(end(), std::forward<_Range>(__range)); | |
| 327 | } | |
| 328 | #endif | |
| 329 | ||
| 330 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back() { | |
| 331 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector<bool>::pop_back called on an empty vector"); | |
| 332 | --__size_; | |
| 333 | } | |
| 334 | ||
| 335 | #if _LIBCPP_STD_VER >= 14 | |
| 336 | template <class... _Args> | |
| 337 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator emplace(const_iterator __position, _Args&&... __args) { | |
| 338 | return insert(__position, value_type(std::forward<_Args>(__args)...)); | |
| 339 | } | |
| 340 | #endif | |
| 341 | ||
| 342 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, const value_type& __x); | |
| 343 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator | |
| 344 | insert(const_iterator __position, size_type __n, const value_type& __x); | |
| 345 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | |
| 346 | iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 347 | insert(const_iterator __position, _InputIterator __first, _InputIterator __last); | |
| 348 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | |
| 349 | iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 350 | insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); | |
| 351 | ||
| 352 | #if _LIBCPP_STD_VER >= 23 | |
| 353 | template <_ContainerCompatibleRange<bool> _Range> | |
| 354 | _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) { | |
| 355 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 356 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 357 | return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n); | |
| 358 | ||
| 359 | } else { | |
| 360 | return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); | |
| 361 | } | |
| 362 | } | |
| 363 | #endif | |
| 364 | ||
| 365 | #ifndef _LIBCPP_CXX03_LANG | |
| 366 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator | |
| 367 | insert(const_iterator __position, initializer_list<value_type> __il) { | |
| 368 | return insert(__position, __il.begin(), __il.end()); | |
| 369 | } | |
| 370 | #endif | |
| 371 | ||
| 372 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __position); | |
| 373 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __first, const_iterator __last); | |
| 374 | ||
| 375 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT { __size_ = 0; } | |
| 376 | ||
| 377 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(vector&) | |
| 378 | #if _LIBCPP_STD_VER >= 14 | |
| 379 | _NOEXCEPT; | |
| 380 | #else | |
| 381 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); | |
| 382 | #endif | |
| 383 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT { | |
| 384 | std::swap(__x, __y); | |
| 385 | } | |
| 386 | ||
| 387 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __sz, value_type __x = false); | |
| 388 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT; | |
| 389 | ||
| 390 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const; | |
| 391 | ||
| 392 | private: | |
| 393 | [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_length_error() { std::__throw_length_error("vector"); } | |
| 394 | ||
| 395 | [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_out_of_range() { std::__throw_out_of_range("vector"); } | |
| 396 | ||
| 397 | template <class _InputIterator, class _Sentinel> | |
| 398 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 399 | __init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) { | |
| 400 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 401 | ||
| 402 | if (__n > 0) { | |
| 403 | __vallocate(__n); | |
| 404 | __construct_at_end(std::move(__first), std::move(__last), __n); | |
| 405 | } | |
| 406 | ||
| 407 | __guard.__complete(); | |
| 408 | } | |
| 409 | ||
| 410 | template <class _InputIterator, class _Sentinel> | |
| 411 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 412 | __init_with_sentinel(_InputIterator __first, _Sentinel __last) { | |
| 413 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 414 | ||
| 415 | for (; __first != __last; ++__first) | |
| 416 | push_back(*__first); | |
| 417 | ||
| 418 | __guard.__complete(); | |
| 419 | } | |
| 420 | ||
| 421 | template <class _Iterator, class _Sentinel> | |
| 422 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last); | |
| 423 | ||
| 424 | // The `_Iterator` in `*_with_size` functions can be input-only only if called from `*_range` (since C++23). | |
| 425 | // Otherwise, `_Iterator` is a forward iterator. | |
| 426 | ||
| 427 | template <class _Iterator, class _Sentinel> | |
| 428 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 429 | __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __ns); | |
| 430 | ||
| 431 | template <class _InputIterator, class _Sentinel> | |
| 432 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 433 | __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last); | |
| 434 | ||
| 435 | template <class _Iterator, class _Sentinel> | |
| 436 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 437 | __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n); | |
| 438 | ||
| 439 | // Allocate space for __n objects | |
| 440 | // throws length_error if __n > max_size() | |
| 441 | // throws (probably bad_alloc) if memory run out | |
| 442 | // Precondition: __begin_ == __end_ == __cap_ == nullptr | |
| 443 | // Precondition: __n > 0 | |
| 444 | // Postcondition: capacity() >= __n | |
| 445 | // Postcondition: size() == 0 | |
| 446 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) { | |
| 447 | if (__n > max_size()) | |
| 448 | __throw_length_error(); | |
| 449 | auto __allocation = std::__allocate_at_least(__alloc_, __external_cap_to_internal(__n)); | |
| 450 | __begin_ = __allocation.ptr; | |
| 451 | __size_ = 0; | |
| 452 | __cap_ = __allocation.count; | |
| 453 | if (__libcpp_is_constant_evaluated()) { | |
| 454 | for (size_type __i = 0; __i != __cap_; ++__i) | |
| 455 | std::__construct_at(std::__to_address(__begin_) + __i); | |
| 456 | } | |
| 457 | } | |
| 458 | ||
| 459 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vdeallocate() _NOEXCEPT; | |
| 460 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type __align_it(size_type __new_size) _NOEXCEPT { | |
| 461 | return (__new_size + (__bits_per_word - 1)) & ~((size_type)__bits_per_word - 1); | |
| 462 | } | |
| 463 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __new_size) const; | |
| 464 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_at_end(size_type __n, bool __x); | |
| 465 | template <class _InputIterator, class _Sentinel> | |
| 466 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 467 | __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n); | |
| 468 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference __make_ref(size_type __pos) _NOEXCEPT { | |
| 469 | return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word); | |
| 470 | } | |
| 471 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference __make_ref(size_type __pos) const _NOEXCEPT { | |
| 472 | return __bit_const_reference<vector>( | |
| 473 | __begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word); | |
| 474 | } | |
| 475 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iter(size_type __pos) _NOEXCEPT { | |
| 476 | return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word)); | |
| 477 | } | |
| 478 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_iter(size_type __pos) const _NOEXCEPT { | |
| 479 | return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word)); | |
| 480 | } | |
| 481 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT { | |
| 482 | return begin() + (__p - cbegin()); | |
| 483 | } | |
| 484 | ||
| 485 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector& __v) { | |
| 486 | __copy_assign_alloc( | |
| 487 | __v, integral_constant<bool, __storage_traits::propagate_on_container_copy_assignment::value>()); | |
| 488 | } | |
| 489 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector& __c, true_type) { | |
| 490 | if (__alloc_ != __c.__alloc_) | |
| 491 | __vdeallocate(); | |
| 492 | __alloc_ = __c.__alloc_; | |
| 493 | } | |
| 494 | ||
| 495 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector&, false_type) {} | |
| 496 | ||
| 497 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, false_type); | |
| 498 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, true_type) | |
| 499 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | |
| 500 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector& __c) | |
| 501 | _NOEXCEPT_(!__storage_traits::propagate_on_container_move_assignment::value || | |
| 502 | is_nothrow_move_assignable<allocator_type>::value) { | |
| 503 | __move_assign_alloc( | |
| 504 | __c, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>()); | |
| 505 | } | |
| 506 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector& __c, true_type) | |
| 507 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | |
| 508 | __alloc_ = std::move(__c.__alloc_); | |
| 509 | } | |
| 510 | ||
| 511 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector&, false_type) _NOEXCEPT {} | |
| 512 | ||
| 513 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t __hash_code() const _NOEXCEPT; | |
| 514 | ||
| 515 | friend class __bit_reference<vector>; | |
| 516 | friend class __bit_const_reference<vector>; | |
| 517 | friend class __bit_iterator<vector, false>; | |
| 518 | friend class __bit_iterator<vector, true>; | |
| 519 | friend struct __bit_array<vector>; | |
| 520 | friend struct _LIBCPP_TEMPLATE_VIS hash<vector>; | |
| 521 | }; | |
| 522 | ||
| 523 | template <class _Allocator> | |
| 524 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT { | |
| 525 | if (this->__begin_ != nullptr) { | |
| 526 | __storage_traits::deallocate(this->__alloc_, this->__begin_, __cap_); | |
| 527 | this->__begin_ = nullptr; | |
| 528 | this->__size_ = this->__cap_ = 0; | |
| 529 | } | |
| 530 | } | |
| 531 | ||
| 532 | template <class _Allocator> | |
| 533 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type | |
| 534 | vector<bool, _Allocator>::max_size() const _NOEXCEPT { | |
| 535 | size_type __amax = __storage_traits::max_size(__alloc_); | |
| 536 | size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always | |
| 537 | if (__nmax / __bits_per_word <= __amax) | |
| 538 | return __nmax; | |
| 539 | return __internal_cap_to_external(__amax); | |
| 540 | } | |
| 541 | ||
| 542 | // Precondition: __new_size > capacity() | |
| 543 | template <class _Allocator> | |
| 544 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type | |
| 545 | vector<bool, _Allocator>::__recommend(size_type __new_size) const { | |
| 546 | const size_type __ms = max_size(); | |
| 547 | if (__new_size > __ms) | |
| 548 | this->__throw_length_error(); | |
| 549 | const size_type __cap = capacity(); | |
| 550 | if (__cap >= __ms / 2) | |
| 551 | return __ms; | |
| 552 | return std::max(2 * __cap, __align_it(__new_size)); | |
| 553 | } | |
| 554 | ||
| 555 | // Default constructs __n objects starting at __end_ | |
| 556 | // Precondition: __n > 0 | |
| 557 | // Precondition: size() + __n <= capacity() | |
| 558 | // Postcondition: size() == size() + __n | |
| 559 | template <class _Allocator> | |
| 560 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 561 | vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) { | |
| 562 | size_type __old_size = this->__size_; | |
| 563 | this->__size_ += __n; | |
| 564 | if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) { | |
| 565 | if (this->__size_ <= __bits_per_word) | |
| 566 | this->__begin_[0] = __storage_type(0); | |
| 567 | else | |
| 568 | this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); | |
| 569 | } | |
| 570 | std::fill_n(__make_iter(__old_size), __n, __x); | |
| 571 | } | |
| 572 | ||
| 573 | template <class _Allocator> | |
| 574 | template <class _InputIterator, class _Sentinel> | |
| 575 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 576 | vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) { | |
| 577 | size_type __old_size = this->__size_; | |
| 578 | this->__size_ += __n; | |
| 579 | if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) { | |
| 580 | if (this->__size_ <= __bits_per_word) | |
| 581 | this->__begin_[0] = __storage_type(0); | |
| 582 | else | |
| 583 | this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); | |
| 584 | } | |
| 585 | std::__copy(std::move(__first), std::move(__last), __make_iter(__old_size)); | |
| 586 | } | |
| 587 | ||
| 588 | template <class _Allocator> | |
| 589 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector() | |
| 590 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | |
| 591 | : __begin_(nullptr), __size_(0), __cap_(0) {} | |
| 592 | ||
| 593 | template <class _Allocator> | |
| 594 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const allocator_type& __a) | |
| 595 | #if _LIBCPP_STD_VER <= 14 | |
| 596 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) | |
| 597 | #else | |
| 598 | _NOEXCEPT | |
| 599 | #endif | |
| 600 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { | |
| 601 | } | |
| 602 | ||
| 603 | template <class _Allocator> | |
| 604 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n) | |
| 605 | : __begin_(nullptr), __size_(0), __cap_(0) { | |
| 606 | if (__n > 0) { | |
| 607 | __vallocate(__n); | |
| 608 | __construct_at_end(__n, false); | |
| 609 | } | |
| 610 | } | |
| 611 | ||
| 612 | #if _LIBCPP_STD_VER >= 14 | |
| 613 | template <class _Allocator> | |
| 614 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) | |
| 615 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { | |
| 616 | if (__n > 0) { | |
| 617 | __vallocate(__n); | |
| 618 | __construct_at_end(__n, false); | |
| 619 | } | |
| 620 | } | |
| 621 | #endif | |
| 622 | ||
| 623 | template <class _Allocator> | |
| 624 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x) | |
| 625 | : __begin_(nullptr), __size_(0), __cap_(0) { | |
| 626 | if (__n > 0) { | |
| 627 | __vallocate(__n); | |
| 628 | __construct_at_end(__n, __x); | |
| 629 | } | |
| 630 | } | |
| 631 | ||
| 632 | template <class _Allocator> | |
| 633 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 634 | vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) | |
| 635 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { | |
| 636 | if (__n > 0) { | |
| 637 | __vallocate(__n); | |
| 638 | __construct_at_end(__n, __x); | |
| 639 | } | |
| 640 | } | |
| 641 | ||
| 642 | template <class _Allocator> | |
| 643 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > | |
| 644 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last) | |
| 645 | : __begin_(nullptr), __size_(0), __cap_(0) { | |
| 646 | __init_with_sentinel(__first, __last); | |
| 647 | } | |
| 648 | ||
| 649 | template <class _Allocator> | |
| 650 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > | |
| 651 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 652 | vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a) | |
| 653 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { | |
| 654 | __init_with_sentinel(__first, __last); | |
| 655 | } | |
| 656 | ||
| 657 | template <class _Allocator> | |
| 658 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | |
| 659 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last) | |
| 660 | : __begin_(nullptr), __size_(0), __cap_(0) { | |
| 661 | auto __n = static_cast<size_type>(std::distance(__first, __last)); | |
| 662 | __init_with_size(__first, __last, __n); | |
| 663 | } | |
| 664 | ||
| 665 | template <class _Allocator> | |
| 666 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | |
| 667 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 668 | vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a) | |
| 669 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { | |
| 670 | auto __n = static_cast<size_type>(std::distance(__first, __last)); | |
| 671 | __init_with_size(__first, __last, __n); | |
| 672 | } | |
| 673 | ||
| 674 | #ifndef _LIBCPP_CXX03_LANG | |
| 675 | ||
| 676 | template <class _Allocator> | |
| 677 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(initializer_list<value_type> __il) | |
| 678 | : __begin_(nullptr), __size_(0), __cap_(0) { | |
| 679 | size_type __n = static_cast<size_type>(__il.size()); | |
| 680 | if (__n > 0) { | |
| 681 | __vallocate(__n); | |
| 682 | __construct_at_end(__il.begin(), __il.end(), __n); | |
| 683 | } | |
| 684 | } | |
| 685 | ||
| 686 | template <class _Allocator> | |
| 687 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 688 | vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) | |
| 689 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) { | |
| 690 | size_type __n = static_cast<size_type>(__il.size()); | |
| 691 | if (__n > 0) { | |
| 692 | __vallocate(__n); | |
| 693 | __construct_at_end(__il.begin(), __il.end(), __n); | |
| 694 | } | |
| 695 | } | |
| 696 | ||
| 697 | #endif // _LIBCPP_CXX03_LANG | |
| 698 | ||
| 699 | template <class _Allocator> | |
| 700 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v) | |
| 701 | : __begin_(nullptr), | |
| 702 | __size_(0), | |
| 703 | __cap_(0), | |
| 704 | __alloc_(__storage_traits::select_on_container_copy_construction(__v.__alloc_)) { | |
| 705 | if (__v.size() > 0) { | |
| 706 | __vallocate(__v.size()); | |
| 707 | __construct_at_end(__v.begin(), __v.end(), __v.size()); | |
| 708 | } | |
| 709 | } | |
| 710 | ||
| 711 | template <class _Allocator> | |
| 712 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a) | |
| 713 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(__a) { | |
| 714 | if (__v.size() > 0) { | |
| 715 | __vallocate(__v.size()); | |
| 716 | __construct_at_end(__v.begin(), __v.end(), __v.size()); | |
| 717 | } | |
| 718 | } | |
| 719 | ||
| 720 | template <class _Allocator> | |
| 721 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& vector<bool, _Allocator>::operator=(const vector& __v) { | |
| 722 | if (this != std::addressof(__v)) { | |
| 723 | __copy_assign_alloc(__v); | |
| 724 | if (__v.__size_) { | |
| 725 | if (__v.__size_ > capacity()) { | |
| 726 | __vdeallocate(); | |
| 727 | __vallocate(__v.__size_); | |
| 728 | } | |
| 729 | std::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_); | |
| 730 | } | |
| 731 | __size_ = __v.__size_; | |
| 732 | } | |
| 733 | return *this; | |
| 734 | } | |
| 735 | ||
| 736 | template <class _Allocator> | |
| 737 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(vector&& __v) | |
| 738 | #if _LIBCPP_STD_VER >= 17 | |
| 739 | _NOEXCEPT | |
| 740 | #else | |
| 741 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | |
| 742 | #endif | |
| 743 | : __begin_(__v.__begin_), | |
| 744 | __size_(__v.__size_), | |
| 745 | __cap_(__v.__cap_), | |
| 746 | __alloc_(std::move(__v.__alloc_)) { | |
| 747 | __v.__begin_ = nullptr; | |
| 748 | __v.__size_ = 0; | |
| 749 | __v.__cap_ = 0; | |
| 750 | } | |
| 751 | ||
| 752 | template <class _Allocator> | |
| 753 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 754 | vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a) | |
| 755 | : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(__a) { | |
| 756 | if (__a == allocator_type(__v.__alloc_)) { | |
| 757 | this->__begin_ = __v.__begin_; | |
| 758 | this->__size_ = __v.__size_; | |
| 759 | this->__cap_ = __v.__cap_; | |
| 760 | __v.__begin_ = nullptr; | |
| 761 | __v.__cap_ = __v.__size_ = 0; | |
| 762 | } else if (__v.size() > 0) { | |
| 763 | __vallocate(__v.size()); | |
| 764 | __construct_at_end(__v.begin(), __v.end(), __v.size()); | |
| 765 | } | |
| 766 | } | |
| 767 | ||
| 768 | template <class _Allocator> | |
| 769 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& | |
| 770 | vector<bool, _Allocator>::operator=(vector&& __v) | |
| 771 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { | |
| 772 | __move_assign(__v, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>()); | |
| 773 | return *this; | |
| 774 | } | |
| 775 | ||
| 776 | template <class _Allocator> | |
| 777 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vector& __c, false_type) { | |
| 778 | if (__alloc_ != __c.__alloc_) | |
| 779 | assign(__c.begin(), __c.end()); | |
| 780 | else | |
| 781 | __move_assign(__c, true_type()); | |
| 782 | } | |
| 783 | ||
| 784 | template <class _Allocator> | |
| 785 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vector& __c, true_type) | |
| 786 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | |
| 787 | __vdeallocate(); | |
| 788 | __move_assign_alloc(__c); | |
| 789 | this->__begin_ = __c.__begin_; | |
| 790 | this->__size_ = __c.__size_; | |
| 791 | this->__cap_ = __c.__cap_; | |
| 792 | __c.__begin_ = nullptr; | |
| 793 | __c.__cap_ = __c.__size_ = 0; | |
| 794 | } | |
| 795 | ||
| 796 | template <class _Allocator> | |
| 797 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) { | |
| 798 | __size_ = 0; | |
| 799 | if (__n > 0) { | |
| 800 | size_type __c = capacity(); | |
| 801 | if (__n <= __c) | |
| 802 | __size_ = __n; | |
| 803 | else { | |
| 804 | vector __v(get_allocator()); | |
| 805 | __v.reserve(__recommend(__n)); | |
| 806 | __v.__size_ = __n; | |
| 807 | swap(__v); | |
| 808 | } | |
| 809 | std::fill_n(begin(), __n, __x); | |
| 810 | } | |
| 811 | } | |
| 812 | ||
| 813 | template <class _Allocator> | |
| 814 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > | |
| 815 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { | |
| 816 | __assign_with_sentinel(__first, __last); | |
| 817 | } | |
| 818 | ||
| 819 | template <class _Allocator> | |
| 820 | template <class _Iterator, class _Sentinel> | |
| 821 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 822 | vector<bool, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) { | |
| 823 | clear(); | |
| 824 | for (; __first != __last; ++__first) | |
| 825 | push_back(*__first); | |
| 826 | } | |
| 827 | ||
| 828 | template <class _Allocator> | |
| 829 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | |
| 830 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) { | |
| 831 | __assign_with_size(__first, __last, std::distance(__first, __last)); | |
| 832 | } | |
| 833 | ||
| 834 | template <class _Allocator> | |
| 835 | template <class _Iterator, class _Sentinel> | |
| 836 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 837 | vector<bool, _Allocator>::__assign_with_size(_Iterator __first, _Sentinel __last, difference_type __ns) { | |
| 838 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__ns >= 0, "invalid range specified"); | |
| 839 | ||
| 840 | clear(); | |
| 841 | ||
| 842 | const size_t __n = static_cast<size_type>(__ns); | |
| 843 | if (__n) { | |
| 844 | if (__n > capacity()) { | |
| 845 | __vdeallocate(); | |
| 846 | __vallocate(__n); | |
| 847 | } | |
| 848 | __construct_at_end(std::move(__first), std::move(__last), __n); | |
| 849 | } | |
| 850 | } | |
| 851 | ||
| 852 | template <class _Allocator> | |
| 853 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::reserve(size_type __n) { | |
| 854 | if (__n > capacity()) { | |
| 855 | if (__n > max_size()) | |
| 856 | this->__throw_length_error(); | |
| 857 | vector __v(this->get_allocator()); | |
| 858 | __v.__vallocate(__n); | |
| 859 | __v.__construct_at_end(this->begin(), this->end(), this->size()); | |
| 860 | swap(__v); | |
| 861 | } | |
| 862 | } | |
| 863 | ||
| 864 | template <class _Allocator> | |
| 865 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT { | |
| 866 | if (__external_cap_to_internal(size()) < __cap_) { | |
| 867 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 868 | try { | |
| 869 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 870 | vector __v(*this, allocator_type(__alloc_)); | |
| 871 | if (__v.__cap_ < __cap_) | |
| 872 | __v.swap(*this); | |
| 873 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 874 | } catch (...) { | |
| 875 | } | |
| 876 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 877 | } | |
| 878 | } | |
| 879 | ||
| 880 | template <class _Allocator> | |
| 881 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::reference vector<bool, _Allocator>::at(size_type __n) { | |
| 882 | if (__n >= size()) | |
| 883 | this->__throw_out_of_range(); | |
| 884 | return (*this)[__n]; | |
| 885 | } | |
| 886 | ||
| 887 | template <class _Allocator> | |
| 888 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::const_reference | |
| 889 | vector<bool, _Allocator>::at(size_type __n) const { | |
| 890 | if (__n >= size()) | |
| 891 | this->__throw_out_of_range(); | |
| 892 | return (*this)[__n]; | |
| 893 | } | |
| 894 | ||
| 895 | template <class _Allocator> | |
| 896 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::push_back(const value_type& __x) { | |
| 897 | if (this->__size_ == this->capacity()) | |
| 898 | reserve(__recommend(this->__size_ + 1)); | |
| 899 | ++this->__size_; | |
| 900 | back() = __x; | |
| 901 | } | |
| 902 | ||
| 903 | template <class _Allocator> | |
| 904 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 905 | vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x) { | |
| 906 | iterator __r; | |
| 907 | if (size() < capacity()) { | |
| 908 | const_iterator __old_end = end(); | |
| 909 | ++__size_; | |
| 910 | std::copy_backward(__position, __old_end, end()); | |
| 911 | __r = __const_iterator_cast(__position); | |
| 912 | } else { | |
| 913 | vector __v(get_allocator()); | |
| 914 | __v.reserve(__recommend(__size_ + 1)); | |
| 915 | __v.__size_ = __size_ + 1; | |
| 916 | __r = std::copy(cbegin(), __position, __v.begin()); | |
| 917 | std::copy_backward(__position, cend(), __v.end()); | |
| 918 | swap(__v); | |
| 919 | } | |
| 920 | *__r = __x; | |
| 921 | return __r; | |
| 922 | } | |
| 923 | ||
| 924 | template <class _Allocator> | |
| 925 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 926 | vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x) { | |
| 927 | iterator __r; | |
| 928 | size_type __c = capacity(); | |
| 929 | if (__n <= __c && size() <= __c - __n) { | |
| 930 | const_iterator __old_end = end(); | |
| 931 | __size_ += __n; | |
| 932 | std::copy_backward(__position, __old_end, end()); | |
| 933 | __r = __const_iterator_cast(__position); | |
| 934 | } else { | |
| 935 | vector __v(get_allocator()); | |
| 936 | __v.reserve(__recommend(__size_ + __n)); | |
| 937 | __v.__size_ = __size_ + __n; | |
| 938 | __r = std::copy(cbegin(), __position, __v.begin()); | |
| 939 | std::copy_backward(__position, cend(), __v.end()); | |
| 940 | swap(__v); | |
| 941 | } | |
| 942 | std::fill_n(__r, __n, __x); | |
| 943 | return __r; | |
| 944 | } | |
| 945 | ||
| 946 | template <class _Allocator> | |
| 947 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > | |
| 948 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 949 | vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { | |
| 950 | return __insert_with_sentinel(__position, __first, __last); | |
| 951 | } | |
| 952 | ||
| 953 | template <class _Allocator> | |
| 954 | template <class _InputIterator, class _Sentinel> | |
| 955 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<bool, _Allocator>::iterator | |
| 956 | vector<bool, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) { | |
| 957 | difference_type __off = __position - begin(); | |
| 958 | iterator __p = __const_iterator_cast(__position); | |
| 959 | iterator __old_end = end(); | |
| 960 | for (; size() != capacity() && __first != __last; ++__first) { | |
| 961 | ++this->__size_; | |
| 962 | back() = *__first; | |
| 963 | } | |
| 964 | vector __v(get_allocator()); | |
| 965 | if (__first != __last) { | |
| 966 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 967 | try { | |
| 968 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 969 | __v.__assign_with_sentinel(std::move(__first), std::move(__last)); | |
| 970 | difference_type __old_size = static_cast<difference_type>(__old_end - begin()); | |
| 971 | difference_type __old_p = __p - begin(); | |
| 972 | reserve(__recommend(size() + __v.size())); | |
| 973 | __p = begin() + __old_p; | |
| 974 | __old_end = begin() + __old_size; | |
| 975 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 976 | } catch (...) { | |
| 977 | erase(__old_end, end()); | |
| 978 | throw; | |
| 979 | } | |
| 980 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 981 | } | |
| 982 | __p = std::rotate(__p, __old_end, end()); | |
| 983 | insert(__p, __v.begin(), __v.end()); | |
| 984 | return begin() + __off; | |
| 985 | } | |
| 986 | ||
| 987 | template <class _Allocator> | |
| 988 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | |
| 989 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 990 | vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) { | |
| 991 | return __insert_with_size(__position, __first, __last, std::distance(__first, __last)); | |
| 992 | } | |
| 993 | ||
| 994 | template <class _Allocator> | |
| 995 | template <class _Iterator, class _Sentinel> | |
| 996 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<bool, _Allocator>::iterator | |
| 997 | vector<bool, _Allocator>::__insert_with_size( | |
| 998 | const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n_signed) { | |
| 999 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__n_signed >= 0, "invalid range specified"); | |
| 1000 | const size_type __n = static_cast<size_type>(__n_signed); | |
| 1001 | iterator __r; | |
| 1002 | size_type __c = capacity(); | |
| 1003 | if (__n <= __c && size() <= __c - __n) { | |
| 1004 | const_iterator __old_end = end(); | |
| 1005 | __size_ += __n; | |
| 1006 | std::copy_backward(__position, __old_end, end()); | |
| 1007 | __r = __const_iterator_cast(__position); | |
| 1008 | } else { | |
| 1009 | vector __v(get_allocator()); | |
| 1010 | __v.reserve(__recommend(__size_ + __n)); | |
| 1011 | __v.__size_ = __size_ + __n; | |
| 1012 | __r = std::copy(cbegin(), __position, __v.begin()); | |
| 1013 | std::copy_backward(__position, cend(), __v.end()); | |
| 1014 | swap(__v); | |
| 1015 | } | |
| 1016 | std::__copy(std::move(__first), std::move(__last), __r); | |
| 1017 | return __r; | |
| 1018 | } | |
| 1019 | ||
| 1020 | template <class _Allocator> | |
| 1021 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 1022 | vector<bool, _Allocator>::erase(const_iterator __position) { | |
| 1023 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 1024 | __position != end(), "vector<bool>::erase(iterator) called with a non-dereferenceable iterator"); | |
| 1025 | iterator __r = __const_iterator_cast(__position); | |
| 1026 | std::copy(__position + 1, this->cend(), __r); | |
| 1027 | --__size_; | |
| 1028 | return __r; | |
| 1029 | } | |
| 1030 | ||
| 1031 | template <class _Allocator> | |
| 1032 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 1033 | vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) { | |
| 1034 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( | |
| 1035 | __first <= __last, "vector<bool>::erase(iterator, iterator) called with an invalid range"); | |
| 1036 | iterator __r = __const_iterator_cast(__first); | |
| 1037 | difference_type __d = __last - __first; | |
| 1038 | std::copy(__last, this->cend(), __r); | |
| 1039 | __size_ -= __d; | |
| 1040 | return __r; | |
| 1041 | } | |
| 1042 | ||
| 1043 | template <class _Allocator> | |
| 1044 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x) | |
| 1045 | #if _LIBCPP_STD_VER >= 14 | |
| 1046 | _NOEXCEPT | |
| 1047 | #else | |
| 1048 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) | |
| 1049 | #endif | |
| 1050 | { | |
| 1051 | std::swap(this->__begin_, __x.__begin_); | |
| 1052 | std::swap(this->__size_, __x.__size_); | |
| 1053 | std::swap(this->__cap_, __x.__cap_); | |
| 1054 | std::__swap_allocator(this->__alloc_, __x.__alloc_); | |
| 1055 | } | |
| 1056 | ||
| 1057 | template <class _Allocator> | |
| 1058 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::resize(size_type __sz, value_type __x) { | |
| 1059 | size_type __cs = size(); | |
| 1060 | if (__cs < __sz) { | |
| 1061 | iterator __r; | |
| 1062 | size_type __c = capacity(); | |
| 1063 | size_type __n = __sz - __cs; | |
| 1064 | if (__n <= __c && __cs <= __c - __n) { | |
| 1065 | __r = end(); | |
| 1066 | __size_ += __n; | |
| 1067 | } else { | |
| 1068 | vector __v(get_allocator()); | |
| 1069 | __v.reserve(__recommend(__size_ + __n)); | |
| 1070 | __v.__size_ = __size_ + __n; | |
| 1071 | __r = std::copy(cbegin(), cend(), __v.begin()); | |
| 1072 | swap(__v); | |
| 1073 | } | |
| 1074 | std::fill_n(__r, __n, __x); | |
| 1075 | } else | |
| 1076 | __size_ = __sz; | |
| 1077 | } | |
| 1078 | ||
| 1079 | template <class _Allocator> | |
| 1080 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::flip() _NOEXCEPT { | |
| 1081 | // Flip each storage word entirely, including the last potentially partial word. | |
| 1082 | // The unused bits in the last word are safe to flip as they won't be accessed. | |
| 1083 | __storage_pointer __p = __begin_; | |
| 1084 | for (size_type __n = __external_cap_to_internal(size()); __n != 0; ++__p, --__n) | |
| 1085 | *__p = ~*__p; | |
| 1086 | } | |
| 1087 | ||
| 1088 | template <class _Allocator> | |
| 1089 | _LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<bool, _Allocator>::__invariants() const { | |
| 1090 | if (this->__begin_ == nullptr) { | |
| 1091 | if (this->__size_ != 0 || this->__cap_ != 0) | |
| 1092 | return false; | |
| 1093 | } else { | |
| 1094 | if (this->__cap_ == 0) | |
| 1095 | return false; | |
| 1096 | if (this->__size_ > this->capacity()) | |
| 1097 | return false; | |
| 1098 | } | |
| 1099 | return true; | |
| 1100 | } | |
| 1101 | ||
| 1102 | template <class _Allocator> | |
| 1103 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() const _NOEXCEPT { | |
| 1104 | size_t __h = 0; | |
| 1105 | // do middle whole words | |
| 1106 | size_type __n = __size_; | |
| 1107 | __storage_pointer __p = __begin_; | |
| 1108 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) | |
| 1109 | __h ^= *__p; | |
| 1110 | // do last partial word | |
| 1111 | if (__n > 0) { | |
| 1112 | const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | |
| 1113 | __h ^= *__p & __m; | |
| 1114 | } | |
| 1115 | return __h; | |
| 1116 | } | |
| 1117 | ||
| 1118 | template <class _Allocator> | |
| 1119 | struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > | |
| 1120 | : public __unary_function<vector<bool, _Allocator>, size_t> { | |
| 1121 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t | |
| 1122 | operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT { | |
| 1123 | return __vec.__hash_code(); | |
| 1124 | } | |
| 1125 | }; | |
| 1126 | ||
| 1127 | _LIBCPP_END_NAMESPACE_STD | |
| 1128 | ||
| 1129 | _LIBCPP_POP_MACROS | |
| 1130 | ||
| 1131 | #endif // _LIBCPP___VECTOR_VECTOR_BOOL_H |
lib/libcxx/include/__vector/vector_bool_formatter.h created+49| ... | ... | @@ -0,0 +1,49 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___VECTOR_VECTOR_BOOL_FORMATTER_H | |
| 10 | #define _LIBCPP___VECTOR_VECTOR_BOOL_FORMATTER_H | |
| 11 | ||
| 12 | #include <__concepts/same_as.h> | |
| 13 | #include <__config> | |
| 14 | #include <__format/formatter.h> | |
| 15 | #include <__format/formatter_bool.h> | |
| 16 | #include <__fwd/vector.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | #if _LIBCPP_STD_VER >= 23 | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | template <class _Tp, class _CharT> | |
| 27 | // Since is-vector-bool-reference is only used once it's inlined here. | |
| 28 | requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>> | |
| 29 | struct _LIBCPP_TEMPLATE_VIS formatter<_Tp, _CharT> { | |
| 30 | private: | |
| 31 | formatter<bool, _CharT> __underlying_; | |
| 32 | ||
| 33 | public: | |
| 34 | template <class _ParseContext> | |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | |
| 36 | return __underlying_.parse(__ctx); | |
| 37 | } | |
| 38 | ||
| 39 | template <class _FormatContext> | |
| 40 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _Tp& __ref, _FormatContext& __ctx) const { | |
| 41 | return __underlying_.format(__ref, __ctx); | |
| 42 | } | |
| 43 | }; | |
| 44 | ||
| 45 | _LIBCPP_END_NAMESPACE_STD | |
| 46 | ||
| 47 | #endif // _LIBCPP_STD_VER >= 23 | |
| 48 | ||
| 49 | #endif // _LIBCPP___VECTOR_VECTOR_BOOL_FORMATTER_H |
lib/libcxx/include/__verbose_abort+8-2| ... | ... | @@ -18,10 +18,16 @@ |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | #if defined(_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT) | |
| 22 | # define _LIBCPP_VERBOSE_ABORT_NOEXCEPT | |
| 23 | #else | |
| 24 | # define _LIBCPP_VERBOSE_ABORT_NOEXCEPT _NOEXCEPT | |
| 25 | #endif | |
| 26 | ||
| 21 | 27 | // This function should never be called directly from the code -- it should only be called through |
| 22 | 28 | // the _LIBCPP_VERBOSE_ABORT macro. |
| 23 | _LIBCPP_NORETURN _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS | |
| 24 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...); | |
| 29 | [[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT( | |
| 30 | __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT; | |
| 25 | 31 | |
| 26 | 32 | // _LIBCPP_VERBOSE_ABORT(format, args...) |
| 27 | 33 | // |
lib/libcxx/include/algorithm+250-237| ... | ... | @@ -313,6 +313,9 @@ namespace ranges { |
| 313 | 313 | template<class I, class F> |
| 314 | 314 | using for_each_result = in_fun_result<I, F>; // since C++20 |
| 315 | 315 | |
| 316 | template<class I, class F> | |
| 317 | using for_each_n_result = in_fun_result<I, F>; // since C++20 | |
| 318 | ||
| 316 | 319 | template<input_iterator I, sentinel_for<I> S, class Proj = identity, |
| 317 | 320 | indirectly_unary_invocable<projected<I, Proj>> Fun> |
| 318 | 321 | constexpr ranges::for_each_result<I, Fun> |
| ... | ... | @@ -700,6 +703,12 @@ namespace ranges { |
| 700 | 703 | ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {}, |
| 701 | 704 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 |
| 702 | 705 | |
| 706 | template<class I, class O> | |
| 707 | using move_result = in_out_result<I, O>; // since C++20 | |
| 708 | ||
| 709 | template<class I, class O> | |
| 710 | using move_backward_result = in_out_result<I, O>; // since C++20 | |
| 711 | ||
| 703 | 712 | template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2> |
| 704 | 713 | requires indirectly_movable<I1, I2> |
| 705 | 714 | constexpr ranges::move_backward_result<I1, I2> |
| ... | ... | @@ -1228,9 +1237,9 @@ template <class InputIterator1, class InputIterator2> |
| 1228 | 1237 | mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); |
| 1229 | 1238 | |
| 1230 | 1239 | template <class InputIterator1, class InputIterator2> |
| 1231 | constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20 | |
| 1240 | constexpr pair<InputIterator1, InputIterator2> | |
| 1232 | 1241 | mismatch(InputIterator1 first1, InputIterator1 last1, |
| 1233 | InputIterator2 first2, InputIterator2 last2); // **C++14** | |
| 1242 | InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr in C++20 | |
| 1234 | 1243 | |
| 1235 | 1244 | template <class InputIterator1, class InputIterator2, class BinaryPredicate> |
| 1236 | 1245 | constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20 |
| ... | ... | @@ -1238,19 +1247,19 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate> |
| 1238 | 1247 | InputIterator2 first2, BinaryPredicate pred); |
| 1239 | 1248 | |
| 1240 | 1249 | template <class InputIterator1, class InputIterator2, class BinaryPredicate> |
| 1241 | constexpr pair<InputIterator1, InputIterator2> // constexpr in C++20 | |
| 1250 | constexpr pair<InputIterator1, InputIterator2> | |
| 1242 | 1251 | mismatch(InputIterator1 first1, InputIterator1 last1, |
| 1243 | 1252 | InputIterator2 first2, InputIterator2 last2, |
| 1244 | BinaryPredicate pred); // **C++14** | |
| 1253 | BinaryPredicate pred); // since C++14, constexpr in C++20 | |
| 1245 | 1254 | |
| 1246 | 1255 | template <class InputIterator1, class InputIterator2> |
| 1247 | 1256 | constexpr bool // constexpr in C++20 |
| 1248 | 1257 | equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); |
| 1249 | 1258 | |
| 1250 | 1259 | template <class InputIterator1, class InputIterator2> |
| 1251 | constexpr bool // constexpr in C++20 | |
| 1260 | constexpr bool | |
| 1252 | 1261 | equal(InputIterator1 first1, InputIterator1 last1, |
| 1253 | InputIterator2 first2, InputIterator2 last2); // **C++14** | |
| 1262 | InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr in C++20 | |
| 1254 | 1263 | |
| 1255 | 1264 | template <class InputIterator1, class InputIterator2, class BinaryPredicate> |
| 1256 | 1265 | constexpr bool // constexpr in C++20 |
| ... | ... | @@ -1258,10 +1267,10 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate> |
| 1258 | 1267 | InputIterator2 first2, BinaryPredicate pred); |
| 1259 | 1268 | |
| 1260 | 1269 | template <class InputIterator1, class InputIterator2, class BinaryPredicate> |
| 1261 | constexpr bool // constexpr in C++20 | |
| 1270 | constexpr bool | |
| 1262 | 1271 | equal(InputIterator1 first1, InputIterator1 last1, |
| 1263 | 1272 | InputIterator2 first2, InputIterator2 last2, |
| 1264 | BinaryPredicate pred); // **C++14** | |
| 1273 | BinaryPredicate pred); // since C++14, constexpr in C++20 | |
| 1265 | 1274 | |
| 1266 | 1275 | template<class ForwardIterator1, class ForwardIterator2> |
| 1267 | 1276 | constexpr bool // constexpr in C++20 |
| ... | ... | @@ -1269,9 +1278,9 @@ template<class ForwardIterator1, class ForwardIterator2> |
| 1269 | 1278 | ForwardIterator2 first2); |
| 1270 | 1279 | |
| 1271 | 1280 | template<class ForwardIterator1, class ForwardIterator2> |
| 1272 | constexpr bool // constexpr in C++20 | |
| 1281 | constexpr bool | |
| 1273 | 1282 | is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1274 | ForwardIterator2 first2, ForwardIterator2 last2); // **C++14** | |
| 1283 | ForwardIterator2 first2, ForwardIterator2 last2); // since C++14, constexpr in C++20 | |
| 1275 | 1284 | |
| 1276 | 1285 | template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> |
| 1277 | 1286 | constexpr bool // constexpr in C++20 |
| ... | ... | @@ -1279,10 +1288,10 @@ template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> |
| 1279 | 1288 | ForwardIterator2 first2, BinaryPredicate pred); |
| 1280 | 1289 | |
| 1281 | 1290 | template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate> |
| 1282 | constexpr bool // constexpr in C++20 | |
| 1291 | constexpr bool | |
| 1283 | 1292 | is_permutation(ForwardIterator1 first1, ForwardIterator1 last1, |
| 1284 | 1293 | ForwardIterator2 first2, ForwardIterator2 last2, |
| 1285 | BinaryPredicate pred); // **C++14** | |
| 1294 | BinaryPredicate pred); // since C++14, constexpr in C++20 | |
| 1286 | 1295 | |
| 1287 | 1296 | template <class ForwardIterator1, class ForwardIterator2> |
| 1288 | 1297 | constexpr ForwardIterator1 // constexpr in C++20 |
| ... | ... | @@ -1521,11 +1530,11 @@ template <class RandomAccessIterator, class Compare> |
| 1521 | 1530 | sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); |
| 1522 | 1531 | |
| 1523 | 1532 | template <class RandomAccessIterator> |
| 1524 | void | |
| 1533 | constexpr void // constexpr in C++26 | |
| 1525 | 1534 | stable_sort(RandomAccessIterator first, RandomAccessIterator last); |
| 1526 | 1535 | |
| 1527 | 1536 | template <class RandomAccessIterator, class Compare> |
| 1528 | void | |
| 1537 | constexpr void // constexpr in C++26 | |
| 1529 | 1538 | stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); |
| 1530 | 1539 | |
| 1531 | 1540 | template <class RandomAccessIterator> |
| ... | ... | @@ -1818,232 +1827,236 @@ template <class BidirectionalIterator, class Compare> |
| 1818 | 1827 | |
| 1819 | 1828 | */ |
| 1820 | 1829 | |
| 1821 | #include <__config> | |
| 1822 | ||
| 1823 | #include <__algorithm/adjacent_find.h> | |
| 1824 | #include <__algorithm/all_of.h> | |
| 1825 | #include <__algorithm/any_of.h> | |
| 1826 | #include <__algorithm/binary_search.h> | |
| 1827 | #include <__algorithm/copy.h> | |
| 1828 | #include <__algorithm/copy_backward.h> | |
| 1829 | #include <__algorithm/copy_if.h> | |
| 1830 | #include <__algorithm/copy_n.h> | |
| 1831 | #include <__algorithm/count.h> | |
| 1832 | #include <__algorithm/count_if.h> | |
| 1833 | #include <__algorithm/equal.h> | |
| 1834 | #include <__algorithm/equal_range.h> | |
| 1835 | #include <__algorithm/fill.h> | |
| 1836 | #include <__algorithm/fill_n.h> | |
| 1837 | #include <__algorithm/find.h> | |
| 1838 | #include <__algorithm/find_end.h> | |
| 1839 | #include <__algorithm/find_first_of.h> | |
| 1840 | #include <__algorithm/find_if.h> | |
| 1841 | #include <__algorithm/find_if_not.h> | |
| 1842 | #include <__algorithm/for_each.h> | |
| 1843 | #include <__algorithm/generate.h> | |
| 1844 | #include <__algorithm/generate_n.h> | |
| 1845 | #include <__algorithm/includes.h> | |
| 1846 | #include <__algorithm/inplace_merge.h> | |
| 1847 | #include <__algorithm/is_heap.h> | |
| 1848 | #include <__algorithm/is_heap_until.h> | |
| 1849 | #include <__algorithm/is_partitioned.h> | |
| 1850 | #include <__algorithm/is_permutation.h> | |
| 1851 | #include <__algorithm/is_sorted.h> | |
| 1852 | #include <__algorithm/is_sorted_until.h> | |
| 1853 | #include <__algorithm/iter_swap.h> | |
| 1854 | #include <__algorithm/lexicographical_compare.h> | |
| 1855 | #include <__algorithm/lower_bound.h> | |
| 1856 | #include <__algorithm/make_heap.h> | |
| 1857 | #include <__algorithm/max.h> | |
| 1858 | #include <__algorithm/max_element.h> | |
| 1859 | #include <__algorithm/merge.h> | |
| 1860 | #include <__algorithm/min.h> | |
| 1861 | #include <__algorithm/min_element.h> | |
| 1862 | #include <__algorithm/minmax.h> | |
| 1863 | #include <__algorithm/minmax_element.h> | |
| 1864 | #include <__algorithm/mismatch.h> | |
| 1865 | #include <__algorithm/move.h> | |
| 1866 | #include <__algorithm/move_backward.h> | |
| 1867 | #include <__algorithm/next_permutation.h> | |
| 1868 | #include <__algorithm/none_of.h> | |
| 1869 | #include <__algorithm/nth_element.h> | |
| 1870 | #include <__algorithm/partial_sort.h> | |
| 1871 | #include <__algorithm/partial_sort_copy.h> | |
| 1872 | #include <__algorithm/partition.h> | |
| 1873 | #include <__algorithm/partition_copy.h> | |
| 1874 | #include <__algorithm/partition_point.h> | |
| 1875 | #include <__algorithm/pop_heap.h> | |
| 1876 | #include <__algorithm/prev_permutation.h> | |
| 1877 | #include <__algorithm/push_heap.h> | |
| 1878 | #include <__algorithm/remove.h> | |
| 1879 | #include <__algorithm/remove_copy.h> | |
| 1880 | #include <__algorithm/remove_copy_if.h> | |
| 1881 | #include <__algorithm/remove_if.h> | |
| 1882 | #include <__algorithm/replace.h> | |
| 1883 | #include <__algorithm/replace_copy.h> | |
| 1884 | #include <__algorithm/replace_copy_if.h> | |
| 1885 | #include <__algorithm/replace_if.h> | |
| 1886 | #include <__algorithm/reverse.h> | |
| 1887 | #include <__algorithm/reverse_copy.h> | |
| 1888 | #include <__algorithm/rotate.h> | |
| 1889 | #include <__algorithm/rotate_copy.h> | |
| 1890 | #include <__algorithm/search.h> | |
| 1891 | #include <__algorithm/search_n.h> | |
| 1892 | #include <__algorithm/set_difference.h> | |
| 1893 | #include <__algorithm/set_intersection.h> | |
| 1894 | #include <__algorithm/set_symmetric_difference.h> | |
| 1895 | #include <__algorithm/set_union.h> | |
| 1896 | #include <__algorithm/shuffle.h> | |
| 1897 | #include <__algorithm/sort.h> | |
| 1898 | #include <__algorithm/sort_heap.h> | |
| 1899 | #include <__algorithm/stable_partition.h> | |
| 1900 | #include <__algorithm/stable_sort.h> | |
| 1901 | #include <__algorithm/swap_ranges.h> | |
| 1902 | #include <__algorithm/transform.h> | |
| 1903 | #include <__algorithm/unique.h> | |
| 1904 | #include <__algorithm/unique_copy.h> | |
| 1905 | #include <__algorithm/upper_bound.h> | |
| 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> | |
| 1830 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1831 | # include <__cxx03/algorithm> | |
| 1832 | #else | |
| 1833 | # include <__config> | |
| 1834 | ||
| 1835 | # include <__algorithm/adjacent_find.h> | |
| 1836 | # include <__algorithm/all_of.h> | |
| 1837 | # include <__algorithm/any_of.h> | |
| 1838 | # include <__algorithm/binary_search.h> | |
| 1839 | # include <__algorithm/copy.h> | |
| 1840 | # include <__algorithm/copy_backward.h> | |
| 1841 | # include <__algorithm/copy_if.h> | |
| 1842 | # include <__algorithm/copy_n.h> | |
| 1843 | # include <__algorithm/count.h> | |
| 1844 | # include <__algorithm/count_if.h> | |
| 1845 | # include <__algorithm/equal.h> | |
| 1846 | # include <__algorithm/equal_range.h> | |
| 1847 | # include <__algorithm/fill.h> | |
| 1848 | # include <__algorithm/fill_n.h> | |
| 1849 | # include <__algorithm/find.h> | |
| 1850 | # include <__algorithm/find_end.h> | |
| 1851 | # include <__algorithm/find_first_of.h> | |
| 1852 | # include <__algorithm/find_if.h> | |
| 1853 | # include <__algorithm/find_if_not.h> | |
| 1854 | # include <__algorithm/for_each.h> | |
| 1855 | # include <__algorithm/generate.h> | |
| 1856 | # include <__algorithm/generate_n.h> | |
| 1857 | # include <__algorithm/includes.h> | |
| 1858 | # include <__algorithm/inplace_merge.h> | |
| 1859 | # include <__algorithm/is_heap.h> | |
| 1860 | # include <__algorithm/is_heap_until.h> | |
| 1861 | # include <__algorithm/is_partitioned.h> | |
| 1862 | # include <__algorithm/is_permutation.h> | |
| 1863 | # include <__algorithm/is_sorted.h> | |
| 1864 | # include <__algorithm/is_sorted_until.h> | |
| 1865 | # include <__algorithm/iter_swap.h> | |
| 1866 | # include <__algorithm/lexicographical_compare.h> | |
| 1867 | # include <__algorithm/lower_bound.h> | |
| 1868 | # include <__algorithm/make_heap.h> | |
| 1869 | # include <__algorithm/max.h> | |
| 1870 | # include <__algorithm/max_element.h> | |
| 1871 | # include <__algorithm/merge.h> | |
| 1872 | # include <__algorithm/min.h> | |
| 1873 | # include <__algorithm/min_element.h> | |
| 1874 | # include <__algorithm/minmax.h> | |
| 1875 | # include <__algorithm/minmax_element.h> | |
| 1876 | # include <__algorithm/mismatch.h> | |
| 1877 | # include <__algorithm/move.h> | |
| 1878 | # include <__algorithm/move_backward.h> | |
| 1879 | # include <__algorithm/next_permutation.h> | |
| 1880 | # include <__algorithm/none_of.h> | |
| 1881 | # include <__algorithm/nth_element.h> | |
| 1882 | # include <__algorithm/partial_sort.h> | |
| 1883 | # include <__algorithm/partial_sort_copy.h> | |
| 1884 | # include <__algorithm/partition.h> | |
| 1885 | # include <__algorithm/partition_copy.h> | |
| 1886 | # include <__algorithm/partition_point.h> | |
| 1887 | # include <__algorithm/pop_heap.h> | |
| 1888 | # include <__algorithm/prev_permutation.h> | |
| 1889 | # include <__algorithm/push_heap.h> | |
| 1890 | # include <__algorithm/remove.h> | |
| 1891 | # include <__algorithm/remove_copy.h> | |
| 1892 | # include <__algorithm/remove_copy_if.h> | |
| 1893 | # include <__algorithm/remove_if.h> | |
| 1894 | # include <__algorithm/replace.h> | |
| 1895 | # include <__algorithm/replace_copy.h> | |
| 1896 | # include <__algorithm/replace_copy_if.h> | |
| 1897 | # include <__algorithm/replace_if.h> | |
| 1898 | # include <__algorithm/reverse.h> | |
| 1899 | # include <__algorithm/reverse_copy.h> | |
| 1900 | # include <__algorithm/rotate.h> | |
| 1901 | # include <__algorithm/rotate_copy.h> | |
| 1902 | # include <__algorithm/search.h> | |
| 1903 | # include <__algorithm/search_n.h> | |
| 1904 | # include <__algorithm/set_difference.h> | |
| 1905 | # include <__algorithm/set_intersection.h> | |
| 1906 | # include <__algorithm/set_symmetric_difference.h> | |
| 1907 | # include <__algorithm/set_union.h> | |
| 1908 | # include <__algorithm/shuffle.h> | |
| 1909 | # include <__algorithm/sort.h> | |
| 1910 | # include <__algorithm/sort_heap.h> | |
| 1911 | # include <__algorithm/stable_partition.h> | |
| 1912 | # include <__algorithm/stable_sort.h> | |
| 1913 | # include <__algorithm/swap_ranges.h> | |
| 1914 | # include <__algorithm/transform.h> | |
| 1915 | # include <__algorithm/unique.h> | |
| 1916 | # include <__algorithm/unique_copy.h> | |
| 1917 | # include <__algorithm/upper_bound.h> | |
| 1918 | ||
| 1919 | # if _LIBCPP_STD_VER >= 17 | |
| 1920 | # include <__algorithm/clamp.h> | |
| 1921 | # include <__algorithm/for_each_n.h> | |
| 1922 | # include <__algorithm/pstl.h> | |
| 1923 | # include <__algorithm/sample.h> | |
| 1924 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1925 | ||
| 1926 | # if _LIBCPP_STD_VER >= 20 | |
| 1927 | # include <__algorithm/in_found_result.h> | |
| 1928 | # include <__algorithm/in_fun_result.h> | |
| 1929 | # include <__algorithm/in_in_out_result.h> | |
| 1930 | # include <__algorithm/in_in_result.h> | |
| 1931 | # include <__algorithm/in_out_out_result.h> | |
| 1932 | # include <__algorithm/in_out_result.h> | |
| 1933 | # include <__algorithm/lexicographical_compare_three_way.h> | |
| 1934 | # include <__algorithm/min_max_result.h> | |
| 1935 | # include <__algorithm/ranges_adjacent_find.h> | |
| 1936 | # include <__algorithm/ranges_all_of.h> | |
| 1937 | # include <__algorithm/ranges_any_of.h> | |
| 1938 | # include <__algorithm/ranges_binary_search.h> | |
| 1939 | # include <__algorithm/ranges_clamp.h> | |
| 1940 | # include <__algorithm/ranges_contains.h> | |
| 1941 | # include <__algorithm/ranges_copy.h> | |
| 1942 | # include <__algorithm/ranges_copy_backward.h> | |
| 1943 | # include <__algorithm/ranges_copy_if.h> | |
| 1944 | # include <__algorithm/ranges_copy_n.h> | |
| 1945 | # include <__algorithm/ranges_count.h> | |
| 1946 | # include <__algorithm/ranges_count_if.h> | |
| 1947 | # include <__algorithm/ranges_equal.h> | |
| 1948 | # include <__algorithm/ranges_equal_range.h> | |
| 1949 | # include <__algorithm/ranges_fill.h> | |
| 1950 | # include <__algorithm/ranges_fill_n.h> | |
| 1951 | # include <__algorithm/ranges_find.h> | |
| 1952 | # include <__algorithm/ranges_find_end.h> | |
| 1953 | # include <__algorithm/ranges_find_first_of.h> | |
| 1954 | # include <__algorithm/ranges_find_if.h> | |
| 1955 | # include <__algorithm/ranges_find_if_not.h> | |
| 1956 | # include <__algorithm/ranges_for_each.h> | |
| 1957 | # include <__algorithm/ranges_for_each_n.h> | |
| 1958 | # include <__algorithm/ranges_generate.h> | |
| 1959 | # include <__algorithm/ranges_generate_n.h> | |
| 1960 | # include <__algorithm/ranges_includes.h> | |
| 1961 | # include <__algorithm/ranges_inplace_merge.h> | |
| 1962 | # include <__algorithm/ranges_is_heap.h> | |
| 1963 | # include <__algorithm/ranges_is_heap_until.h> | |
| 1964 | # include <__algorithm/ranges_is_partitioned.h> | |
| 1965 | # include <__algorithm/ranges_is_permutation.h> | |
| 1966 | # include <__algorithm/ranges_is_sorted.h> | |
| 1967 | # include <__algorithm/ranges_is_sorted_until.h> | |
| 1968 | # include <__algorithm/ranges_lexicographical_compare.h> | |
| 1969 | # include <__algorithm/ranges_lower_bound.h> | |
| 1970 | # include <__algorithm/ranges_make_heap.h> | |
| 1971 | # include <__algorithm/ranges_max.h> | |
| 1972 | # include <__algorithm/ranges_max_element.h> | |
| 1973 | # include <__algorithm/ranges_merge.h> | |
| 1974 | # include <__algorithm/ranges_min.h> | |
| 1975 | # include <__algorithm/ranges_min_element.h> | |
| 1976 | # include <__algorithm/ranges_minmax.h> | |
| 1977 | # include <__algorithm/ranges_minmax_element.h> | |
| 1978 | # include <__algorithm/ranges_mismatch.h> | |
| 1979 | # include <__algorithm/ranges_move.h> | |
| 1980 | # include <__algorithm/ranges_move_backward.h> | |
| 1981 | # include <__algorithm/ranges_next_permutation.h> | |
| 1982 | # include <__algorithm/ranges_none_of.h> | |
| 1983 | # include <__algorithm/ranges_nth_element.h> | |
| 1984 | # include <__algorithm/ranges_partial_sort.h> | |
| 1985 | # include <__algorithm/ranges_partial_sort_copy.h> | |
| 1986 | # include <__algorithm/ranges_partition.h> | |
| 1987 | # include <__algorithm/ranges_partition_copy.h> | |
| 1988 | # include <__algorithm/ranges_partition_point.h> | |
| 1989 | # include <__algorithm/ranges_pop_heap.h> | |
| 1990 | # include <__algorithm/ranges_prev_permutation.h> | |
| 1991 | # include <__algorithm/ranges_push_heap.h> | |
| 1992 | # include <__algorithm/ranges_remove.h> | |
| 1993 | # include <__algorithm/ranges_remove_copy.h> | |
| 1994 | # include <__algorithm/ranges_remove_copy_if.h> | |
| 1995 | # include <__algorithm/ranges_remove_if.h> | |
| 1996 | # include <__algorithm/ranges_replace.h> | |
| 1997 | # include <__algorithm/ranges_replace_copy.h> | |
| 1998 | # include <__algorithm/ranges_replace_copy_if.h> | |
| 1999 | # include <__algorithm/ranges_replace_if.h> | |
| 2000 | # include <__algorithm/ranges_reverse.h> | |
| 2001 | # include <__algorithm/ranges_reverse_copy.h> | |
| 2002 | # include <__algorithm/ranges_rotate.h> | |
| 2003 | # include <__algorithm/ranges_rotate_copy.h> | |
| 2004 | # include <__algorithm/ranges_sample.h> | |
| 2005 | # include <__algorithm/ranges_search.h> | |
| 2006 | # include <__algorithm/ranges_search_n.h> | |
| 2007 | # include <__algorithm/ranges_set_difference.h> | |
| 2008 | # include <__algorithm/ranges_set_intersection.h> | |
| 2009 | # include <__algorithm/ranges_set_symmetric_difference.h> | |
| 2010 | # include <__algorithm/ranges_set_union.h> | |
| 2011 | # include <__algorithm/ranges_shuffle.h> | |
| 2012 | # include <__algorithm/ranges_sort.h> | |
| 2013 | # include <__algorithm/ranges_sort_heap.h> | |
| 2014 | # include <__algorithm/ranges_stable_partition.h> | |
| 2015 | # include <__algorithm/ranges_stable_sort.h> | |
| 2016 | # include <__algorithm/ranges_swap_ranges.h> | |
| 2017 | # include <__algorithm/ranges_transform.h> | |
| 2018 | # include <__algorithm/ranges_unique.h> | |
| 2019 | # include <__algorithm/ranges_unique_copy.h> | |
| 2020 | # include <__algorithm/ranges_upper_bound.h> | |
| 2021 | # include <__algorithm/shift_left.h> | |
| 2022 | # include <__algorithm/shift_right.h> | |
| 2023 | # endif | |
| 2024 | ||
| 2025 | # if _LIBCPP_STD_VER >= 23 | |
| 2026 | # include <__algorithm/ranges_contains_subrange.h> | |
| 2027 | # include <__algorithm/ranges_ends_with.h> | |
| 2028 | # include <__algorithm/ranges_find_last.h> | |
| 2029 | # include <__algorithm/ranges_fold.h> | |
| 2030 | # include <__algorithm/ranges_starts_with.h> | |
| 2031 | # endif // _LIBCPP_STD_VER >= 23 | |
| 2032 | ||
| 2033 | # include <version> | |
| 2022 | 2034 | |
| 2023 | 2035 | // standard-mandated includes |
| 2024 | 2036 | |
| 2025 | 2037 | // [algorithm.syn] |
| 2026 | #include <initializer_list> | |
| 2027 | ||
| 2028 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 2029 | # pragma GCC system_header | |
| 2030 | #endif | |
| 2031 | ||
| 2032 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14 | |
| 2033 | # include <execution> | |
| 2034 | #endif | |
| 2035 | ||
| 2036 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 2037 | # include <atomic> | |
| 2038 | # include <bit> | |
| 2039 | # include <concepts> | |
| 2040 | # include <cstdlib> | |
| 2041 | # include <cstring> | |
| 2042 | # include <iterator> | |
| 2043 | # include <memory> | |
| 2044 | # include <stdexcept> | |
| 2045 | # include <type_traits> | |
| 2046 | # include <utility> | |
| 2047 | #endif | |
| 2038 | # include <initializer_list> | |
| 2039 | ||
| 2040 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 2041 | # pragma GCC system_header | |
| 2042 | # endif | |
| 2043 | ||
| 2044 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14 | |
| 2045 | # include <execution> | |
| 2046 | # endif | |
| 2047 | ||
| 2048 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 2049 | # include <atomic> | |
| 2050 | # include <bit> | |
| 2051 | # include <concepts> | |
| 2052 | # include <cstdlib> | |
| 2053 | # include <cstring> | |
| 2054 | # include <iterator> | |
| 2055 | # include <memory> | |
| 2056 | # include <stdexcept> | |
| 2057 | # include <type_traits> | |
| 2058 | # include <utility> | |
| 2059 | # endif | |
| 2060 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 2048 | 2061 | |
| 2049 | 2062 | #endif // _LIBCPP_ALGORITHM |
lib/libcxx/include/any+77-73| ... | ... | @@ -80,40 +80,44 @@ namespace std { |
| 80 | 80 | |
| 81 | 81 | */ |
| 82 | 82 | |
| 83 | #include <__config> | |
| 84 | #include <__memory/allocator.h> | |
| 85 | #include <__memory/allocator_destructor.h> | |
| 86 | #include <__memory/allocator_traits.h> | |
| 87 | #include <__memory/unique_ptr.h> | |
| 88 | #include <__type_traits/add_const.h> | |
| 89 | #include <__type_traits/add_pointer.h> | |
| 90 | #include <__type_traits/aligned_storage.h> | |
| 91 | #include <__type_traits/conditional.h> | |
| 92 | #include <__type_traits/decay.h> | |
| 93 | #include <__type_traits/is_constructible.h> | |
| 94 | #include <__type_traits/is_function.h> | |
| 95 | #include <__type_traits/is_nothrow_constructible.h> | |
| 96 | #include <__type_traits/is_reference.h> | |
| 97 | #include <__type_traits/is_same.h> | |
| 98 | #include <__type_traits/is_void.h> | |
| 99 | #include <__type_traits/remove_cv.h> | |
| 100 | #include <__type_traits/remove_cvref.h> | |
| 101 | #include <__type_traits/remove_reference.h> | |
| 102 | #include <__utility/forward.h> | |
| 103 | #include <__utility/in_place.h> | |
| 104 | #include <__utility/move.h> | |
| 105 | #include <__utility/unreachable.h> | |
| 106 | #include <__verbose_abort> | |
| 107 | #include <initializer_list> | |
| 108 | #include <typeinfo> | |
| 109 | #include <version> | |
| 110 | ||
| 111 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 112 | # pragma GCC system_header | |
| 113 | #endif | |
| 83 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 84 | # include <__cxx03/any> | |
| 85 | #else | |
| 86 | # include <__config> | |
| 87 | # include <__memory/allocator.h> | |
| 88 | # include <__memory/allocator_destructor.h> | |
| 89 | # include <__memory/allocator_traits.h> | |
| 90 | # include <__memory/unique_ptr.h> | |
| 91 | # include <__type_traits/add_cv_quals.h> | |
| 92 | # include <__type_traits/add_pointer.h> | |
| 93 | # include <__type_traits/aligned_storage.h> | |
| 94 | # include <__type_traits/conditional.h> | |
| 95 | # include <__type_traits/decay.h> | |
| 96 | # include <__type_traits/enable_if.h> | |
| 97 | # include <__type_traits/is_constructible.h> | |
| 98 | # include <__type_traits/is_function.h> | |
| 99 | # include <__type_traits/is_nothrow_constructible.h> | |
| 100 | # include <__type_traits/is_reference.h> | |
| 101 | # include <__type_traits/is_same.h> | |
| 102 | # include <__type_traits/is_void.h> | |
| 103 | # include <__type_traits/remove_cv.h> | |
| 104 | # include <__type_traits/remove_cvref.h> | |
| 105 | # include <__type_traits/remove_reference.h> | |
| 106 | # include <__utility/forward.h> | |
| 107 | # include <__utility/in_place.h> | |
| 108 | # include <__utility/move.h> | |
| 109 | # include <__utility/unreachable.h> | |
| 110 | # include <__verbose_abort> | |
| 111 | # include <initializer_list> | |
| 112 | # include <typeinfo> | |
| 113 | # include <version> | |
| 114 | ||
| 115 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 116 | # pragma GCC system_header | |
| 117 | # endif | |
| 114 | 118 | |
| 115 | 119 | _LIBCPP_PUSH_MACROS |
| 116 | #include <__undef_macros> | |
| 120 | # include <__undef_macros> | |
| 117 | 121 | |
| 118 | 122 | namespace std { |
| 119 | 123 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast { |
| ... | ... | @@ -124,14 +128,14 @@ public: |
| 124 | 128 | |
| 125 | 129 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 126 | 130 | |
| 127 | #if _LIBCPP_STD_VER >= 17 | |
| 131 | # if _LIBCPP_STD_VER >= 17 | |
| 128 | 132 | |
| 129 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { | |
| 130 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 133 | [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { | |
| 134 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 131 | 135 | throw bad_any_cast(); |
| 132 | # else | |
| 136 | # else | |
| 133 | 137 | _LIBCPP_VERBOSE_ABORT("bad_any_cast was thrown in -fno-exceptions mode"); |
| 134 | # endif | |
| 138 | # endif | |
| 135 | 139 | } |
| 136 | 140 | |
| 137 | 141 | // Forward declarations |
| ... | ... | @@ -145,11 +149,11 @@ _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any*) _NOEXCEPT; |
| 145 | 149 | |
| 146 | 150 | namespace __any_imp { |
| 147 | 151 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 148 | using _Buffer = aligned_storage_t<3 * sizeof(void*), alignof(void*)>; | |
| 152 | using _Buffer _LIBCPP_NODEBUG = aligned_storage_t<3 * sizeof(void*), alignof(void*)>; | |
| 149 | 153 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 150 | 154 | |
| 151 | 155 | template <class _Tp> |
| 152 | using _IsSmallObject = | |
| 156 | using _IsSmallObject _LIBCPP_NODEBUG = | |
| 153 | 157 | integral_constant<bool, |
| 154 | 158 | sizeof(_Tp) <= sizeof(_Buffer) && alignof(_Buffer) % alignof(_Tp) == 0 && |
| 155 | 159 | is_nothrow_move_constructible<_Tp>::value >; |
| ... | ... | @@ -165,8 +169,6 @@ template <class _Tp> |
| 165 | 169 | struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo { |
| 166 | 170 | static constexpr int __id = 0; |
| 167 | 171 | }; |
| 168 | template <class _Tp> | |
| 169 | constexpr int __unique_typeinfo<_Tp>::__id; | |
| 170 | 172 | |
| 171 | 173 | template <class _Tp> |
| 172 | 174 | inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() { |
| ... | ... | @@ -175,15 +177,15 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() { |
| 175 | 177 | |
| 176 | 178 | template <class _Tp> |
| 177 | 179 | inline _LIBCPP_HIDE_FROM_ABI bool __compare_typeid(type_info const* __id, const void* __fallback_id) { |
| 178 | # if !defined(_LIBCPP_HAS_NO_RTTI) | |
| 180 | # if _LIBCPP_HAS_RTTI | |
| 179 | 181 | if (__id && *__id == typeid(_Tp)) |
| 180 | 182 | return true; |
| 181 | # endif | |
| 183 | # endif | |
| 182 | 184 | return !__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>(); |
| 183 | 185 | } |
| 184 | 186 | |
| 185 | 187 | template <class _Tp> |
| 186 | using _Handler = conditional_t< _IsSmallObject<_Tp>::value, _SmallHandler<_Tp>, _LargeHandler<_Tp>>; | |
| 188 | using _Handler _LIBCPP_NODEBUG = conditional_t< _IsSmallObject<_Tp>::value, _SmallHandler<_Tp>, _LargeHandler<_Tp>>; | |
| 187 | 189 | |
| 188 | 190 | } // namespace __any_imp |
| 189 | 191 | |
| ... | ... | @@ -265,7 +267,7 @@ public: |
| 265 | 267 | // 6.3.4 any observers |
| 266 | 268 | _LIBCPP_HIDE_FROM_ABI bool has_value() const _NOEXCEPT { return __h_ != nullptr; } |
| 267 | 269 | |
| 268 | # if !defined(_LIBCPP_HAS_NO_RTTI) | |
| 270 | # if _LIBCPP_HAS_RTTI | |
| 269 | 271 | _LIBCPP_HIDE_FROM_ABI const type_info& type() const _NOEXCEPT { |
| 270 | 272 | if (__h_) { |
| 271 | 273 | return *static_cast<type_info const*>(this->__call(_Action::_TypeInfo)); |
| ... | ... | @@ -273,11 +275,12 @@ public: |
| 273 | 275 | return typeid(void); |
| 274 | 276 | } |
| 275 | 277 | } |
| 276 | # endif | |
| 278 | # endif | |
| 277 | 279 | |
| 278 | 280 | private: |
| 279 | typedef __any_imp::_Action _Action; | |
| 280 | using _HandleFuncPtr = void* (*)(_Action, any const*, any*, const type_info*, const void* __fallback_info); | |
| 281 | using _Action _LIBCPP_NODEBUG = __any_imp::_Action; | |
| 282 | using _HandleFuncPtr | |
| 283 | _LIBCPP_NODEBUG = void* (*)(_Action, any const*, any*, const type_info*, const void* __fallback_info); | |
| 281 | 284 | |
| 282 | 285 | union _Storage { |
| 283 | 286 | _LIBCPP_HIDE_FROM_ABI constexpr _Storage() : __ptr(nullptr) {} |
| ... | ... | @@ -371,11 +374,11 @@ private: |
| 371 | 374 | } |
| 372 | 375 | |
| 373 | 376 | _LIBCPP_HIDE_FROM_ABI static void* __type_info() { |
| 374 | # if !defined(_LIBCPP_HAS_NO_RTTI) | |
| 377 | # if _LIBCPP_HAS_RTTI | |
| 375 | 378 | return const_cast<void*>(static_cast<void const*>(&typeid(_Tp))); |
| 376 | # else | |
| 379 | # else | |
| 377 | 380 | return nullptr; |
| 378 | # endif | |
| 381 | # endif | |
| 379 | 382 | } |
| 380 | 383 | }; |
| 381 | 384 | |
| ... | ... | @@ -443,11 +446,11 @@ private: |
| 443 | 446 | } |
| 444 | 447 | |
| 445 | 448 | _LIBCPP_HIDE_FROM_ABI static void* __type_info() { |
| 446 | # if !defined(_LIBCPP_HAS_NO_RTTI) | |
| 449 | # if _LIBCPP_HAS_RTTI | |
| 447 | 450 | return const_cast<void*>(static_cast<void const*>(&typeid(_Tp))); |
| 448 | # else | |
| 451 | # else | |
| 449 | 452 | return nullptr; |
| 450 | # endif | |
| 453 | # endif | |
| 451 | 454 | } |
| 452 | 455 | }; |
| 453 | 456 | |
| ... | ... | @@ -578,37 +581,38 @@ _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any* __any) _NOEXCEPT { |
| 578 | 581 | void* __p = __any->__call( |
| 579 | 582 | _Action::_Get, |
| 580 | 583 | nullptr, |
| 581 | # if !defined(_LIBCPP_HAS_NO_RTTI) | |
| 584 | # if _LIBCPP_HAS_RTTI | |
| 582 | 585 | &typeid(_ValueType), |
| 583 | # else | |
| 586 | # else | |
| 584 | 587 | nullptr, |
| 585 | # endif | |
| 588 | # endif | |
| 586 | 589 | __any_imp::__get_fallback_typeid<_ValueType>()); |
| 587 | 590 | return std::__pointer_or_func_cast<_ReturnType>(__p, is_function<_ValueType>{}); |
| 588 | 591 | } |
| 589 | 592 | return nullptr; |
| 590 | 593 | } |
| 591 | 594 | |
| 592 | #endif // _LIBCPP_STD_VER >= 17 | |
| 595 | # endif // _LIBCPP_STD_VER >= 17 | |
| 593 | 596 | |
| 594 | 597 | _LIBCPP_END_NAMESPACE_STD |
| 595 | 598 | |
| 596 | 599 | _LIBCPP_POP_MACROS |
| 597 | 600 | |
| 598 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 599 | # include <chrono> | |
| 600 | #endif | |
| 601 | ||
| 602 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 603 | # include <atomic> | |
| 604 | # include <concepts> | |
| 605 | # include <cstdlib> | |
| 606 | # include <iosfwd> | |
| 607 | # include <iterator> | |
| 608 | # include <memory> | |
| 609 | # include <stdexcept> | |
| 610 | # include <type_traits> | |
| 611 | # include <variant> | |
| 612 | #endif | |
| 601 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 602 | # include <chrono> | |
| 603 | # endif | |
| 604 | ||
| 605 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 606 | # include <atomic> | |
| 607 | # include <concepts> | |
| 608 | # include <cstdlib> | |
| 609 | # include <iosfwd> | |
| 610 | # include <iterator> | |
| 611 | # include <memory> | |
| 612 | # include <stdexcept> | |
| 613 | # include <type_traits> | |
| 614 | # include <variant> | |
| 615 | # endif | |
| 616 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 613 | 617 | |
| 614 | 618 | #endif // _LIBCPP_ANY |
lib/libcxx/include/array+158-99| ... | ... | @@ -19,17 +19,17 @@ template <class T, size_t N > |
| 19 | 19 | struct array |
| 20 | 20 | { |
| 21 | 21 | // types: |
| 22 | typedef T & reference; | |
| 23 | typedef const T & const_reference; | |
| 24 | typedef implementation defined iterator; | |
| 25 | typedef implementation defined const_iterator; | |
| 26 | typedef size_t size_type; | |
| 27 | typedef ptrdiff_t difference_type; | |
| 28 | typedef T value_type; | |
| 29 | typedef T* pointer; | |
| 30 | typedef const T* const_pointer; | |
| 31 | typedef std::reverse_iterator<iterator> reverse_iterator; | |
| 32 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 22 | using value_type = T; | |
| 23 | using pointer = T*; | |
| 24 | using const_pointer = const T*; | |
| 25 | using reference = T&; | |
| 26 | using const_reference = const T&; | |
| 27 | using size_type = size_t; | |
| 28 | using difference_type = ptrdiff_t; | |
| 29 | using iterator = implementation-defined; | |
| 30 | using const_iterator = implementation-defined; | |
| 31 | using reverse_iterator = std::reverse_iterator<iterator>; | |
| 32 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | |
| 33 | 33 | |
| 34 | 34 | // No explicit construct/copy/destroy for aggregate type |
| 35 | 35 | void fill(const T& u); // constexpr in C++20 |
| ... | ... | @@ -111,78 +111,88 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce |
| 111 | 111 | |
| 112 | 112 | */ |
| 113 | 113 | |
| 114 | #include <__algorithm/equal.h> | |
| 115 | #include <__algorithm/fill_n.h> | |
| 116 | #include <__algorithm/lexicographical_compare.h> | |
| 117 | #include <__algorithm/lexicographical_compare_three_way.h> | |
| 118 | #include <__algorithm/swap_ranges.h> | |
| 119 | #include <__assert> | |
| 120 | #include <__config> | |
| 121 | #include <__fwd/array.h> | |
| 122 | #include <__iterator/reverse_iterator.h> | |
| 123 | #include <__iterator/wrap_iter.h> | |
| 124 | #include <__tuple/sfinae_helpers.h> | |
| 125 | #include <__type_traits/conditional.h> | |
| 126 | #include <__type_traits/conjunction.h> | |
| 127 | #include <__type_traits/is_array.h> | |
| 128 | #include <__type_traits/is_const.h> | |
| 129 | #include <__type_traits/is_constructible.h> | |
| 130 | #include <__type_traits/is_nothrow_constructible.h> | |
| 131 | #include <__type_traits/is_same.h> | |
| 132 | #include <__type_traits/is_swappable.h> | |
| 133 | #include <__type_traits/is_trivially_relocatable.h> | |
| 134 | #include <__type_traits/remove_cv.h> | |
| 135 | #include <__utility/empty.h> | |
| 136 | #include <__utility/integer_sequence.h> | |
| 137 | #include <__utility/move.h> | |
| 138 | #include <__utility/unreachable.h> | |
| 139 | #include <stdexcept> | |
| 140 | #include <version> | |
| 114 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 115 | # include <__cxx03/array> | |
| 116 | #else | |
| 117 | # include <__algorithm/equal.h> | |
| 118 | # include <__algorithm/fill_n.h> | |
| 119 | # include <__algorithm/lexicographical_compare.h> | |
| 120 | # include <__algorithm/lexicographical_compare_three_way.h> | |
| 121 | # include <__algorithm/swap_ranges.h> | |
| 122 | # include <__assert> | |
| 123 | # include <__config> | |
| 124 | # include <__cstddef/ptrdiff_t.h> | |
| 125 | # include <__fwd/array.h> | |
| 126 | # include <__iterator/reverse_iterator.h> | |
| 127 | # include <__iterator/static_bounded_iter.h> | |
| 128 | # include <__iterator/wrap_iter.h> | |
| 129 | # include <__tuple/sfinae_helpers.h> | |
| 130 | # include <__type_traits/conditional.h> | |
| 131 | # include <__type_traits/conjunction.h> | |
| 132 | # include <__type_traits/enable_if.h> | |
| 133 | # include <__type_traits/is_array.h> | |
| 134 | # include <__type_traits/is_const.h> | |
| 135 | # include <__type_traits/is_constructible.h> | |
| 136 | # include <__type_traits/is_nothrow_constructible.h> | |
| 137 | # include <__type_traits/is_same.h> | |
| 138 | # include <__type_traits/is_swappable.h> | |
| 139 | # include <__type_traits/is_trivially_relocatable.h> | |
| 140 | # include <__type_traits/remove_cv.h> | |
| 141 | # include <__utility/empty.h> | |
| 142 | # include <__utility/integer_sequence.h> | |
| 143 | # include <__utility/move.h> | |
| 144 | # include <__utility/unreachable.h> | |
| 145 | # include <stdexcept> | |
| 146 | # include <version> | |
| 141 | 147 | |
| 142 | 148 | // standard-mandated includes |
| 143 | 149 | |
| 144 | 150 | // [iterator.range] |
| 145 | #include <__iterator/access.h> | |
| 146 | #include <__iterator/data.h> | |
| 147 | #include <__iterator/empty.h> | |
| 148 | #include <__iterator/reverse_access.h> | |
| 149 | #include <__iterator/size.h> | |
| 151 | # include <__iterator/access.h> | |
| 152 | # include <__iterator/data.h> | |
| 153 | # include <__iterator/empty.h> | |
| 154 | # include <__iterator/reverse_access.h> | |
| 155 | # include <__iterator/size.h> | |
| 150 | 156 | |
| 151 | 157 | // [array.syn] |
| 152 | #include <compare> | |
| 153 | #include <initializer_list> | |
| 158 | # include <compare> | |
| 159 | # include <initializer_list> | |
| 154 | 160 | |
| 155 | 161 | // [tuple.helper] |
| 156 | #include <__tuple/tuple_element.h> | |
| 157 | #include <__tuple/tuple_size.h> | |
| 162 | # include <__tuple/tuple_element.h> | |
| 163 | # include <__tuple/tuple_size.h> | |
| 158 | 164 | |
| 159 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 160 | # pragma GCC system_header | |
| 161 | #endif | |
| 165 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 166 | # pragma GCC system_header | |
| 167 | # endif | |
| 162 | 168 | |
| 163 | 169 | _LIBCPP_PUSH_MACROS |
| 164 | #include <__undef_macros> | |
| 170 | # include <__undef_macros> | |
| 165 | 171 | |
| 166 | 172 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 167 | 173 | |
| 168 | 174 | template <class _Tp, size_t _Size> |
| 169 | 175 | struct _LIBCPP_TEMPLATE_VIS array { |
| 170 | using __trivially_relocatable = __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>; | |
| 176 | using __trivially_relocatable _LIBCPP_NODEBUG = | |
| 177 | __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>; | |
| 171 | 178 | |
| 172 | 179 | // types: |
| 173 | using __self = array; | |
| 174 | using value_type = _Tp; | |
| 175 | using reference = value_type&; | |
| 176 | using const_reference = const value_type&; | |
| 177 | using pointer = value_type*; | |
| 178 | using const_pointer = const value_type*; | |
| 179 | #if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY) | |
| 180 | using __self _LIBCPP_NODEBUG = array; | |
| 181 | using value_type = _Tp; | |
| 182 | using reference = value_type&; | |
| 183 | using const_reference = const value_type&; | |
| 184 | using pointer = value_type*; | |
| 185 | using const_pointer = const value_type*; | |
| 186 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | |
| 187 | using iterator = __static_bounded_iter<pointer, _Size>; | |
| 188 | using const_iterator = __static_bounded_iter<const_pointer, _Size>; | |
| 189 | # elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY) | |
| 180 | 190 | using iterator = __wrap_iter<pointer>; |
| 181 | 191 | using const_iterator = __wrap_iter<const_pointer>; |
| 182 | #else | |
| 192 | # else | |
| 183 | 193 | using iterator = pointer; |
| 184 | 194 | using const_iterator = const_pointer; |
| 185 | #endif | |
| 195 | # endif | |
| 186 | 196 | using size_type = size_t; |
| 187 | 197 | using difference_type = ptrdiff_t; |
| 188 | 198 | using reverse_iterator = std::reverse_iterator<iterator>; |
| ... | ... | @@ -200,13 +210,33 @@ struct _LIBCPP_TEMPLATE_VIS array { |
| 200 | 210 | } |
| 201 | 211 | |
| 202 | 212 | // iterators: |
| 203 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { return iterator(data()); } | |
| 213 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { | |
| 214 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | |
| 215 | return std::__make_static_bounded_iter<_Size>(data(), data()); | |
| 216 | # else | |
| 217 | return iterator(data()); | |
| 218 | # endif | |
| 219 | } | |
| 204 | 220 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT { |
| 221 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | |
| 222 | return std::__make_static_bounded_iter<_Size>(data(), data()); | |
| 223 | # else | |
| 205 | 224 | return const_iterator(data()); |
| 225 | # endif | |
| 226 | } | |
| 227 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { | |
| 228 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | |
| 229 | return std::__make_static_bounded_iter<_Size>(data() + _Size, data()); | |
| 230 | # else | |
| 231 | return iterator(data() + _Size); | |
| 232 | # endif | |
| 206 | 233 | } |
| 207 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { return iterator(data() + _Size); } | |
| 208 | 234 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT { |
| 235 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | |
| 236 | return std::__make_static_bounded_iter<_Size>(data() + _Size, data()); | |
| 237 | # else | |
| 209 | 238 | return const_iterator(data() + _Size); |
| 239 | # endif | |
| 210 | 240 | } |
| 211 | 241 | |
| 212 | 242 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT { |
| ... | ... | @@ -232,7 +262,7 @@ struct _LIBCPP_TEMPLATE_VIS array { |
| 232 | 262 | // capacity: |
| 233 | 263 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; } |
| 234 | 264 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; } |
| 235 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; } | |
| 265 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; } | |
| 236 | 266 | |
| 237 | 267 | // element access: |
| 238 | 268 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT { |
| ... | ... | @@ -270,20 +300,28 @@ struct _LIBCPP_TEMPLATE_VIS array { |
| 270 | 300 | template <class _Tp> |
| 271 | 301 | struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { |
| 272 | 302 | // types: |
| 273 | typedef array __self; | |
| 274 | typedef _Tp value_type; | |
| 275 | typedef value_type& reference; | |
| 276 | typedef const value_type& const_reference; | |
| 277 | typedef value_type* iterator; | |
| 278 | typedef const value_type* const_iterator; | |
| 279 | typedef value_type* pointer; | |
| 280 | typedef const value_type* const_pointer; | |
| 281 | typedef size_t size_type; | |
| 282 | typedef ptrdiff_t difference_type; | |
| 283 | typedef std::reverse_iterator<iterator> reverse_iterator; | |
| 284 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 285 | ||
| 286 | typedef __conditional_t<is_const<_Tp>::value, const __empty, __empty> _EmptyType; | |
| 303 | using __self _LIBCPP_NODEBUG = array; | |
| 304 | using value_type = _Tp; | |
| 305 | using reference = value_type&; | |
| 306 | using const_reference = const value_type&; | |
| 307 | using pointer = value_type*; | |
| 308 | using const_pointer = const value_type*; | |
| 309 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | |
| 310 | using iterator = __static_bounded_iter<pointer, 0>; | |
| 311 | using const_iterator = __static_bounded_iter<const_pointer, 0>; | |
| 312 | # elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY) | |
| 313 | using iterator = __wrap_iter<pointer>; | |
| 314 | using const_iterator = __wrap_iter<const_pointer>; | |
| 315 | # else | |
| 316 | using iterator = pointer; | |
| 317 | using const_iterator = const_pointer; | |
| 318 | # endif | |
| 319 | using size_type = size_t; | |
| 320 | using difference_type = ptrdiff_t; | |
| 321 | using reverse_iterator = std::reverse_iterator<iterator>; | |
| 322 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; | |
| 323 | ||
| 324 | using _EmptyType _LIBCPP_NODEBUG = __conditional_t<is_const<_Tp>::value, const __empty, __empty>; | |
| 287 | 325 | |
| 288 | 326 | struct _ArrayInStructT { |
| 289 | 327 | _Tp __data_[1]; |
| ... | ... | @@ -303,13 +341,33 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { |
| 303 | 341 | } |
| 304 | 342 | |
| 305 | 343 | // iterators: |
| 306 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { return iterator(data()); } | |
| 344 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator begin() _NOEXCEPT { | |
| 345 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | |
| 346 | return std::__make_static_bounded_iter<0>(data(), data()); | |
| 347 | # else | |
| 348 | return iterator(data()); | |
| 349 | # endif | |
| 350 | } | |
| 307 | 351 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator begin() const _NOEXCEPT { |
| 352 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | |
| 353 | return std::__make_static_bounded_iter<0>(data(), data()); | |
| 354 | # else | |
| 308 | 355 | return const_iterator(data()); |
| 356 | # endif | |
| 357 | } | |
| 358 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { | |
| 359 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | |
| 360 | return std::__make_static_bounded_iter<0>(data(), data()); | |
| 361 | # else | |
| 362 | return iterator(data()); | |
| 363 | # endif | |
| 309 | 364 | } |
| 310 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 iterator end() _NOEXCEPT { return iterator(data()); } | |
| 311 | 365 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const_iterator end() const _NOEXCEPT { |
| 366 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY) | |
| 367 | return std::__make_static_bounded_iter<0>(data(), data()); | |
| 368 | # else | |
| 312 | 369 | return const_iterator(data()); |
| 370 | # endif | |
| 313 | 371 | } |
| 314 | 372 | |
| 315 | 373 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator rbegin() _NOEXCEPT { |
| ... | ... | @@ -335,7 +393,7 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { |
| 335 | 393 | // capacity: |
| 336 | 394 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; } |
| 337 | 395 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; } |
| 338 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; } | |
| 396 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; } | |
| 339 | 397 | |
| 340 | 398 | // element access: |
| 341 | 399 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT { |
| ... | ... | @@ -379,10 +437,10 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { |
| 379 | 437 | } |
| 380 | 438 | }; |
| 381 | 439 | |
| 382 | #if _LIBCPP_STD_VER >= 17 | |
| 440 | # if _LIBCPP_STD_VER >= 17 | |
| 383 | 441 | template <class _Tp, class... _Args, class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value> > |
| 384 | 442 | array(_Tp, _Args...) -> array<_Tp, 1 + sizeof...(_Args)>; |
| 385 | #endif | |
| 443 | # endif | |
| 386 | 444 | |
| 387 | 445 | template <class _Tp, size_t _Size> |
| 388 | 446 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool |
| ... | ... | @@ -390,7 +448,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { |
| 390 | 448 | return std::equal(__x.begin(), __x.end(), __y.begin()); |
| 391 | 449 | } |
| 392 | 450 | |
| 393 | #if _LIBCPP_STD_VER <= 17 | |
| 451 | # if _LIBCPP_STD_VER <= 17 | |
| 394 | 452 | |
| 395 | 453 | template <class _Tp, size_t _Size> |
| 396 | 454 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { |
| ... | ... | @@ -417,16 +475,15 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const array<_Tp, _Size>& __x, const |
| 417 | 475 | return !(__x < __y); |
| 418 | 476 | } |
| 419 | 477 | |
| 420 | #else // _LIBCPP_STD_VER <= 17 | |
| 478 | # else // _LIBCPP_STD_VER <= 17 | |
| 421 | 479 | |
| 422 | 480 | template <class _Tp, size_t _Size> |
| 423 | 481 | _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> |
| 424 | 482 | operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { |
| 425 | return std::lexicographical_compare_three_way( | |
| 426 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | |
| 483 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | |
| 427 | 484 | } |
| 428 | 485 | |
| 429 | #endif // _LIBCPP_STD_VER <= 17 | |
| 486 | # endif // _LIBCPP_STD_VER <= 17 | |
| 430 | 487 | |
| 431 | 488 | template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable_v<_Tp>, int> = 0> |
| 432 | 489 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y) |
| ... | ... | @@ -440,7 +497,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_con |
| 440 | 497 | template <size_t _Ip, class _Tp, size_t _Size> |
| 441 | 498 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > { |
| 442 | 499 | static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)"); |
| 443 | typedef _Tp type; | |
| 500 | using type = _Tp; | |
| 444 | 501 | }; |
| 445 | 502 | |
| 446 | 503 | template <size_t _Ip, class _Tp, size_t _Size> |
| ... | ... | @@ -467,7 +524,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const |
| 467 | 524 | return std::move(__a.__elems_[_Ip]); |
| 468 | 525 | } |
| 469 | 526 | |
| 470 | #if _LIBCPP_STD_VER >= 20 | |
| 527 | # if _LIBCPP_STD_VER >= 20 | |
| 471 | 528 | |
| 472 | 529 | template <typename _Tp, size_t _Size, size_t... _Index> |
| 473 | 530 | _LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size> |
| ... | ... | @@ -497,19 +554,21 @@ to_array(_Tp (&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) { |
| 497 | 554 | return std::__to_array_rvalue_impl(std::move(__arr), make_index_sequence<_Size>()); |
| 498 | 555 | } |
| 499 | 556 | |
| 500 | #endif // _LIBCPP_STD_VER >= 20 | |
| 557 | # endif // _LIBCPP_STD_VER >= 20 | |
| 501 | 558 | |
| 502 | 559 | _LIBCPP_END_NAMESPACE_STD |
| 503 | 560 | |
| 504 | 561 | _LIBCPP_POP_MACROS |
| 505 | 562 | |
| 506 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 507 | # include <algorithm> | |
| 508 | # include <concepts> | |
| 509 | # include <cstdlib> | |
| 510 | # include <iterator> | |
| 511 | # include <type_traits> | |
| 512 | # include <utility> | |
| 513 | #endif | |
| 563 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 564 | # include <algorithm> | |
| 565 | # include <concepts> | |
| 566 | # include <cstdlib> | |
| 567 | # include <iterator> | |
| 568 | # include <new> | |
| 569 | # include <type_traits> | |
| 570 | # include <utility> | |
| 571 | # endif | |
| 572 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 514 | 573 | |
| 515 | 574 | #endif // _LIBCPP_ARRAY |
lib/libcxx/include/atomic+96-87| ... | ... | @@ -101,12 +101,12 @@ struct atomic |
| 101 | 101 | bool compare_exchange_strong(T& expc, T desr, |
| 102 | 102 | memory_order m = memory_order_seq_cst) noexcept; |
| 103 | 103 | |
| 104 | void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept; | |
| 105 | void wait(T, memory_order = memory_order::seq_cst) const noexcept; | |
| 106 | void notify_one() volatile noexcept; | |
| 107 | void notify_one() noexcept; | |
| 108 | void notify_all() volatile noexcept; | |
| 109 | void notify_all() noexcept; | |
| 104 | void wait(T, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20 | |
| 105 | void wait(T, memory_order = memory_order::seq_cst) const noexcept; // since C++20 | |
| 106 | void notify_one() volatile noexcept; // since C++20 | |
| 107 | void notify_one() noexcept; // since C++20 | |
| 108 | void notify_all() volatile noexcept; // since C++20 | |
| 109 | void notify_all() noexcept; // since C++20 | |
| 110 | 110 | }; |
| 111 | 111 | |
| 112 | 112 | template <> |
| ... | ... | @@ -184,12 +184,12 @@ struct atomic<integral> |
| 184 | 184 | integral operator^=(integral op) volatile noexcept; |
| 185 | 185 | integral operator^=(integral op) noexcept; |
| 186 | 186 | |
| 187 | void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept; | |
| 188 | void wait(integral, memory_order = memory_order::seq_cst) const noexcept; | |
| 189 | void notify_one() volatile noexcept; | |
| 190 | void notify_one() noexcept; | |
| 191 | void notify_all() volatile noexcept; | |
| 192 | void notify_all() noexcept; | |
| 187 | void wait(integral, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20 | |
| 188 | void wait(integral, memory_order = memory_order::seq_cst) const noexcept; // since C++20 | |
| 189 | void notify_one() volatile noexcept; // since C++20 | |
| 190 | void notify_one() noexcept; // since C++20 | |
| 191 | void notify_all() volatile noexcept; // since C++20 | |
| 192 | void notify_all() noexcept; // since C++20 | |
| 193 | 193 | }; |
| 194 | 194 | |
| 195 | 195 | template <class T> |
| ... | ... | @@ -254,12 +254,12 @@ struct atomic<T*> |
| 254 | 254 | T* operator-=(ptrdiff_t op) volatile noexcept; |
| 255 | 255 | T* operator-=(ptrdiff_t op) noexcept; |
| 256 | 256 | |
| 257 | void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept; | |
| 258 | void wait(T*, memory_order = memory_order::seq_cst) const noexcept; | |
| 259 | void notify_one() volatile noexcept; | |
| 260 | void notify_one() noexcept; | |
| 261 | void notify_all() volatile noexcept; | |
| 262 | void notify_all() noexcept; | |
| 257 | void wait(T*, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20 | |
| 258 | void wait(T*, memory_order = memory_order::seq_cst) const noexcept; // since C++20 | |
| 259 | void notify_one() volatile noexcept; // since C++20 | |
| 260 | void notify_one() noexcept; // since C++20 | |
| 261 | void notify_all() volatile noexcept; // since C++20 | |
| 262 | void notify_all() noexcept; // since C++20 | |
| 263 | 263 | }; |
| 264 | 264 | |
| 265 | 265 | template<> |
| ... | ... | @@ -321,12 +321,12 @@ struct atomic<floating-point-type> { // since C++20 |
| 321 | 321 | floating-point-type operator-=(floating-point-type) volatile noexcept; |
| 322 | 322 | floating-point-type operator-=(floating-point-type) noexcept; |
| 323 | 323 | |
| 324 | void wait(floating-point-type, memory_order = memory_order::seq_cst) const volatile noexcept; | |
| 325 | void wait(floating-point-type, memory_order = memory_order::seq_cst) const noexcept; | |
| 326 | void notify_one() volatile noexcept; | |
| 327 | void notify_one() noexcept; | |
| 328 | void notify_all() volatile noexcept; | |
| 329 | void notify_all() noexcept; | |
| 324 | void wait(floating-point-type, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20 | |
| 325 | void wait(floating-point-type, memory_order = memory_order::seq_cst) const noexcept; // since C++20 | |
| 326 | void notify_one() volatile noexcept; // since C++20 | |
| 327 | void notify_one() noexcept; // since C++20 | |
| 328 | void notify_all() volatile noexcept; // since C++20 | |
| 329 | void notify_all() noexcept; // since C++20 | |
| 330 | 330 | }; |
| 331 | 331 | |
| 332 | 332 | // [atomics.nonmembers], non-member functions |
| ... | ... | @@ -443,23 +443,23 @@ template<class T> |
| 443 | 443 | memory_order) noexcept; |
| 444 | 444 | |
| 445 | 445 | template<class T> |
| 446 | void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept; | |
| 446 | void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type) noexcept; // since C++20 | |
| 447 | 447 | template<class T> |
| 448 | void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept; | |
| 448 | void atomic_wait(const atomic<T>*, atomic<T>::value_type) noexcept; // since C++20 | |
| 449 | 449 | template<class T> |
| 450 | void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type, | |
| 450 | void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type, // since C++20 | |
| 451 | 451 | memory_order) noexcept; |
| 452 | 452 | template<class T> |
| 453 | void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type, | |
| 453 | void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type, // since C++20 | |
| 454 | 454 | memory_order) noexcept; |
| 455 | 455 | template<class T> |
| 456 | void atomic_notify_one(volatile atomic<T>*) noexcept; | |
| 456 | void atomic_notify_one(volatile atomic<T>*) noexcept; // since C++20 | |
| 457 | 457 | template<class T> |
| 458 | void atomic_notify_one(atomic<T>*) noexcept; | |
| 458 | void atomic_notify_one(atomic<T>*) noexcept; // since C++20 | |
| 459 | 459 | template<class T> |
| 460 | void atomic_notify_all(volatile atomic<T>*) noexcept; | |
| 460 | void atomic_notify_all(volatile atomic<T>*) noexcept; // since C++20 | |
| 461 | 461 | template<class T> |
| 462 | void atomic_notify_all(atomic<T>*) noexcept; | |
| 462 | void atomic_notify_all(atomic<T>*) noexcept; // since C++20 | |
| 463 | 463 | |
| 464 | 464 | // Atomics for standard typedef types |
| 465 | 465 | |
| ... | ... | @@ -534,12 +534,12 @@ typedef struct atomic_flag |
| 534 | 534 | void clear(memory_order m = memory_order_seq_cst) volatile noexcept; |
| 535 | 535 | void clear(memory_order m = memory_order_seq_cst) noexcept; |
| 536 | 536 | |
| 537 | void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept; | |
| 538 | void wait(bool, memory_order = memory_order::seq_cst) const noexcept; | |
| 539 | void notify_one() volatile noexcept; | |
| 540 | void notify_one() noexcept; | |
| 541 | void notify_all() volatile noexcept; | |
| 542 | void notify_all() noexcept; | |
| 537 | void wait(bool, memory_order = memory_order::seq_cst) const volatile noexcept; // since C++20 | |
| 538 | void wait(bool, memory_order = memory_order::seq_cst) const noexcept; // since C++20 | |
| 539 | void notify_one() volatile noexcept; // since C++20 | |
| 540 | void notify_one() noexcept; // since C++20 | |
| 541 | void notify_all() volatile noexcept; // since C++20 | |
| 542 | void notify_all() noexcept; // since C++20 | |
| 543 | 543 | } atomic_flag; |
| 544 | 544 | |
| 545 | 545 | bool atomic_flag_test(volatile atomic_flag* obj) noexcept; |
| ... | ... | @@ -557,14 +557,14 @@ void atomic_flag_clear(atomic_flag* obj) noexcept; |
| 557 | 557 | void atomic_flag_clear_explicit(volatile atomic_flag* obj, memory_order m) noexcept; |
| 558 | 558 | void atomic_flag_clear_explicit(atomic_flag* obj, memory_order m) noexcept; |
| 559 | 559 | |
| 560 | void atomic_wait(const volatile atomic_flag* obj, T old) noexcept; | |
| 561 | void atomic_wait(const atomic_flag* obj, T old) noexcept; | |
| 562 | void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept; | |
| 563 | void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept; | |
| 564 | void atomic_one(volatile atomic_flag* obj) noexcept; | |
| 565 | void atomic_one(atomic_flag* obj) noexcept; | |
| 566 | void atomic_all(volatile atomic_flag* obj) noexcept; | |
| 567 | void atomic_all(atomic_flag* obj) noexcept; | |
| 560 | void atomic_wait(const volatile atomic_flag* obj, T old) noexcept; // since C++20 | |
| 561 | void atomic_wait(const atomic_flag* obj, T old) noexcept; // since C++20 | |
| 562 | void atomic_wait_explicit(const volatile atomic_flag* obj, T old, memory_order m) noexcept; // since C++20 | |
| 563 | void atomic_wait_explicit(const atomic_flag* obj, T old, memory_order m) noexcept; // since C++20 | |
| 564 | void atomic_one(volatile atomic_flag* obj) noexcept; // since C++20 | |
| 565 | void atomic_one(atomic_flag* obj) noexcept; // since C++20 | |
| 566 | void atomic_all(volatile atomic_flag* obj) noexcept; // since C++20 | |
| 567 | void atomic_all(atomic_flag* obj) noexcept; // since C++20 | |
| 568 | 568 | |
| 569 | 569 | // fences |
| 570 | 570 | |
| ... | ... | @@ -587,46 +587,55 @@ template <class T> |
| 587 | 587 | |
| 588 | 588 | */ |
| 589 | 589 | |
| 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 | ||
| 596 | #include <__atomic/aliases.h> | |
| 597 | #include <__atomic/atomic.h> | |
| 598 | #include <__atomic/atomic_base.h> | |
| 599 | #include <__atomic/atomic_flag.h> | |
| 600 | #include <__atomic/atomic_init.h> | |
| 601 | #include <__atomic/atomic_lock_free.h> | |
| 602 | #include <__atomic/atomic_sync.h> | |
| 603 | #include <__atomic/check_memory_order.h> | |
| 604 | #include <__atomic/contention_t.h> | |
| 605 | #include <__atomic/cxx_atomic_impl.h> | |
| 606 | #include <__atomic/fence.h> | |
| 607 | #include <__atomic/is_always_lock_free.h> | |
| 608 | #include <__atomic/kill_dependency.h> | |
| 609 | #include <__atomic/memory_order.h> | |
| 610 | #include <version> | |
| 611 | ||
| 612 | #if _LIBCPP_STD_VER >= 20 | |
| 613 | # include <__atomic/atomic_ref.h> | |
| 614 | #endif | |
| 615 | ||
| 616 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 617 | # pragma GCC system_header | |
| 618 | #endif | |
| 619 | ||
| 620 | #ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER | |
| 621 | # error <atomic> is not implemented | |
| 622 | #endif | |
| 623 | ||
| 624 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 625 | # include <cmath> | |
| 626 | # include <compare> | |
| 627 | # include <cstdlib> | |
| 628 | # include <cstring> | |
| 629 | # include <type_traits> | |
| 630 | #endif | |
| 590 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 591 | # include <__cxx03/atomic> | |
| 592 | #else | |
| 593 | # include <__config> | |
| 594 | ||
| 595 | # if defined(_LIBCPP_STDATOMIC_H) || defined(kill_dependency) || defined(atomic_load) | |
| 596 | # define _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED 1 | |
| 597 | # else | |
| 598 | # define _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED 0 | |
| 599 | # endif | |
| 600 | ||
| 601 | # if _LIBCPP_STD_VER < 23 && _LIBCPP_STDATOMIC_H_HAS_DEFINITELY_BEEN_INCLUDED | |
| 602 | # error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23. | |
| 603 | # endif | |
| 604 | ||
| 605 | # include <__atomic/aliases.h> | |
| 606 | # include <__atomic/atomic.h> | |
| 607 | # include <__atomic/atomic_flag.h> | |
| 608 | # include <__atomic/atomic_init.h> | |
| 609 | # include <__atomic/atomic_lock_free.h> | |
| 610 | # include <__atomic/atomic_sync.h> | |
| 611 | # include <__atomic/check_memory_order.h> | |
| 612 | # include <__atomic/contention_t.h> | |
| 613 | # include <__atomic/fence.h> | |
| 614 | # include <__atomic/is_always_lock_free.h> | |
| 615 | # include <__atomic/kill_dependency.h> | |
| 616 | # include <__atomic/memory_order.h> | |
| 617 | # include <version> | |
| 618 | ||
| 619 | # if _LIBCPP_STD_VER >= 20 | |
| 620 | # include <__atomic/atomic_ref.h> | |
| 621 | # endif | |
| 622 | ||
| 623 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 624 | # pragma GCC system_header | |
| 625 | # endif | |
| 626 | ||
| 627 | # if !_LIBCPP_HAS_ATOMIC_HEADER | |
| 628 | # error <atomic> is not implemented | |
| 629 | # endif | |
| 630 | ||
| 631 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 632 | # include <cmath> | |
| 633 | # include <compare> | |
| 634 | # include <cstddef> | |
| 635 | # include <cstdlib> | |
| 636 | # include <cstring> | |
| 637 | # include <type_traits> | |
| 638 | # endif | |
| 639 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 631 | 640 | |
| 632 | 641 | #endif // _LIBCPP_ATOMIC |
lib/libcxx/include/barrier+43-144| ... | ... | @@ -17,7 +17,7 @@ namespace std |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | 19 | template<class CompletionFunction = see below> |
| 20 | class barrier | |
| 20 | class barrier // since C++20 | |
| 21 | 21 | { |
| 22 | 22 | public: |
| 23 | 23 | using arrival_token = see below; |
| ... | ... | @@ -45,30 +45,33 @@ namespace std |
| 45 | 45 | |
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | #include <__config> | |
| 49 | ||
| 50 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 51 | ||
| 52 | # include <__assert> | |
| 53 | # include <__atomic/atomic_base.h> | |
| 54 | # include <__atomic/memory_order.h> | |
| 55 | # include <__memory/unique_ptr.h> | |
| 56 | # include <__thread/poll_with_backoff.h> | |
| 57 | # include <__thread/timed_backoff_policy.h> | |
| 58 | # include <__utility/move.h> | |
| 59 | # include <cstddef> | |
| 60 | # include <cstdint> | |
| 61 | # include <limits> | |
| 62 | # include <version> | |
| 63 | ||
| 64 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 65 | # pragma GCC system_header | |
| 66 | # endif | |
| 48 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 49 | # include <__cxx03/barrier> | |
| 50 | #else | |
| 51 | # include <__config> | |
| 52 | ||
| 53 | # if _LIBCPP_HAS_THREADS | |
| 54 | ||
| 55 | # include <__assert> | |
| 56 | # include <__atomic/atomic.h> | |
| 57 | # include <__atomic/memory_order.h> | |
| 58 | # include <__cstddef/ptrdiff_t.h> | |
| 59 | # include <__memory/unique_ptr.h> | |
| 60 | # include <__thread/poll_with_backoff.h> | |
| 61 | # include <__thread/timed_backoff_policy.h> | |
| 62 | # include <__utility/move.h> | |
| 63 | # include <cstdint> | |
| 64 | # include <limits> | |
| 65 | # include <version> | |
| 66 | ||
| 67 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 68 | # pragma GCC system_header | |
| 69 | # endif | |
| 67 | 70 | |
| 68 | 71 | _LIBCPP_PUSH_MACROS |
| 69 | # include <__undef_macros> | |
| 72 | # include <__undef_macros> | |
| 70 | 73 | |
| 71 | # if _LIBCPP_STD_VER >= 14 | |
| 74 | # if _LIBCPP_STD_VER >= 20 | |
| 72 | 75 | |
| 73 | 76 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 74 | 77 | |
| ... | ... | @@ -76,8 +79,6 @@ struct __empty_completion { |
| 76 | 79 | inline _LIBCPP_HIDE_FROM_ABI void operator()() noexcept {} |
| 77 | 80 | }; |
| 78 | 81 | |
| 79 | # ifndef _LIBCPP_HAS_NO_TREE_BARRIER | |
| 80 | ||
| 81 | 82 | /* |
| 82 | 83 | |
| 83 | 84 | The default implementation of __barrier_base is a classic tree barrier. |
| ... | ... | @@ -92,7 +93,7 @@ It looks different from literature pseudocode for two main reasons: |
| 92 | 93 | |
| 93 | 94 | */ |
| 94 | 95 | |
| 95 | using __barrier_phase_t = uint8_t; | |
| 96 | using __barrier_phase_t _LIBCPP_NODEBUG = uint8_t; | |
| 96 | 97 | |
| 97 | 98 | class __barrier_algorithm_base; |
| 98 | 99 | |
| ... | ... | @@ -109,9 +110,9 @@ template <class _CompletionF> |
| 109 | 110 | class __barrier_base { |
| 110 | 111 | ptrdiff_t __expected_; |
| 111 | 112 | unique_ptr<__barrier_algorithm_base, void (*)(__barrier_algorithm_base*)> __base_; |
| 112 | __atomic_base<ptrdiff_t> __expected_adjustment_; | |
| 113 | atomic<ptrdiff_t> __expected_adjustment_; | |
| 113 | 114 | _CompletionF __completion_; |
| 114 | __atomic_base<__barrier_phase_t> __phase_; | |
| 115 | atomic<__barrier_phase_t> __phase_; | |
| 115 | 116 | |
| 116 | 117 | public: |
| 117 | 118 | using arrival_token = __barrier_phase_t; |
| ... | ... | @@ -125,7 +126,7 @@ public: |
| 125 | 126 | __expected_adjustment_(0), |
| 126 | 127 | __completion_(std::move(__completion)), |
| 127 | 128 | __phase_(0) {} |
| 128 | _LIBCPP_NODISCARD _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) { | |
| 129 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) { | |
| 129 | 130 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( |
| 130 | 131 | __update <= __expected_, "update is greater than the expected count for the current barrier phase"); |
| 131 | 132 | |
| ... | ... | @@ -150,111 +151,8 @@ public: |
| 150 | 151 | } |
| 151 | 152 | }; |
| 152 | 153 | |
| 153 | # else | |
| 154 | ||
| 155 | /* | |
| 156 | ||
| 157 | The alternative implementation of __barrier_base is a central barrier. | |
| 158 | ||
| 159 | Two versions of this algorithm are provided: | |
| 160 | 1. A fairly straightforward implementation of the litterature for the | |
| 161 | general case where the completion function is not empty. | |
| 162 | 2. An optimized implementation that exploits 2's complement arithmetic | |
| 163 | and well-defined overflow in atomic arithmetic, to handle the phase | |
| 164 | roll-over for free. | |
| 165 | ||
| 166 | */ | |
| 167 | ||
| 168 | template <class _CompletionF> | |
| 169 | class __barrier_base { | |
| 170 | __atomic_base<ptrdiff_t> __expected; | |
| 171 | __atomic_base<ptrdiff_t> __arrived; | |
| 172 | _CompletionF __completion; | |
| 173 | __atomic_base<bool> __phase; | |
| 174 | ||
| 175 | public: | |
| 176 | using arrival_token = bool; | |
| 177 | ||
| 178 | static constexpr ptrdiff_t max() noexcept { return numeric_limits<ptrdiff_t>::max(); } | |
| 179 | ||
| 180 | _LIBCPP_HIDE_FROM_ABI __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF()) | |
| 181 | : __expected(__expected), __arrived(__expected), __completion(std::move(__completion)), __phase(false) {} | |
| 182 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t update) { | |
| 183 | auto const __old_phase = __phase.load(memory_order_relaxed); | |
| 184 | auto const __result = __arrived.fetch_sub(update, memory_order_acq_rel) - update; | |
| 185 | auto const new_expected = __expected.load(memory_order_relaxed); | |
| 186 | ||
| 187 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | |
| 188 | update <= new_expected, "update is greater than the expected count for the current barrier phase"); | |
| 189 | ||
| 190 | if (0 == __result) { | |
| 191 | __completion(); | |
| 192 | __arrived.store(new_expected, memory_order_relaxed); | |
| 193 | __phase.store(!__old_phase, memory_order_release); | |
| 194 | __phase.notify_all(); | |
| 195 | } | |
| 196 | return __old_phase; | |
| 197 | } | |
| 198 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __old_phase) const { | |
| 199 | __phase.wait(__old_phase, memory_order_acquire); | |
| 200 | } | |
| 201 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_drop() { | |
| 202 | __expected.fetch_sub(1, memory_order_relaxed); | |
| 203 | (void)arrive(1); | |
| 204 | } | |
| 205 | }; | |
| 206 | ||
| 207 | template <> | |
| 208 | class __barrier_base<__empty_completion> { | |
| 209 | static constexpr uint64_t __expected_unit = 1ull; | |
| 210 | static constexpr uint64_t __arrived_unit = 1ull << 32; | |
| 211 | static constexpr uint64_t __expected_mask = __arrived_unit - 1; | |
| 212 | static constexpr uint64_t __phase_bit = 1ull << 63; | |
| 213 | static constexpr uint64_t __arrived_mask = (__phase_bit - 1) & ~__expected_mask; | |
| 214 | ||
| 215 | __atomic_base<uint64_t> __phase_arrived_expected; | |
| 216 | ||
| 217 | static _LIBCPP_HIDE_FROM_ABI constexpr uint64_t __init(ptrdiff_t __count) _NOEXCEPT { | |
| 218 | return ((uint64_t(1u << 31) - __count) << 32) | (uint64_t(1u << 31) - __count); | |
| 219 | } | |
| 220 | ||
| 221 | public: | |
| 222 | using arrival_token = uint64_t; | |
| 223 | ||
| 224 | static constexpr ptrdiff_t max() noexcept { return ptrdiff_t(1u << 31) - 1; } | |
| 225 | ||
| 226 | _LIBCPP_HIDE_FROM_ABI explicit inline __barrier_base(ptrdiff_t __count, __empty_completion = __empty_completion()) | |
| 227 | : __phase_arrived_expected(__init(__count)) {} | |
| 228 | [[nodiscard]] inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t update) { | |
| 229 | auto const __inc = __arrived_unit * update; | |
| 230 | auto const __old = __phase_arrived_expected.fetch_add(__inc, memory_order_acq_rel); | |
| 231 | ||
| 232 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN( | |
| 233 | update <= __old, "update is greater than the expected count for the current barrier phase"); | |
| 234 | ||
| 235 | if ((__old ^ (__old + __inc)) & __phase_bit) { | |
| 236 | __phase_arrived_expected.fetch_add((__old & __expected_mask) << 32, memory_order_relaxed); | |
| 237 | __phase_arrived_expected.notify_all(); | |
| 238 | } | |
| 239 | return __old & __phase_bit; | |
| 240 | } | |
| 241 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(arrival_token&& __phase) const { | |
| 242 | auto const __test_fn = [=]() -> bool { | |
| 243 | uint64_t const __current = __phase_arrived_expected.load(memory_order_acquire); | |
| 244 | return ((__current & __phase_bit) != __phase); | |
| 245 | }; | |
| 246 | __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy()); | |
| 247 | } | |
| 248 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_drop() { | |
| 249 | __phase_arrived_expected.fetch_add(__expected_unit, memory_order_relaxed); | |
| 250 | (void)arrive(1); | |
| 251 | } | |
| 252 | }; | |
| 253 | ||
| 254 | # endif // !_LIBCPP_HAS_NO_TREE_BARRIER | |
| 255 | ||
| 256 | 154 | template <class _CompletionF = __empty_completion> |
| 257 | class _LIBCPP_DEPRECATED_ATOMIC_SYNC barrier { | |
| 155 | class barrier { | |
| 258 | 156 | __barrier_base<_CompletionF> __b_; |
| 259 | 157 | |
| 260 | 158 | public: |
| ... | ... | @@ -277,7 +175,7 @@ public: |
| 277 | 175 | barrier(barrier const&) = delete; |
| 278 | 176 | barrier& operator=(barrier const&) = delete; |
| 279 | 177 | |
| 280 | _LIBCPP_NODISCARD _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) { | |
| 178 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) { | |
| 281 | 179 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update > 0, "barrier:arrive must be called with a value greater than 0"); |
| 282 | 180 | return __b_.arrive(__update); |
| 283 | 181 | } |
| ... | ... | @@ -290,19 +188,20 @@ public: |
| 290 | 188 | |
| 291 | 189 | _LIBCPP_END_NAMESPACE_STD |
| 292 | 190 | |
| 293 | # endif // _LIBCPP_STD_VER >= 14 | |
| 191 | # endif // _LIBCPP_STD_VER >= 20 | |
| 294 | 192 | |
| 295 | 193 | _LIBCPP_POP_MACROS |
| 296 | 194 | |
| 297 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 195 | # endif // _LIBCPP_HAS_THREADS | |
| 298 | 196 | |
| 299 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 300 | # include <atomic> | |
| 301 | # include <concepts> | |
| 302 | # include <iterator> | |
| 303 | # include <memory> | |
| 304 | # include <stdexcept> | |
| 305 | # include <variant> | |
| 306 | #endif | |
| 197 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 198 | # include <atomic> | |
| 199 | # include <concepts> | |
| 200 | # include <iterator> | |
| 201 | # include <memory> | |
| 202 | # include <stdexcept> | |
| 203 | # include <variant> | |
| 204 | # endif | |
| 205 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 307 | 206 | |
| 308 | #endif //_LIBCPP_BARRIER | |
| 207 | #endif // _LIBCPP_BARRIER |
lib/libcxx/include/bit+36-36| ... | ... | @@ -61,41 +61,41 @@ namespace std { |
| 61 | 61 | |
| 62 | 62 | */ |
| 63 | 63 | |
| 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 | ||
| 84 | #include <version> | |
| 85 | ||
| 86 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 87 | # pragma GCC system_header | |
| 88 | #endif | |
| 89 | ||
| 90 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 91 | # include <cstdint> | |
| 92 | #endif | |
| 93 | ||
| 94 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 95 | # include <cstdlib> | |
| 96 | # include <iosfwd> | |
| 97 | # include <limits> | |
| 98 | # include <type_traits> | |
| 99 | #endif | |
| 64 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 65 | # include <__cxx03/bit> | |
| 66 | #else | |
| 67 | # include <__config> | |
| 68 | ||
| 69 | # if _LIBCPP_STD_VER >= 20 | |
| 70 | # include <__bit/bit_cast.h> | |
| 71 | # include <__bit/bit_ceil.h> | |
| 72 | # include <__bit/bit_floor.h> | |
| 73 | # include <__bit/bit_log2.h> | |
| 74 | # include <__bit/bit_width.h> | |
| 75 | # include <__bit/countl.h> | |
| 76 | # include <__bit/countr.h> | |
| 77 | # include <__bit/endian.h> | |
| 78 | # include <__bit/has_single_bit.h> | |
| 79 | # include <__bit/popcount.h> | |
| 80 | # include <__bit/rotate.h> | |
| 81 | # endif | |
| 82 | ||
| 83 | # if _LIBCPP_STD_VER >= 23 | |
| 84 | # include <__bit/byteswap.h> | |
| 85 | # endif | |
| 86 | ||
| 87 | # include <version> | |
| 88 | ||
| 89 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 90 | # pragma GCC system_header | |
| 91 | # endif | |
| 92 | ||
| 93 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 94 | # include <cstdlib> | |
| 95 | # include <iosfwd> | |
| 96 | # include <limits> | |
| 97 | # include <type_traits> | |
| 98 | # endif | |
| 99 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 100 | 100 | |
| 101 | 101 | #endif // _LIBCPP_BIT |
lib/libcxx/include/bitset+135-125| ... | ... | @@ -126,32 +126,38 @@ template <size_t N> struct hash<std::bitset<N>>; |
| 126 | 126 | |
| 127 | 127 | // clang-format on |
| 128 | 128 | |
| 129 | #include <__algorithm/count.h> | |
| 130 | #include <__algorithm/fill.h> | |
| 131 | #include <__algorithm/find.h> | |
| 132 | #include <__bit_reference> | |
| 133 | #include <__config> | |
| 134 | #include <__functional/hash.h> | |
| 135 | #include <__functional/unary_function.h> | |
| 136 | #include <__type_traits/is_char_like_type.h> | |
| 137 | #include <climits> | |
| 138 | #include <cstddef> | |
| 139 | #include <stdexcept> | |
| 140 | #include <string_view> | |
| 141 | #include <version> | |
| 129 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 130 | # include <__cxx03/bitset> | |
| 131 | #else | |
| 132 | # include <__algorithm/count.h> | |
| 133 | # include <__algorithm/fill.h> | |
| 134 | # include <__algorithm/fill_n.h> | |
| 135 | # include <__algorithm/find.h> | |
| 136 | # include <__assert> | |
| 137 | # include <__bit_reference> | |
| 138 | # include <__config> | |
| 139 | # include <__cstddef/ptrdiff_t.h> | |
| 140 | # include <__cstddef/size_t.h> | |
| 141 | # include <__functional/hash.h> | |
| 142 | # include <__functional/unary_function.h> | |
| 143 | # include <__type_traits/is_char_like_type.h> | |
| 144 | # include <climits> | |
| 145 | # include <stdexcept> | |
| 146 | # include <string_view> | |
| 147 | # include <version> | |
| 142 | 148 | |
| 143 | 149 | // standard-mandated includes |
| 144 | 150 | |
| 145 | 151 | // [bitset.syn] |
| 146 | #include <iosfwd> | |
| 147 | #include <string> | |
| 152 | # include <iosfwd> | |
| 153 | # include <string> | |
| 148 | 154 | |
| 149 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 150 | # pragma GCC system_header | |
| 151 | #endif | |
| 155 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 156 | # pragma GCC system_header | |
| 157 | # endif | |
| 152 | 158 | |
| 153 | 159 | _LIBCPP_PUSH_MACROS |
| 154 | #include <__undef_macros> | |
| 160 | # include <__undef_macros> | |
| 155 | 161 | |
| 156 | 162 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 157 | 163 | |
| ... | ... | @@ -166,9 +172,7 @@ struct __has_storage_type<__bitset<_N_words, _Size> > { |
| 166 | 172 | template <size_t _N_words, size_t _Size> |
| 167 | 173 | class __bitset { |
| 168 | 174 | public: |
| 169 | typedef ptrdiff_t difference_type; | |
| 170 | typedef size_t size_type; | |
| 171 | typedef size_type __storage_type; | |
| 175 | typedef size_t __storage_type; | |
| 172 | 176 | |
| 173 | 177 | protected: |
| 174 | 178 | typedef __bitset __self; |
| ... | ... | @@ -185,9 +189,9 @@ protected: |
| 185 | 189 | __storage_type __first_[_N_words]; |
| 186 | 190 | |
| 187 | 191 | typedef __bit_reference<__bitset> reference; |
| 188 | typedef __bit_const_reference<__bitset> const_reference; | |
| 189 | typedef __bit_iterator<__bitset, false> iterator; | |
| 190 | typedef __bit_iterator<__bitset, true> const_iterator; | |
| 192 | typedef __bit_const_reference<__bitset> __const_reference; | |
| 193 | typedef __bit_iterator<__bitset, false> __iterator; | |
| 194 | typedef __bit_iterator<__bitset, true> __const_iterator; | |
| 191 | 195 | |
| 192 | 196 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; |
| 193 | 197 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; |
| ... | ... | @@ -195,14 +199,14 @@ protected: |
| 195 | 199 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT { |
| 196 | 200 | return reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word); |
| 197 | 201 | } |
| 198 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT { | |
| 199 | return const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word); | |
| 202 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __const_reference __make_ref(size_t __pos) const _NOEXCEPT { | |
| 203 | return __const_reference(__first_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word); | |
| 200 | 204 | } |
| 201 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT { | |
| 202 | return iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word); | |
| 205 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT { | |
| 206 | return __iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word); | |
| 203 | 207 | } |
| 204 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT { | |
| 205 | return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word); | |
| 208 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT { | |
| 209 | return __const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word); | |
| 206 | 210 | } |
| 207 | 211 | |
| 208 | 212 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT; |
| ... | ... | @@ -222,10 +226,10 @@ protected: |
| 222 | 226 | _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT; |
| 223 | 227 | |
| 224 | 228 | private: |
| 225 | #ifdef _LIBCPP_CXX03_LANG | |
| 229 | # ifdef _LIBCPP_CXX03_LANG | |
| 226 | 230 | void __init(unsigned long long __v, false_type) _NOEXCEPT; |
| 227 | 231 | _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT; |
| 228 | #endif // _LIBCPP_CXX03_LANG | |
| 232 | # endif // _LIBCPP_CXX03_LANG | |
| 229 | 233 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(false_type) const; |
| 230 | 234 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(true_type) const; |
| 231 | 235 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(false_type) const; |
| ... | ... | @@ -236,16 +240,16 @@ private: |
| 236 | 240 | |
| 237 | 241 | template <size_t _N_words, size_t _Size> |
| 238 | 242 | inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT |
| 239 | #ifndef _LIBCPP_CXX03_LANG | |
| 243 | # ifndef _LIBCPP_CXX03_LANG | |
| 240 | 244 | : __first_{0} |
| 241 | #endif | |
| 245 | # endif | |
| 242 | 246 | { |
| 243 | #ifdef _LIBCPP_CXX03_LANG | |
| 247 | # ifdef _LIBCPP_CXX03_LANG | |
| 244 | 248 | std::fill_n(__first_, _N_words, __storage_type(0)); |
| 245 | #endif | |
| 249 | # endif | |
| 246 | 250 | } |
| 247 | 251 | |
| 248 | #ifdef _LIBCPP_CXX03_LANG | |
| 252 | # ifdef _LIBCPP_CXX03_LANG | |
| 249 | 253 | |
| 250 | 254 | template <size_t _N_words, size_t _Size> |
| 251 | 255 | void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT { |
| ... | ... | @@ -271,54 +275,54 @@ inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned lon |
| 271 | 275 | std::fill(__first_ + 1, __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0)); |
| 272 | 276 | } |
| 273 | 277 | |
| 274 | #endif // _LIBCPP_CXX03_LANG | |
| 278 | # endif // _LIBCPP_CXX03_LANG | |
| 275 | 279 | |
| 276 | 280 | template <size_t _N_words, size_t _Size> |
| 277 | 281 | inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT |
| 278 | #ifndef _LIBCPP_CXX03_LANG | |
| 279 | # if __SIZEOF_SIZE_T__ == 8 | |
| 282 | # ifndef _LIBCPP_CXX03_LANG | |
| 283 | # if __SIZEOF_SIZE_T__ == 8 | |
| 280 | 284 | : __first_{__v} |
| 281 | # elif __SIZEOF_SIZE_T__ == 4 | |
| 285 | # elif __SIZEOF_SIZE_T__ == 4 | |
| 282 | 286 | : __first_{static_cast<__storage_type>(__v), |
| 283 | 287 | _Size >= 2 * __bits_per_word |
| 284 | 288 | ? static_cast<__storage_type>(__v >> __bits_per_word) |
| 285 | 289 | : static_cast<__storage_type>((__v >> __bits_per_word) & |
| 286 | 290 | (__storage_type(1) << (_Size - __bits_per_word)) - 1)} |
| 287 | # else | |
| 288 | # error This constructor has not been ported to this platform | |
| 291 | # else | |
| 292 | # error This constructor has not been ported to this platform | |
| 293 | # endif | |
| 289 | 294 | # endif |
| 290 | #endif | |
| 291 | 295 | { |
| 292 | #ifdef _LIBCPP_CXX03_LANG | |
| 296 | # ifdef _LIBCPP_CXX03_LANG | |
| 293 | 297 | __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>()); |
| 294 | #endif | |
| 298 | # endif | |
| 295 | 299 | } |
| 296 | 300 | |
| 297 | 301 | template <size_t _N_words, size_t _Size> |
| 298 | 302 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void |
| 299 | 303 | __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT { |
| 300 | for (size_type __i = 0; __i < _N_words; ++__i) | |
| 304 | for (size_t __i = 0; __i < _N_words; ++__i) | |
| 301 | 305 | __first_[__i] &= __v.__first_[__i]; |
| 302 | 306 | } |
| 303 | 307 | |
| 304 | 308 | template <size_t _N_words, size_t _Size> |
| 305 | 309 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void |
| 306 | 310 | __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT { |
| 307 | for (size_type __i = 0; __i < _N_words; ++__i) | |
| 311 | for (size_t __i = 0; __i < _N_words; ++__i) | |
| 308 | 312 | __first_[__i] |= __v.__first_[__i]; |
| 309 | 313 | } |
| 310 | 314 | |
| 311 | 315 | template <size_t _N_words, size_t _Size> |
| 312 | 316 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void |
| 313 | 317 | __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT { |
| 314 | for (size_type __i = 0; __i < _N_words; ++__i) | |
| 318 | for (size_t __i = 0; __i < _N_words; ++__i) | |
| 315 | 319 | __first_[__i] ^= __v.__first_[__i]; |
| 316 | 320 | } |
| 317 | 321 | |
| 318 | 322 | template <size_t _N_words, size_t _Size> |
| 319 | 323 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Size>::flip() _NOEXCEPT { |
| 320 | 324 | // do middle whole words |
| 321 | size_type __n = _Size; | |
| 325 | size_t __n = _Size; | |
| 322 | 326 | __storage_pointer __p = __first_; |
| 323 | 327 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) |
| 324 | 328 | *__p = ~*__p; |
| ... | ... | @@ -334,8 +338,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz |
| 334 | 338 | template <size_t _N_words, size_t _Size> |
| 335 | 339 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long |
| 336 | 340 | __bitset<_N_words, _Size>::to_ulong(false_type) const { |
| 337 | const_iterator __e = __make_iter(_Size); | |
| 338 | const_iterator __i = std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true); | |
| 341 | __const_iterator __e = __make_iter(_Size); | |
| 342 | __const_iterator __i = std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true); | |
| 339 | 343 | if (__i != __e) |
| 340 | 344 | __throw_overflow_error("bitset to_ulong overflow error"); |
| 341 | 345 | |
| ... | ... | @@ -351,8 +355,8 @@ __bitset<_N_words, _Size>::to_ulong(true_type) const { |
| 351 | 355 | template <size_t _N_words, size_t _Size> |
| 352 | 356 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long |
| 353 | 357 | __bitset<_N_words, _Size>::to_ullong(false_type) const { |
| 354 | const_iterator __e = __make_iter(_Size); | |
| 355 | const_iterator __i = std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true); | |
| 358 | __const_iterator __e = __make_iter(_Size); | |
| 359 | __const_iterator __i = std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true); | |
| 356 | 360 | if (__i != __e) |
| 357 | 361 | __throw_overflow_error("bitset to_ullong overflow error"); |
| 358 | 362 | |
| ... | ... | @@ -386,7 +390,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const { |
| 386 | 390 | template <size_t _N_words, size_t _Size> |
| 387 | 391 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::all() const _NOEXCEPT { |
| 388 | 392 | // do middle whole words |
| 389 | size_type __n = _Size; | |
| 393 | size_t __n = _Size; | |
| 390 | 394 | __const_storage_pointer __p = __first_; |
| 391 | 395 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) |
| 392 | 396 | if (~*__p) |
| ... | ... | @@ -403,7 +407,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Siz |
| 403 | 407 | template <size_t _N_words, size_t _Size> |
| 404 | 408 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::any() const _NOEXCEPT { |
| 405 | 409 | // do middle whole words |
| 406 | size_type __n = _Size; | |
| 410 | size_t __n = _Size; | |
| 407 | 411 | __const_storage_pointer __p = __first_; |
| 408 | 412 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) |
| 409 | 413 | if (*__p) |
| ... | ... | @@ -420,7 +424,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Siz |
| 420 | 424 | template <size_t _N_words, size_t _Size> |
| 421 | 425 | inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT { |
| 422 | 426 | size_t __h = 0; |
| 423 | for (size_type __i = 0; __i < _N_words; ++__i) | |
| 427 | for (size_t __i = 0; __i < _N_words; ++__i) | |
| 424 | 428 | __h ^= __first_[__i]; |
| 425 | 429 | return __h; |
| 426 | 430 | } |
| ... | ... | @@ -428,9 +432,7 @@ inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT { |
| 428 | 432 | template <size_t _Size> |
| 429 | 433 | class __bitset<1, _Size> { |
| 430 | 434 | public: |
| 431 | typedef ptrdiff_t difference_type; | |
| 432 | typedef size_t size_type; | |
| 433 | typedef size_type __storage_type; | |
| 435 | typedef size_t __storage_type; | |
| 434 | 436 | |
| 435 | 437 | protected: |
| 436 | 438 | typedef __bitset __self; |
| ... | ... | @@ -447,9 +449,9 @@ protected: |
| 447 | 449 | __storage_type __first_; |
| 448 | 450 | |
| 449 | 451 | typedef __bit_reference<__bitset> reference; |
| 450 | typedef __bit_const_reference<__bitset> const_reference; | |
| 451 | typedef __bit_iterator<__bitset, false> iterator; | |
| 452 | typedef __bit_iterator<__bitset, true> const_iterator; | |
| 452 | typedef __bit_const_reference<__bitset> __const_reference; | |
| 453 | typedef __bit_iterator<__bitset, false> __iterator; | |
| 454 | typedef __bit_iterator<__bitset, true> __const_iterator; | |
| 453 | 455 | |
| 454 | 456 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; |
| 455 | 457 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; |
| ... | ... | @@ -457,14 +459,14 @@ protected: |
| 457 | 459 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t __pos) _NOEXCEPT { |
| 458 | 460 | return reference(&__first_, __storage_type(1) << __pos); |
| 459 | 461 | } |
| 460 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t __pos) const _NOEXCEPT { | |
| 461 | return const_reference(&__first_, __storage_type(1) << __pos); | |
| 462 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __const_reference __make_ref(size_t __pos) const _NOEXCEPT { | |
| 463 | return __const_reference(&__first_, __storage_type(1) << __pos); | |
| 462 | 464 | } |
| 463 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t __pos) _NOEXCEPT { | |
| 464 | return iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word); | |
| 465 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT { | |
| 466 | return __iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word); | |
| 465 | 467 | } |
| 466 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t __pos) const _NOEXCEPT { | |
| 467 | return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word); | |
| 468 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT { | |
| 469 | return __const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word); | |
| 468 | 470 | } |
| 469 | 471 | |
| 470 | 472 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT; |
| ... | ... | @@ -545,9 +547,7 @@ inline size_t __bitset<1, _Size>::__hash_code() const _NOEXCEPT { |
| 545 | 547 | template <> |
| 546 | 548 | class __bitset<0, 0> { |
| 547 | 549 | public: |
| 548 | typedef ptrdiff_t difference_type; | |
| 549 | typedef size_t size_type; | |
| 550 | typedef size_type __storage_type; | |
| 550 | typedef size_t __storage_type; | |
| 551 | 551 | |
| 552 | 552 | protected: |
| 553 | 553 | typedef __bitset __self; |
| ... | ... | @@ -562,9 +562,9 @@ protected: |
| 562 | 562 | friend struct __bit_array<__bitset>; |
| 563 | 563 | |
| 564 | 564 | typedef __bit_reference<__bitset> reference; |
| 565 | typedef __bit_const_reference<__bitset> const_reference; | |
| 566 | typedef __bit_iterator<__bitset, false> iterator; | |
| 567 | typedef __bit_iterator<__bitset, true> const_iterator; | |
| 565 | typedef __bit_const_reference<__bitset> __const_reference; | |
| 566 | typedef __bit_iterator<__bitset, false> __iterator; | |
| 567 | typedef __bit_iterator<__bitset, true> __const_iterator; | |
| 568 | 568 | |
| 569 | 569 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; |
| 570 | 570 | _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT; |
| ... | ... | @@ -572,14 +572,14 @@ protected: |
| 572 | 572 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference __make_ref(size_t) _NOEXCEPT { |
| 573 | 573 | return reference(nullptr, 1); |
| 574 | 574 | } |
| 575 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __make_ref(size_t) const _NOEXCEPT { | |
| 576 | return const_reference(nullptr, 1); | |
| 575 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __const_reference __make_ref(size_t) const _NOEXCEPT { | |
| 576 | return __const_reference(nullptr, 1); | |
| 577 | 577 | } |
| 578 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 iterator __make_iter(size_t) _NOEXCEPT { | |
| 579 | return iterator(nullptr, 0); | |
| 578 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t) _NOEXCEPT { | |
| 579 | return __iterator(nullptr, 0); | |
| 580 | 580 | } |
| 581 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const_iterator __make_iter(size_t) const _NOEXCEPT { | |
| 582 | return const_iterator(nullptr, 0); | |
| 581 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t) const _NOEXCEPT { | |
| 582 | return __const_iterator(nullptr, 0); | |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset&) _NOEXCEPT {} |
| ... | ... | @@ -611,30 +611,30 @@ class _LIBCPP_TEMPLATE_VIS bitset |
| 611 | 611 | : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> { |
| 612 | 612 | public: |
| 613 | 613 | static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1; |
| 614 | typedef __bitset<__n_words, _Size> base; | |
| 614 | typedef __bitset<__n_words, _Size> __base; | |
| 615 | 615 | |
| 616 | 616 | public: |
| 617 | typedef typename base::reference reference; | |
| 618 | typedef typename base::const_reference const_reference; | |
| 617 | typedef typename __base::reference reference; | |
| 618 | typedef typename __base::__const_reference __const_reference; | |
| 619 | 619 | |
| 620 | 620 | // 23.3.5.1 constructors: |
| 621 | 621 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} |
| 622 | _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) {} | |
| 623 | 623 | template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0> |
| 624 | 624 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset( |
| 625 | 625 | const _CharT* __str, |
| 626 | #if _LIBCPP_STD_VER >= 26 | |
| 626 | # if _LIBCPP_STD_VER >= 26 | |
| 627 | 627 | typename basic_string_view<_CharT>::size_type __n = basic_string_view<_CharT>::npos, |
| 628 | #else | |
| 628 | # else | |
| 629 | 629 | typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, |
| 630 | #endif | |
| 630 | # endif | |
| 631 | 631 | _CharT __zero = _CharT('0'), |
| 632 | 632 | _CharT __one = _CharT('1')) { |
| 633 | 633 | |
| 634 | 634 | size_t __rlen = std::min(__n, char_traits<_CharT>::length(__str)); |
| 635 | 635 | __init_from_string_view(basic_string_view<_CharT>(__str, __rlen), __zero, __one); |
| 636 | 636 | } |
| 637 | #if _LIBCPP_STD_VER >= 26 | |
| 637 | # if _LIBCPP_STD_VER >= 26 | |
| 638 | 638 | template <class _CharT, class _Traits> |
| 639 | 639 | _LIBCPP_HIDE_FROM_ABI constexpr explicit bitset( |
| 640 | 640 | basic_string_view<_CharT, _Traits> __str, |
| ... | ... | @@ -648,7 +648,7 @@ public: |
| 648 | 648 | size_t __rlen = std::min(__n, __str.size() - __pos); |
| 649 | 649 | __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one); |
| 650 | 650 | } |
| 651 | #endif | |
| 651 | # endif | |
| 652 | 652 | template <class _CharT, class _Traits, class _Allocator> |
| 653 | 653 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset( |
| 654 | 654 | const basic_string<_CharT, _Traits, _Allocator>& __str, |
| ... | ... | @@ -679,12 +679,21 @@ public: |
| 679 | 679 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset& flip(size_t __pos); |
| 680 | 680 | |
| 681 | 681 | // element access: |
| 682 | #ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | |
| 683 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const { return base::__make_ref(__p); } | |
| 684 | #else | |
| 685 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const { return base::__make_ref(__p); } | |
| 686 | #endif | |
| 687 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) { return base::__make_ref(__p); } | |
| 682 | # ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | |
| 683 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const { | |
| 684 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); | |
| 685 | return __base::__make_ref(__p); | |
| 686 | } | |
| 687 | # else | |
| 688 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __const_reference operator[](size_t __p) const { | |
| 689 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); | |
| 690 | return __base::__make_ref(__p); | |
| 691 | } | |
| 692 | # endif | |
| 693 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 reference operator[](size_t __p) { | |
| 694 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds"); | |
| 695 | return __base::__make_ref(__p); | |
| 696 | } | |
| 688 | 697 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const; |
| 689 | 698 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const; |
| 690 | 699 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -701,9 +710,9 @@ public: |
| 701 | 710 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t count() const _NOEXCEPT; |
| 702 | 711 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT { return _Size; } |
| 703 | 712 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const bitset& __rhs) const _NOEXCEPT; |
| 704 | #if _LIBCPP_STD_VER <= 17 | |
| 713 | # if _LIBCPP_STD_VER <= 17 | |
| 705 | 714 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT; |
| 706 | #endif | |
| 715 | # endif | |
| 707 | 716 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const; |
| 708 | 717 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT; |
| 709 | 718 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT; |
| ... | ... | @@ -725,10 +734,10 @@ private: |
| 725 | 734 | _CharT __c = __str[__mp - 1 - __i]; |
| 726 | 735 | (*this)[__i] = _Traits::eq(__c, __one); |
| 727 | 736 | } |
| 728 | std::fill(base::__make_iter(__i), base::__make_iter(_Size), false); | |
| 737 | std::fill(__base::__make_iter(__i), __base::__make_iter(_Size), false); | |
| 729 | 738 | } |
| 730 | 739 | |
| 731 | _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return base::__hash_code(); } | |
| 740 | _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return __base::__hash_code(); } | |
| 732 | 741 | |
| 733 | 742 | friend struct hash<bitset>; |
| 734 | 743 | }; |
| ... | ... | @@ -736,43 +745,43 @@ private: |
| 736 | 745 | template <size_t _Size> |
| 737 | 746 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& |
| 738 | 747 | bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT { |
| 739 | base::operator&=(__rhs); | |
| 748 | __base::operator&=(__rhs); | |
| 740 | 749 | return *this; |
| 741 | 750 | } |
| 742 | 751 | |
| 743 | 752 | template <size_t _Size> |
| 744 | 753 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& |
| 745 | 754 | bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT { |
| 746 | base::operator|=(__rhs); | |
| 755 | __base::operator|=(__rhs); | |
| 747 | 756 | return *this; |
| 748 | 757 | } |
| 749 | 758 | |
| 750 | 759 | template <size_t _Size> |
| 751 | 760 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& |
| 752 | 761 | bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT { |
| 753 | base::operator^=(__rhs); | |
| 762 | __base::operator^=(__rhs); | |
| 754 | 763 | return *this; |
| 755 | 764 | } |
| 756 | 765 | |
| 757 | 766 | template <size_t _Size> |
| 758 | 767 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator<<=(size_t __pos) _NOEXCEPT { |
| 759 | 768 | __pos = std::min(__pos, _Size); |
| 760 | std::copy_backward(base::__make_iter(0), base::__make_iter(_Size - __pos), base::__make_iter(_Size)); | |
| 761 | std::fill_n(base::__make_iter(0), __pos, false); | |
| 769 | std::copy_backward(__base::__make_iter(0), __base::__make_iter(_Size - __pos), __base::__make_iter(_Size)); | |
| 770 | std::fill_n(__base::__make_iter(0), __pos, false); | |
| 762 | 771 | return *this; |
| 763 | 772 | } |
| 764 | 773 | |
| 765 | 774 | template <size_t _Size> |
| 766 | 775 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT { |
| 767 | 776 | __pos = std::min(__pos, _Size); |
| 768 | std::copy(base::__make_iter(__pos), base::__make_iter(_Size), base::__make_iter(0)); | |
| 769 | std::fill_n(base::__make_iter(_Size - __pos), __pos, false); | |
| 777 | std::copy(__base::__make_iter(__pos), __base::__make_iter(_Size), __base::__make_iter(0)); | |
| 778 | std::fill_n(__base::__make_iter(_Size - __pos), __pos, false); | |
| 770 | 779 | return *this; |
| 771 | 780 | } |
| 772 | 781 | |
| 773 | 782 | template <size_t _Size> |
| 774 | 783 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set() _NOEXCEPT { |
| 775 | std::fill_n(base::__make_iter(0), _Size, true); | |
| 784 | std::fill_n(__base::__make_iter(0), _Size, true); | |
| 776 | 785 | return *this; |
| 777 | 786 | } |
| 778 | 787 | |
| ... | ... | @@ -787,7 +796,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size> |
| 787 | 796 | |
| 788 | 797 | template <size_t _Size> |
| 789 | 798 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset() _NOEXCEPT { |
| 790 | std::fill_n(base::__make_iter(0), _Size, false); | |
| 799 | std::fill_n(__base::__make_iter(0), _Size, false); | |
| 791 | 800 | return *this; |
| 792 | 801 | } |
| 793 | 802 | |
| ... | ... | @@ -809,7 +818,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size> bitset< |
| 809 | 818 | |
| 810 | 819 | template <size_t _Size> |
| 811 | 820 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip() _NOEXCEPT { |
| 812 | base::flip(); | |
| 821 | __base::flip(); | |
| 813 | 822 | return *this; |
| 814 | 823 | } |
| 815 | 824 | |
| ... | ... | @@ -818,19 +827,19 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size> |
| 818 | 827 | if (__pos >= _Size) |
| 819 | 828 | __throw_out_of_range("bitset flip argument out of range"); |
| 820 | 829 | |
| 821 | reference __r = base::__make_ref(__pos); | |
| 830 | reference __r = __base::__make_ref(__pos); | |
| 822 | 831 | __r = ~__r; |
| 823 | 832 | return *this; |
| 824 | 833 | } |
| 825 | 834 | |
| 826 | 835 | template <size_t _Size> |
| 827 | 836 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long bitset<_Size>::to_ulong() const { |
| 828 | return base::to_ulong(); | |
| 837 | return __base::to_ulong(); | |
| 829 | 838 | } |
| 830 | 839 | |
| 831 | 840 | template <size_t _Size> |
| 832 | 841 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long bitset<_Size>::to_ullong() const { |
| 833 | return base::to_ullong(); | |
| 842 | return __base::to_ullong(); | |
| 834 | 843 | } |
| 835 | 844 | |
| 836 | 845 | template <size_t _Size> |
| ... | ... | @@ -867,23 +876,23 @@ bitset<_Size>::to_string(char __zero, char __one) const { |
| 867 | 876 | |
| 868 | 877 | template <size_t _Size> |
| 869 | 878 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT { |
| 870 | return static_cast<size_t>(std::count(base::__make_iter(0), base::__make_iter(_Size), true)); | |
| 879 | return static_cast<size_t>(std::count(__base::__make_iter(0), __base::__make_iter(_Size), true)); | |
| 871 | 880 | } |
| 872 | 881 | |
| 873 | 882 | template <size_t _Size> |
| 874 | 883 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool |
| 875 | 884 | bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT { |
| 876 | return std::equal(base::__make_iter(0), base::__make_iter(_Size), __rhs.__make_iter(0)); | |
| 885 | return std::equal(__base::__make_iter(0), __base::__make_iter(_Size), __rhs.__make_iter(0)); | |
| 877 | 886 | } |
| 878 | 887 | |
| 879 | #if _LIBCPP_STD_VER <= 17 | |
| 888 | # if _LIBCPP_STD_VER <= 17 | |
| 880 | 889 | |
| 881 | 890 | template <size_t _Size> |
| 882 | 891 | inline _LIBCPP_HIDE_FROM_ABI bool bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT { |
| 883 | 892 | return !(*this == __rhs); |
| 884 | 893 | } |
| 885 | 894 | |
| 886 | #endif | |
| 895 | # endif | |
| 887 | 896 | |
| 888 | 897 | template <size_t _Size> |
| 889 | 898 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(size_t __pos) const { |
| ... | ... | @@ -895,12 +904,12 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(siz |
| 895 | 904 | |
| 896 | 905 | template <size_t _Size> |
| 897 | 906 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::all() const _NOEXCEPT { |
| 898 | return base::all(); | |
| 907 | return __base::all(); | |
| 899 | 908 | } |
| 900 | 909 | |
| 901 | 910 | template <size_t _Size> |
| 902 | 911 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::any() const _NOEXCEPT { |
| 903 | return base::any(); | |
| 912 | return __base::any(); | |
| 904 | 913 | } |
| 905 | 914 | |
| 906 | 915 | template <size_t _Size> |
| ... | ... | @@ -960,10 +969,11 @@ _LIBCPP_END_NAMESPACE_STD |
| 960 | 969 | |
| 961 | 970 | _LIBCPP_POP_MACROS |
| 962 | 971 | |
| 963 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 964 | # include <concepts> | |
| 965 | # include <cstdlib> | |
| 966 | # include <type_traits> | |
| 967 | #endif | |
| 972 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 973 | # include <concepts> | |
| 974 | # include <cstdlib> | |
| 975 | # include <type_traits> | |
| 976 | # endif | |
| 977 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 968 | 978 | |
| 969 | 979 | #endif // _LIBCPP_BITSET |
lib/libcxx/include/cassert+13-9| ... | ... | @@ -16,16 +16,20 @@ Macros: |
| 16 | 16 | |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | #include <__config> | |
| 19 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 20 | # include <__cxx03/cassert> | |
| 21 | #else | |
| 22 | # include <__config> | |
| 20 | 23 | |
| 21 | 24 | // <assert.h> is not provided by libc++ |
| 22 | #if __has_include(<assert.h>) | |
| 23 | # include <assert.h> | |
| 24 | # ifdef _LIBCPP_ASSERT_H | |
| 25 | # error "If libc++ starts defining <assert.h>, the __has_include check should move to libc++'s <assert.h>" | |
| 25 | # if __has_include(<assert.h>) | |
| 26 | # include <assert.h> | |
| 27 | # ifdef _LIBCPP_ASSERT_H | |
| 28 | # error "If libc++ starts defining <assert.h>, the __has_include check should move to libc++'s <assert.h>" | |
| 29 | # endif | |
| 26 | 30 | # endif |
| 27 | #endif | |
| 28 | 31 | |
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 30 | # pragma GCC system_header | |
| 31 | #endif | |
| 32 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 33 | # pragma GCC system_header | |
| 34 | # endif | |
| 35 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
lib/libcxx/include/ccomplex+21-4| ... | ... | @@ -17,10 +17,27 @@ |
| 17 | 17 | |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | #include <complex> | |
| 20 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 21 | # include <__cxx03/ccomplex> | |
| 22 | #else | |
| 23 | # include <complex> | |
| 24 | ||
| 25 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | # endif | |
| 28 | ||
| 29 | # if _LIBCPP_STD_VER >= 20 | |
| 30 | ||
| 31 | using __standard_header_ccomplex | |
| 32 | _LIBCPP_DEPRECATED_("removed in C++20. Include <complex> instead.") _LIBCPP_NODEBUG = void; | |
| 33 | using __use_standard_header_ccomplex _LIBCPP_NODEBUG = __standard_header_ccomplex; | |
| 34 | ||
| 35 | # elif _LIBCPP_STD_VER >= 17 | |
| 36 | ||
| 37 | using __standard_header_ccomplex _LIBCPP_DEPRECATED_("Include <complex> instead.") _LIBCPP_NODEBUG = void; | |
| 38 | using __use_standard_header_ccomplex _LIBCPP_NODEBUG = __standard_header_ccomplex; | |
| 21 | 39 | |
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 40 | # endif | |
| 41 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 25 | 42 | |
| 26 | 43 | #endif // _LIBCPP_CCOMPLEX |
lib/libcxx/include/cctype+53-49| ... | ... | @@ -34,78 +34,81 @@ int toupper(int c); |
| 34 | 34 | } // std |
| 35 | 35 | */ |
| 36 | 36 | |
| 37 | #include <__config> | |
| 37 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 38 | # include <__cxx03/cctype> | |
| 39 | #else | |
| 40 | # include <__config> | |
| 38 | 41 | |
| 39 | #include <ctype.h> | |
| 42 | # include <ctype.h> | |
| 40 | 43 | |
| 41 | #ifndef _LIBCPP_CTYPE_H | |
| 44 | # ifndef _LIBCPP_CTYPE_H | |
| 42 | 45 | # error <cctype> tried including <ctype.h> but didn't find libc++'s <ctype.h> header. \ |
| 43 | 46 | This usually means that your header search paths are not configured properly. \ |
| 44 | 47 | The header search paths should contain the C++ Standard Library headers before \ |
| 45 | 48 | any C Standard Library. |
| 46 | #endif | |
| 49 | # endif | |
| 47 | 50 | |
| 48 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 49 | # pragma GCC system_header | |
| 50 | #endif | |
| 51 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 52 | # pragma GCC system_header | |
| 53 | # endif | |
| 51 | 54 | |
| 52 | 55 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 53 | 56 | |
| 54 | #ifdef isalnum | |
| 55 | # undef isalnum | |
| 56 | #endif | |
| 57 | # ifdef isalnum | |
| 58 | # undef isalnum | |
| 59 | # endif | |
| 57 | 60 | |
| 58 | #ifdef isalpha | |
| 59 | # undef isalpha | |
| 60 | #endif | |
| 61 | # ifdef isalpha | |
| 62 | # undef isalpha | |
| 63 | # endif | |
| 61 | 64 | |
| 62 | #ifdef isblank | |
| 63 | # undef isblank | |
| 64 | #endif | |
| 65 | # ifdef isblank | |
| 66 | # undef isblank | |
| 67 | # endif | |
| 65 | 68 | |
| 66 | #ifdef iscntrl | |
| 67 | # undef iscntrl | |
| 68 | #endif | |
| 69 | # ifdef iscntrl | |
| 70 | # undef iscntrl | |
| 71 | # endif | |
| 69 | 72 | |
| 70 | #ifdef isdigit | |
| 71 | # undef isdigit | |
| 72 | #endif | |
| 73 | # ifdef isdigit | |
| 74 | # undef isdigit | |
| 75 | # endif | |
| 73 | 76 | |
| 74 | #ifdef isgraph | |
| 75 | # undef isgraph | |
| 76 | #endif | |
| 77 | # ifdef isgraph | |
| 78 | # undef isgraph | |
| 79 | # endif | |
| 77 | 80 | |
| 78 | #ifdef islower | |
| 79 | # undef islower | |
| 80 | #endif | |
| 81 | # ifdef islower | |
| 82 | # undef islower | |
| 83 | # endif | |
| 81 | 84 | |
| 82 | #ifdef isprint | |
| 83 | # undef isprint | |
| 84 | #endif | |
| 85 | # ifdef isprint | |
| 86 | # undef isprint | |
| 87 | # endif | |
| 85 | 88 | |
| 86 | #ifdef ispunct | |
| 87 | # undef ispunct | |
| 88 | #endif | |
| 89 | # ifdef ispunct | |
| 90 | # undef ispunct | |
| 91 | # endif | |
| 89 | 92 | |
| 90 | #ifdef isspace | |
| 91 | # undef isspace | |
| 92 | #endif | |
| 93 | # ifdef isspace | |
| 94 | # undef isspace | |
| 95 | # endif | |
| 93 | 96 | |
| 94 | #ifdef isupper | |
| 95 | # undef isupper | |
| 96 | #endif | |
| 97 | # ifdef isupper | |
| 98 | # undef isupper | |
| 99 | # endif | |
| 97 | 100 | |
| 98 | #ifdef isxdigit | |
| 99 | # undef isxdigit | |
| 100 | #endif | |
| 101 | # ifdef isxdigit | |
| 102 | # undef isxdigit | |
| 103 | # endif | |
| 101 | 104 | |
| 102 | #ifdef tolower | |
| 103 | # undef tolower | |
| 104 | #endif | |
| 105 | # ifdef tolower | |
| 106 | # undef tolower | |
| 107 | # endif | |
| 105 | 108 | |
| 106 | #ifdef toupper | |
| 107 | # undef toupper | |
| 108 | #endif | |
| 109 | # ifdef toupper | |
| 110 | # undef toupper | |
| 111 | # endif | |
| 109 | 112 | |
| 110 | 113 | using ::isalnum _LIBCPP_USING_IF_EXISTS; |
| 111 | 114 | using ::isalpha _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -123,5 +126,6 @@ using ::tolower _LIBCPP_USING_IF_EXISTS; |
| 123 | 126 | using ::toupper _LIBCPP_USING_IF_EXISTS; |
| 124 | 127 | |
| 125 | 128 | _LIBCPP_END_NAMESPACE_STD |
| 129 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 126 | 130 | |
| 127 | 131 | #endif // _LIBCPP_CCTYPE |
lib/libcxx/include/cerrno+11-7| ... | ... | @@ -22,21 +22,24 @@ Macros: |
| 22 | 22 | |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | #include <__config> | |
| 25 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 26 | # include <__cxx03/cerrno> | |
| 27 | #else | |
| 28 | # include <__config> | |
| 26 | 29 | |
| 27 | #include <errno.h> | |
| 30 | # include <errno.h> | |
| 28 | 31 | |
| 29 | #ifndef _LIBCPP_ERRNO_H | |
| 32 | # ifndef _LIBCPP_ERRNO_H | |
| 30 | 33 | # error <cerrno> tried including <errno.h> but didn't find libc++'s <errno.h> header. \ |
| 31 | 34 | This usually means that your header search paths are not configured properly. \ |
| 32 | 35 | The header search paths should contain the C++ Standard Library headers before \ |
| 33 | 36 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 34 | 37 | not be the case. |
| 35 | #endif | |
| 38 | # endif | |
| 36 | 39 | |
| 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 38 | # pragma GCC system_header | |
| 39 | #endif | |
| 40 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 41 | # pragma GCC system_header | |
| 42 | # endif | |
| 40 | 43 | |
| 41 | 44 | // LWG3869 Deprecate std::errc constants related to UNIX STREAMS |
| 42 | 45 | // |
| ... | ... | @@ -44,5 +47,6 @@ Macros: |
| 44 | 47 | // deprecated in libc++ in https://github.com/llvm/llvm-project/pull/80542. |
| 45 | 48 | // Based on the post commit feedback the macro are no longer deprecated. |
| 46 | 49 | // Instead libc++ leaves the deprecation to the provider of errno.h. |
| 50 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 47 | 51 | |
| 48 | 52 | #endif // _LIBCPP_CERRNO |
lib/libcxx/include/cfenv+12-7| ... | ... | @@ -52,21 +52,24 @@ int feupdateenv(const fenv_t* envp); |
| 52 | 52 | } // std |
| 53 | 53 | */ |
| 54 | 54 | |
| 55 | #include <__config> | |
| 55 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 56 | # include <__cxx03/cfenv> | |
| 57 | #else | |
| 58 | # include <__config> | |
| 56 | 59 | |
| 57 | #include <fenv.h> | |
| 60 | # include <fenv.h> | |
| 58 | 61 | |
| 59 | #ifndef _LIBCPP_FENV_H | |
| 62 | # ifndef _LIBCPP_FENV_H | |
| 60 | 63 | # error <cfenv> tried including <fenv.h> but didn't find libc++'s <fenv.h> header. \ |
| 61 | 64 | This usually means that your header search paths are not configured properly. \ |
| 62 | 65 | The header search paths should contain the C++ Standard Library headers before \ |
| 63 | 66 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 64 | 67 | not be the case. |
| 65 | #endif | |
| 68 | # endif | |
| 66 | 69 | |
| 67 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 68 | # pragma GCC system_header | |
| 69 | #endif | |
| 70 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 71 | # pragma GCC system_header | |
| 72 | # endif | |
| 70 | 73 | |
| 71 | 74 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 72 | 75 | |
| ... | ... | @@ -87,4 +90,6 @@ using ::feupdateenv _LIBCPP_USING_IF_EXISTS; |
| 87 | 90 | |
| 88 | 91 | _LIBCPP_END_NAMESPACE_STD |
| 89 | 92 | |
| 93 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 94 | ||
| 90 | 95 | #endif // _LIBCPP_CFENV |
lib/libcxx/include/cfloat+11-7| ... | ... | @@ -69,20 +69,24 @@ Macros: |
| 69 | 69 | LDBL_TRUE_MIN // C11 |
| 70 | 70 | */ |
| 71 | 71 | |
| 72 | #include <__config> | |
| 72 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 73 | # include <__cxx03/cfloat> | |
| 74 | #else | |
| 75 | # include <__config> | |
| 73 | 76 | |
| 74 | #include <float.h> | |
| 77 | # include <float.h> | |
| 75 | 78 | |
| 76 | #ifndef _LIBCPP_FLOAT_H | |
| 79 | # ifndef _LIBCPP_FLOAT_H | |
| 77 | 80 | # error <cfloat> tried including <float.h> but didn't find libc++'s <float.h> header. \ |
| 78 | 81 | This usually means that your header search paths are not configured properly. \ |
| 79 | 82 | The header search paths should contain the C++ Standard Library headers before \ |
| 80 | 83 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 81 | 84 | not be the case. |
| 82 | #endif | |
| 85 | # endif | |
| 83 | 86 | |
| 84 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 85 | # pragma GCC system_header | |
| 86 | #endif | |
| 87 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 88 | # pragma GCC system_header | |
| 89 | # endif | |
| 90 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 87 | 91 | |
| 88 | 92 | #endif // _LIBCPP_CFLOAT |
lib/libcxx/include/charconv+43-37| ... | ... | @@ -65,51 +65,57 @@ namespace std { |
| 65 | 65 | constexpr from_chars_result from_chars(const char* first, const char* last, |
| 66 | 66 | see below& value, int base = 10); // constexpr since C++23 |
| 67 | 67 | |
| 68 | } // namespace std | |
| 69 | ||
| 70 | */ | |
| 68 | from_chars_result from_chars(const char* first, const char* last, | |
| 69 | float& value, chars_format fmt); | |
| 71 | 70 | |
| 72 | #include <__config> | |
| 71 | from_chars_result from_chars(const char* first, const char* last, | |
| 72 | double& value, chars_format fmt); | |
| 73 | 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 | |
| 74 | } // namespace std | |
| 86 | 75 | |
| 87 | #include <version> | |
| 76 | */ | |
| 88 | 77 | |
| 89 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 90 | # pragma GCC system_header | |
| 91 | #endif | |
| 78 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 79 | # include <__cxx03/charconv> | |
| 80 | #else | |
| 81 | # include <__config> | |
| 82 | ||
| 83 | # if _LIBCPP_STD_VER >= 17 | |
| 84 | # include <__charconv/chars_format.h> | |
| 85 | # include <__charconv/from_chars_floating_point.h> | |
| 86 | # include <__charconv/from_chars_integral.h> | |
| 87 | # include <__charconv/from_chars_result.h> | |
| 88 | # include <__charconv/tables.h> | |
| 89 | # include <__charconv/to_chars.h> | |
| 90 | # include <__charconv/to_chars_base_10.h> | |
| 91 | # include <__charconv/to_chars_floating_point.h> | |
| 92 | # include <__charconv/to_chars_integral.h> | |
| 93 | # include <__charconv/to_chars_result.h> | |
| 94 | # include <__charconv/traits.h> | |
| 95 | # endif // _LIBCPP_STD_VER >= 17 | |
| 96 | ||
| 97 | # include <version> | |
| 98 | ||
| 99 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 100 | # pragma GCC system_header | |
| 101 | # endif | |
| 92 | 102 | |
| 93 | 103 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 94 | 104 | |
| 95 | 105 | _LIBCPP_END_NAMESPACE_STD |
| 96 | 106 | |
| 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 | ||
| 104 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 105 | # include <cmath> | |
| 106 | # include <concepts> | |
| 107 | # include <cstdint> | |
| 108 | # include <cstdlib> | |
| 109 | # include <cstring> | |
| 110 | # include <iosfwd> | |
| 111 | # include <limits> | |
| 112 | # include <type_traits> | |
| 113 | #endif | |
| 107 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 108 | # include <cmath> | |
| 109 | # include <concepts> | |
| 110 | # include <cstddef> | |
| 111 | # include <cstdint> | |
| 112 | # include <cstdlib> | |
| 113 | # include <cstring> | |
| 114 | # include <iosfwd> | |
| 115 | # include <limits> | |
| 116 | # include <new> | |
| 117 | # include <type_traits> | |
| 118 | # endif | |
| 119 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 114 | 120 | |
| 115 | 121 | #endif // _LIBCPP_CHARCONV |
lib/libcxx/include/chrono+112-71| ... | ... | @@ -300,6 +300,41 @@ template<class charT, class traits> // C++20 |
| 300 | 300 | basic_ostream<charT, traits>& |
| 301 | 301 | operator<<(basic_ostream<charT, traits>& os, const sys_days& dp); |
| 302 | 302 | |
| 303 | // [time.clock.utc], class utc_clock | |
| 304 | class utc_clock { // C++20 | |
| 305 | public: | |
| 306 | using rep = a signed arithmetic type; | |
| 307 | using period = ratio<unspecified, unspecified>; | |
| 308 | using duration = chrono::duration<rep, period>; | |
| 309 | using time_point = chrono::time_point<utc_clock>; | |
| 310 | static constexpr bool is_steady = unspecified; | |
| 311 | ||
| 312 | static time_point now(); | |
| 313 | ||
| 314 | template<class Duration> | |
| 315 | static sys_time<common_type_t<Duration, seconds>> | |
| 316 | to_sys(const utc_time<Duration>& t); | |
| 317 | template<class Duration> | |
| 318 | static utc_time<common_type_t<Duration, seconds>> | |
| 319 | from_sys(const sys_time<Duration>& t); | |
| 320 | }; | |
| 321 | ||
| 322 | template<class Duration> | |
| 323 | using utc_time = time_point<utc_clock, Duration>; // C++20 | |
| 324 | using utc_seconds = utc_time<seconds>; // C++20 | |
| 325 | ||
| 326 | template<class charT, class traits, class Duration> // C++20 | |
| 327 | basic_ostream<charT, traits>& | |
| 328 | operator<<(basic_ostream<charT, traits>& os, const utc_time<Duration>& t); | |
| 329 | ||
| 330 | struct leap_second_info { // C++20 | |
| 331 | bool is_leap_second; | |
| 332 | seconds elapsed; | |
| 333 | }; | |
| 334 | ||
| 335 | template<class Duration> // C++20 | |
| 336 | leap_second_info get_leap_second_info(const utc_time<Duration>& ut); | |
| 337 | ||
| 303 | 338 | class file_clock // C++20 |
| 304 | 339 | { |
| 305 | 340 | public: |
| ... | ... | @@ -861,6 +896,8 @@ strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y); |
| 861 | 896 | namespace std { |
| 862 | 897 | template<class Duration, class charT> |
| 863 | 898 | struct formatter<chrono::sys_time<Duration>, charT>; // C++20 |
| 899 | template<class Duration, class charT> | |
| 900 | struct formatter<chrono::utc_time<Duration>, charT>; // C++20 | |
| 864 | 901 | template<class Duration, class charT> |
| 865 | 902 | struct formatter<chrono::filetime<Duration>, charT>; // C++20 |
| 866 | 903 | template<class Duration, class charT> |
| ... | ... | @@ -939,84 +976,88 @@ constexpr chrono::year operator ""y(unsigned lo |
| 939 | 976 | |
| 940 | 977 | // clang-format on |
| 941 | 978 | |
| 942 | #include <__config> | |
| 943 | ||
| 944 | #include <__chrono/duration.h> | |
| 945 | #include <__chrono/file_clock.h> | |
| 946 | #include <__chrono/high_resolution_clock.h> | |
| 947 | #include <__chrono/steady_clock.h> | |
| 948 | #include <__chrono/system_clock.h> | |
| 949 | #include <__chrono/time_point.h> | |
| 950 | ||
| 951 | #if _LIBCPP_STD_VER >= 20 | |
| 952 | # include <__chrono/calendar.h> | |
| 953 | # include <__chrono/day.h> | |
| 954 | # include <__chrono/exception.h> | |
| 955 | # include <__chrono/hh_mm_ss.h> | |
| 956 | # include <__chrono/literals.h> | |
| 957 | # include <__chrono/local_info.h> | |
| 958 | # include <__chrono/month.h> | |
| 959 | # include <__chrono/month_weekday.h> | |
| 960 | # include <__chrono/monthday.h> | |
| 961 | # include <__chrono/sys_info.h> | |
| 962 | # include <__chrono/weekday.h> | |
| 963 | # include <__chrono/year.h> | |
| 964 | # include <__chrono/year_month.h> | |
| 965 | # include <__chrono/year_month_day.h> | |
| 966 | # include <__chrono/year_month_weekday.h> | |
| 967 | ||
| 968 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 969 | # include <__chrono/formatter.h> | |
| 970 | # include <__chrono/ostream.h> | |
| 971 | # include <__chrono/parser_std_format_spec.h> | |
| 972 | # include <__chrono/statically_widen.h> | |
| 973 | # endif | |
| 979 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 980 | # include <__cxx03/chrono> | |
| 981 | #else | |
| 982 | # include <__config> | |
| 983 | ||
| 984 | # include <__chrono/duration.h> | |
| 985 | # include <__chrono/file_clock.h> | |
| 986 | # include <__chrono/high_resolution_clock.h> | |
| 987 | # include <__chrono/steady_clock.h> | |
| 988 | # include <__chrono/system_clock.h> | |
| 989 | # include <__chrono/time_point.h> | |
| 990 | ||
| 991 | # if _LIBCPP_STD_VER >= 20 | |
| 992 | # include <__chrono/calendar.h> | |
| 993 | # include <__chrono/day.h> | |
| 994 | # include <__chrono/exception.h> | |
| 995 | # include <__chrono/hh_mm_ss.h> | |
| 996 | # include <__chrono/literals.h> | |
| 997 | # include <__chrono/local_info.h> | |
| 998 | # include <__chrono/month.h> | |
| 999 | # include <__chrono/month_weekday.h> | |
| 1000 | # include <__chrono/monthday.h> | |
| 1001 | # include <__chrono/sys_info.h> | |
| 1002 | # include <__chrono/weekday.h> | |
| 1003 | # include <__chrono/year.h> | |
| 1004 | # include <__chrono/year_month.h> | |
| 1005 | # include <__chrono/year_month_day.h> | |
| 1006 | # include <__chrono/year_month_weekday.h> | |
| 1007 | ||
| 1008 | # if _LIBCPP_HAS_LOCALIZATION | |
| 1009 | # include <__chrono/formatter.h> | |
| 1010 | # include <__chrono/ostream.h> | |
| 1011 | # include <__chrono/parser_std_format_spec.h> | |
| 1012 | # include <__chrono/statically_widen.h> | |
| 1013 | # endif | |
| 1014 | ||
| 1015 | # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 1016 | # include <__chrono/leap_second.h> | |
| 1017 | # include <__chrono/time_zone.h> | |
| 1018 | # include <__chrono/time_zone_link.h> | |
| 1019 | # include <__chrono/tzdb.h> | |
| 1020 | # include <__chrono/tzdb_list.h> | |
| 1021 | # include <__chrono/utc_clock.h> | |
| 1022 | # include <__chrono/zoned_time.h> | |
| 1023 | # endif | |
| 974 | 1024 | |
| 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 | 1025 | # endif |
| 984 | 1026 | |
| 985 | #endif | |
| 986 | ||
| 987 | #include <version> | |
| 1027 | # include <version> | |
| 988 | 1028 | |
| 989 | 1029 | // standard-mandated includes |
| 990 | 1030 | |
| 991 | 1031 | // [time.syn] |
| 992 | #include <compare> | |
| 993 | ||
| 994 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 995 | # pragma GCC system_header | |
| 996 | #endif | |
| 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 | ||
| 1005 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1006 | # include <bit> | |
| 1007 | # include <concepts> | |
| 1008 | # include <cstring> | |
| 1009 | # include <forward_list> | |
| 1010 | # include <string> | |
| 1011 | # include <tuple> | |
| 1012 | #endif | |
| 1013 | ||
| 1014 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20 | |
| 1015 | # include <charconv> | |
| 1016 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 1017 | # include <locale> | |
| 1018 | # include <ostream> | |
| 1032 | # include <compare> | |
| 1033 | ||
| 1034 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 1035 | # pragma GCC system_header | |
| 1036 | # endif | |
| 1037 | ||
| 1038 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 1039 | # include <cstdint> | |
| 1040 | # include <stdexcept> | |
| 1041 | # include <string_view> | |
| 1042 | # endif | |
| 1043 | ||
| 1044 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1045 | # include <bit> | |
| 1046 | # include <concepts> | |
| 1047 | # include <cstring> | |
| 1048 | # include <forward_list> | |
| 1049 | # include <string> | |
| 1050 | # include <tuple> | |
| 1051 | # include <vector> | |
| 1052 | # endif | |
| 1053 | ||
| 1054 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20 | |
| 1055 | # include <charconv> | |
| 1056 | # if _LIBCPP_HAS_LOCALIZATION | |
| 1057 | # include <locale> | |
| 1058 | # include <ostream> | |
| 1059 | # endif | |
| 1019 | 1060 | # endif |
| 1020 | #endif | |
| 1061 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1021 | 1062 | |
| 1022 | 1063 | #endif // _LIBCPP_CHRONO |
lib/libcxx/include/cinttypes+13-8| ... | ... | @@ -234,26 +234,29 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int |
| 234 | 234 | } // std |
| 235 | 235 | */ |
| 236 | 236 | |
| 237 | #include <__config> | |
| 237 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 238 | # include <__cxx03/cinttypes> | |
| 239 | #else | |
| 240 | # include <__config> | |
| 238 | 241 | |
| 239 | 242 | // standard-mandated includes |
| 240 | 243 | |
| 241 | 244 | // [cinttypes.syn] |
| 242 | #include <cstdint> | |
| 245 | # include <cstdint> | |
| 243 | 246 | |
| 244 | #include <inttypes.h> | |
| 247 | # include <inttypes.h> | |
| 245 | 248 | |
| 246 | #ifndef _LIBCPP_INTTYPES_H | |
| 249 | # ifndef _LIBCPP_INTTYPES_H | |
| 247 | 250 | # error <cinttypes> tried including <inttypes.h> but didn't find libc++'s <inttypes.h> header. \ |
| 248 | 251 | This usually means that your header search paths are not configured properly. \ |
| 249 | 252 | The header search paths should contain the C++ Standard Library headers before \ |
| 250 | 253 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 251 | 254 | not be the case. |
| 252 | #endif | |
| 255 | # endif | |
| 253 | 256 | |
| 254 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 255 | # pragma GCC system_header | |
| 256 | #endif | |
| 257 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 258 | # pragma GCC system_header | |
| 259 | # endif | |
| 257 | 260 | |
| 258 | 261 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 259 | 262 | |
| ... | ... | @@ -267,4 +270,6 @@ using ::wcstoumax _LIBCPP_USING_IF_EXISTS; |
| 267 | 270 | |
| 268 | 271 | _LIBCPP_END_NAMESPACE_STD |
| 269 | 272 | |
| 273 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 274 | ||
| 270 | 275 | #endif // _LIBCPP_CINTTYPES |
lib/libcxx/include/ciso646+16-4| ... | ... | @@ -15,10 +15,22 @@ |
| 15 | 15 | |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | #include <__config> | |
| 18 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 19 | # include <__cxx03/ciso646> | |
| 20 | #else | |
| 21 | # include <__config> | |
| 19 | 22 | |
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | # endif | |
| 26 | ||
| 27 | # if _LIBCPP_STD_VER >= 20 | |
| 28 | ||
| 29 | using __standard_header_ciso646 | |
| 30 | _LIBCPP_DEPRECATED_("removed in C++20. Include <version> instead.") _LIBCPP_NODEBUG = void; | |
| 31 | using __use_standard_header_ciso646 _LIBCPP_NODEBUG = __standard_header_ciso646; | |
| 32 | ||
| 33 | # endif | |
| 34 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 23 | 35 | |
| 24 | 36 | #endif // _LIBCPP_CISO646 |
lib/libcxx/include/climits+10-5| ... | ... | @@ -37,12 +37,17 @@ Macros: |
| 37 | 37 | |
| 38 | 38 | */ |
| 39 | 39 | |
| 40 | #include <__config> | |
| 40 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 41 | # include <__cxx03/climits> | |
| 42 | #else | |
| 43 | # include <__config> | |
| 41 | 44 | |
| 42 | #include <limits.h> | |
| 45 | # include <limits.h> | |
| 43 | 46 | |
| 44 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 45 | # pragma GCC system_header | |
| 46 | #endif | |
| 47 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 48 | # pragma GCC system_header | |
| 49 | # endif | |
| 50 | ||
| 51 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 47 | 52 | |
| 48 | 53 | #endif // _LIBCPP_CLIMITS |
lib/libcxx/include/clocale+12-13| ... | ... | @@ -34,21 +34,18 @@ lconv* localeconv(); |
| 34 | 34 | |
| 35 | 35 | */ |
| 36 | 36 | |
| 37 | #include <__config> | |
| 37 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 38 | # include <__cxx03/clocale> | |
| 39 | #else | |
| 40 | # include <__config> | |
| 38 | 41 | |
| 39 | #include <locale.h> | |
| 42 | # if __has_include(<locale.h>) | |
| 43 | # include <locale.h> | |
| 44 | # endif | |
| 40 | 45 | |
| 41 | #ifndef _LIBCPP_LOCALE_H | |
| 42 | # error <clocale> tried including <locale.h> but didn't find libc++'s <locale.h> header. \ | |
| 43 | This usually means that your header search paths are not configured properly. \ | |
| 44 | The header search paths should contain the C++ Standard Library headers before \ | |
| 45 | any C Standard Library, and you are probably using compiler flags that make that \ | |
| 46 | not be the case. | |
| 47 | #endif | |
| 48 | ||
| 49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 50 | # pragma GCC system_header | |
| 51 | #endif | |
| 46 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 47 | # pragma GCC system_header | |
| 48 | # endif | |
| 52 | 49 | |
| 53 | 50 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 54 | 51 | |
| ... | ... | @@ -58,4 +55,6 @@ using ::localeconv _LIBCPP_USING_IF_EXISTS; |
| 58 | 55 | |
| 59 | 56 | _LIBCPP_END_NAMESPACE_STD |
| 60 | 57 | |
| 58 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 59 | ||
| 61 | 60 | #endif // _LIBCPP_CLOCALE |
lib/libcxx/include/cmath+33-57| ... | ... | @@ -312,35 +312,38 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept |
| 312 | 312 | |
| 313 | 313 | */ |
| 314 | 314 | |
| 315 | #include <__config> | |
| 316 | #include <__math/hypot.h> | |
| 317 | #include <__type_traits/enable_if.h> | |
| 318 | #include <__type_traits/is_arithmetic.h> | |
| 319 | #include <__type_traits/is_constant_evaluated.h> | |
| 320 | #include <__type_traits/is_floating_point.h> | |
| 321 | #include <__type_traits/is_same.h> | |
| 322 | #include <__type_traits/promote.h> | |
| 323 | #include <__type_traits/remove_cv.h> | |
| 324 | #include <limits> | |
| 325 | #include <version> | |
| 326 | ||
| 327 | #include <__math/special_functions.h> | |
| 328 | #include <math.h> | |
| 329 | ||
| 330 | #ifndef _LIBCPP_MATH_H | |
| 315 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 316 | # include <__cxx03/cmath> | |
| 317 | #else | |
| 318 | # include <__config> | |
| 319 | # include <__math/hypot.h> | |
| 320 | # include <__type_traits/enable_if.h> | |
| 321 | # include <__type_traits/is_arithmetic.h> | |
| 322 | # include <__type_traits/is_constant_evaluated.h> | |
| 323 | # include <__type_traits/is_floating_point.h> | |
| 324 | # include <__type_traits/is_same.h> | |
| 325 | # include <__type_traits/promote.h> | |
| 326 | # include <__type_traits/remove_cv.h> | |
| 327 | # include <limits> | |
| 328 | # include <version> | |
| 329 | ||
| 330 | # include <__math/special_functions.h> | |
| 331 | # include <math.h> | |
| 332 | ||
| 333 | # ifndef _LIBCPP_MATH_H | |
| 331 | 334 | # error <cmath> tried including <math.h> but didn't find libc++'s <math.h> header. \ |
| 332 | 335 | This usually means that your header search paths are not configured properly. \ |
| 333 | 336 | The header search paths should contain the C++ Standard Library headers before \ |
| 334 | 337 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 335 | 338 | not be the case. |
| 336 | #endif | |
| 339 | # endif | |
| 337 | 340 | |
| 338 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 339 | # pragma GCC system_header | |
| 340 | #endif | |
| 341 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 342 | # pragma GCC system_header | |
| 343 | # endif | |
| 341 | 344 | |
| 342 | 345 | _LIBCPP_PUSH_MACROS |
| 343 | #include <__undef_macros> | |
| 346 | # include <__undef_macros> | |
| 344 | 347 | |
| 345 | 348 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 346 | 349 | |
| ... | ... | @@ -554,27 +557,13 @@ using ::scalbnl _LIBCPP_USING_IF_EXISTS; |
| 554 | 557 | using ::tgammal _LIBCPP_USING_IF_EXISTS; |
| 555 | 558 | using ::truncl _LIBCPP_USING_IF_EXISTS; |
| 556 | 559 | |
| 557 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> | |
| 558 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT { | |
| 559 | #if __has_builtin(__builtin_isnan) | |
| 560 | return __builtin_isnan(__lcpp_x); | |
| 561 | #else | |
| 562 | return isnan(__lcpp_x); | |
| 563 | #endif | |
| 564 | } | |
| 565 | ||
| 566 | template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0> | |
| 567 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT { | |
| 568 | return std::isnan(__lcpp_x); | |
| 569 | } | |
| 570 | ||
| 571 | 560 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> |
| 572 | 561 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT { |
| 573 | #if __has_builtin(__builtin_isinf) | |
| 562 | # if __has_builtin(__builtin_isinf) | |
| 574 | 563 | return __builtin_isinf(__lcpp_x); |
| 575 | #else | |
| 564 | # else | |
| 576 | 565 | return isinf(__lcpp_x); |
| 577 | #endif | |
| 566 | # endif | |
| 578 | 567 | } |
| 579 | 568 | |
| 580 | 569 | template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0> |
| ... | ... | @@ -582,21 +571,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NO |
| 582 | 571 | return std::isinf(__lcpp_x); |
| 583 | 572 | } |
| 584 | 573 | |
| 585 | template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> | |
| 586 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT { | |
| 587 | #if __has_builtin(__builtin_isfinite) | |
| 588 | return __builtin_isfinite(__lcpp_x); | |
| 589 | #else | |
| 590 | return isfinite(__lcpp_x); | |
| 591 | #endif | |
| 592 | } | |
| 593 | ||
| 594 | template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0> | |
| 595 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT { | |
| 596 | return __builtin_isfinite(__lcpp_x); | |
| 597 | } | |
| 598 | ||
| 599 | #if _LIBCPP_STD_VER >= 20 | |
| 574 | # if _LIBCPP_STD_VER >= 20 | |
| 600 | 575 | template <typename _Fp> |
| 601 | 576 | _LIBCPP_HIDE_FROM_ABI constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept { |
| 602 | 577 | if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0)) |
| ... | ... | @@ -633,14 +608,15 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr |
| 633 | 608 | _IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value)); |
| 634 | 609 | return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t); |
| 635 | 610 | } |
| 636 | #endif // _LIBCPP_STD_VER >= 20 | |
| 611 | # endif // _LIBCPP_STD_VER >= 20 | |
| 637 | 612 | |
| 638 | 613 | _LIBCPP_END_NAMESPACE_STD |
| 639 | 614 | |
| 640 | 615 | _LIBCPP_POP_MACROS |
| 641 | 616 | |
| 642 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 643 | # include <type_traits> | |
| 644 | #endif | |
| 617 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 618 | # include <type_traits> | |
| 619 | # endif | |
| 620 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 645 | 621 | |
| 646 | 622 | #endif // _LIBCPP_CMATH |
lib/libcxx/include/codecvt+34-30| ... | ... | @@ -54,15 +54,18 @@ class codecvt_utf8_utf16 |
| 54 | 54 | |
| 55 | 55 | */ |
| 56 | 56 | |
| 57 | #include <__config> | |
| 58 | #include <__locale> | |
| 59 | #include <version> | |
| 57 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 58 | # include <__cxx03/codecvt> | |
| 59 | #else | |
| 60 | # include <__config> | |
| 61 | # include <__locale> | |
| 62 | # include <version> | |
| 60 | 63 | |
| 61 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 62 | # pragma GCC system_header | |
| 63 | #endif | |
| 64 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 65 | # pragma GCC system_header | |
| 66 | # endif | |
| 64 | 67 | |
| 65 | #if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) | |
| 68 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) | |
| 66 | 69 | |
| 67 | 70 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 68 | 71 | |
| ... | ... | @@ -73,7 +76,7 @@ enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_hea |
| 73 | 76 | template <class _Elem> |
| 74 | 77 | class __codecvt_utf8; |
| 75 | 78 | |
| 76 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 79 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 77 | 80 | template <> |
| 78 | 81 | class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t> { |
| 79 | 82 | unsigned long __maxcode_; |
| ... | ... | @@ -112,7 +115,7 @@ protected: |
| 112 | 115 | int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; |
| 113 | 116 | int do_max_length() const _NOEXCEPT override; |
| 114 | 117 | }; |
| 115 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 118 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 116 | 119 | |
| 117 | 120 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 118 | 121 | template <> |
| ... | ... | @@ -203,7 +206,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 203 | 206 | template <class _Elem, bool _LittleEndian> |
| 204 | 207 | class __codecvt_utf16; |
| 205 | 208 | |
| 206 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 209 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 207 | 210 | template <> |
| 208 | 211 | class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t> { |
| 209 | 212 | unsigned long __maxcode_; |
| ... | ... | @@ -281,7 +284,7 @@ protected: |
| 281 | 284 | int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; |
| 282 | 285 | int do_max_length() const _NOEXCEPT override; |
| 283 | 286 | }; |
| 284 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 287 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 285 | 288 | |
| 286 | 289 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 287 | 290 | template <> |
| ... | ... | @@ -448,7 +451,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 448 | 451 | template <class _Elem> |
| 449 | 452 | class __codecvt_utf8_utf16; |
| 450 | 453 | |
| 451 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 454 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 452 | 455 | template <> |
| 453 | 456 | class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t> { |
| 454 | 457 | unsigned long __maxcode_; |
| ... | ... | @@ -487,7 +490,7 @@ protected: |
| 487 | 490 | int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override; |
| 488 | 491 | int do_max_length() const _NOEXCEPT override; |
| 489 | 492 | }; |
| 490 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 493 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 491 | 494 | |
| 492 | 495 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 493 | 496 | template <> |
| ... | ... | @@ -576,22 +579,23 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 576 | 579 | |
| 577 | 580 | _LIBCPP_END_NAMESPACE_STD |
| 578 | 581 | |
| 579 | #endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) | |
| 580 | ||
| 581 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 582 | # include <atomic> | |
| 583 | # include <concepts> | |
| 584 | # include <cstddef> | |
| 585 | # include <cstdlib> | |
| 586 | # include <cstring> | |
| 587 | # include <initializer_list> | |
| 588 | # include <iosfwd> | |
| 589 | # include <limits> | |
| 590 | # include <mutex> | |
| 591 | # include <new> | |
| 592 | # include <stdexcept> | |
| 593 | # include <type_traits> | |
| 594 | # include <typeinfo> | |
| 595 | #endif | |
| 582 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT) | |
| 583 | ||
| 584 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 585 | # include <atomic> | |
| 586 | # include <concepts> | |
| 587 | # include <cstddef> | |
| 588 | # include <cstdlib> | |
| 589 | # include <cstring> | |
| 590 | # include <initializer_list> | |
| 591 | # include <iosfwd> | |
| 592 | # include <limits> | |
| 593 | # include <mutex> | |
| 594 | # include <new> | |
| 595 | # include <stdexcept> | |
| 596 | # include <type_traits> | |
| 597 | # include <typeinfo> | |
| 598 | # endif | |
| 599 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 596 | 600 | |
| 597 | 601 | #endif // _LIBCPP_CODECVT |
lib/libcxx/include/compare+33-34| ... | ... | @@ -140,39 +140,38 @@ namespace std { |
| 140 | 140 | } |
| 141 | 141 | */ |
| 142 | 142 | |
| 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 | ||
| 161 | #include <version> | |
| 162 | ||
| 163 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 164 | # pragma GCC system_header | |
| 165 | #endif | |
| 166 | ||
| 167 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 168 | # include <cstddef> | |
| 169 | # include <cstdint> | |
| 170 | # include <limits> | |
| 171 | #endif | |
| 172 | ||
| 173 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 174 | # include <cmath> | |
| 175 | # include <type_traits> | |
| 176 | #endif | |
| 143 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 144 | # include <__cxx03/compare> | |
| 145 | #else | |
| 146 | # include <__config> | |
| 147 | ||
| 148 | # if _LIBCPP_STD_VER >= 20 | |
| 149 | # include <__compare/common_comparison_category.h> | |
| 150 | # include <__compare/compare_partial_order_fallback.h> | |
| 151 | # include <__compare/compare_strong_order_fallback.h> | |
| 152 | # include <__compare/compare_three_way.h> | |
| 153 | # include <__compare/compare_three_way_result.h> | |
| 154 | # include <__compare/compare_weak_order_fallback.h> | |
| 155 | # include <__compare/is_eq.h> | |
| 156 | # include <__compare/ordering.h> | |
| 157 | # include <__compare/partial_order.h> | |
| 158 | # include <__compare/strong_order.h> | |
| 159 | # include <__compare/synth_three_way.h> | |
| 160 | # include <__compare/three_way_comparable.h> | |
| 161 | # include <__compare/weak_order.h> | |
| 162 | # endif // _LIBCPP_STD_VER >= 20 | |
| 163 | ||
| 164 | # include <version> | |
| 165 | ||
| 166 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 167 | # pragma GCC system_header | |
| 168 | # endif | |
| 169 | ||
| 170 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 171 | # include <cmath> | |
| 172 | # include <cstddef> | |
| 173 | # include <type_traits> | |
| 174 | # endif | |
| 175 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 177 | 176 | |
| 178 | 177 | #endif // _LIBCPP_COMPARE |
lib/libcxx/include/complex+100-98| ... | ... | @@ -256,26 +256,29 @@ template<class T> complex<T> tanh (const complex<T>&); |
| 256 | 256 | |
| 257 | 257 | */ |
| 258 | 258 | |
| 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> | |
| 266 | #include <cmath> | |
| 267 | #include <version> | |
| 268 | ||
| 269 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 270 | # include <sstream> // for std::basic_ostringstream | |
| 271 | #endif | |
| 272 | ||
| 273 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 274 | # pragma GCC system_header | |
| 275 | #endif | |
| 259 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 260 | # include <__cxx03/complex> | |
| 261 | #else | |
| 262 | # include <__config> | |
| 263 | # include <__fwd/complex.h> | |
| 264 | # include <__fwd/tuple.h> | |
| 265 | # include <__tuple/tuple_element.h> | |
| 266 | # include <__tuple/tuple_size.h> | |
| 267 | # include <__type_traits/conditional.h> | |
| 268 | # include <__utility/move.h> | |
| 269 | # include <cmath> | |
| 270 | # include <version> | |
| 271 | ||
| 272 | # if _LIBCPP_HAS_LOCALIZATION | |
| 273 | # include <sstream> // for std::basic_ostringstream | |
| 274 | # endif | |
| 275 | ||
| 276 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 277 | # pragma GCC system_header | |
| 278 | # endif | |
| 276 | 279 | |
| 277 | 280 | _LIBCPP_PUSH_MACROS |
| 278 | #include <__undef_macros> | |
| 281 | # include <__undef_macros> | |
| 279 | 282 | |
| 280 | 283 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 281 | 284 | |
| ... | ... | @@ -374,7 +377,7 @@ public: |
| 374 | 377 | return *this; |
| 375 | 378 | } |
| 376 | 379 | |
| 377 | #if _LIBCPP_STD_VER >= 26 | |
| 380 | # if _LIBCPP_STD_VER >= 26 | |
| 378 | 381 | template <size_t _Ip, class _Xp> |
| 379 | 382 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; |
| 380 | 383 | |
| ... | ... | @@ -386,7 +389,7 @@ public: |
| 386 | 389 | |
| 387 | 390 | template <size_t _Ip, class _Xp> |
| 388 | 391 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; |
| 389 | #endif | |
| 392 | # endif | |
| 390 | 393 | }; |
| 391 | 394 | |
| 392 | 395 | template <> |
| ... | ... | @@ -397,18 +400,18 @@ class _LIBCPP_TEMPLATE_VIS complex<long double>; |
| 397 | 400 | struct __from_builtin_tag {}; |
| 398 | 401 | |
| 399 | 402 | template <class _Tp> |
| 400 | using __complex_t = | |
| 403 | using __complex_t _LIBCPP_NODEBUG = | |
| 401 | 404 | __conditional_t<is_same<_Tp, float>::value, |
| 402 | 405 | _Complex float, |
| 403 | 406 | __conditional_t<is_same<_Tp, double>::value, _Complex double, _Complex long double> >; |
| 404 | 407 | |
| 405 | 408 | template <class _Tp> |
| 406 | 409 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re, _Tp __im) { |
| 407 | #if __has_builtin(__builtin_complex) | |
| 410 | # if __has_builtin(__builtin_complex) | |
| 408 | 411 | return __builtin_complex(__re, __im); |
| 409 | #else | |
| 412 | # else | |
| 410 | 413 | return __complex_t<_Tp>{__re, __im}; |
| 411 | #endif | |
| 414 | # endif | |
| 412 | 415 | } |
| 413 | 416 | |
| 414 | 417 | template <> |
| ... | ... | @@ -493,7 +496,7 @@ public: |
| 493 | 496 | return *this; |
| 494 | 497 | } |
| 495 | 498 | |
| 496 | #if _LIBCPP_STD_VER >= 26 | |
| 499 | # if _LIBCPP_STD_VER >= 26 | |
| 497 | 500 | template <size_t _Ip, class _Xp> |
| 498 | 501 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; |
| 499 | 502 | |
| ... | ... | @@ -505,7 +508,7 @@ public: |
| 505 | 508 | |
| 506 | 509 | template <size_t _Ip, class _Xp> |
| 507 | 510 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; |
| 508 | #endif | |
| 511 | # endif | |
| 509 | 512 | }; |
| 510 | 513 | |
| 511 | 514 | template <> |
| ... | ... | @@ -593,7 +596,7 @@ public: |
| 593 | 596 | return *this; |
| 594 | 597 | } |
| 595 | 598 | |
| 596 | #if _LIBCPP_STD_VER >= 26 | |
| 599 | # if _LIBCPP_STD_VER >= 26 | |
| 597 | 600 | template <size_t _Ip, class _Xp> |
| 598 | 601 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; |
| 599 | 602 | |
| ... | ... | @@ -605,7 +608,7 @@ public: |
| 605 | 608 | |
| 606 | 609 | template <size_t _Ip, class _Xp> |
| 607 | 610 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; |
| 608 | #endif | |
| 611 | # endif | |
| 609 | 612 | }; |
| 610 | 613 | |
| 611 | 614 | template <> |
| ... | ... | @@ -694,7 +697,7 @@ public: |
| 694 | 697 | return *this; |
| 695 | 698 | } |
| 696 | 699 | |
| 697 | #if _LIBCPP_STD_VER >= 26 | |
| 700 | # if _LIBCPP_STD_VER >= 26 | |
| 698 | 701 | template <size_t _Ip, class _Xp> |
| 699 | 702 | friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept; |
| 700 | 703 | |
| ... | ... | @@ -706,7 +709,7 @@ public: |
| 706 | 709 | |
| 707 | 710 | template <size_t _Ip, class _Xp> |
| 708 | 711 | friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept; |
| 709 | #endif | |
| 712 | # endif | |
| 710 | 713 | }; |
| 711 | 714 | |
| 712 | 715 | inline _LIBCPP_CONSTEXPR complex<float>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {} |
| ... | ... | @@ -861,7 +864,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const |
| 861 | 864 | return __x.real() == __y && __x.imag() == 0; |
| 862 | 865 | } |
| 863 | 866 | |
| 864 | #if _LIBCPP_STD_VER <= 17 | |
| 867 | # if _LIBCPP_STD_VER <= 17 | |
| 865 | 868 | |
| 866 | 869 | template <class _Tp> |
| 867 | 870 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const _Tp& __x, const complex<_Tp>& __y) { |
| ... | ... | @@ -884,7 +887,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator!=(const |
| 884 | 887 | return !(__x == __y); |
| 885 | 888 | } |
| 886 | 889 | |
| 887 | #endif | |
| 890 | # endif | |
| 888 | 891 | |
| 889 | 892 | // 26.3.7 values: |
| 890 | 893 | |
| ... | ... | @@ -997,14 +1000,14 @@ conj(_Tp __re) { |
| 997 | 1000 | template <class _Tp> |
| 998 | 1001 | inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> proj(const complex<_Tp>& __c) { |
| 999 | 1002 | complex<_Tp> __r = __c; |
| 1000 | if (std::__constexpr_isinf(__c.real()) || std::__constexpr_isinf(__c.imag())) | |
| 1003 | if (std::isinf(__c.real()) || std::isinf(__c.imag())) | |
| 1001 | 1004 | __r = complex<_Tp>(INFINITY, std::copysign(_Tp(0), __c.imag())); |
| 1002 | 1005 | return __r; |
| 1003 | 1006 | } |
| 1004 | 1007 | |
| 1005 | 1008 | template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> |
| 1006 | 1009 | inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) { |
| 1007 | if (std::__constexpr_isinf(__re)) | |
| 1010 | if (std::isinf(__re)) | |
| 1008 | 1011 | __re = std::abs(__re); |
| 1009 | 1012 | return complex<_Tp>(__re); |
| 1010 | 1013 | } |
| ... | ... | @@ -1019,23 +1022,23 @@ inline _LIBCPP_HIDE_FROM_ABI typename __libcpp_complex_overload_traits<_Tp>::_Co |
| 1019 | 1022 | |
| 1020 | 1023 | template <class _Tp> |
| 1021 | 1024 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> polar(const _Tp& __rho, const _Tp& __theta = _Tp()) { |
| 1022 | if (std::__constexpr_isnan(__rho) || std::signbit(__rho)) | |
| 1025 | if (std::isnan(__rho) || std::signbit(__rho)) | |
| 1023 | 1026 | return complex<_Tp>(_Tp(NAN), _Tp(NAN)); |
| 1024 | if (std::__constexpr_isnan(__theta)) { | |
| 1025 | if (std::__constexpr_isinf(__rho)) | |
| 1027 | if (std::isnan(__theta)) { | |
| 1028 | if (std::isinf(__rho)) | |
| 1026 | 1029 | return complex<_Tp>(__rho, __theta); |
| 1027 | 1030 | return complex<_Tp>(__theta, __theta); |
| 1028 | 1031 | } |
| 1029 | if (std::__constexpr_isinf(__theta)) { | |
| 1030 | if (std::__constexpr_isinf(__rho)) | |
| 1032 | if (std::isinf(__theta)) { | |
| 1033 | if (std::isinf(__rho)) | |
| 1031 | 1034 | return complex<_Tp>(__rho, _Tp(NAN)); |
| 1032 | 1035 | return complex<_Tp>(_Tp(NAN), _Tp(NAN)); |
| 1033 | 1036 | } |
| 1034 | 1037 | _Tp __x = __rho * std::cos(__theta); |
| 1035 | if (std::__constexpr_isnan(__x)) | |
| 1038 | if (std::isnan(__x)) | |
| 1036 | 1039 | __x = 0; |
| 1037 | 1040 | _Tp __y = __rho * std::sin(__theta); |
| 1038 | if (std::__constexpr_isnan(__y)) | |
| 1041 | if (std::isnan(__y)) | |
| 1039 | 1042 | __y = 0; |
| 1040 | 1043 | return complex<_Tp>(__x, __y); |
| 1041 | 1044 | } |
| ... | ... | @@ -1058,14 +1061,12 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) { |
| 1058 | 1061 | |
| 1059 | 1062 | template <class _Tp> |
| 1060 | 1063 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) { |
| 1061 | if (std::__constexpr_isinf(__x.imag())) | |
| 1064 | if (std::isinf(__x.imag())) | |
| 1062 | 1065 | return complex<_Tp>(_Tp(INFINITY), __x.imag()); |
| 1063 | if (std::__constexpr_isinf(__x.real())) { | |
| 1066 | if (std::isinf(__x.real())) { | |
| 1064 | 1067 | if (__x.real() > _Tp(0)) |
| 1065 | return complex<_Tp>( | |
| 1066 | __x.real(), std::__constexpr_isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag())); | |
| 1067 | return complex<_Tp>( | |
| 1068 | std::__constexpr_isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag())); | |
| 1068 | return complex<_Tp>(__x.real(), std::isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag())); | |
| 1069 | return complex<_Tp>(std::isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag())); | |
| 1069 | 1070 | } |
| 1070 | 1071 | return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2)); |
| 1071 | 1072 | } |
| ... | ... | @@ -1078,12 +1079,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> exp(const complex<_Tp>& __x) { |
| 1078 | 1079 | if (__i == 0) { |
| 1079 | 1080 | return complex<_Tp>(std::exp(__x.real()), std::copysign(_Tp(0), __x.imag())); |
| 1080 | 1081 | } |
| 1081 | if (std::__constexpr_isinf(__x.real())) { | |
| 1082 | if (std::isinf(__x.real())) { | |
| 1082 | 1083 | if (__x.real() < _Tp(0)) { |
| 1083 | if (!std::__constexpr_isfinite(__i)) | |
| 1084 | if (!std::isfinite(__i)) | |
| 1084 | 1085 | __i = _Tp(1); |
| 1085 | } else if (__i == 0 || !std::__constexpr_isfinite(__i)) { | |
| 1086 | if (std::__constexpr_isinf(__i)) | |
| 1086 | } else if (__i == 0 || !std::isfinite(__i)) { | |
| 1087 | if (std::isinf(__i)) | |
| 1087 | 1088 | __i = _Tp(NAN); |
| 1088 | 1089 | return complex<_Tp>(__x.real(), __i); |
| 1089 | 1090 | } |
| ... | ... | @@ -1099,20 +1100,20 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const com |
| 1099 | 1100 | return std::exp(__y * std::log(__x)); |
| 1100 | 1101 | } |
| 1101 | 1102 | |
| 1102 | template <class _Tp, class _Up> | |
| 1103 | template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_floating_point<_Up>::value, int> = 0> | |
| 1103 | 1104 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> |
| 1104 | 1105 | pow(const complex<_Tp>& __x, const complex<_Up>& __y) { |
| 1105 | 1106 | typedef complex<typename __promote<_Tp, _Up>::type> result_type; |
| 1106 | 1107 | return std::pow(result_type(__x), result_type(__y)); |
| 1107 | 1108 | } |
| 1108 | 1109 | |
| 1109 | template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Up>::value, int> = 0> | |
| 1110 | template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_arithmetic<_Up>::value, int> = 0> | |
| 1110 | 1111 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) { |
| 1111 | 1112 | typedef complex<typename __promote<_Tp, _Up>::type> result_type; |
| 1112 | 1113 | return std::pow(result_type(__x), result_type(__y)); |
| 1113 | 1114 | } |
| 1114 | 1115 | |
| 1115 | template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value, int> = 0> | |
| 1116 | template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_floating_point<_Up>::value, int> = 0> | |
| 1116 | 1117 | inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const _Tp& __x, const complex<_Up>& __y) { |
| 1117 | 1118 | typedef complex<typename __promote<_Tp, _Up>::type> result_type; |
| 1118 | 1119 | return std::pow(result_type(__x), result_type(__y)); |
| ... | ... | @@ -1130,21 +1131,21 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> __sqr(const complex<_Tp>& __x) { |
| 1130 | 1131 | template <class _Tp> |
| 1131 | 1132 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) { |
| 1132 | 1133 | const _Tp __pi(atan2(+0., -0.)); |
| 1133 | if (std::__constexpr_isinf(__x.real())) { | |
| 1134 | if (std::__constexpr_isnan(__x.imag())) | |
| 1134 | if (std::isinf(__x.real())) { | |
| 1135 | if (std::isnan(__x.imag())) | |
| 1135 | 1136 | return __x; |
| 1136 | if (std::__constexpr_isinf(__x.imag())) | |
| 1137 | if (std::isinf(__x.imag())) | |
| 1137 | 1138 | return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag())); |
| 1138 | 1139 | return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag())); |
| 1139 | 1140 | } |
| 1140 | if (std::__constexpr_isnan(__x.real())) { | |
| 1141 | if (std::__constexpr_isinf(__x.imag())) | |
| 1141 | if (std::isnan(__x.real())) { | |
| 1142 | if (std::isinf(__x.imag())) | |
| 1142 | 1143 | return complex<_Tp>(__x.imag(), __x.real()); |
| 1143 | 1144 | if (__x.imag() == 0) |
| 1144 | 1145 | return __x; |
| 1145 | 1146 | return complex<_Tp>(__x.real(), __x.real()); |
| 1146 | 1147 | } |
| 1147 | if (std::__constexpr_isinf(__x.imag())) | |
| 1148 | if (std::isinf(__x.imag())) | |
| 1148 | 1149 | return complex<_Tp>(std::copysign(__x.imag(), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); |
| 1149 | 1150 | complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) + _Tp(1))); |
| 1150 | 1151 | return complex<_Tp>(std::copysign(__z.real(), __x.real()), std::copysign(__z.imag(), __x.imag())); |
| ... | ... | @@ -1155,10 +1156,10 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asinh(const complex<_Tp>& __x) { |
| 1155 | 1156 | template <class _Tp> |
| 1156 | 1157 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { |
| 1157 | 1158 | const _Tp __pi(atan2(+0., -0.)); |
| 1158 | if (std::__constexpr_isinf(__x.real())) { | |
| 1159 | if (std::__constexpr_isnan(__x.imag())) | |
| 1159 | if (std::isinf(__x.real())) { | |
| 1160 | if (std::isnan(__x.imag())) | |
| 1160 | 1161 | return complex<_Tp>(std::abs(__x.real()), __x.imag()); |
| 1161 | if (std::__constexpr_isinf(__x.imag())) { | |
| 1162 | if (std::isinf(__x.imag())) { | |
| 1162 | 1163 | if (__x.real() > 0) |
| 1163 | 1164 | return complex<_Tp>(__x.real(), std::copysign(__pi * _Tp(0.25), __x.imag())); |
| 1164 | 1165 | else |
| ... | ... | @@ -1168,12 +1169,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { |
| 1168 | 1169 | return complex<_Tp>(-__x.real(), std::copysign(__pi, __x.imag())); |
| 1169 | 1170 | return complex<_Tp>(__x.real(), std::copysign(_Tp(0), __x.imag())); |
| 1170 | 1171 | } |
| 1171 | if (std::__constexpr_isnan(__x.real())) { | |
| 1172 | if (std::__constexpr_isinf(__x.imag())) | |
| 1172 | if (std::isnan(__x.real())) { | |
| 1173 | if (std::isinf(__x.imag())) | |
| 1173 | 1174 | return complex<_Tp>(std::abs(__x.imag()), __x.real()); |
| 1174 | 1175 | return complex<_Tp>(__x.real(), __x.real()); |
| 1175 | 1176 | } |
| 1176 | if (std::__constexpr_isinf(__x.imag())) | |
| 1177 | if (std::isinf(__x.imag())) | |
| 1177 | 1178 | return complex<_Tp>(std::abs(__x.imag()), std::copysign(__pi / _Tp(2), __x.imag())); |
| 1178 | 1179 | complex<_Tp> __z = std::log(__x + std::sqrt(std::__sqr(__x) - _Tp(1))); |
| 1179 | 1180 | return complex<_Tp>(std::copysign(__z.real(), _Tp(0)), std::copysign(__z.imag(), __x.imag())); |
| ... | ... | @@ -1184,18 +1185,18 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acosh(const complex<_Tp>& __x) { |
| 1184 | 1185 | template <class _Tp> |
| 1185 | 1186 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) { |
| 1186 | 1187 | const _Tp __pi(atan2(+0., -0.)); |
| 1187 | if (std::__constexpr_isinf(__x.imag())) { | |
| 1188 | if (std::isinf(__x.imag())) { | |
| 1188 | 1189 | return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); |
| 1189 | 1190 | } |
| 1190 | if (std::__constexpr_isnan(__x.imag())) { | |
| 1191 | if (std::__constexpr_isinf(__x.real()) || __x.real() == 0) | |
| 1191 | if (std::isnan(__x.imag())) { | |
| 1192 | if (std::isinf(__x.real()) || __x.real() == 0) | |
| 1192 | 1193 | return complex<_Tp>(std::copysign(_Tp(0), __x.real()), __x.imag()); |
| 1193 | 1194 | return complex<_Tp>(__x.imag(), __x.imag()); |
| 1194 | 1195 | } |
| 1195 | if (std::__constexpr_isnan(__x.real())) { | |
| 1196 | if (std::isnan(__x.real())) { | |
| 1196 | 1197 | return complex<_Tp>(__x.real(), __x.real()); |
| 1197 | 1198 | } |
| 1198 | if (std::__constexpr_isinf(__x.real())) { | |
| 1199 | if (std::isinf(__x.real())) { | |
| 1199 | 1200 | return complex<_Tp>(std::copysign(_Tp(0), __x.real()), std::copysign(__pi / _Tp(2), __x.imag())); |
| 1200 | 1201 | } |
| 1201 | 1202 | if (std::abs(__x.real()) == _Tp(1) && __x.imag() == _Tp(0)) { |
| ... | ... | @@ -1209,11 +1210,11 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> atanh(const complex<_Tp>& __x) { |
| 1209 | 1210 | |
| 1210 | 1211 | template <class _Tp> |
| 1211 | 1212 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) { |
| 1212 | if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag())) | |
| 1213 | if (std::isinf(__x.real()) && !std::isfinite(__x.imag())) | |
| 1213 | 1214 | return complex<_Tp>(__x.real(), _Tp(NAN)); |
| 1214 | if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag())) | |
| 1215 | if (__x.real() == 0 && !std::isfinite(__x.imag())) | |
| 1215 | 1216 | return complex<_Tp>(__x.real(), _Tp(NAN)); |
| 1216 | if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real())) | |
| 1217 | if (__x.imag() == 0 && !std::isfinite(__x.real())) | |
| 1217 | 1218 | return __x; |
| 1218 | 1219 | return complex<_Tp>(std::sinh(__x.real()) * std::cos(__x.imag()), std::cosh(__x.real()) * std::sin(__x.imag())); |
| 1219 | 1220 | } |
| ... | ... | @@ -1222,13 +1223,13 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> sinh(const complex<_Tp>& __x) { |
| 1222 | 1223 | |
| 1223 | 1224 | template <class _Tp> |
| 1224 | 1225 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) { |
| 1225 | if (std::__constexpr_isinf(__x.real()) && !std::__constexpr_isfinite(__x.imag())) | |
| 1226 | if (std::isinf(__x.real()) && !std::isfinite(__x.imag())) | |
| 1226 | 1227 | return complex<_Tp>(std::abs(__x.real()), _Tp(NAN)); |
| 1227 | if (__x.real() == 0 && !std::__constexpr_isfinite(__x.imag())) | |
| 1228 | if (__x.real() == 0 && !std::isfinite(__x.imag())) | |
| 1228 | 1229 | return complex<_Tp>(_Tp(NAN), __x.real()); |
| 1229 | 1230 | if (__x.real() == 0 && __x.imag() == 0) |
| 1230 | 1231 | return complex<_Tp>(_Tp(1), __x.imag()); |
| 1231 | if (__x.imag() == 0 && !std::__constexpr_isfinite(__x.real())) | |
| 1232 | if (__x.imag() == 0 && !std::isfinite(__x.real())) | |
| 1232 | 1233 | return complex<_Tp>(std::abs(__x.real()), __x.imag()); |
| 1233 | 1234 | return complex<_Tp>(std::cosh(__x.real()) * std::cos(__x.imag()), std::sinh(__x.real()) * std::sin(__x.imag())); |
| 1234 | 1235 | } |
| ... | ... | @@ -1237,18 +1238,18 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> cosh(const complex<_Tp>& __x) { |
| 1237 | 1238 | |
| 1238 | 1239 | template <class _Tp> |
| 1239 | 1240 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> tanh(const complex<_Tp>& __x) { |
| 1240 | if (std::__constexpr_isinf(__x.real())) { | |
| 1241 | if (!std::__constexpr_isfinite(__x.imag())) | |
| 1241 | if (std::isinf(__x.real())) { | |
| 1242 | if (!std::isfinite(__x.imag())) | |
| 1242 | 1243 | return complex<_Tp>(std::copysign(_Tp(1), __x.real()), _Tp(0)); |
| 1243 | 1244 | return complex<_Tp>(std::copysign(_Tp(1), __x.real()), std::copysign(_Tp(0), std::sin(_Tp(2) * __x.imag()))); |
| 1244 | 1245 | } |
| 1245 | if (std::__constexpr_isnan(__x.real()) && __x.imag() == 0) | |
| 1246 | if (std::isnan(__x.real()) && __x.imag() == 0) | |
| 1246 | 1247 | return __x; |
| 1247 | 1248 | _Tp __2r(_Tp(2) * __x.real()); |
| 1248 | 1249 | _Tp __2i(_Tp(2) * __x.imag()); |
| 1249 | 1250 | _Tp __d(std::cosh(__2r) + std::cos(__2i)); |
| 1250 | 1251 | _Tp __2rsh(std::sinh(__2r)); |
| 1251 | if (std::__constexpr_isinf(__2rsh) && std::__constexpr_isinf(__d)) | |
| 1252 | if (std::isinf(__2rsh) && std::isinf(__d)) | |
| 1252 | 1253 | return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1), __2i > _Tp(0) ? _Tp(0) : _Tp(-0.)); |
| 1253 | 1254 | return complex<_Tp>(__2rsh / __d, std::sin(__2i) / __d); |
| 1254 | 1255 | } |
| ... | ... | @@ -1266,10 +1267,10 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> asin(const complex<_Tp>& __x) { |
| 1266 | 1267 | template <class _Tp> |
| 1267 | 1268 | _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) { |
| 1268 | 1269 | const _Tp __pi(atan2(+0., -0.)); |
| 1269 | if (std::__constexpr_isinf(__x.real())) { | |
| 1270 | if (std::__constexpr_isnan(__x.imag())) | |
| 1270 | if (std::isinf(__x.real())) { | |
| 1271 | if (std::isnan(__x.imag())) | |
| 1271 | 1272 | return complex<_Tp>(__x.imag(), __x.real()); |
| 1272 | if (std::__constexpr_isinf(__x.imag())) { | |
| 1273 | if (std::isinf(__x.imag())) { | |
| 1273 | 1274 | if (__x.real() < _Tp(0)) |
| 1274 | 1275 | return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag()); |
| 1275 | 1276 | return complex<_Tp>(_Tp(0.25) * __pi, -__x.imag()); |
| ... | ... | @@ -1278,12 +1279,12 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> acos(const complex<_Tp>& __x) { |
| 1278 | 1279 | return complex<_Tp>(__pi, std::signbit(__x.imag()) ? -__x.real() : __x.real()); |
| 1279 | 1280 | return complex<_Tp>(_Tp(0), std::signbit(__x.imag()) ? __x.real() : -__x.real()); |
| 1280 | 1281 | } |
| 1281 | if (std::__constexpr_isnan(__x.real())) { | |
| 1282 | if (std::__constexpr_isinf(__x.imag())) | |
| 1282 | if (std::isnan(__x.real())) { | |
| 1283 | if (std::isinf(__x.imag())) | |
| 1283 | 1284 | return complex<_Tp>(__x.real(), -__x.imag()); |
| 1284 | 1285 | return complex<_Tp>(__x.real(), __x.real()); |
| 1285 | 1286 | } |
| 1286 | if (std::__constexpr_isinf(__x.imag())) | |
| 1287 | if (std::isinf(__x.imag())) | |
| 1287 | 1288 | return complex<_Tp>(__pi / _Tp(2), -__x.imag()); |
| 1288 | 1289 | if (__x.real() == 0 && (__x.imag() == 0 || std::isnan(__x.imag()))) |
| 1289 | 1290 | return complex<_Tp>(__pi / _Tp(2), -__x.imag()); |
| ... | ... | @@ -1324,7 +1325,7 @@ _LIBCPP_HIDE_FROM_ABI complex<_Tp> tan(const complex<_Tp>& __x) { |
| 1324 | 1325 | return complex<_Tp>(__z.imag(), -__z.real()); |
| 1325 | 1326 | } |
| 1326 | 1327 | |
| 1327 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 1328 | # if _LIBCPP_HAS_LOCALIZATION | |
| 1328 | 1329 | template <class _Tp, class _CharT, class _Traits> |
| 1329 | 1330 | _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
| 1330 | 1331 | operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x) { |
| ... | ... | @@ -1381,9 +1382,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) { |
| 1381 | 1382 | __s << '(' << __x.real() << ',' << __x.imag() << ')'; |
| 1382 | 1383 | return __os << __s.str(); |
| 1383 | 1384 | } |
| 1384 | #endif // !_LIBCPP_HAS_NO_LOCALIZATION | |
| 1385 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 1385 | 1386 | |
| 1386 | #if _LIBCPP_STD_VER >= 26 | |
| 1387 | # if _LIBCPP_STD_VER >= 26 | |
| 1387 | 1388 | |
| 1388 | 1389 | // [complex.tuple], tuple interface |
| 1389 | 1390 | |
| ... | ... | @@ -1436,9 +1437,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexce |
| 1436 | 1437 | } |
| 1437 | 1438 | } |
| 1438 | 1439 | |
| 1439 | #endif // _LIBCPP_STD_VER >= 26 | |
| 1440 | # endif // _LIBCPP_STD_VER >= 26 | |
| 1440 | 1441 | |
| 1441 | #if _LIBCPP_STD_VER >= 14 | |
| 1442 | # if _LIBCPP_STD_VER >= 14 | |
| 1442 | 1443 | // Literal suffix for complex number literals [complex.literals] |
| 1443 | 1444 | inline namespace literals { |
| 1444 | 1445 | inline namespace complex_literals { |
| ... | ... | @@ -1465,16 +1466,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long |
| 1465 | 1466 | } |
| 1466 | 1467 | } // namespace complex_literals |
| 1467 | 1468 | } // namespace literals |
| 1468 | #endif | |
| 1469 | # endif | |
| 1469 | 1470 | |
| 1470 | 1471 | _LIBCPP_END_NAMESPACE_STD |
| 1471 | 1472 | |
| 1472 | 1473 | _LIBCPP_POP_MACROS |
| 1473 | 1474 | |
| 1474 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1475 | # include <iosfwd> | |
| 1476 | # include <stdexcept> | |
| 1477 | # include <type_traits> | |
| 1478 | #endif | |
| 1475 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1476 | # include <iosfwd> | |
| 1477 | # include <stdexcept> | |
| 1478 | # include <type_traits> | |
| 1479 | # endif | |
| 1480 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1479 | 1481 | |
| 1480 | 1482 | #endif // _LIBCPP_COMPLEX |
lib/libcxx/include/complex.h+15-11| ... | ... | @@ -17,16 +17,20 @@ |
| 17 | 17 | |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | #include <__config> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | #ifdef __cplusplus | |
| 27 | # include <ccomplex> | |
| 28 | #elif __has_include_next(<complex.h>) | |
| 29 | # include_next <complex.h> | |
| 30 | #endif | |
| 20 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 21 | # include <__cxx03/complex.h> | |
| 22 | #else | |
| 23 | # include <__config> | |
| 24 | ||
| 25 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | # endif | |
| 28 | ||
| 29 | # ifdef __cplusplus | |
| 30 | # include <complex> | |
| 31 | # elif __has_include_next(<complex.h>) | |
| 32 | # include_next <complex.h> | |
| 33 | # endif | |
| 34 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 31 | 35 | |
| 32 | 36 | #endif // _LIBCPP_COMPLEX_H |
lib/libcxx/include/concepts+41-40| ... | ... | @@ -129,45 +129,46 @@ namespace std { |
| 129 | 129 | |
| 130 | 130 | */ |
| 131 | 131 | |
| 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 | ||
| 159 | #include <version> | |
| 160 | ||
| 161 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 162 | # include <cstddef> | |
| 163 | #endif | |
| 164 | ||
| 165 | #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) | |
| 166 | # include <type_traits> | |
| 167 | #endif | |
| 168 | ||
| 169 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 170 | # pragma GCC system_header | |
| 171 | #endif | |
| 132 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 133 | # include <__cxx03/concepts> | |
| 134 | #else | |
| 135 | # include <__config> | |
| 136 | ||
| 137 | # if _LIBCPP_STD_VER >= 20 | |
| 138 | # include <__concepts/arithmetic.h> | |
| 139 | # include <__concepts/assignable.h> | |
| 140 | # include <__concepts/boolean_testable.h> | |
| 141 | # include <__concepts/class_or_enum.h> | |
| 142 | # include <__concepts/common_reference_with.h> | |
| 143 | # include <__concepts/common_with.h> | |
| 144 | # include <__concepts/constructible.h> | |
| 145 | # include <__concepts/convertible_to.h> | |
| 146 | # include <__concepts/copyable.h> | |
| 147 | # include <__concepts/derived_from.h> | |
| 148 | # include <__concepts/destructible.h> | |
| 149 | # include <__concepts/different_from.h> | |
| 150 | # include <__concepts/equality_comparable.h> | |
| 151 | # include <__concepts/invocable.h> | |
| 152 | # include <__concepts/movable.h> | |
| 153 | # include <__concepts/predicate.h> | |
| 154 | # include <__concepts/regular.h> | |
| 155 | # include <__concepts/relation.h> | |
| 156 | # include <__concepts/same_as.h> | |
| 157 | # include <__concepts/semiregular.h> | |
| 158 | # include <__concepts/swappable.h> | |
| 159 | # include <__concepts/totally_ordered.h> | |
| 160 | # endif // _LIBCPP_STD_VER >= 20 | |
| 161 | ||
| 162 | # include <version> | |
| 163 | ||
| 164 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 165 | # include <cstddef> | |
| 166 | # include <type_traits> | |
| 167 | # endif | |
| 168 | ||
| 169 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 170 | # pragma GCC system_header | |
| 171 | # endif | |
| 172 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 172 | 173 | |
| 173 | 174 | #endif // _LIBCPP_CONCEPTS |
lib/libcxx/include/condition_variable+43-39| ... | ... | @@ -118,29 +118,32 @@ public: |
| 118 | 118 | |
| 119 | 119 | */ |
| 120 | 120 | |
| 121 | #include <__chrono/duration.h> | |
| 122 | #include <__chrono/steady_clock.h> | |
| 123 | #include <__chrono/time_point.h> | |
| 124 | #include <__condition_variable/condition_variable.h> | |
| 125 | #include <__config> | |
| 126 | #include <__memory/shared_ptr.h> | |
| 127 | #include <__mutex/lock_guard.h> | |
| 128 | #include <__mutex/mutex.h> | |
| 129 | #include <__mutex/tag_types.h> | |
| 130 | #include <__mutex/unique_lock.h> | |
| 131 | #include <__stop_token/stop_callback.h> | |
| 132 | #include <__stop_token/stop_token.h> | |
| 133 | #include <__utility/move.h> | |
| 134 | #include <version> | |
| 135 | ||
| 136 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 137 | # pragma GCC system_header | |
| 138 | #endif | |
| 121 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 122 | # include <__cxx03/condition_variable> | |
| 123 | #else | |
| 124 | # include <__chrono/duration.h> | |
| 125 | # include <__chrono/steady_clock.h> | |
| 126 | # include <__chrono/time_point.h> | |
| 127 | # include <__condition_variable/condition_variable.h> | |
| 128 | # include <__config> | |
| 129 | # include <__memory/shared_ptr.h> | |
| 130 | # include <__mutex/lock_guard.h> | |
| 131 | # include <__mutex/mutex.h> | |
| 132 | # include <__mutex/tag_types.h> | |
| 133 | # include <__mutex/unique_lock.h> | |
| 134 | # include <__stop_token/stop_callback.h> | |
| 135 | # include <__stop_token/stop_token.h> | |
| 136 | # include <__utility/move.h> | |
| 137 | # include <version> | |
| 138 | ||
| 139 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 140 | # pragma GCC system_header | |
| 141 | # endif | |
| 139 | 142 | |
| 140 | 143 | _LIBCPP_PUSH_MACROS |
| 141 | #include <__undef_macros> | |
| 144 | # include <__undef_macros> | |
| 142 | 145 | |
| 143 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 146 | # if _LIBCPP_HAS_THREADS | |
| 144 | 147 | |
| 145 | 148 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 146 | 149 | |
| ... | ... | @@ -173,7 +176,7 @@ public: |
| 173 | 176 | template <class _Lock, class _Rep, class _Period, class _Predicate> |
| 174 | 177 | bool _LIBCPP_HIDE_FROM_ABI wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); |
| 175 | 178 | |
| 176 | # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) | |
| 179 | # if _LIBCPP_STD_VER >= 20 | |
| 177 | 180 | |
| 178 | 181 | template <class _Lock, class _Predicate> |
| 179 | 182 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait(_Lock& __lock, stop_token __stoken, _Predicate __pred); |
| ... | ... | @@ -186,7 +189,7 @@ public: |
| 186 | 189 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool |
| 187 | 190 | wait_for(_Lock& __lock, stop_token __stoken, const chrono::duration<_Rep, _Period>& __rel_time, _Predicate __pred); |
| 188 | 191 | |
| 189 | # endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) | |
| 192 | # endif // _LIBCPP_STD_VER >= 20 | |
| 190 | 193 | }; |
| 191 | 194 | |
| 192 | 195 | inline condition_variable_any::condition_variable_any() : __mut_(make_shared<mutex>()) {} |
| ... | ... | @@ -260,7 +263,7 @@ condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Pe |
| 260 | 263 | return wait_until(__lock, chrono::steady_clock::now() + __d, std::move(__pred)); |
| 261 | 264 | } |
| 262 | 265 | |
| 263 | # if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) | |
| 266 | # if _LIBCPP_STD_VER >= 20 | |
| 264 | 267 | |
| 265 | 268 | template <class _Lock, class _Predicate> |
| 266 | 269 | bool condition_variable_any::wait(_Lock& __user_lock, stop_token __stoken, _Predicate __pred) { |
| ... | ... | @@ -341,29 +344,30 @@ bool condition_variable_any::wait_for( |
| 341 | 344 | return wait_until(__lock, std::move(__stoken), chrono::steady_clock::now() + __rel_time, std::move(__pred)); |
| 342 | 345 | } |
| 343 | 346 | |
| 344 | # endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) | |
| 347 | # endif // _LIBCPP_STD_VER >= 20 | |
| 345 | 348 | |
| 346 | 349 | _LIBCPP_EXPORTED_FROM_ABI void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>); |
| 347 | 350 | |
| 348 | 351 | _LIBCPP_END_NAMESPACE_STD |
| 349 | 352 | |
| 350 | #endif // !_LIBCPP_HAS_NO_THREADS | |
| 353 | # endif // _LIBCPP_HAS_THREADS | |
| 351 | 354 | |
| 352 | 355 | _LIBCPP_POP_MACROS |
| 353 | 356 | |
| 354 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 355 | # include <atomic> | |
| 356 | # include <concepts> | |
| 357 | # include <cstdint> | |
| 358 | # include <cstdlib> | |
| 359 | # include <cstring> | |
| 360 | # include <initializer_list> | |
| 361 | # include <iosfwd> | |
| 362 | # include <new> | |
| 363 | # include <stdexcept> | |
| 364 | # include <system_error> | |
| 365 | # include <type_traits> | |
| 366 | # include <typeinfo> | |
| 367 | #endif | |
| 357 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 358 | # include <atomic> | |
| 359 | # include <concepts> | |
| 360 | # include <cstdint> | |
| 361 | # include <cstdlib> | |
| 362 | # include <cstring> | |
| 363 | # include <initializer_list> | |
| 364 | # include <iosfwd> | |
| 365 | # include <new> | |
| 366 | # include <stdexcept> | |
| 367 | # include <system_error> | |
| 368 | # include <type_traits> | |
| 369 | # include <typeinfo> | |
| 370 | # endif | |
| 371 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 368 | 372 | |
| 369 | 373 | #endif // _LIBCPP_CONDITION_VARIABLE |
lib/libcxx/include/coroutine+22-17| ... | ... | @@ -38,30 +38,35 @@ struct suspend_always; |
| 38 | 38 | |
| 39 | 39 | */ |
| 40 | 40 | |
| 41 | #include <__config> | |
| 41 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 42 | # include <__cxx03/coroutine> | |
| 43 | #else | |
| 44 | # include <__config> | |
| 42 | 45 | |
| 43 | #if _LIBCPP_STD_VER >= 20 | |
| 44 | # include <__coroutine/coroutine_handle.h> | |
| 45 | # include <__coroutine/coroutine_traits.h> | |
| 46 | # include <__coroutine/noop_coroutine_handle.h> | |
| 47 | # include <__coroutine/trivial_awaitables.h> | |
| 48 | #endif // _LIBCPP_STD_VER >= 20 | |
| 46 | # if _LIBCPP_STD_VER >= 20 | |
| 47 | # include <__coroutine/coroutine_handle.h> | |
| 48 | # include <__coroutine/coroutine_traits.h> | |
| 49 | # include <__coroutine/noop_coroutine_handle.h> | |
| 50 | # include <__coroutine/trivial_awaitables.h> | |
| 51 | # endif // _LIBCPP_STD_VER >= 20 | |
| 49 | 52 | |
| 50 | #include <version> | |
| 53 | # include <version> | |
| 51 | 54 | |
| 52 | 55 | // standard-mandated includes |
| 53 | 56 | |
| 54 | 57 | // [coroutine.syn] |
| 55 | #include <compare> | |
| 58 | # include <compare> | |
| 56 | 59 | |
| 57 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | |
| 58 | # pragma GCC system_header | |
| 59 | #endif | |
| 60 | # ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | |
| 61 | # pragma GCC system_header | |
| 62 | # endif | |
| 60 | 63 | |
| 61 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 62 | # include <iosfwd> | |
| 63 | # include <limits> | |
| 64 | # include <type_traits> | |
| 65 | #endif | |
| 64 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 65 | # include <cstddef> | |
| 66 | # include <iosfwd> | |
| 67 | # include <limits> | |
| 68 | # include <type_traits> | |
| 69 | # endif | |
| 70 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 66 | 71 | |
| 67 | 72 | #endif // _LIBCPP_COROUTINE |
lib/libcxx/include/csetjmp+14-9| ... | ... | @@ -30,19 +30,22 @@ void longjmp(jmp_buf env, int val); |
| 30 | 30 | |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | #include <__config> | |
| 33 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 34 | # include <__cxx03/csetjmp> | |
| 35 | #else | |
| 36 | # include <__config> | |
| 34 | 37 | |
| 35 | 38 | // <setjmp.h> is not provided by libc++ |
| 36 | #if __has_include(<setjmp.h>) | |
| 37 | # include <setjmp.h> | |
| 38 | # ifdef _LIBCPP_SETJMP_H | |
| 39 | # error "If libc++ starts defining <setjmp.h>, the __has_include check should move to libc++'s <setjmp.h>" | |
| 39 | # if __has_include(<setjmp.h>) | |
| 40 | # include <setjmp.h> | |
| 41 | # ifdef _LIBCPP_SETJMP_H | |
| 42 | # error "If libc++ starts defining <setjmp.h>, the __has_include check should move to libc++'s <setjmp.h>" | |
| 43 | # endif | |
| 40 | 44 | # endif |
| 41 | #endif | |
| 42 | 45 | |
| 43 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 44 | # pragma GCC system_header | |
| 45 | #endif | |
| 46 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 47 | # pragma GCC system_header | |
| 48 | # endif | |
| 46 | 49 | |
| 47 | 50 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 51 | |
| ... | ... | @@ -51,4 +54,6 @@ using ::longjmp _LIBCPP_USING_IF_EXISTS; |
| 51 | 54 | |
| 52 | 55 | _LIBCPP_END_NAMESPACE_STD |
| 53 | 56 | |
| 57 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 58 | ||
| 54 | 59 | #endif // _LIBCPP_CSETJMP |
lib/libcxx/include/csignal+14-9| ... | ... | @@ -39,19 +39,22 @@ int raise(int sig); |
| 39 | 39 | |
| 40 | 40 | */ |
| 41 | 41 | |
| 42 | #include <__config> | |
| 42 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 43 | # include <__cxx03/csignal> | |
| 44 | #else | |
| 45 | # include <__config> | |
| 43 | 46 | |
| 44 | 47 | // <signal.h> is not provided by libc++ |
| 45 | #if __has_include(<signal.h>) | |
| 46 | # include <signal.h> | |
| 47 | # ifdef _LIBCPP_SIGNAL_H | |
| 48 | # error "If libc++ starts defining <signal.h>, the __has_include check should move to libc++'s <signal.h>" | |
| 48 | # if __has_include(<signal.h>) | |
| 49 | # include <signal.h> | |
| 50 | # ifdef _LIBCPP_SIGNAL_H | |
| 51 | # error "If libc++ starts defining <signal.h>, the __has_include check should move to libc++'s <signal.h>" | |
| 52 | # endif | |
| 49 | 53 | # endif |
| 50 | #endif | |
| 51 | 54 | |
| 52 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 53 | # pragma GCC system_header | |
| 54 | #endif | |
| 55 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 56 | # pragma GCC system_header | |
| 57 | # endif | |
| 55 | 58 | |
| 56 | 59 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 57 | 60 | |
| ... | ... | @@ -61,4 +64,6 @@ using ::raise _LIBCPP_USING_IF_EXISTS; |
| 61 | 64 | |
| 62 | 65 | _LIBCPP_END_NAMESPACE_STD |
| 63 | 66 | |
| 67 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 68 | ||
| 64 | 69 | #endif // _LIBCPP_CSIGNAL |
lib/libcxx/include/cstdalign created+59| ... | ... | @@ -0,0 +1,59 @@ |
| 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_CSTDALIGN | |
| 11 | #define _LIBCPP_CSTDALIGN | |
| 12 | ||
| 13 | /* | |
| 14 | cstdalign synopsis | |
| 15 | ||
| 16 | Macros: | |
| 17 | ||
| 18 | __alignas_is_defined | |
| 19 | __alignof_is_defined | |
| 20 | ||
| 21 | */ | |
| 22 | ||
| 23 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 24 | # include <__cxx03/__config> | |
| 25 | #else | |
| 26 | # include <__config> | |
| 27 | ||
| 28 | // <stdalign.h> is not provided by libc++ | |
| 29 | # if __has_include(<stdalign.h>) | |
| 30 | # include <stdalign.h> | |
| 31 | # ifdef _LIBCPP_STDALIGN_H | |
| 32 | # error "If libc++ starts defining <stdalign.h>, the __has_include check should move to libc++'s <stdalign.h>" | |
| 33 | # endif | |
| 34 | # endif | |
| 35 | ||
| 36 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 37 | # pragma GCC system_header | |
| 38 | # endif | |
| 39 | ||
| 40 | # undef __alignas_is_defined | |
| 41 | # define __alignas_is_defined 1 | |
| 42 | ||
| 43 | # undef __alignof_is_defined | |
| 44 | # define __alignof_is_defined 1 | |
| 45 | ||
| 46 | # if _LIBCPP_STD_VER >= 20 | |
| 47 | ||
| 48 | using __standard_header_cstdalign _LIBCPP_DEPRECATED_("removed in C++20.") _LIBCPP_NODEBUG = void; | |
| 49 | using __use_standard_header_cstdalign _LIBCPP_NODEBUG = __standard_header_cstdalign; | |
| 50 | ||
| 51 | # elif _LIBCPP_STD_VER >= 17 | |
| 52 | ||
| 53 | using __standard_header_cstdalign _LIBCPP_DEPRECATED _LIBCPP_NODEBUG = void; | |
| 54 | using __use_standard_header_cstdalign _LIBCPP_NODEBUG = __standard_header_cstdalign; | |
| 55 | ||
| 56 | # endif | |
| 57 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 58 | ||
| 59 | #endif // _LIBCPP_CSTDALIGN |
lib/libcxx/include/cstdarg+14-9| ... | ... | @@ -31,19 +31,22 @@ Types: |
| 31 | 31 | |
| 32 | 32 | */ |
| 33 | 33 | |
| 34 | #include <__config> | |
| 34 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 35 | # include <__cxx03/cstdarg> | |
| 36 | #else | |
| 37 | # include <__config> | |
| 35 | 38 | |
| 36 | 39 | // <stdarg.h> is not provided by libc++ |
| 37 | #if __has_include(<stdarg.h>) | |
| 38 | # include <stdarg.h> | |
| 39 | # ifdef _LIBCPP_STDARG_H | |
| 40 | # error "If libc++ starts defining <stdarg.h>, the __has_include check should move to libc++'s <stdarg.h>" | |
| 40 | # if __has_include(<stdarg.h>) | |
| 41 | # include <stdarg.h> | |
| 42 | # ifdef _LIBCPP_STDARG_H | |
| 43 | # error "If libc++ starts defining <stdarg.h>, the __has_include check should move to libc++'s <stdarg.h>" | |
| 44 | # endif | |
| 41 | 45 | # endif |
| 42 | #endif | |
| 43 | 46 | |
| 44 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 45 | # pragma GCC system_header | |
| 46 | #endif | |
| 47 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 48 | # pragma GCC system_header | |
| 49 | # endif | |
| 47 | 50 | |
| 48 | 51 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 49 | 52 | |
| ... | ... | @@ -51,4 +54,6 @@ using ::va_list _LIBCPP_USING_IF_EXISTS; |
| 51 | 54 | |
| 52 | 55 | _LIBCPP_END_NAMESPACE_STD |
| 53 | 56 | |
| 57 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 58 | ||
| 54 | 59 | #endif // _LIBCPP_CSTDARG |
lib/libcxx/include/cstdbool+22-6| ... | ... | @@ -19,13 +19,29 @@ Macros: |
| 19 | 19 | |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | #include <__config> | |
| 22 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 23 | # include <__cxx03/cstdbool> | |
| 24 | #else | |
| 25 | # include <__config> | |
| 23 | 26 | |
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 28 | # pragma GCC system_header | |
| 29 | # endif | |
| 27 | 30 | |
| 28 | #undef __bool_true_false_are_defined | |
| 29 | #define __bool_true_false_are_defined 1 | |
| 31 | # undef __bool_true_false_are_defined | |
| 32 | # define __bool_true_false_are_defined 1 | |
| 33 | ||
| 34 | # if _LIBCPP_STD_VER >= 20 | |
| 35 | ||
| 36 | using __standard_header_cstdbool _LIBCPP_DEPRECATED_("removed in C++20.") _LIBCPP_NODEBUG = void; | |
| 37 | using __use_standard_header_cstdbool _LIBCPP_NODEBUG = __standard_header_cstdbool; | |
| 38 | ||
| 39 | # elif _LIBCPP_STD_VER >= 17 | |
| 40 | ||
| 41 | using __standard_header_cstdbool _LIBCPP_DEPRECATED _LIBCPP_NODEBUG = void; | |
| 42 | using __use_standard_header_cstdbool _LIBCPP_NODEBUG = __standard_header_cstdbool; | |
| 43 | ||
| 44 | # endif | |
| 45 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 30 | 46 | |
| 31 | 47 | #endif // _LIBCPP_CSTDBOOL |
lib/libcxx/include/cstddef+19-89| ... | ... | @@ -33,101 +33,31 @@ Types: |
| 33 | 33 | |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | #include <__config> | |
| 37 | #include <__type_traits/enable_if.h> | |
| 38 | #include <__type_traits/integral_constant.h> | |
| 39 | #include <__type_traits/is_integral.h> | |
| 40 | #include <version> | |
| 36 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 37 | # include <__cxx03/cstddef> | |
| 38 | #else | |
| 39 | # include <__config> | |
| 40 | # include <version> | |
| 41 | 41 | |
| 42 | #include <stddef.h> | |
| 42 | # include <stddef.h> | |
| 43 | 43 | |
| 44 | #ifndef _LIBCPP_STDDEF_H | |
| 44 | # ifndef _LIBCPP_STDDEF_H | |
| 45 | 45 | # error <cstddef> tried including <stddef.h> but didn't find libc++'s <stddef.h> header. \ |
| 46 | 46 | This usually means that your header search paths are not configured properly. \ |
| 47 | 47 | The header search paths should contain the C++ Standard Library headers before \ |
| 48 | 48 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 49 | 49 | not be the case. |
| 50 | #endif | |
| 51 | ||
| 52 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 53 | # pragma GCC system_header | |
| 54 | #endif | |
| 55 | ||
| 56 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 57 | ||
| 58 | using ::nullptr_t; | |
| 59 | using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS; | |
| 60 | using ::size_t _LIBCPP_USING_IF_EXISTS; | |
| 61 | ||
| 62 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 63 | using ::max_align_t _LIBCPP_USING_IF_EXISTS; | |
| 64 | #endif | |
| 65 | ||
| 66 | _LIBCPP_END_NAMESPACE_STD | |
| 67 | ||
| 68 | #if _LIBCPP_STD_VER >= 17 | |
| 69 | namespace std // purposefully not versioned | |
| 70 | { | |
| 71 | enum class byte : unsigned char {}; | |
| 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept { | |
| 74 | return static_cast<byte>( | |
| 75 | static_cast<unsigned char>(static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs))); | |
| 76 | } | |
| 77 | ||
| 78 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept { | |
| 79 | return __lhs = __lhs | __rhs; | |
| 80 | } | |
| 81 | ||
| 82 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept { | |
| 83 | return static_cast<byte>( | |
| 84 | static_cast<unsigned char>(static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs))); | |
| 85 | } | |
| 86 | ||
| 87 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept { | |
| 88 | return __lhs = __lhs & __rhs; | |
| 89 | } | |
| 90 | ||
| 91 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept { | |
| 92 | return static_cast<byte>( | |
| 93 | static_cast<unsigned char>(static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs))); | |
| 94 | } | |
| 95 | ||
| 96 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept { | |
| 97 | return __lhs = __lhs ^ __rhs; | |
| 98 | } | |
| 99 | ||
| 100 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept { | |
| 101 | return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(__b))); | |
| 102 | } | |
| 103 | ||
| 104 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | |
| 105 | _LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift) noexcept { | |
| 106 | return __lhs = __lhs << __shift; | |
| 107 | } | |
| 108 | ||
| 109 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | |
| 110 | _LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept { | |
| 111 | return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); | |
| 112 | } | |
| 113 | ||
| 114 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | |
| 115 | _LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift) noexcept { | |
| 116 | return __lhs = __lhs >> __shift; | |
| 117 | } | |
| 118 | ||
| 119 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | |
| 120 | _LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept { | |
| 121 | return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); | |
| 122 | } | |
| 123 | ||
| 124 | template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0> | |
| 125 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept { | |
| 126 | return static_cast<_Integer>(__b); | |
| 127 | } | |
| 128 | ||
| 129 | } // namespace std | |
| 130 | ||
| 131 | #endif | |
| 50 | # endif | |
| 51 | ||
| 52 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 53 | # pragma GCC system_header | |
| 54 | # endif | |
| 55 | ||
| 56 | # include <__cstddef/byte.h> | |
| 57 | # include <__cstddef/max_align_t.h> | |
| 58 | # include <__cstddef/nullptr_t.h> | |
| 59 | # include <__cstddef/ptrdiff_t.h> | |
| 60 | # include <__cstddef/size_t.h> | |
| 61 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 132 | 62 | |
| 133 | 63 | #endif // _LIBCPP_CSTDDEF |
lib/libcxx/include/cstdint+12-13| ... | ... | @@ -140,21 +140,18 @@ Types: |
| 140 | 140 | } // std |
| 141 | 141 | */ |
| 142 | 142 | |
| 143 | #include <__config> | |
| 143 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 144 | # include <__cxx03/cstdint> | |
| 145 | #else | |
| 146 | # include <__config> | |
| 144 | 147 | |
| 145 | #include <stdint.h> | |
| 148 | # if __has_include(<stdint.h>) | |
| 149 | # include <stdint.h> | |
| 150 | # endif | |
| 146 | 151 | |
| 147 | #ifndef _LIBCPP_STDINT_H | |
| 148 | # error <cstdint> tried including <stdint.h> but didn't find libc++'s <stdint.h> header. \ | |
| 149 | This usually means that your header search paths are not configured properly. \ | |
| 150 | The header search paths should contain the C++ Standard Library headers before \ | |
| 151 | any C Standard Library, and you are probably using compiler flags that make that \ | |
| 152 | not be the case. | |
| 153 | #endif | |
| 154 | ||
| 155 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 156 | # pragma GCC system_header | |
| 157 | #endif | |
| 152 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 153 | # pragma GCC system_header | |
| 154 | # endif | |
| 158 | 155 | |
| 159 | 156 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 160 | 157 | |
| ... | ... | @@ -196,4 +193,6 @@ using ::uintmax_t _LIBCPP_USING_IF_EXISTS; |
| 196 | 193 | |
| 197 | 194 | _LIBCPP_END_NAMESPACE_STD |
| 198 | 195 | |
| 196 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 197 | ||
| 199 | 198 | #endif // _LIBCPP_CSTDINT |
lib/libcxx/include/cstdio+15-10| ... | ... | @@ -95,27 +95,30 @@ void perror(const char* s); |
| 95 | 95 | } // std |
| 96 | 96 | */ |
| 97 | 97 | |
| 98 | #include <__config> | |
| 98 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 99 | # include <__cxx03/cstdio> | |
| 100 | #else | |
| 101 | # include <__config> | |
| 102 | # include <__cstddef/size_t.h> | |
| 99 | 103 | |
| 100 | #include <stdio.h> | |
| 104 | # include <stdio.h> | |
| 101 | 105 | |
| 102 | #ifndef _LIBCPP_STDIO_H | |
| 106 | # ifndef _LIBCPP_STDIO_H | |
| 103 | 107 | # error <cstdio> tried including <stdio.h> but didn't find libc++'s <stdio.h> header. \ |
| 104 | 108 | This usually means that your header search paths are not configured properly. \ |
| 105 | 109 | The header search paths should contain the C++ Standard Library headers before \ |
| 106 | 110 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 107 | 111 | not be the case. |
| 108 | #endif | |
| 112 | # endif | |
| 109 | 113 | |
| 110 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 111 | # pragma GCC system_header | |
| 112 | #endif | |
| 114 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 115 | # pragma GCC system_header | |
| 116 | # endif | |
| 113 | 117 | |
| 114 | 118 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 115 | 119 | |
| 116 | 120 | using ::FILE _LIBCPP_USING_IF_EXISTS; |
| 117 | 121 | using ::fpos_t _LIBCPP_USING_IF_EXISTS; |
| 118 | using ::size_t _LIBCPP_USING_IF_EXISTS; | |
| 119 | 122 | |
| 120 | 123 | using ::fclose _LIBCPP_USING_IF_EXISTS; |
| 121 | 124 | using ::fflush _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -158,9 +161,9 @@ using ::tmpfile _LIBCPP_USING_IF_EXISTS; |
| 158 | 161 | using ::tmpnam _LIBCPP_USING_IF_EXISTS; |
| 159 | 162 | |
| 160 | 163 | using ::getchar _LIBCPP_USING_IF_EXISTS; |
| 161 | #if _LIBCPP_STD_VER <= 11 | |
| 164 | # if _LIBCPP_STD_VER <= 11 | |
| 162 | 165 | using ::gets _LIBCPP_USING_IF_EXISTS; |
| 163 | #endif | |
| 166 | # endif | |
| 164 | 167 | using ::scanf _LIBCPP_USING_IF_EXISTS; |
| 165 | 168 | using ::vscanf _LIBCPP_USING_IF_EXISTS; |
| 166 | 169 | |
| ... | ... | @@ -171,4 +174,6 @@ using ::vprintf _LIBCPP_USING_IF_EXISTS; |
| 171 | 174 | |
| 172 | 175 | _LIBCPP_END_NAMESPACE_STD |
| 173 | 176 | |
| 177 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 178 | ||
| 174 | 179 | #endif // _LIBCPP_CSTDIO |
lib/libcxx/include/cstdlib+19-14| ... | ... | @@ -81,25 +81,28 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 |
| 81 | 81 | |
| 82 | 82 | */ |
| 83 | 83 | |
| 84 | #include <__config> | |
| 84 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 85 | # include <__cxx03/cstdlib> | |
| 86 | #else | |
| 87 | # include <__config> | |
| 88 | # include <__cstddef/size_t.h> | |
| 85 | 89 | |
| 86 | #include <stdlib.h> | |
| 90 | # include <stdlib.h> | |
| 87 | 91 | |
| 88 | #ifndef _LIBCPP_STDLIB_H | |
| 92 | # ifndef _LIBCPP_STDLIB_H | |
| 89 | 93 | # error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \ |
| 90 | 94 | This usually means that your header search paths are not configured properly. \ |
| 91 | 95 | The header search paths should contain the C++ Standard Library headers before \ |
| 92 | 96 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 93 | 97 | not be the case. |
| 94 | #endif | |
| 98 | # endif | |
| 95 | 99 | |
| 96 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 97 | # pragma GCC system_header | |
| 98 | #endif | |
| 100 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 101 | # pragma GCC system_header | |
| 102 | # endif | |
| 99 | 103 | |
| 100 | 104 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 101 | 105 | |
| 102 | using ::size_t _LIBCPP_USING_IF_EXISTS; | |
| 103 | 106 | using ::div_t _LIBCPP_USING_IF_EXISTS; |
| 104 | 107 | using ::ldiv_t _LIBCPP_USING_IF_EXISTS; |
| 105 | 108 | using ::lldiv_t _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -135,20 +138,22 @@ using ::div _LIBCPP_USING_IF_EXISTS; |
| 135 | 138 | using ::ldiv _LIBCPP_USING_IF_EXISTS; |
| 136 | 139 | using ::lldiv _LIBCPP_USING_IF_EXISTS; |
| 137 | 140 | using ::mblen _LIBCPP_USING_IF_EXISTS; |
| 138 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 141 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 139 | 142 | using ::mbtowc _LIBCPP_USING_IF_EXISTS; |
| 140 | 143 | using ::wctomb _LIBCPP_USING_IF_EXISTS; |
| 141 | 144 | using ::mbstowcs _LIBCPP_USING_IF_EXISTS; |
| 142 | 145 | using ::wcstombs _LIBCPP_USING_IF_EXISTS; |
| 143 | #endif | |
| 144 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 146 | # endif | |
| 147 | # if !defined(_LIBCPP_CXX03_LANG) | |
| 145 | 148 | using ::at_quick_exit _LIBCPP_USING_IF_EXISTS; |
| 146 | 149 | using ::quick_exit _LIBCPP_USING_IF_EXISTS; |
| 147 | #endif | |
| 148 | #if _LIBCPP_STD_VER >= 17 | |
| 150 | # endif | |
| 151 | # if _LIBCPP_STD_VER >= 17 | |
| 149 | 152 | using ::aligned_alloc _LIBCPP_USING_IF_EXISTS; |
| 150 | #endif | |
| 153 | # endif | |
| 151 | 154 | |
| 152 | 155 | _LIBCPP_END_NAMESPACE_STD |
| 153 | 156 | |
| 157 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 158 | ||
| 154 | 159 | #endif // _LIBCPP_CSTDLIB |
lib/libcxx/include/cstring+14-9| ... | ... | @@ -56,26 +56,29 @@ size_t strlen(const char* s); |
| 56 | 56 | |
| 57 | 57 | */ |
| 58 | 58 | |
| 59 | #include <__config> | |
| 60 | #include <__type_traits/is_constant_evaluated.h> | |
| 59 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 60 | # include <__cxx03/cstring> | |
| 61 | #else | |
| 62 | # include <__config> | |
| 63 | # include <__cstddef/size_t.h> | |
| 64 | # include <__type_traits/is_constant_evaluated.h> | |
| 61 | 65 | |
| 62 | #include <string.h> | |
| 66 | # include <string.h> | |
| 63 | 67 | |
| 64 | #ifndef _LIBCPP_STRING_H | |
| 68 | # ifndef _LIBCPP_STRING_H | |
| 65 | 69 | # error <cstring> tried including <string.h> but didn't find libc++'s <string.h> header. \ |
| 66 | 70 | This usually means that your header search paths are not configured properly. \ |
| 67 | 71 | The header search paths should contain the C++ Standard Library headers before \ |
| 68 | 72 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 69 | 73 | not be the case. |
| 70 | #endif | |
| 74 | # endif | |
| 71 | 75 | |
| 72 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 73 | # pragma GCC system_header | |
| 74 | #endif | |
| 76 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 77 | # pragma GCC system_header | |
| 78 | # endif | |
| 75 | 79 | |
| 76 | 80 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 77 | 81 | |
| 78 | using ::size_t _LIBCPP_USING_IF_EXISTS; | |
| 79 | 82 | using ::memcpy _LIBCPP_USING_IF_EXISTS; |
| 80 | 83 | using ::memmove _LIBCPP_USING_IF_EXISTS; |
| 81 | 84 | using ::strcpy _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -101,4 +104,6 @@ using ::strlen _LIBCPP_USING_IF_EXISTS; |
| 101 | 104 | |
| 102 | 105 | _LIBCPP_END_NAMESPACE_STD |
| 103 | 106 | |
| 107 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 108 | ||
| 104 | 109 | #endif // _LIBCPP_CSTRING |
lib/libcxx/include/ctgmath+23-5| ... | ... | @@ -18,11 +18,29 @@ |
| 18 | 18 | |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | #include <ccomplex> | |
| 22 | #include <cmath> | |
| 21 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 22 | # include <__cxx03/ctgmath> | |
| 23 | #else | |
| 24 | # include <cmath> | |
| 25 | # include <complex> | |
| 26 | ||
| 27 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 28 | # pragma GCC system_header | |
| 29 | # endif | |
| 30 | ||
| 31 | # if _LIBCPP_STD_VER >= 20 | |
| 32 | ||
| 33 | using __standard_header_ctgmath | |
| 34 | _LIBCPP_DEPRECATED_("removed in C++20. Include <cmath> and <complex> instead.") _LIBCPP_NODEBUG = void; | |
| 35 | using __use_standard_header_ctgmath _LIBCPP_NODEBUG = __standard_header_ctgmath; | |
| 36 | ||
| 37 | # elif _LIBCPP_STD_VER >= 17 | |
| 38 | ||
| 39 | using __standard_header_ctgmath _LIBCPP_DEPRECATED_("Include <cmath> and <complex> instead.") _LIBCPP_NODEBUG = void; | |
| 40 | using __use_standard_header_ctgmath _LIBCPP_NODEBUG = __standard_header_ctgmath; | |
| 41 | ||
| 42 | # endif | |
| 23 | 43 | |
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 44 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 27 | 45 | |
| 28 | 46 | #endif // _LIBCPP_CTGMATH |
lib/libcxx/include/ctime+19-14| ... | ... | @@ -45,29 +45,32 @@ int timespec_get( struct timespec *ts, int base); // C++17 |
| 45 | 45 | |
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | #include <__config> | |
| 48 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 49 | # include <__cxx03/ctime> | |
| 50 | #else | |
| 51 | # include <__config> | |
| 52 | # include <__cstddef/size_t.h> | |
| 49 | 53 | |
| 50 | 54 | // <time.h> is not provided by libc++ |
| 51 | #if __has_include(<time.h>) | |
| 52 | # include <time.h> | |
| 53 | # ifdef _LIBCPP_TIME_H | |
| 54 | # error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>" | |
| 55 | # if __has_include(<time.h>) | |
| 56 | # include <time.h> | |
| 57 | # ifdef _LIBCPP_TIME_H | |
| 58 | # error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>" | |
| 59 | # endif | |
| 55 | 60 | # endif |
| 56 | #endif | |
| 57 | 61 | |
| 58 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 59 | # pragma GCC system_header | |
| 60 | #endif | |
| 62 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 63 | # pragma GCC system_header | |
| 64 | # endif | |
| 61 | 65 | |
| 62 | 66 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 63 | 67 | |
| 64 | 68 | using ::clock_t _LIBCPP_USING_IF_EXISTS; |
| 65 | using ::size_t _LIBCPP_USING_IF_EXISTS; | |
| 66 | 69 | using ::time_t _LIBCPP_USING_IF_EXISTS; |
| 67 | 70 | using ::tm _LIBCPP_USING_IF_EXISTS; |
| 68 | #if _LIBCPP_STD_VER >= 17 | |
| 71 | # if _LIBCPP_STD_VER >= 17 | |
| 69 | 72 | using ::timespec _LIBCPP_USING_IF_EXISTS; |
| 70 | #endif | |
| 73 | # endif | |
| 71 | 74 | using ::clock _LIBCPP_USING_IF_EXISTS; |
| 72 | 75 | using ::difftime _LIBCPP_USING_IF_EXISTS; |
| 73 | 76 | using ::mktime _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -77,10 +80,12 @@ using ::ctime _LIBCPP_USING_IF_EXISTS; |
| 77 | 80 | using ::gmtime _LIBCPP_USING_IF_EXISTS; |
| 78 | 81 | using ::localtime _LIBCPP_USING_IF_EXISTS; |
| 79 | 82 | using ::strftime _LIBCPP_USING_IF_EXISTS; |
| 80 | #if _LIBCPP_STD_VER >= 17 | |
| 83 | # if _LIBCPP_STD_VER >= 17 | |
| 81 | 84 | using ::timespec_get _LIBCPP_USING_IF_EXISTS; |
| 82 | #endif | |
| 85 | # endif | |
| 83 | 86 | |
| 84 | 87 | _LIBCPP_END_NAMESPACE_STD |
| 85 | 88 | |
| 89 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 90 | ||
| 86 | 91 | #endif // _LIBCPP_CTIME |
lib/libcxx/include/ctype.h+32-28| ... | ... | @@ -29,33 +29,37 @@ int tolower(int c); |
| 29 | 29 | int toupper(int c); |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | #include <__config> | |
| 33 | ||
| 34 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 35 | # pragma GCC system_header | |
| 36 | #endif | |
| 37 | ||
| 38 | #if __has_include_next(<ctype.h>) | |
| 39 | # include_next <ctype.h> | |
| 40 | #endif | |
| 41 | ||
| 42 | #ifdef __cplusplus | |
| 43 | ||
| 44 | # undef isalnum | |
| 45 | # undef isalpha | |
| 46 | # undef isblank | |
| 47 | # undef iscntrl | |
| 48 | # undef isdigit | |
| 49 | # undef isgraph | |
| 50 | # undef islower | |
| 51 | # undef isprint | |
| 52 | # undef ispunct | |
| 53 | # undef isspace | |
| 54 | # undef isupper | |
| 55 | # undef isxdigit | |
| 56 | # undef tolower | |
| 57 | # undef toupper | |
| 58 | ||
| 59 | #endif | |
| 32 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 33 | # include <__cxx03/ctype.h> | |
| 34 | #else | |
| 35 | # include <__config> | |
| 36 | ||
| 37 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 38 | # pragma GCC system_header | |
| 39 | # endif | |
| 40 | ||
| 41 | # if __has_include_next(<ctype.h>) | |
| 42 | # include_next <ctype.h> | |
| 43 | # endif | |
| 44 | ||
| 45 | # ifdef __cplusplus | |
| 46 | ||
| 47 | # undef isalnum | |
| 48 | # undef isalpha | |
| 49 | # undef isblank | |
| 50 | # undef iscntrl | |
| 51 | # undef isdigit | |
| 52 | # undef isgraph | |
| 53 | # undef islower | |
| 54 | # undef isprint | |
| 55 | # undef ispunct | |
| 56 | # undef isspace | |
| 57 | # undef isupper | |
| 58 | # undef isxdigit | |
| 59 | # undef tolower | |
| 60 | # undef toupper | |
| 61 | ||
| 62 | # endif | |
| 63 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 60 | 64 | |
| 61 | 65 | #endif // _LIBCPP_CTYPE_H |
lib/libcxx/include/cuchar+17-12| ... | ... | @@ -36,40 +36,45 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps); |
| 36 | 36 | |
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | #include <__config> | |
| 39 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 40 | # include <__cxx03/cuchar> | |
| 41 | #else | |
| 42 | # include <__config> | |
| 43 | # include <__cstddef/size_t.h> | |
| 40 | 44 | |
| 41 | #include <uchar.h> | |
| 45 | # include <uchar.h> | |
| 42 | 46 | |
| 43 | #ifndef _LIBCPP_UCHAR_H | |
| 47 | # ifndef _LIBCPP_UCHAR_H | |
| 44 | 48 | # error <cuchar> tried including <uchar.h> but didn't find libc++'s <uchar.h> header. \ |
| 45 | 49 | This usually means that your header search paths are not configured properly. \ |
| 46 | 50 | The header search paths should contain the C++ Standard Library headers before \ |
| 47 | 51 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 48 | 52 | not be the case. |
| 49 | #endif | |
| 53 | # endif | |
| 50 | 54 | |
| 51 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 52 | # pragma GCC system_header | |
| 53 | #endif | |
| 55 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 56 | # pragma GCC system_header | |
| 57 | # endif | |
| 54 | 58 | |
| 55 | 59 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 56 | 60 | |
| 57 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 61 | # if !defined(_LIBCPP_CXX03_LANG) | |
| 58 | 62 | |
| 59 | 63 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS; |
| 60 | using ::size_t _LIBCPP_USING_IF_EXISTS; | |
| 61 | 64 | |
| 62 | # if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8) | |
| 65 | # if _LIBCPP_HAS_C8RTOMB_MBRTOC8 | |
| 63 | 66 | using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS; |
| 64 | 67 | using ::c8rtomb _LIBCPP_USING_IF_EXISTS; |
| 65 | # endif | |
| 68 | # endif | |
| 66 | 69 | using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS; |
| 67 | 70 | using ::c16rtomb _LIBCPP_USING_IF_EXISTS; |
| 68 | 71 | using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS; |
| 69 | 72 | using ::c32rtomb _LIBCPP_USING_IF_EXISTS; |
| 70 | 73 | |
| 71 | #endif // _LIBCPP_CXX03_LANG | |
| 74 | # endif // _LIBCPP_CXX03_LANG | |
| 72 | 75 | |
| 73 | 76 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 77 | |
| 78 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 79 | ||
| 75 | 80 | #endif // _LIBCPP_CUCHAR |
lib/libcxx/include/cwchar+31-27| ... | ... | @@ -102,32 +102,35 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, |
| 102 | 102 | |
| 103 | 103 | */ |
| 104 | 104 | |
| 105 | #include <__config> | |
| 106 | #include <__type_traits/copy_cv.h> | |
| 107 | #include <__type_traits/is_constant_evaluated.h> | |
| 108 | #include <__type_traits/is_equality_comparable.h> | |
| 109 | #include <__type_traits/is_same.h> | |
| 110 | #include <__type_traits/remove_cv.h> | |
| 111 | #include <cwctype> | |
| 105 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 106 | # include <__cxx03/cwchar> | |
| 107 | #else | |
| 108 | # include <__config> | |
| 109 | # include <__cstddef/size_t.h> | |
| 110 | # include <__type_traits/copy_cv.h> | |
| 111 | # include <__type_traits/is_constant_evaluated.h> | |
| 112 | # include <__type_traits/is_equality_comparable.h> | |
| 113 | # include <__type_traits/is_same.h> | |
| 114 | # include <__type_traits/remove_cv.h> | |
| 115 | # include <cwctype> | |
| 112 | 116 | |
| 113 | #include <wchar.h> | |
| 117 | # include <wchar.h> | |
| 114 | 118 | |
| 115 | #ifndef _LIBCPP_WCHAR_H | |
| 119 | # ifndef _LIBCPP_WCHAR_H | |
| 116 | 120 | # error <cwchar> tried including <wchar.h> but didn't find libc++'s <wchar.h> header. \ |
| 117 | 121 | This usually means that your header search paths are not configured properly. \ |
| 118 | 122 | The header search paths should contain the C++ Standard Library headers before \ |
| 119 | 123 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 120 | 124 | not be the case. |
| 121 | #endif | |
| 125 | # endif | |
| 122 | 126 | |
| 123 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 124 | # pragma GCC system_header | |
| 125 | #endif | |
| 127 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 128 | # pragma GCC system_header | |
| 129 | # endif | |
| 126 | 130 | |
| 127 | 131 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 128 | 132 | |
| 129 | 133 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS; |
| 130 | using ::size_t _LIBCPP_USING_IF_EXISTS; | |
| 131 | 134 | using ::tm _LIBCPP_USING_IF_EXISTS; |
| 132 | 135 | using ::wint_t _LIBCPP_USING_IF_EXISTS; |
| 133 | 136 | using ::FILE _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -194,9 +197,9 @@ using ::vwprintf _LIBCPP_USING_IF_EXISTS; |
| 194 | 197 | using ::wprintf _LIBCPP_USING_IF_EXISTS; |
| 195 | 198 | |
| 196 | 199 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wcslen(const wchar_t* __str) { |
| 197 | #if __has_builtin(__builtin_wcslen) | |
| 200 | # if __has_builtin(__builtin_wcslen) | |
| 198 | 201 | return __builtin_wcslen(__str); |
| 199 | #else | |
| 202 | # else | |
| 200 | 203 | if (!__libcpp_is_constant_evaluated()) |
| 201 | 204 | return std::wcslen(__str); |
| 202 | 205 | |
| ... | ... | @@ -204,14 +207,14 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wc |
| 204 | 207 | for (; *__str != L'\0'; ++__str) |
| 205 | 208 | ++__len; |
| 206 | 209 | return __len; |
| 207 | #endif | |
| 210 | # endif | |
| 208 | 211 | } |
| 209 | 212 | |
| 210 | 213 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int |
| 211 | 214 | __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) { |
| 212 | #if __has_builtin(__builtin_wmemcmp) | |
| 215 | # if __has_builtin(__builtin_wmemcmp) | |
| 213 | 216 | return __builtin_wmemcmp(__lhs, __rhs, __count); |
| 214 | #else | |
| 217 | # else | |
| 215 | 218 | if (!__libcpp_is_constant_evaluated()) |
| 216 | 219 | return std::wmemcmp(__lhs, __rhs, __count); |
| 217 | 220 | |
| ... | ... | @@ -222,7 +225,7 @@ __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) |
| 222 | 225 | return 1; |
| 223 | 226 | } |
| 224 | 227 | return 0; |
| 225 | #endif | |
| 228 | # endif | |
| 226 | 229 | } |
| 227 | 230 | |
| 228 | 231 | template <class _Tp, class _Up> |
| ... | ... | @@ -231,18 +234,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp |
| 231 | 234 | __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value, |
| 232 | 235 | "Calling wmemchr on non-trivially equality comparable types is unsafe."); |
| 233 | 236 | |
| 234 | #if __has_builtin(__builtin_wmemchr) | |
| 237 | # if __has_builtin(__builtin_wmemchr) | |
| 235 | 238 | if (!__libcpp_is_constant_evaluated()) { |
| 236 | 239 | wchar_t __value_buffer = 0; |
| 237 | 240 | __builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t)); |
| 238 | 241 | return reinterpret_cast<_Tp*>( |
| 239 | 242 | __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count)); |
| 240 | 243 | } |
| 241 | # if _LIBCPP_STD_VER >= 17 | |
| 244 | # if _LIBCPP_STD_VER >= 17 | |
| 242 | 245 | else if constexpr (is_same_v<remove_cv_t<_Tp>, wchar_t>) |
| 243 | 246 | return __builtin_wmemchr(__str, __value, __count); |
| 244 | # endif | |
| 245 | #endif // __has_builtin(__builtin_wmemchr) | |
| 247 | # endif | |
| 248 | # endif // __has_builtin(__builtin_wmemchr) | |
| 246 | 249 | |
| 247 | 250 | for (; __count; --__count) { |
| 248 | 251 | if (*__str == __value) |
| ... | ... | @@ -254,8 +257,9 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp |
| 254 | 257 | |
| 255 | 258 | _LIBCPP_END_NAMESPACE_STD |
| 256 | 259 | |
| 257 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 258 | # include <cstddef> | |
| 259 | #endif | |
| 260 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 261 | # include <cstddef> | |
| 262 | # endif | |
| 263 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 260 | 264 | |
| 261 | 265 | #endif // _LIBCPP_CWCHAR |
lib/libcxx/include/cwctype+15-10| ... | ... | @@ -49,26 +49,29 @@ wctrans_t wctrans(const char* property); |
| 49 | 49 | |
| 50 | 50 | */ |
| 51 | 51 | |
| 52 | #include <__config> | |
| 53 | #include <cctype> | |
| 52 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 53 | # include <__cxx03/cwctype> | |
| 54 | #else | |
| 55 | # include <__config> | |
| 56 | # include <cctype> | |
| 54 | 57 | |
| 55 | #include <wctype.h> | |
| 58 | # include <wctype.h> | |
| 56 | 59 | |
| 57 | #ifndef _LIBCPP_WCTYPE_H | |
| 60 | # ifndef _LIBCPP_WCTYPE_H | |
| 58 | 61 | # error <cwctype> tried including <wctype.h> but didn't find libc++'s <wctype.h> header. \ |
| 59 | 62 | This usually means that your header search paths are not configured properly. \ |
| 60 | 63 | The header search paths should contain the C++ Standard Library headers before \ |
| 61 | 64 | any C Standard Library, and you are probably using compiler flags that make that \ |
| 62 | 65 | not be the case. |
| 63 | #endif | |
| 66 | # endif | |
| 64 | 67 | |
| 65 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 66 | # pragma GCC system_header | |
| 67 | #endif | |
| 68 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 69 | # pragma GCC system_header | |
| 70 | # endif | |
| 68 | 71 | |
| 69 | 72 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 70 | 73 | |
| 71 | #if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H) | |
| 74 | # if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H) | |
| 72 | 75 | using ::wint_t _LIBCPP_USING_IF_EXISTS; |
| 73 | 76 | using ::wctrans_t _LIBCPP_USING_IF_EXISTS; |
| 74 | 77 | using ::wctype_t _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -90,8 +93,10 @@ using ::towlower _LIBCPP_USING_IF_EXISTS; |
| 90 | 93 | using ::towupper _LIBCPP_USING_IF_EXISTS; |
| 91 | 94 | using ::towctrans _LIBCPP_USING_IF_EXISTS; |
| 92 | 95 | using ::wctrans _LIBCPP_USING_IF_EXISTS; |
| 93 | #endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H | |
| 96 | # endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H | |
| 94 | 97 | |
| 95 | 98 | _LIBCPP_END_NAMESPACE_STD |
| 96 | 99 | |
| 100 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 101 | ||
| 97 | 102 | #endif // _LIBCPP_CWCTYPE |
lib/libcxx/include/deque+267-233| ... | ... | @@ -177,72 +177,90 @@ template <class T, class Allocator, class Predicate> |
| 177 | 177 | |
| 178 | 178 | */ |
| 179 | 179 | |
| 180 | #include <__algorithm/copy.h> | |
| 181 | #include <__algorithm/copy_backward.h> | |
| 182 | #include <__algorithm/copy_n.h> | |
| 183 | #include <__algorithm/equal.h> | |
| 184 | #include <__algorithm/fill_n.h> | |
| 185 | #include <__algorithm/lexicographical_compare.h> | |
| 186 | #include <__algorithm/lexicographical_compare_three_way.h> | |
| 187 | #include <__algorithm/min.h> | |
| 188 | #include <__algorithm/remove.h> | |
| 189 | #include <__algorithm/remove_if.h> | |
| 190 | #include <__algorithm/unwrap_iter.h> | |
| 191 | #include <__assert> | |
| 192 | #include <__config> | |
| 193 | #include <__debug_utils/sanitizers.h> | |
| 194 | #include <__format/enable_insertable.h> | |
| 195 | #include <__fwd/deque.h> | |
| 196 | #include <__iterator/distance.h> | |
| 197 | #include <__iterator/iterator_traits.h> | |
| 198 | #include <__iterator/next.h> | |
| 199 | #include <__iterator/prev.h> | |
| 200 | #include <__iterator/reverse_iterator.h> | |
| 201 | #include <__iterator/segmented_iterator.h> | |
| 202 | #include <__memory/addressof.h> | |
| 203 | #include <__memory/allocator_destructor.h> | |
| 204 | #include <__memory/pointer_traits.h> | |
| 205 | #include <__memory/temp_value.h> | |
| 206 | #include <__memory/unique_ptr.h> | |
| 207 | #include <__memory_resource/polymorphic_allocator.h> | |
| 208 | #include <__ranges/access.h> | |
| 209 | #include <__ranges/concepts.h> | |
| 210 | #include <__ranges/container_compatible_range.h> | |
| 211 | #include <__ranges/from_range.h> | |
| 212 | #include <__ranges/size.h> | |
| 213 | #include <__split_buffer> | |
| 214 | #include <__type_traits/is_allocator.h> | |
| 215 | #include <__type_traits/is_convertible.h> | |
| 216 | #include <__type_traits/is_same.h> | |
| 217 | #include <__type_traits/is_swappable.h> | |
| 218 | #include <__type_traits/type_identity.h> | |
| 219 | #include <__utility/forward.h> | |
| 220 | #include <__utility/move.h> | |
| 221 | #include <__utility/pair.h> | |
| 222 | #include <__utility/swap.h> | |
| 223 | #include <limits> | |
| 224 | #include <stdexcept> | |
| 225 | #include <version> | |
| 180 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 181 | # include <__cxx03/deque> | |
| 182 | #else | |
| 183 | # include <__algorithm/copy.h> | |
| 184 | # include <__algorithm/copy_backward.h> | |
| 185 | # include <__algorithm/copy_n.h> | |
| 186 | # include <__algorithm/equal.h> | |
| 187 | # include <__algorithm/fill_n.h> | |
| 188 | # include <__algorithm/lexicographical_compare.h> | |
| 189 | # include <__algorithm/lexicographical_compare_three_way.h> | |
| 190 | # include <__algorithm/max.h> | |
| 191 | # include <__algorithm/min.h> | |
| 192 | # include <__algorithm/move.h> | |
| 193 | # include <__algorithm/move_backward.h> | |
| 194 | # include <__algorithm/remove.h> | |
| 195 | # include <__algorithm/remove_if.h> | |
| 196 | # include <__algorithm/unwrap_iter.h> | |
| 197 | # include <__assert> | |
| 198 | # include <__config> | |
| 199 | # include <__debug_utils/sanitizers.h> | |
| 200 | # include <__format/enable_insertable.h> | |
| 201 | # include <__fwd/deque.h> | |
| 202 | # include <__iterator/distance.h> | |
| 203 | # include <__iterator/iterator_traits.h> | |
| 204 | # include <__iterator/move_iterator.h> | |
| 205 | # include <__iterator/next.h> | |
| 206 | # include <__iterator/prev.h> | |
| 207 | # include <__iterator/reverse_iterator.h> | |
| 208 | # include <__iterator/segmented_iterator.h> | |
| 209 | # include <__memory/addressof.h> | |
| 210 | # include <__memory/allocator.h> | |
| 211 | # include <__memory/allocator_destructor.h> | |
| 212 | # include <__memory/allocator_traits.h> | |
| 213 | # include <__memory/compressed_pair.h> | |
| 214 | # include <__memory/pointer_traits.h> | |
| 215 | # include <__memory/swap_allocator.h> | |
| 216 | # include <__memory/temp_value.h> | |
| 217 | # include <__memory/unique_ptr.h> | |
| 218 | # include <__memory_resource/polymorphic_allocator.h> | |
| 219 | # include <__ranges/access.h> | |
| 220 | # include <__ranges/concepts.h> | |
| 221 | # include <__ranges/container_compatible_range.h> | |
| 222 | # include <__ranges/from_range.h> | |
| 223 | # include <__ranges/size.h> | |
| 224 | # include <__split_buffer> | |
| 225 | # include <__type_traits/conditional.h> | |
| 226 | # include <__type_traits/container_traits.h> | |
| 227 | # include <__type_traits/disjunction.h> | |
| 228 | # include <__type_traits/enable_if.h> | |
| 229 | # include <__type_traits/is_allocator.h> | |
| 230 | # include <__type_traits/is_convertible.h> | |
| 231 | # include <__type_traits/is_nothrow_assignable.h> | |
| 232 | # include <__type_traits/is_nothrow_constructible.h> | |
| 233 | # include <__type_traits/is_same.h> | |
| 234 | # include <__type_traits/is_swappable.h> | |
| 235 | # include <__type_traits/is_trivially_relocatable.h> | |
| 236 | # include <__type_traits/type_identity.h> | |
| 237 | # include <__utility/forward.h> | |
| 238 | # include <__utility/move.h> | |
| 239 | # include <__utility/pair.h> | |
| 240 | # include <__utility/swap.h> | |
| 241 | # include <limits> | |
| 242 | # include <stdexcept> | |
| 243 | # include <version> | |
| 226 | 244 | |
| 227 | 245 | // standard-mandated includes |
| 228 | 246 | |
| 229 | 247 | // [iterator.range] |
| 230 | #include <__iterator/access.h> | |
| 231 | #include <__iterator/data.h> | |
| 232 | #include <__iterator/empty.h> | |
| 233 | #include <__iterator/reverse_access.h> | |
| 234 | #include <__iterator/size.h> | |
| 248 | # include <__iterator/access.h> | |
| 249 | # include <__iterator/data.h> | |
| 250 | # include <__iterator/empty.h> | |
| 251 | # include <__iterator/reverse_access.h> | |
| 252 | # include <__iterator/size.h> | |
| 235 | 253 | |
| 236 | 254 | // [deque.syn] |
| 237 | #include <compare> | |
| 238 | #include <initializer_list> | |
| 255 | # include <compare> | |
| 256 | # include <initializer_list> | |
| 239 | 257 | |
| 240 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 241 | # pragma GCC system_header | |
| 242 | #endif | |
| 258 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 259 | # pragma GCC system_header | |
| 260 | # endif | |
| 243 | 261 | |
| 244 | 262 | _LIBCPP_PUSH_MACROS |
| 245 | #include <__undef_macros> | |
| 263 | # include <__undef_macros> | |
| 246 | 264 | |
| 247 | 265 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 248 | 266 | |
| ... | ... | @@ -257,13 +275,13 @@ template <class _ValueType, |
| 257 | 275 | class _MapPointer, |
| 258 | 276 | class _DiffType, |
| 259 | 277 | _DiffType _BS = |
| 260 | #ifdef _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE | |
| 278 | # ifdef _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE | |
| 261 | 279 | // Keep template parameter to avoid changing all template declarations thoughout |
| 262 | 280 | // this file. |
| 263 | 281 | 0 |
| 264 | #else | |
| 282 | # else | |
| 265 | 283 | __deque_block_size<_ValueType, _DiffType>::value |
| 266 | #endif | |
| 284 | # endif | |
| 267 | 285 | > |
| 268 | 286 | class _LIBCPP_TEMPLATE_VIS __deque_iterator { |
| 269 | 287 | typedef _MapPointer __map_iterator; |
| ... | ... | @@ -284,10 +302,10 @@ public: |
| 284 | 302 | typedef _Reference reference; |
| 285 | 303 | |
| 286 | 304 | _LIBCPP_HIDE_FROM_ABI __deque_iterator() _NOEXCEPT |
| 287 | #if _LIBCPP_STD_VER >= 14 | |
| 305 | # if _LIBCPP_STD_VER >= 14 | |
| 288 | 306 | : __m_iter_(nullptr), |
| 289 | 307 | __ptr_(nullptr) |
| 290 | #endif | |
| 308 | # endif | |
| 291 | 309 | { |
| 292 | 310 | } |
| 293 | 311 | |
| ... | ... | @@ -376,13 +394,10 @@ public: |
| 376 | 394 | return __x.__ptr_ == __y.__ptr_; |
| 377 | 395 | } |
| 378 | 396 | |
| 379 | #if _LIBCPP_STD_VER <= 17 | |
| 397 | # if _LIBCPP_STD_VER <= 17 | |
| 380 | 398 | _LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y) { |
| 381 | 399 | return !(__x == __y); |
| 382 | 400 | } |
| 383 | #endif | |
| 384 | ||
| 385 | // TODO(mordante) disable these overloads in the LLVM 20 release. | |
| 386 | 401 | _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __deque_iterator& __x, const __deque_iterator& __y) { |
| 387 | 402 | return __x.__m_iter_ < __y.__m_iter_ || (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_); |
| 388 | 403 | } |
| ... | ... | @@ -399,7 +414,8 @@ public: |
| 399 | 414 | return !(__x < __y); |
| 400 | 415 | } |
| 401 | 416 | |
| 402 | #if _LIBCPP_STD_VER >= 20 | |
| 417 | # else | |
| 418 | ||
| 403 | 419 | _LIBCPP_HIDE_FROM_ABI friend strong_ordering operator<=>(const __deque_iterator& __x, const __deque_iterator& __y) { |
| 404 | 420 | if (__x.__m_iter_ < __y.__m_iter_) |
| 405 | 421 | return strong_ordering::less; |
| ... | ... | @@ -420,7 +436,7 @@ public: |
| 420 | 436 | |
| 421 | 437 | return strong_ordering::greater; |
| 422 | 438 | } |
| 423 | #endif // _LIBCPP_STD_VER >= 20 | |
| 439 | # endif // _LIBCPP_STD_VER >= 20 | |
| 424 | 440 | |
| 425 | 441 | private: |
| 426 | 442 | _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT |
| ... | ... | @@ -440,12 +456,13 @@ template <class _ValueType, class _Pointer, class _Reference, class _MapPointer, |
| 440 | 456 | struct __segmented_iterator_traits< |
| 441 | 457 | __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize> > { |
| 442 | 458 | private: |
| 443 | using _Iterator = __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>; | |
| 459 | using _Iterator _LIBCPP_NODEBUG = | |
| 460 | __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>; | |
| 444 | 461 | |
| 445 | 462 | public: |
| 446 | using __is_segmented_iterator = true_type; | |
| 447 | using __segment_iterator = _MapPointer; | |
| 448 | using __local_iterator = _Pointer; | |
| 463 | using __is_segmented_iterator _LIBCPP_NODEBUG = true_type; | |
| 464 | using __segment_iterator _LIBCPP_NODEBUG = _MapPointer; | |
| 465 | using __local_iterator _LIBCPP_NODEBUG = _Pointer; | |
| 449 | 466 | |
| 450 | 467 | static _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_Iterator __iter) { return __iter.__m_iter_; } |
| 451 | 468 | static _LIBCPP_HIDE_FROM_ABI __local_iterator __local(_Iterator __iter) { return __iter.__ptr_; } |
| ... | ... | @@ -475,8 +492,8 @@ public: |
| 475 | 492 | |
| 476 | 493 | using value_type = _Tp; |
| 477 | 494 | |
| 478 | using allocator_type = _Allocator; | |
| 479 | using __alloc_traits = allocator_traits<allocator_type>; | |
| 495 | using allocator_type = _Allocator; | |
| 496 | using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>; | |
| 480 | 497 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 481 | 498 | static_assert(is_same<typename allocator_type::value_type, value_type>::value, |
| 482 | 499 | "Allocator::value_type must be same type as value_type"); |
| ... | ... | @@ -487,13 +504,13 @@ public: |
| 487 | 504 | using pointer = typename __alloc_traits::pointer; |
| 488 | 505 | using const_pointer = typename __alloc_traits::const_pointer; |
| 489 | 506 | |
| 490 | using __pointer_allocator = __rebind_alloc<__alloc_traits, pointer>; | |
| 491 | using __const_pointer_allocator = __rebind_alloc<__alloc_traits, const_pointer>; | |
| 492 | using __map = __split_buffer<pointer, __pointer_allocator>; | |
| 493 | using __map_alloc_traits = allocator_traits<__pointer_allocator>; | |
| 494 | using __map_pointer = typename __map_alloc_traits::pointer; | |
| 495 | using __map_const_pointer = typename allocator_traits<__const_pointer_allocator>::const_pointer; | |
| 496 | using __map_const_iterator = typename __map::const_iterator; | |
| 507 | using __pointer_allocator _LIBCPP_NODEBUG = __rebind_alloc<__alloc_traits, pointer>; | |
| 508 | using __const_pointer_allocator _LIBCPP_NODEBUG = __rebind_alloc<__alloc_traits, const_pointer>; | |
| 509 | using __map _LIBCPP_NODEBUG = __split_buffer<pointer, __pointer_allocator>; | |
| 510 | using __map_alloc_traits _LIBCPP_NODEBUG = allocator_traits<__pointer_allocator>; | |
| 511 | using __map_pointer _LIBCPP_NODEBUG = typename __map_alloc_traits::pointer; | |
| 512 | using __map_const_pointer _LIBCPP_NODEBUG = typename allocator_traits<__const_pointer_allocator>::const_pointer; | |
| 513 | using __map_const_iterator _LIBCPP_NODEBUG = typename __map::const_iterator; | |
| 497 | 514 | |
| 498 | 515 | using reference = value_type&; |
| 499 | 516 | using const_reference = const value_type&; |
| ... | ... | @@ -509,7 +526,7 @@ public: |
| 509 | 526 | // - size_type: is always trivially relocatable, since it is required to be an integral type |
| 510 | 527 | // - allocator_type: may not be trivially relocatable, so it's checked |
| 511 | 528 | // 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< | |
| 529 | using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t< | |
| 513 | 530 | __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value, |
| 514 | 531 | deque, |
| 515 | 532 | void>; |
| ... | ... | @@ -584,12 +601,12 @@ private: |
| 584 | 601 | |
| 585 | 602 | __map __map_; |
| 586 | 603 | size_type __start_; |
| 587 | __compressed_pair<size_type, allocator_type> __size_; | |
| 604 | _LIBCPP_COMPRESSED_PAIR(size_type, __size_, allocator_type, __alloc_); | |
| 588 | 605 | |
| 589 | 606 | public: |
| 590 | 607 | // construct/copy/destroy: |
| 591 | 608 | _LIBCPP_HIDE_FROM_ABI deque() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| 592 | : __start_(0), __size_(0, __default_init_tag()) { | |
| 609 | : __start_(0), __size_(0) { | |
| 593 | 610 | __annotate_new(0); |
| 594 | 611 | } |
| 595 | 612 | |
| ... | ... | @@ -603,19 +620,19 @@ public: |
| 603 | 620 | } |
| 604 | 621 | |
| 605 | 622 | _LIBCPP_HIDE_FROM_ABI explicit deque(const allocator_type& __a) |
| 606 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { | |
| 623 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { | |
| 607 | 624 | __annotate_new(0); |
| 608 | 625 | } |
| 609 | 626 | |
| 610 | 627 | explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n); |
| 611 | #if _LIBCPP_STD_VER >= 14 | |
| 628 | # if _LIBCPP_STD_VER >= 14 | |
| 612 | 629 | explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const _Allocator& __a); |
| 613 | #endif | |
| 630 | # endif | |
| 614 | 631 | _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v); |
| 615 | 632 | |
| 616 | 633 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> |
| 617 | 634 | _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a) |
| 618 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { | |
| 635 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { | |
| 619 | 636 | __annotate_new(0); |
| 620 | 637 | if (__n > 0) |
| 621 | 638 | __append(__n, __v); |
| ... | ... | @@ -626,10 +643,10 @@ public: |
| 626 | 643 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 627 | 644 | _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l, const allocator_type& __a); |
| 628 | 645 | |
| 629 | #if _LIBCPP_STD_VER >= 23 | |
| 646 | # if _LIBCPP_STD_VER >= 23 | |
| 630 | 647 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 631 | 648 | _LIBCPP_HIDE_FROM_ABI deque(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) |
| 632 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { | |
| 649 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { | |
| 633 | 650 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { |
| 634 | 651 | __append_with_size(ranges::begin(__range), ranges::distance(__range)); |
| 635 | 652 | |
| ... | ... | @@ -639,14 +656,14 @@ public: |
| 639 | 656 | } |
| 640 | 657 | } |
| 641 | 658 | } |
| 642 | #endif | |
| 659 | # endif | |
| 643 | 660 | |
| 644 | 661 | _LIBCPP_HIDE_FROM_ABI deque(const deque& __c); |
| 645 | 662 | _LIBCPP_HIDE_FROM_ABI deque(const deque& __c, const __type_identity_t<allocator_type>& __a); |
| 646 | 663 | |
| 647 | 664 | _LIBCPP_HIDE_FROM_ABI deque& operator=(const deque& __c); |
| 648 | 665 | |
| 649 | #ifndef _LIBCPP_CXX03_LANG | |
| 666 | # ifndef _LIBCPP_CXX03_LANG | |
| 650 | 667 | _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il); |
| 651 | 668 | _LIBCPP_HIDE_FROM_ABI deque(initializer_list<value_type> __il, const allocator_type& __a); |
| 652 | 669 | |
| ... | ... | @@ -662,7 +679,7 @@ public: |
| 662 | 679 | is_nothrow_move_assignable<allocator_type>::value); |
| 663 | 680 | |
| 664 | 681 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); } |
| 665 | #endif // _LIBCPP_CXX03_LANG | |
| 682 | # endif // _LIBCPP_CXX03_LANG | |
| 666 | 683 | |
| 667 | 684 | template <class _InputIter, |
| 668 | 685 | __enable_if_t<__has_input_iterator_category<_InputIter>::value && |
| ... | ... | @@ -672,7 +689,7 @@ public: |
| 672 | 689 | template <class _RAIter, __enable_if_t<__has_random_access_iterator_category<_RAIter>::value, int> = 0> |
| 673 | 690 | _LIBCPP_HIDE_FROM_ABI void assign(_RAIter __f, _RAIter __l); |
| 674 | 691 | |
| 675 | #if _LIBCPP_STD_VER >= 23 | |
| 692 | # if _LIBCPP_STD_VER >= 23 | |
| 676 | 693 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 677 | 694 | _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) { |
| 678 | 695 | if constexpr (ranges::random_access_range<_Range>) { |
| ... | ... | @@ -687,13 +704,13 @@ public: |
| 687 | 704 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); |
| 688 | 705 | } |
| 689 | 706 | } |
| 690 | #endif | |
| 707 | # endif | |
| 691 | 708 | |
| 692 | 709 | _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v); |
| 693 | 710 | |
| 694 | 711 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT; |
| 695 | _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __size_.second(); } | |
| 696 | _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __size_.second(); } | |
| 712 | _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __alloc_; } | |
| 713 | _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __alloc_; } | |
| 697 | 714 | |
| 698 | 715 | // iterators: |
| 699 | 716 | |
| ... | ... | @@ -732,8 +749,8 @@ public: |
| 732 | 749 | // capacity: |
| 733 | 750 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size(); } |
| 734 | 751 | |
| 735 | _LIBCPP_HIDE_FROM_ABI size_type& __size() _NOEXCEPT { return __size_.first(); } | |
| 736 | _LIBCPP_HIDE_FROM_ABI const size_type& __size() const _NOEXCEPT { return __size_.first(); } | |
| 752 | _LIBCPP_HIDE_FROM_ABI size_type& __size() _NOEXCEPT { return __size_; } | |
| 753 | _LIBCPP_HIDE_FROM_ABI const size_type& __size() const _NOEXCEPT { return __size_; } | |
| 737 | 754 | |
| 738 | 755 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 739 | 756 | return std::min<size_type>(__alloc_traits::max_size(__alloc()), numeric_limits<difference_type>::max()); |
| ... | ... | @@ -741,7 +758,7 @@ public: |
| 741 | 758 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); |
| 742 | 759 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v); |
| 743 | 760 | _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; |
| 744 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } | |
| 761 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } | |
| 745 | 762 | |
| 746 | 763 | // element access: |
| 747 | 764 | _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __i) _NOEXCEPT; |
| ... | ... | @@ -756,25 +773,25 @@ public: |
| 756 | 773 | // 23.2.2.3 modifiers: |
| 757 | 774 | _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v); |
| 758 | 775 | _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __v); |
| 759 | #ifndef _LIBCPP_CXX03_LANG | |
| 760 | # if _LIBCPP_STD_VER >= 17 | |
| 776 | # ifndef _LIBCPP_CXX03_LANG | |
| 777 | # if _LIBCPP_STD_VER >= 17 | |
| 761 | 778 | template <class... _Args> |
| 762 | 779 | _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args); |
| 763 | 780 | template <class... _Args> |
| 764 | 781 | _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args); |
| 765 | # else | |
| 782 | # else | |
| 766 | 783 | template <class... _Args> |
| 767 | 784 | _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args); |
| 768 | 785 | template <class... _Args> |
| 769 | 786 | _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); |
| 770 | # endif | |
| 787 | # endif | |
| 771 | 788 | template <class... _Args> |
| 772 | 789 | _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args); |
| 773 | 790 | |
| 774 | 791 | _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v); |
| 775 | 792 | _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __v); |
| 776 | 793 | |
| 777 | # if _LIBCPP_STD_VER >= 23 | |
| 794 | # if _LIBCPP_STD_VER >= 23 | |
| 778 | 795 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 779 | 796 | _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) { |
| 780 | 797 | insert_range(begin(), std::forward<_Range>(__range)); |
| ... | ... | @@ -784,14 +801,14 @@ public: |
| 784 | 801 | _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) { |
| 785 | 802 | insert_range(end(), std::forward<_Range>(__range)); |
| 786 | 803 | } |
| 787 | # endif | |
| 804 | # endif | |
| 788 | 805 | |
| 789 | 806 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v); |
| 790 | 807 | |
| 791 | 808 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) { |
| 792 | 809 | return insert(__p, __il.begin(), __il.end()); |
| 793 | 810 | } |
| 794 | #endif // _LIBCPP_CXX03_LANG | |
| 811 | # endif // _LIBCPP_CXX03_LANG | |
| 795 | 812 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v); |
| 796 | 813 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v); |
| 797 | 814 | template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0> |
| ... | ... | @@ -802,7 +819,7 @@ public: |
| 802 | 819 | template <class _BiIter, __enable_if_t<__has_bidirectional_iterator_category<_BiIter>::value, int> = 0> |
| 803 | 820 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _BiIter __f, _BiIter __l); |
| 804 | 821 | |
| 805 | #if _LIBCPP_STD_VER >= 23 | |
| 822 | # if _LIBCPP_STD_VER >= 23 | |
| 806 | 823 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 807 | 824 | _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) { |
| 808 | 825 | if constexpr (ranges::bidirectional_range<_Range>) { |
| ... | ... | @@ -817,7 +834,7 @@ public: |
| 817 | 834 | return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); |
| 818 | 835 | } |
| 819 | 836 | } |
| 820 | #endif | |
| 837 | # endif | |
| 821 | 838 | |
| 822 | 839 | _LIBCPP_HIDE_FROM_ABI void pop_front(); |
| 823 | 840 | _LIBCPP_HIDE_FROM_ABI void pop_back(); |
| ... | ... | @@ -825,11 +842,11 @@ public: |
| 825 | 842 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l); |
| 826 | 843 | |
| 827 | 844 | _LIBCPP_HIDE_FROM_ABI void swap(deque& __c) |
| 828 | #if _LIBCPP_STD_VER >= 14 | |
| 845 | # if _LIBCPP_STD_VER >= 14 | |
| 829 | 846 | _NOEXCEPT; |
| 830 | #else | |
| 847 | # else | |
| 831 | 848 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 832 | #endif | |
| 849 | # endif | |
| 833 | 850 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; |
| 834 | 851 | |
| 835 | 852 | _LIBCPP_HIDE_FROM_ABI bool __invariants() const { |
| ... | ... | @@ -907,7 +924,7 @@ private: |
| 907 | 924 | (void)__end; |
| 908 | 925 | (void)__annotation_type; |
| 909 | 926 | (void)__place; |
| 910 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 927 | # if _LIBCPP_HAS_ASAN | |
| 911 | 928 | // __beg - index of the first item to annotate |
| 912 | 929 | // __end - index behind the last item to annotate (so last item + 1) |
| 913 | 930 | // __annotation_type - __asan_unposion or __asan_poison |
| ... | ... | @@ -1000,23 +1017,23 @@ private: |
| 1000 | 1017 | std::__annotate_double_ended_contiguous_container<_Allocator>( |
| 1001 | 1018 | __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end); |
| 1002 | 1019 | } |
| 1003 | #endif // !_LIBCPP_HAS_NO_ASAN | |
| 1020 | # endif // _LIBCPP_HAS_ASAN | |
| 1004 | 1021 | } |
| 1005 | 1022 | |
| 1006 | 1023 | _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { |
| 1007 | 1024 | (void)__current_size; |
| 1008 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 1025 | # if _LIBCPP_HAS_ASAN | |
| 1009 | 1026 | if (__current_size == 0) |
| 1010 | 1027 | __annotate_from_to(0, __map_.size() * __block_size, __asan_poison, __asan_back_moved); |
| 1011 | 1028 | else { |
| 1012 | 1029 | __annotate_from_to(0, __start_, __asan_poison, __asan_front_moved); |
| 1013 | 1030 | __annotate_from_to(__start_ + __current_size, __map_.size() * __block_size, __asan_poison, __asan_back_moved); |
| 1014 | 1031 | } |
| 1015 | #endif | |
| 1032 | # endif // _LIBCPP_HAS_ASAN | |
| 1016 | 1033 | } |
| 1017 | 1034 | |
| 1018 | 1035 | _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT { |
| 1019 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 1036 | # if _LIBCPP_HAS_ASAN | |
| 1020 | 1037 | if (empty()) { |
| 1021 | 1038 | for (size_t __i = 0; __i < __map_.size(); ++__i) { |
| 1022 | 1039 | __annotate_whole_block(__i, __asan_unposion); |
| ... | ... | @@ -1025,37 +1042,37 @@ private: |
| 1025 | 1042 | __annotate_from_to(0, __start_, __asan_unposion, __asan_front_moved); |
| 1026 | 1043 | __annotate_from_to(__start_ + size(), __map_.size() * __block_size, __asan_unposion, __asan_back_moved); |
| 1027 | 1044 | } |
| 1028 | #endif | |
| 1045 | # endif // _LIBCPP_HAS_ASAN | |
| 1029 | 1046 | } |
| 1030 | 1047 | |
| 1031 | 1048 | _LIBCPP_HIDE_FROM_ABI void __annotate_increase_front(size_type __n) const _NOEXCEPT { |
| 1032 | 1049 | (void)__n; |
| 1033 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 1050 | # if _LIBCPP_HAS_ASAN | |
| 1034 | 1051 | __annotate_from_to(__start_ - __n, __start_, __asan_unposion, __asan_front_moved); |
| 1035 | #endif | |
| 1052 | # endif | |
| 1036 | 1053 | } |
| 1037 | 1054 | |
| 1038 | 1055 | _LIBCPP_HIDE_FROM_ABI void __annotate_increase_back(size_type __n) const _NOEXCEPT { |
| 1039 | 1056 | (void)__n; |
| 1040 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 1057 | # if _LIBCPP_HAS_ASAN | |
| 1041 | 1058 | __annotate_from_to(__start_ + size(), __start_ + size() + __n, __asan_unposion, __asan_back_moved); |
| 1042 | #endif | |
| 1059 | # endif | |
| 1043 | 1060 | } |
| 1044 | 1061 | |
| 1045 | 1062 | _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_front(size_type __old_size, size_type __old_start) const _NOEXCEPT { |
| 1046 | 1063 | (void)__old_size; |
| 1047 | 1064 | (void)__old_start; |
| 1048 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 1065 | # if _LIBCPP_HAS_ASAN | |
| 1049 | 1066 | __annotate_from_to(__old_start, __old_start + (__old_size - size()), __asan_poison, __asan_front_moved); |
| 1050 | #endif | |
| 1067 | # endif | |
| 1051 | 1068 | } |
| 1052 | 1069 | |
| 1053 | 1070 | _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_back(size_type __old_size, size_type __old_start) const _NOEXCEPT { |
| 1054 | 1071 | (void)__old_size; |
| 1055 | 1072 | (void)__old_start; |
| 1056 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 1073 | # if _LIBCPP_HAS_ASAN | |
| 1057 | 1074 | __annotate_from_to(__old_start + size(), __old_start + __old_size, __asan_poison, __asan_back_moved); |
| 1058 | #endif | |
| 1075 | # endif | |
| 1059 | 1076 | } |
| 1060 | 1077 | |
| 1061 | 1078 | _LIBCPP_HIDE_FROM_ABI void __annotate_poison_block(const void* __beginning, const void* __end) const _NOEXCEPT { |
| ... | ... | @@ -1066,7 +1083,7 @@ private: |
| 1066 | 1083 | __annotate_whole_block(size_t __block_index, __asan_annotation_type __annotation_type) const _NOEXCEPT { |
| 1067 | 1084 | (void)__block_index; |
| 1068 | 1085 | (void)__annotation_type; |
| 1069 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 1086 | # if _LIBCPP_HAS_ASAN | |
| 1070 | 1087 | __map_const_iterator __block_it = __map_.begin() + __block_index; |
| 1071 | 1088 | const void* __block_start = std::__to_address(*__block_it); |
| 1072 | 1089 | const void* __block_end = std::__to_address(*__block_it + __block_size); |
| ... | ... | @@ -1077,9 +1094,9 @@ private: |
| 1077 | 1094 | std::__annotate_double_ended_contiguous_container<_Allocator>( |
| 1078 | 1095 | __block_start, __block_end, __block_start, __block_start, __block_start, __block_end); |
| 1079 | 1096 | } |
| 1080 | #endif | |
| 1097 | # endif | |
| 1081 | 1098 | } |
| 1082 | #if !defined(_LIBCPP_HAS_NO_ASAN) | |
| 1099 | # if _LIBCPP_HAS_ASAN | |
| 1083 | 1100 | |
| 1084 | 1101 | public: |
| 1085 | 1102 | _LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT { |
| ... | ... | @@ -1141,7 +1158,7 @@ public: |
| 1141 | 1158 | } |
| 1142 | 1159 | |
| 1143 | 1160 | private: |
| 1144 | #endif // _LIBCPP_VERIFY_ASAN_DEQUE_ANNOTATIONS | |
| 1161 | # endif // _LIBCPP_HAS_ASAN | |
| 1145 | 1162 | _LIBCPP_HIDE_FROM_ABI bool __maybe_remove_front_spare(bool __keep_one = true) { |
| 1146 | 1163 | if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) { |
| 1147 | 1164 | __annotate_whole_block(0, __asan_unposion); |
| ... | ... | @@ -1216,8 +1233,8 @@ private: |
| 1216 | 1233 | clear(); |
| 1217 | 1234 | shrink_to_fit(); |
| 1218 | 1235 | } |
| 1219 | __alloc() = __c.__alloc(); | |
| 1220 | __map_.__alloc() = __c.__map_.__alloc(); | |
| 1236 | __alloc() = __c.__alloc(); | |
| 1237 | __map_.__alloc_ = __c.__map_.__alloc_; | |
| 1221 | 1238 | } |
| 1222 | 1239 | |
| 1223 | 1240 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const deque&, false_type) {} |
| ... | ... | @@ -1231,7 +1248,7 @@ template <class _Tp, class _Alloc> |
| 1231 | 1248 | _LIBCPP_CONSTEXPR const typename allocator_traits<_Alloc>::difference_type deque<_Tp, _Alloc>::__block_size = |
| 1232 | 1249 | __deque_block_size<value_type, difference_type>::value; |
| 1233 | 1250 | |
| 1234 | #if _LIBCPP_STD_VER >= 17 | |
| 1251 | # if _LIBCPP_STD_VER >= 17 | |
| 1235 | 1252 | template <class _InputIterator, |
| 1236 | 1253 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, |
| 1237 | 1254 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| ... | ... | @@ -1243,34 +1260,34 @@ template <class _InputIterator, |
| 1243 | 1260 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 1244 | 1261 | class = enable_if_t<__is_allocator<_Alloc>::value> > |
| 1245 | 1262 | deque(_InputIterator, _InputIterator, _Alloc) -> deque<__iter_value_type<_InputIterator>, _Alloc>; |
| 1246 | #endif | |
| 1263 | # endif | |
| 1247 | 1264 | |
| 1248 | #if _LIBCPP_STD_VER >= 23 | |
| 1265 | # if _LIBCPP_STD_VER >= 23 | |
| 1249 | 1266 | template <ranges::input_range _Range, |
| 1250 | 1267 | class _Alloc = allocator<ranges::range_value_t<_Range>>, |
| 1251 | 1268 | class = enable_if_t<__is_allocator<_Alloc>::value> > |
| 1252 | 1269 | deque(from_range_t, _Range&&, _Alloc = _Alloc()) -> deque<ranges::range_value_t<_Range>, _Alloc>; |
| 1253 | #endif | |
| 1270 | # endif | |
| 1254 | 1271 | |
| 1255 | 1272 | template <class _Tp, class _Allocator> |
| 1256 | deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0, __default_init_tag()) { | |
| 1273 | deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0) { | |
| 1257 | 1274 | __annotate_new(0); |
| 1258 | 1275 | if (__n > 0) |
| 1259 | 1276 | __append(__n); |
| 1260 | 1277 | } |
| 1261 | 1278 | |
| 1262 | #if _LIBCPP_STD_VER >= 14 | |
| 1279 | # if _LIBCPP_STD_VER >= 14 | |
| 1263 | 1280 | template <class _Tp, class _Allocator> |
| 1264 | 1281 | deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a) |
| 1265 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { | |
| 1282 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { | |
| 1266 | 1283 | __annotate_new(0); |
| 1267 | 1284 | if (__n > 0) |
| 1268 | 1285 | __append(__n); |
| 1269 | 1286 | } |
| 1270 | #endif | |
| 1287 | # endif | |
| 1271 | 1288 | |
| 1272 | 1289 | template <class _Tp, class _Allocator> |
| 1273 | deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0), __size_(0, __default_init_tag()) { | |
| 1290 | deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0), __size_(0) { | |
| 1274 | 1291 | __annotate_new(0); |
| 1275 | 1292 | if (__n > 0) |
| 1276 | 1293 | __append(__n, __v); |
| ... | ... | @@ -1278,7 +1295,7 @@ deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0 |
| 1278 | 1295 | |
| 1279 | 1296 | template <class _Tp, class _Allocator> |
| 1280 | 1297 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| 1281 | deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __size_(0, __default_init_tag()) { | |
| 1298 | deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __size_(0) { | |
| 1282 | 1299 | __annotate_new(0); |
| 1283 | 1300 | __append(__f, __l); |
| 1284 | 1301 | } |
| ... | ... | @@ -1286,7 +1303,7 @@ deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __s |
| 1286 | 1303 | template <class _Tp, class _Allocator> |
| 1287 | 1304 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| 1288 | 1305 | deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a) |
| 1289 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { | |
| 1306 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { | |
| 1290 | 1307 | __annotate_new(0); |
| 1291 | 1308 | __append(__f, __l); |
| 1292 | 1309 | } |
| ... | ... | @@ -1295,14 +1312,15 @@ template <class _Tp, class _Allocator> |
| 1295 | 1312 | deque<_Tp, _Allocator>::deque(const deque& __c) |
| 1296 | 1313 | : __map_(__pointer_allocator(__alloc_traits::select_on_container_copy_construction(__c.__alloc()))), |
| 1297 | 1314 | __start_(0), |
| 1298 | __size_(0, __map_.__alloc()) { | |
| 1315 | __size_(0), | |
| 1316 | __alloc_(__map_.__alloc_) { | |
| 1299 | 1317 | __annotate_new(0); |
| 1300 | 1318 | __append(__c.begin(), __c.end()); |
| 1301 | 1319 | } |
| 1302 | 1320 | |
| 1303 | 1321 | template <class _Tp, class _Allocator> |
| 1304 | 1322 | deque<_Tp, _Allocator>::deque(const deque& __c, const __type_identity_t<allocator_type>& __a) |
| 1305 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { | |
| 1323 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { | |
| 1306 | 1324 | __annotate_new(0); |
| 1307 | 1325 | __append(__c.begin(), __c.end()); |
| 1308 | 1326 | } |
| ... | ... | @@ -1316,24 +1334,27 @@ deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(const deque& __c) { |
| 1316 | 1334 | return *this; |
| 1317 | 1335 | } |
| 1318 | 1336 | |
| 1319 | #ifndef _LIBCPP_CXX03_LANG | |
| 1337 | # ifndef _LIBCPP_CXX03_LANG | |
| 1320 | 1338 | |
| 1321 | 1339 | template <class _Tp, class _Allocator> |
| 1322 | deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il) : __start_(0), __size_(0, __default_init_tag()) { | |
| 1340 | deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il) : __start_(0), __size_(0) { | |
| 1323 | 1341 | __annotate_new(0); |
| 1324 | 1342 | __append(__il.begin(), __il.end()); |
| 1325 | 1343 | } |
| 1326 | 1344 | |
| 1327 | 1345 | template <class _Tp, class _Allocator> |
| 1328 | 1346 | deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator_type& __a) |
| 1329 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { | |
| 1347 | : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) { | |
| 1330 | 1348 | __annotate_new(0); |
| 1331 | 1349 | __append(__il.begin(), __il.end()); |
| 1332 | 1350 | } |
| 1333 | 1351 | |
| 1334 | 1352 | template <class _Tp, class _Allocator> |
| 1335 | 1353 | inline deque<_Tp, _Allocator>::deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value) |
| 1336 | : __map_(std::move(__c.__map_)), __start_(std::move(__c.__start_)), __size_(std::move(__c.__size_)) { | |
| 1354 | : __map_(std::move(__c.__map_)), | |
| 1355 | __start_(std::move(__c.__start_)), | |
| 1356 | __size_(std::move(__c.__size_)), | |
| 1357 | __alloc_(std::move(__c.__alloc_)) { | |
| 1337 | 1358 | __c.__start_ = 0; |
| 1338 | 1359 | __c.__size() = 0; |
| 1339 | 1360 | } |
| ... | ... | @@ -1342,7 +1363,8 @@ template <class _Tp, class _Allocator> |
| 1342 | 1363 | inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<allocator_type>& __a) |
| 1343 | 1364 | : __map_(std::move(__c.__map_), __pointer_allocator(__a)), |
| 1344 | 1365 | __start_(std::move(__c.__start_)), |
| 1345 | __size_(std::move(__c.__size()), __a) { | |
| 1366 | __size_(std::move(__c.__size_)), | |
| 1367 | __alloc_(__a) { | |
| 1346 | 1368 | if (__a == __c.__alloc()) { |
| 1347 | 1369 | __c.__start_ = 0; |
| 1348 | 1370 | __c.__size() = 0; |
| ... | ... | @@ -1380,7 +1402,7 @@ void deque<_Tp, _Allocator>::__move_assign(deque& __c, |
| 1380 | 1402 | __move_assign(__c); |
| 1381 | 1403 | } |
| 1382 | 1404 | |
| 1383 | #endif // _LIBCPP_CXX03_LANG | |
| 1405 | # endif // _LIBCPP_CXX03_LANG | |
| 1384 | 1406 | |
| 1385 | 1407 | template <class _Tp, class _Allocator> |
| 1386 | 1408 | template <class _InputIter, |
| ... | ... | @@ -1568,7 +1590,7 @@ void deque<_Tp, _Allocator>::push_front(const value_type& __v) { |
| 1568 | 1590 | ++__size(); |
| 1569 | 1591 | } |
| 1570 | 1592 | |
| 1571 | #ifndef _LIBCPP_CXX03_LANG | |
| 1593 | # ifndef _LIBCPP_CXX03_LANG | |
| 1572 | 1594 | template <class _Tp, class _Allocator> |
| 1573 | 1595 | void deque<_Tp, _Allocator>::push_back(value_type&& __v) { |
| 1574 | 1596 | allocator_type& __a = __alloc(); |
| ... | ... | @@ -1582,11 +1604,11 @@ void deque<_Tp, _Allocator>::push_back(value_type&& __v) { |
| 1582 | 1604 | |
| 1583 | 1605 | template <class _Tp, class _Allocator> |
| 1584 | 1606 | template <class... _Args> |
| 1585 | # if _LIBCPP_STD_VER >= 17 | |
| 1607 | # if _LIBCPP_STD_VER >= 17 | |
| 1586 | 1608 | typename deque<_Tp, _Allocator>::reference |
| 1587 | # else | |
| 1609 | # else | |
| 1588 | 1610 | void |
| 1589 | # endif | |
| 1611 | # endif | |
| 1590 | 1612 | deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) { |
| 1591 | 1613 | allocator_type& __a = __alloc(); |
| 1592 | 1614 | if (__back_spare() == 0) |
| ... | ... | @@ -1595,9 +1617,9 @@ deque<_Tp, _Allocator>::emplace_back(_Args&&... __args) { |
| 1595 | 1617 | __annotate_increase_back(1); |
| 1596 | 1618 | __alloc_traits::construct(__a, std::addressof(*end()), std::forward<_Args>(__args)...); |
| 1597 | 1619 | ++__size(); |
| 1598 | # if _LIBCPP_STD_VER >= 17 | |
| 1620 | # if _LIBCPP_STD_VER >= 17 | |
| 1599 | 1621 | return *--end(); |
| 1600 | # endif | |
| 1622 | # endif | |
| 1601 | 1623 | } |
| 1602 | 1624 | |
| 1603 | 1625 | template <class _Tp, class _Allocator> |
| ... | ... | @@ -1614,11 +1636,11 @@ void deque<_Tp, _Allocator>::push_front(value_type&& __v) { |
| 1614 | 1636 | |
| 1615 | 1637 | template <class _Tp, class _Allocator> |
| 1616 | 1638 | template <class... _Args> |
| 1617 | # if _LIBCPP_STD_VER >= 17 | |
| 1639 | # if _LIBCPP_STD_VER >= 17 | |
| 1618 | 1640 | typename deque<_Tp, _Allocator>::reference |
| 1619 | # else | |
| 1641 | # else | |
| 1620 | 1642 | void |
| 1621 | # endif | |
| 1643 | # endif | |
| 1622 | 1644 | deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) { |
| 1623 | 1645 | allocator_type& __a = __alloc(); |
| 1624 | 1646 | if (__front_spare() == 0) |
| ... | ... | @@ -1628,9 +1650,9 @@ deque<_Tp, _Allocator>::emplace_front(_Args&&... __args) { |
| 1628 | 1650 | __alloc_traits::construct(__a, std::addressof(*--begin()), std::forward<_Args>(__args)...); |
| 1629 | 1651 | --__start_; |
| 1630 | 1652 | ++__size(); |
| 1631 | # if _LIBCPP_STD_VER >= 17 | |
| 1653 | # if _LIBCPP_STD_VER >= 17 | |
| 1632 | 1654 | return *begin(); |
| 1633 | # endif | |
| 1655 | # endif | |
| 1634 | 1656 | } |
| 1635 | 1657 | |
| 1636 | 1658 | template <class _Tp, class _Allocator> |
| ... | ... | @@ -1728,7 +1750,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::emplace(const_ |
| 1728 | 1750 | return begin() + __pos; |
| 1729 | 1751 | } |
| 1730 | 1752 | |
| 1731 | #endif // _LIBCPP_CXX03_LANG | |
| 1753 | # endif // _LIBCPP_CXX03_LANG | |
| 1732 | 1754 | |
| 1733 | 1755 | template <class _Tp, class _Allocator> |
| 1734 | 1756 | typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::insert(const_iterator __p, const value_type& __v) { |
| ... | ... | @@ -1951,11 +1973,11 @@ template <class _Tp, class _Allocator> |
| 1951 | 1973 | template <class _InputIterator, class _Sentinel> |
| 1952 | 1974 | _LIBCPP_HIDE_FROM_ABI void deque<_Tp, _Allocator>::__append_with_sentinel(_InputIterator __f, _Sentinel __l) { |
| 1953 | 1975 | for (; __f != __l; ++__f) |
| 1954 | #ifdef _LIBCPP_CXX03_LANG | |
| 1976 | # ifdef _LIBCPP_CXX03_LANG | |
| 1955 | 1977 | push_back(*__f); |
| 1956 | #else | |
| 1978 | # else | |
| 1957 | 1979 | emplace_back(*__f); |
| 1958 | #endif | |
| 1980 | # endif | |
| 1959 | 1981 | } |
| 1960 | 1982 | |
| 1961 | 1983 | template <class _Tp, class _Allocator> |
| ... | ... | @@ -2023,39 +2045,39 @@ void deque<_Tp, _Allocator>::__add_front_capacity() { |
| 2023 | 2045 | __start_ += __block_size; |
| 2024 | 2046 | pointer __pt = __map_.back(); |
| 2025 | 2047 | __map_.pop_back(); |
| 2026 | __map_.push_front(__pt); | |
| 2048 | __map_.emplace_front(__pt); | |
| 2027 | 2049 | } |
| 2028 | 2050 | // Else if __map_.size() < __map_.capacity() then we need to allocate 1 buffer |
| 2029 | 2051 | else if (__map_.size() < __map_.capacity()) { // we can put the new buffer into the map, but don't shift things around |
| 2030 | 2052 | // until all buffers are allocated. If we throw, we don't need to fix |
| 2031 | 2053 | // anything up (any added buffers are undetectible) |
| 2032 | 2054 | if (__map_.__front_spare() > 0) |
| 2033 | __map_.push_front(__alloc_traits::allocate(__a, __block_size)); | |
| 2055 | __map_.emplace_front(__alloc_traits::allocate(__a, __block_size)); | |
| 2034 | 2056 | else { |
| 2035 | __map_.push_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2057 | __map_.emplace_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2036 | 2058 | // Done allocating, reorder capacity |
| 2037 | 2059 | pointer __pt = __map_.back(); |
| 2038 | 2060 | __map_.pop_back(); |
| 2039 | __map_.push_front(__pt); | |
| 2061 | __map_.emplace_front(__pt); | |
| 2040 | 2062 | } |
| 2041 | 2063 | __start_ = __map_.size() == 1 ? __block_size / 2 : __start_ + __block_size; |
| 2042 | 2064 | } |
| 2043 | 2065 | // Else need to allocate 1 buffer, *and* we need to reallocate __map_. |
| 2044 | 2066 | else { |
| 2045 | 2067 | __split_buffer<pointer, __pointer_allocator&> __buf( |
| 2046 | std::max<size_type>(2 * __map_.capacity(), 1), 0, __map_.__alloc()); | |
| 2068 | std::max<size_type>(2 * __map_.capacity(), 1), 0, __map_.__alloc_); | |
| 2047 | 2069 | |
| 2048 | 2070 | typedef __allocator_destructor<_Allocator> _Dp; |
| 2049 | 2071 | unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size)); |
| 2050 | __buf.push_back(__hold.get()); | |
| 2072 | __buf.emplace_back(__hold.get()); | |
| 2051 | 2073 | __hold.release(); |
| 2052 | 2074 | |
| 2053 | 2075 | for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i) |
| 2054 | __buf.push_back(*__i); | |
| 2076 | __buf.emplace_back(*__i); | |
| 2055 | 2077 | std::swap(__map_.__first_, __buf.__first_); |
| 2056 | 2078 | std::swap(__map_.__begin_, __buf.__begin_); |
| 2057 | 2079 | std::swap(__map_.__end_, __buf.__end_); |
| 2058 | std::swap(__map_.__end_cap(), __buf.__end_cap()); | |
| 2080 | std::swap(__map_.__cap_, __buf.__cap_); | |
| 2059 | 2081 | __start_ = __map_.size() == 1 ? __block_size / 2 : __start_ + __block_size; |
| 2060 | 2082 | } |
| 2061 | 2083 | __annotate_whole_block(0, __asan_poison); |
| ... | ... | @@ -2077,7 +2099,7 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) { |
| 2077 | 2099 | for (; __back_capacity > 0; --__back_capacity) { |
| 2078 | 2100 | pointer __pt = __map_.back(); |
| 2079 | 2101 | __map_.pop_back(); |
| 2080 | __map_.push_front(__pt); | |
| 2102 | __map_.emplace_front(__pt); | |
| 2081 | 2103 | } |
| 2082 | 2104 | } |
| 2083 | 2105 | // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers |
| ... | ... | @@ -2088,17 +2110,17 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) { |
| 2088 | 2110 | for (; __nb > 0; --__nb, __start_ += __block_size - (__map_.size() == 1)) { |
| 2089 | 2111 | if (__map_.__front_spare() == 0) |
| 2090 | 2112 | break; |
| 2091 | __map_.push_front(__alloc_traits::allocate(__a, __block_size)); | |
| 2113 | __map_.emplace_front(__alloc_traits::allocate(__a, __block_size)); | |
| 2092 | 2114 | __annotate_whole_block(0, __asan_poison); |
| 2093 | 2115 | } |
| 2094 | 2116 | for (; __nb > 0; --__nb, ++__back_capacity) |
| 2095 | __map_.push_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2117 | __map_.emplace_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2096 | 2118 | // Done allocating, reorder capacity |
| 2097 | 2119 | __start_ += __back_capacity * __block_size; |
| 2098 | 2120 | for (; __back_capacity > 0; --__back_capacity) { |
| 2099 | 2121 | pointer __pt = __map_.back(); |
| 2100 | 2122 | __map_.pop_back(); |
| 2101 | __map_.push_front(__pt); | |
| 2123 | __map_.emplace_front(__pt); | |
| 2102 | 2124 | __annotate_whole_block(0, __asan_poison); |
| 2103 | 2125 | } |
| 2104 | 2126 | } |
| ... | ... | @@ -2106,33 +2128,33 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) { |
| 2106 | 2128 | else { |
| 2107 | 2129 | size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty(); |
| 2108 | 2130 | __split_buffer<pointer, __pointer_allocator&> __buf( |
| 2109 | std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()), 0, __map_.__alloc()); | |
| 2110 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2131 | std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()), 0, __map_.__alloc_); | |
| 2132 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2111 | 2133 | try { |
| 2112 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2134 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2113 | 2135 | for (; __nb > 0; --__nb) { |
| 2114 | __buf.push_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2136 | __buf.emplace_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2115 | 2137 | // ASan: this is empty container, we have to poison whole block |
| 2116 | 2138 | __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size)); |
| 2117 | 2139 | } |
| 2118 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2140 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2119 | 2141 | } catch (...) { |
| 2120 | 2142 | __annotate_delete(); |
| 2121 | 2143 | for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) |
| 2122 | 2144 | __alloc_traits::deallocate(__a, *__i, __block_size); |
| 2123 | 2145 | throw; |
| 2124 | 2146 | } |
| 2125 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2147 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2126 | 2148 | for (; __back_capacity > 0; --__back_capacity) { |
| 2127 | __buf.push_back(__map_.back()); | |
| 2149 | __buf.emplace_back(__map_.back()); | |
| 2128 | 2150 | __map_.pop_back(); |
| 2129 | 2151 | } |
| 2130 | 2152 | for (__map_pointer __i = __map_.begin(); __i != __map_.end(); ++__i) |
| 2131 | __buf.push_back(*__i); | |
| 2153 | __buf.emplace_back(*__i); | |
| 2132 | 2154 | std::swap(__map_.__first_, __buf.__first_); |
| 2133 | 2155 | std::swap(__map_.__begin_, __buf.__begin_); |
| 2134 | 2156 | std::swap(__map_.__end_, __buf.__end_); |
| 2135 | std::swap(__map_.__end_cap(), __buf.__end_cap()); | |
| 2157 | std::swap(__map_.__cap_, __buf.__cap_); | |
| 2136 | 2158 | __start_ += __ds; |
| 2137 | 2159 | } |
| 2138 | 2160 | } |
| ... | ... | @@ -2146,39 +2168,39 @@ void deque<_Tp, _Allocator>::__add_back_capacity() { |
| 2146 | 2168 | __start_ -= __block_size; |
| 2147 | 2169 | pointer __pt = __map_.front(); |
| 2148 | 2170 | __map_.pop_front(); |
| 2149 | __map_.push_back(__pt); | |
| 2171 | __map_.emplace_back(__pt); | |
| 2150 | 2172 | } |
| 2151 | 2173 | // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers |
| 2152 | 2174 | else if (__map_.size() < __map_.capacity()) { // we can put the new buffer into the map, but don't shift things around |
| 2153 | 2175 | // until it is allocated. If we throw, we don't need to fix |
| 2154 | 2176 | // anything up (any added buffers are undetectible) |
| 2155 | 2177 | if (__map_.__back_spare() != 0) |
| 2156 | __map_.push_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2178 | __map_.emplace_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2157 | 2179 | else { |
| 2158 | __map_.push_front(__alloc_traits::allocate(__a, __block_size)); | |
| 2180 | __map_.emplace_front(__alloc_traits::allocate(__a, __block_size)); | |
| 2159 | 2181 | // Done allocating, reorder capacity |
| 2160 | 2182 | pointer __pt = __map_.front(); |
| 2161 | 2183 | __map_.pop_front(); |
| 2162 | __map_.push_back(__pt); | |
| 2184 | __map_.emplace_back(__pt); | |
| 2163 | 2185 | } |
| 2164 | 2186 | __annotate_whole_block(__map_.size() - 1, __asan_poison); |
| 2165 | 2187 | } |
| 2166 | 2188 | // Else need to allocate 1 buffer, *and* we need to reallocate __map_. |
| 2167 | 2189 | else { |
| 2168 | 2190 | __split_buffer<pointer, __pointer_allocator&> __buf( |
| 2169 | std::max<size_type>(2 * __map_.capacity(), 1), __map_.size(), __map_.__alloc()); | |
| 2191 | std::max<size_type>(2 * __map_.capacity(), 1), __map_.size(), __map_.__alloc_); | |
| 2170 | 2192 | |
| 2171 | 2193 | typedef __allocator_destructor<_Allocator> _Dp; |
| 2172 | 2194 | unique_ptr<pointer, _Dp> __hold(__alloc_traits::allocate(__a, __block_size), _Dp(__a, __block_size)); |
| 2173 | __buf.push_back(__hold.get()); | |
| 2195 | __buf.emplace_back(__hold.get()); | |
| 2174 | 2196 | __hold.release(); |
| 2175 | 2197 | |
| 2176 | 2198 | for (__map_pointer __i = __map_.end(); __i != __map_.begin();) |
| 2177 | __buf.push_front(*--__i); | |
| 2199 | __buf.emplace_front(*--__i); | |
| 2178 | 2200 | std::swap(__map_.__first_, __buf.__first_); |
| 2179 | 2201 | std::swap(__map_.__begin_, __buf.__begin_); |
| 2180 | 2202 | std::swap(__map_.__end_, __buf.__end_); |
| 2181 | std::swap(__map_.__end_cap(), __buf.__end_cap()); | |
| 2203 | std::swap(__map_.__cap_, __buf.__cap_); | |
| 2182 | 2204 | __annotate_whole_block(__map_.size() - 1, __asan_poison); |
| 2183 | 2205 | } |
| 2184 | 2206 | } |
| ... | ... | @@ -2199,7 +2221,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) { |
| 2199 | 2221 | for (; __front_capacity > 0; --__front_capacity) { |
| 2200 | 2222 | pointer __pt = __map_.front(); |
| 2201 | 2223 | __map_.pop_front(); |
| 2202 | __map_.push_back(__pt); | |
| 2224 | __map_.emplace_back(__pt); | |
| 2203 | 2225 | } |
| 2204 | 2226 | } |
| 2205 | 2227 | // Else if __nb <= __map_.capacity() - __map_.size() then we need to allocate __nb buffers |
| ... | ... | @@ -2210,11 +2232,11 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) { |
| 2210 | 2232 | for (; __nb > 0; --__nb) { |
| 2211 | 2233 | if (__map_.__back_spare() == 0) |
| 2212 | 2234 | break; |
| 2213 | __map_.push_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2235 | __map_.emplace_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2214 | 2236 | __annotate_whole_block(__map_.size() - 1, __asan_poison); |
| 2215 | 2237 | } |
| 2216 | 2238 | for (; __nb > 0; --__nb, ++__front_capacity, __start_ += __block_size - (__map_.size() == 1)) { |
| 2217 | __map_.push_front(__alloc_traits::allocate(__a, __block_size)); | |
| 2239 | __map_.emplace_front(__alloc_traits::allocate(__a, __block_size)); | |
| 2218 | 2240 | __annotate_whole_block(0, __asan_poison); |
| 2219 | 2241 | } |
| 2220 | 2242 | // Done allocating, reorder capacity |
| ... | ... | @@ -2222,7 +2244,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) { |
| 2222 | 2244 | for (; __front_capacity > 0; --__front_capacity) { |
| 2223 | 2245 | pointer __pt = __map_.front(); |
| 2224 | 2246 | __map_.pop_front(); |
| 2225 | __map_.push_back(__pt); | |
| 2247 | __map_.emplace_back(__pt); | |
| 2226 | 2248 | } |
| 2227 | 2249 | } |
| 2228 | 2250 | // Else need to allocate __nb buffers, *and* we need to reallocate __map_. |
| ... | ... | @@ -2231,33 +2253,33 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) { |
| 2231 | 2253 | __split_buffer<pointer, __pointer_allocator&> __buf( |
| 2232 | 2254 | std::max<size_type>(2 * __map_.capacity(), __nb + __map_.size()), |
| 2233 | 2255 | __map_.size() - __front_capacity, |
| 2234 | __map_.__alloc()); | |
| 2235 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2256 | __map_.__alloc_); | |
| 2257 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2236 | 2258 | try { |
| 2237 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2259 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2238 | 2260 | for (; __nb > 0; --__nb) { |
| 2239 | __buf.push_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2261 | __buf.emplace_back(__alloc_traits::allocate(__a, __block_size)); | |
| 2240 | 2262 | // ASan: this is an empty container, we have to poison the whole block |
| 2241 | 2263 | __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size)); |
| 2242 | 2264 | } |
| 2243 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2265 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2244 | 2266 | } catch (...) { |
| 2245 | 2267 | __annotate_delete(); |
| 2246 | 2268 | for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) |
| 2247 | 2269 | __alloc_traits::deallocate(__a, *__i, __block_size); |
| 2248 | 2270 | throw; |
| 2249 | 2271 | } |
| 2250 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2272 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2251 | 2273 | for (; __front_capacity > 0; --__front_capacity) { |
| 2252 | __buf.push_back(__map_.front()); | |
| 2274 | __buf.emplace_back(__map_.front()); | |
| 2253 | 2275 | __map_.pop_front(); |
| 2254 | 2276 | } |
| 2255 | 2277 | for (__map_pointer __i = __map_.end(); __i != __map_.begin();) |
| 2256 | __buf.push_front(*--__i); | |
| 2278 | __buf.emplace_front(*--__i); | |
| 2257 | 2279 | std::swap(__map_.__first_, __buf.__first_); |
| 2258 | 2280 | std::swap(__map_.__begin_, __buf.__begin_); |
| 2259 | 2281 | std::swap(__map_.__end_, __buf.__end_); |
| 2260 | std::swap(__map_.__end_cap(), __buf.__end_cap()); | |
| 2282 | std::swap(__map_.__cap_, __buf.__cap_); | |
| 2261 | 2283 | __start_ -= __ds; |
| 2262 | 2284 | } |
| 2263 | 2285 | } |
| ... | ... | @@ -2413,7 +2435,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it |
| 2413 | 2435 | difference_type __pos = __f - __b; |
| 2414 | 2436 | iterator __p = __b + __pos; |
| 2415 | 2437 | allocator_type& __a = __alloc(); |
| 2416 | if (static_cast<size_t>(__pos) <= (size() - 1) / 2) { // erase from front | |
| 2438 | if (static_cast<size_type>(__pos) <= (size() - 1) / 2) { // erase from front | |
| 2417 | 2439 | std::move_backward(__b, __p, std::next(__p)); |
| 2418 | 2440 | __alloc_traits::destroy(__a, std::addressof(*__b)); |
| 2419 | 2441 | --__size(); |
| ... | ... | @@ -2441,7 +2463,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it |
| 2441 | 2463 | iterator __p = __b + __pos; |
| 2442 | 2464 | if (__n > 0) { |
| 2443 | 2465 | allocator_type& __a = __alloc(); |
| 2444 | if (static_cast<size_t>(__pos) <= (size() - __n) / 2) { // erase from front | |
| 2466 | if (static_cast<size_type>(__pos) <= (size() - __n) / 2) { // erase from front | |
| 2445 | 2467 | iterator __i = std::move_backward(__b, __p, __p + __n); |
| 2446 | 2468 | for (; __b != __i; ++__b) |
| 2447 | 2469 | __alloc_traits::destroy(__a, std::addressof(*__b)); |
| ... | ... | @@ -2484,11 +2506,11 @@ void deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f) { |
| 2484 | 2506 | |
| 2485 | 2507 | template <class _Tp, class _Allocator> |
| 2486 | 2508 | inline void deque<_Tp, _Allocator>::swap(deque& __c) |
| 2487 | #if _LIBCPP_STD_VER >= 14 | |
| 2509 | # if _LIBCPP_STD_VER >= 14 | |
| 2488 | 2510 | _NOEXCEPT |
| 2489 | #else | |
| 2511 | # else | |
| 2490 | 2512 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) |
| 2491 | #endif | |
| 2513 | # endif | |
| 2492 | 2514 | { |
| 2493 | 2515 | __map_.swap(__c.__map_); |
| 2494 | 2516 | std::swap(__start_, __c.__start_); |
| ... | ... | @@ -2524,7 +2546,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const deque<_Tp, _Allocator>& __x, |
| 2524 | 2546 | return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); |
| 2525 | 2547 | } |
| 2526 | 2548 | |
| 2527 | #if _LIBCPP_STD_VER <= 17 | |
| 2549 | # if _LIBCPP_STD_VER <= 17 | |
| 2528 | 2550 | |
| 2529 | 2551 | template <class _Tp, class _Allocator> |
| 2530 | 2552 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { |
| ... | ... | @@ -2551,7 +2573,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const deque<_Tp, _Allocator>& __x, |
| 2551 | 2573 | return !(__y < __x); |
| 2552 | 2574 | } |
| 2553 | 2575 | |
| 2554 | #else // _LIBCPP_STD_VER <= 17 | |
| 2576 | # else // _LIBCPP_STD_VER <= 17 | |
| 2555 | 2577 | |
| 2556 | 2578 | template <class _Tp, class _Allocator> |
| 2557 | 2579 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> |
| ... | ... | @@ -2559,7 +2581,7 @@ operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y |
| 2559 | 2581 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 2560 | 2582 | } |
| 2561 | 2583 | |
| 2562 | #endif // _LIBCPP_STD_VER <= 17 | |
| 2584 | # endif // _LIBCPP_STD_VER <= 17 | |
| 2563 | 2585 | |
| 2564 | 2586 | template <class _Tp, class _Allocator> |
| 2565 | 2587 | inline _LIBCPP_HIDE_FROM_ABI void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y) |
| ... | ... | @@ -2567,7 +2589,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _ |
| 2567 | 2589 | __x.swap(__y); |
| 2568 | 2590 | } |
| 2569 | 2591 | |
| 2570 | #if _LIBCPP_STD_VER >= 20 | |
| 2592 | # if _LIBCPP_STD_VER >= 20 | |
| 2571 | 2593 | template <class _Tp, class _Allocator, class _Up> |
| 2572 | 2594 | inline _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::size_type |
| 2573 | 2595 | erase(deque<_Tp, _Allocator>& __c, const _Up& __v) { |
| ... | ... | @@ -2586,36 +2608,48 @@ erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) { |
| 2586 | 2608 | |
| 2587 | 2609 | template <> |
| 2588 | 2610 | inline constexpr bool __format::__enable_insertable<std::deque<char>> = true; |
| 2589 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2611 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2590 | 2612 | template <> |
| 2591 | 2613 | inline constexpr bool __format::__enable_insertable<std::deque<wchar_t>> = true; |
| 2592 | # endif | |
| 2614 | # endif | |
| 2615 | ||
| 2616 | # endif // _LIBCPP_STD_VER >= 20 | |
| 2593 | 2617 | |
| 2594 | #endif // _LIBCPP_STD_VER >= 20 | |
| 2618 | template <class _Tp, class _Allocator> | |
| 2619 | struct __container_traits<deque<_Tp, _Allocator> > { | |
| 2620 | // http://eel.is/c++draft/deque.modifiers#3 | |
| 2621 | // If an exception is thrown other than by the copy constructor, move constructor, assignment operator, or move | |
| 2622 | // assignment operator of T, there are no effects. If an exception is thrown while inserting a single element at | |
| 2623 | // either end, there are no effects. Otherwise, if an exception is thrown by the move constructor of a | |
| 2624 | // non-Cpp17CopyInsertable T, the effects are unspecified. | |
| 2625 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | |
| 2626 | _Or<is_nothrow_move_constructible<_Tp>, __is_cpp17_copy_insertable<_Allocator> >::value; | |
| 2627 | }; | |
| 2595 | 2628 | |
| 2596 | 2629 | _LIBCPP_END_NAMESPACE_STD |
| 2597 | 2630 | |
| 2598 | #if _LIBCPP_STD_VER >= 17 | |
| 2631 | # if _LIBCPP_STD_VER >= 17 | |
| 2599 | 2632 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 2600 | 2633 | namespace pmr { |
| 2601 | 2634 | template <class _ValueT> |
| 2602 | 2635 | using deque _LIBCPP_AVAILABILITY_PMR = std::deque<_ValueT, polymorphic_allocator<_ValueT>>; |
| 2603 | 2636 | } // namespace pmr |
| 2604 | 2637 | _LIBCPP_END_NAMESPACE_STD |
| 2605 | #endif | |
| 2638 | # endif | |
| 2606 | 2639 | |
| 2607 | 2640 | _LIBCPP_POP_MACROS |
| 2608 | 2641 | |
| 2609 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 2610 | # include <algorithm> | |
| 2611 | # include <atomic> | |
| 2612 | # include <concepts> | |
| 2613 | # include <cstdlib> | |
| 2614 | # include <functional> | |
| 2615 | # include <iosfwd> | |
| 2616 | # include <iterator> | |
| 2617 | # include <type_traits> | |
| 2618 | # include <typeinfo> | |
| 2619 | #endif | |
| 2642 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 2643 | # include <algorithm> | |
| 2644 | # include <atomic> | |
| 2645 | # include <concepts> | |
| 2646 | # include <cstdlib> | |
| 2647 | # include <functional> | |
| 2648 | # include <iosfwd> | |
| 2649 | # include <iterator> | |
| 2650 | # include <type_traits> | |
| 2651 | # include <typeinfo> | |
| 2652 | # endif | |
| 2653 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 2620 | 2654 | |
| 2621 | 2655 | #endif // _LIBCPP_DEQUE |
lib/libcxx/include/errno.h+272-268| ... | ... | @@ -22,378 +22,382 @@ Macros: |
| 22 | 22 | |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | #include <__config> | |
| 25 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 26 | # include <__cxx03/errno.h> | |
| 27 | #else | |
| 28 | # include <__config> | |
| 26 | 29 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 28 | # pragma GCC system_header | |
| 29 | #endif | |
| 30 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 31 | # pragma GCC system_header | |
| 32 | # endif | |
| 30 | 33 | |
| 31 | #if __has_include_next(<errno.h>) | |
| 32 | # include_next <errno.h> | |
| 33 | #endif | |
| 34 | # if __has_include_next(<errno.h>) | |
| 35 | # include_next <errno.h> | |
| 36 | # endif | |
| 34 | 37 | |
| 35 | #ifdef __cplusplus | |
| 38 | # ifdef __cplusplus | |
| 36 | 39 | |
| 37 | # if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) | |
| 40 | # if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) | |
| 38 | 41 | |
| 39 | # ifdef ELAST | |
| 42 | # ifdef ELAST | |
| 40 | 43 | |
| 41 | 44 | static const int __elast1 = ELAST + 1; |
| 42 | 45 | static const int __elast2 = ELAST + 2; |
| 43 | 46 | |
| 44 | # else | |
| 47 | # else | |
| 45 | 48 | |
| 46 | 49 | static const int __elast1 = 104; |
| 47 | 50 | static const int __elast2 = 105; |
| 48 | 51 | |
| 49 | # endif | |
| 52 | # endif | |
| 50 | 53 | |
| 51 | # ifdef ENOTRECOVERABLE | |
| 54 | # ifdef ENOTRECOVERABLE | |
| 52 | 55 | |
| 53 | # define EOWNERDEAD __elast1 | |
| 56 | # define EOWNERDEAD __elast1 | |
| 54 | 57 | |
| 55 | # ifdef ELAST | |
| 56 | # undef ELAST | |
| 57 | # define ELAST EOWNERDEAD | |
| 58 | # endif | |
| 58 | # ifdef ELAST | |
| 59 | # undef ELAST | |
| 60 | # define ELAST EOWNERDEAD | |
| 61 | # endif | |
| 59 | 62 | |
| 60 | # elif defined(EOWNERDEAD) | |
| 63 | # elif defined(EOWNERDEAD) | |
| 61 | 64 | |
| 62 | # define ENOTRECOVERABLE __elast1 | |
| 63 | # ifdef ELAST | |
| 64 | # undef ELAST | |
| 65 | # define ELAST ENOTRECOVERABLE | |
| 66 | # endif | |
| 65 | # define ENOTRECOVERABLE __elast1 | |
| 66 | # ifdef ELAST | |
| 67 | # undef ELAST | |
| 68 | # define ELAST ENOTRECOVERABLE | |
| 69 | # endif | |
| 67 | 70 | |
| 68 | # else // defined(EOWNERDEAD) | |
| 71 | # else // defined(EOWNERDEAD) | |
| 69 | 72 | |
| 70 | # define EOWNERDEAD __elast1 | |
| 71 | # define ENOTRECOVERABLE __elast2 | |
| 72 | # ifdef ELAST | |
| 73 | # undef ELAST | |
| 74 | # define ELAST ENOTRECOVERABLE | |
| 75 | # endif | |
| 73 | # define EOWNERDEAD __elast1 | |
| 74 | # define ENOTRECOVERABLE __elast2 | |
| 75 | # ifdef ELAST | |
| 76 | # undef ELAST | |
| 77 | # define ELAST ENOTRECOVERABLE | |
| 78 | # endif | |
| 76 | 79 | |
| 77 | # endif // defined(EOWNERDEAD) | |
| 80 | # endif // defined(EOWNERDEAD) | |
| 78 | 81 | |
| 79 | # endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) | |
| 82 | # endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) | |
| 80 | 83 | |
| 81 | 84 | // supply errno values likely to be missing, particularly on Windows |
| 82 | 85 | |
| 83 | # ifndef EAFNOSUPPORT | |
| 84 | # define EAFNOSUPPORT 9901 | |
| 85 | # endif | |
| 86 | # ifndef EAFNOSUPPORT | |
| 87 | # define EAFNOSUPPORT 9901 | |
| 88 | # endif | |
| 86 | 89 | |
| 87 | # ifndef EADDRINUSE | |
| 88 | # define EADDRINUSE 9902 | |
| 89 | # endif | |
| 90 | # ifndef EADDRINUSE | |
| 91 | # define EADDRINUSE 9902 | |
| 92 | # endif | |
| 90 | 93 | |
| 91 | # ifndef EADDRNOTAVAIL | |
| 92 | # define EADDRNOTAVAIL 9903 | |
| 93 | # endif | |
| 94 | # ifndef EADDRNOTAVAIL | |
| 95 | # define EADDRNOTAVAIL 9903 | |
| 96 | # endif | |
| 94 | 97 | |
| 95 | # ifndef EISCONN | |
| 96 | # define EISCONN 9904 | |
| 97 | # endif | |
| 98 | # ifndef EISCONN | |
| 99 | # define EISCONN 9904 | |
| 100 | # endif | |
| 98 | 101 | |
| 99 | # ifndef EBADMSG | |
| 100 | # define EBADMSG 9905 | |
| 101 | # endif | |
| 102 | # ifndef EBADMSG | |
| 103 | # define EBADMSG 9905 | |
| 104 | # endif | |
| 102 | 105 | |
| 103 | # ifndef ECONNABORTED | |
| 104 | # define ECONNABORTED 9906 | |
| 105 | # endif | |
| 106 | # ifndef ECONNABORTED | |
| 107 | # define ECONNABORTED 9906 | |
| 108 | # endif | |
| 106 | 109 | |
| 107 | # ifndef EALREADY | |
| 108 | # define EALREADY 9907 | |
| 109 | # endif | |
| 110 | # ifndef EALREADY | |
| 111 | # define EALREADY 9907 | |
| 112 | # endif | |
| 110 | 113 | |
| 111 | # ifndef ECONNREFUSED | |
| 112 | # define ECONNREFUSED 9908 | |
| 113 | # endif | |
| 114 | # ifndef ECONNREFUSED | |
| 115 | # define ECONNREFUSED 9908 | |
| 116 | # endif | |
| 114 | 117 | |
| 115 | # ifndef ECONNRESET | |
| 116 | # define ECONNRESET 9909 | |
| 117 | # endif | |
| 118 | # ifndef ECONNRESET | |
| 119 | # define ECONNRESET 9909 | |
| 120 | # endif | |
| 118 | 121 | |
| 119 | # ifndef EDESTADDRREQ | |
| 120 | # define EDESTADDRREQ 9910 | |
| 121 | # endif | |
| 122 | # ifndef EDESTADDRREQ | |
| 123 | # define EDESTADDRREQ 9910 | |
| 124 | # endif | |
| 122 | 125 | |
| 123 | # ifndef EHOSTUNREACH | |
| 124 | # define EHOSTUNREACH 9911 | |
| 125 | # endif | |
| 126 | # ifndef EHOSTUNREACH | |
| 127 | # define EHOSTUNREACH 9911 | |
| 128 | # endif | |
| 126 | 129 | |
| 127 | # ifndef EIDRM | |
| 128 | # define EIDRM 9912 | |
| 129 | # endif | |
| 130 | # ifndef EIDRM | |
| 131 | # define EIDRM 9912 | |
| 132 | # endif | |
| 130 | 133 | |
| 131 | # ifndef EMSGSIZE | |
| 132 | # define EMSGSIZE 9913 | |
| 133 | # endif | |
| 134 | # ifndef EMSGSIZE | |
| 135 | # define EMSGSIZE 9913 | |
| 136 | # endif | |
| 134 | 137 | |
| 135 | # ifndef ENETDOWN | |
| 136 | # define ENETDOWN 9914 | |
| 137 | # endif | |
| 138 | # ifndef ENETDOWN | |
| 139 | # define ENETDOWN 9914 | |
| 140 | # endif | |
| 138 | 141 | |
| 139 | # ifndef ENETRESET | |
| 140 | # define ENETRESET 9915 | |
| 141 | # endif | |
| 142 | # ifndef ENETRESET | |
| 143 | # define ENETRESET 9915 | |
| 144 | # endif | |
| 142 | 145 | |
| 143 | # ifndef ENETUNREACH | |
| 144 | # define ENETUNREACH 9916 | |
| 145 | # endif | |
| 146 | # ifndef ENETUNREACH | |
| 147 | # define ENETUNREACH 9916 | |
| 148 | # endif | |
| 146 | 149 | |
| 147 | # ifndef ENOBUFS | |
| 148 | # define ENOBUFS 9917 | |
| 149 | # endif | |
| 150 | # ifndef ENOBUFS | |
| 151 | # define ENOBUFS 9917 | |
| 152 | # endif | |
| 150 | 153 | |
| 151 | # ifndef ENOLINK | |
| 152 | # define ENOLINK 9918 | |
| 153 | # endif | |
| 154 | # ifndef ENOLINK | |
| 155 | # define ENOLINK 9918 | |
| 156 | # endif | |
| 154 | 157 | |
| 155 | # ifndef ENODATA | |
| 156 | # define ENODATA 9919 | |
| 157 | # endif | |
| 158 | # ifndef ENODATA | |
| 159 | # define ENODATA 9919 | |
| 160 | # endif | |
| 158 | 161 | |
| 159 | # ifndef ENOMSG | |
| 160 | # define ENOMSG 9920 | |
| 161 | # endif | |
| 162 | # ifndef ENOMSG | |
| 163 | # define ENOMSG 9920 | |
| 164 | # endif | |
| 162 | 165 | |
| 163 | # ifndef ENOPROTOOPT | |
| 164 | # define ENOPROTOOPT 9921 | |
| 165 | # endif | |
| 166 | # ifndef ENOPROTOOPT | |
| 167 | # define ENOPROTOOPT 9921 | |
| 168 | # endif | |
| 166 | 169 | |
| 167 | # ifndef ENOSR | |
| 168 | # define ENOSR 9922 | |
| 169 | # endif | |
| 170 | # ifndef ENOSR | |
| 171 | # define ENOSR 9922 | |
| 172 | # endif | |
| 170 | 173 | |
| 171 | # ifndef ENOTSOCK | |
| 172 | # define ENOTSOCK 9923 | |
| 173 | # endif | |
| 174 | # ifndef ENOTSOCK | |
| 175 | # define ENOTSOCK 9923 | |
| 176 | # endif | |
| 174 | 177 | |
| 175 | # ifndef ENOSTR | |
| 176 | # define ENOSTR 9924 | |
| 177 | # endif | |
| 178 | # ifndef ENOSTR | |
| 179 | # define ENOSTR 9924 | |
| 180 | # endif | |
| 178 | 181 | |
| 179 | # ifndef ENOTCONN | |
| 180 | # define ENOTCONN 9925 | |
| 181 | # endif | |
| 182 | # ifndef ENOTCONN | |
| 183 | # define ENOTCONN 9925 | |
| 184 | # endif | |
| 182 | 185 | |
| 183 | # ifndef ENOTSUP | |
| 184 | # define ENOTSUP 9926 | |
| 185 | # endif | |
| 186 | # ifndef ENOTSUP | |
| 187 | # define ENOTSUP 9926 | |
| 188 | # endif | |
| 186 | 189 | |
| 187 | # ifndef ECANCELED | |
| 188 | # define ECANCELED 9927 | |
| 189 | # endif | |
| 190 | # ifndef ECANCELED | |
| 191 | # define ECANCELED 9927 | |
| 192 | # endif | |
| 190 | 193 | |
| 191 | # ifndef EINPROGRESS | |
| 192 | # define EINPROGRESS 9928 | |
| 193 | # endif | |
| 194 | # ifndef EINPROGRESS | |
| 195 | # define EINPROGRESS 9928 | |
| 196 | # endif | |
| 194 | 197 | |
| 195 | # ifndef EOPNOTSUPP | |
| 196 | # define EOPNOTSUPP 9929 | |
| 197 | # endif | |
| 198 | # ifndef EOPNOTSUPP | |
| 199 | # define EOPNOTSUPP 9929 | |
| 200 | # endif | |
| 198 | 201 | |
| 199 | # ifndef EWOULDBLOCK | |
| 200 | # define EWOULDBLOCK 9930 | |
| 201 | # endif | |
| 202 | # ifndef EWOULDBLOCK | |
| 203 | # define EWOULDBLOCK 9930 | |
| 204 | # endif | |
| 202 | 205 | |
| 203 | # ifndef EOWNERDEAD | |
| 204 | # define EOWNERDEAD 9931 | |
| 205 | # endif | |
| 206 | # ifndef EOWNERDEAD | |
| 207 | # define EOWNERDEAD 9931 | |
| 208 | # endif | |
| 206 | 209 | |
| 207 | # ifndef EPROTO | |
| 208 | # define EPROTO 9932 | |
| 209 | # endif | |
| 210 | # ifndef EPROTO | |
| 211 | # define EPROTO 9932 | |
| 212 | # endif | |
| 210 | 213 | |
| 211 | # ifndef EPROTONOSUPPORT | |
| 212 | # define EPROTONOSUPPORT 9933 | |
| 213 | # endif | |
| 214 | # ifndef EPROTONOSUPPORT | |
| 215 | # define EPROTONOSUPPORT 9933 | |
| 216 | # endif | |
| 214 | 217 | |
| 215 | # ifndef ENOTRECOVERABLE | |
| 216 | # define ENOTRECOVERABLE 9934 | |
| 217 | # endif | |
| 218 | # ifndef ENOTRECOVERABLE | |
| 219 | # define ENOTRECOVERABLE 9934 | |
| 220 | # endif | |
| 218 | 221 | |
| 219 | # ifndef ETIME | |
| 220 | # define ETIME 9935 | |
| 221 | # endif | |
| 222 | # ifndef ETIME | |
| 223 | # define ETIME 9935 | |
| 224 | # endif | |
| 222 | 225 | |
| 223 | # ifndef ETXTBSY | |
| 224 | # define ETXTBSY 9936 | |
| 225 | # endif | |
| 226 | # ifndef ETXTBSY | |
| 227 | # define ETXTBSY 9936 | |
| 228 | # endif | |
| 226 | 229 | |
| 227 | # ifndef ETIMEDOUT | |
| 228 | # define ETIMEDOUT 9938 | |
| 229 | # endif | |
| 230 | # ifndef ETIMEDOUT | |
| 231 | # define ETIMEDOUT 9938 | |
| 232 | # endif | |
| 230 | 233 | |
| 231 | # ifndef ELOOP | |
| 232 | # define ELOOP 9939 | |
| 233 | # endif | |
| 234 | # ifndef ELOOP | |
| 235 | # define ELOOP 9939 | |
| 236 | # endif | |
| 234 | 237 | |
| 235 | # ifndef EOVERFLOW | |
| 236 | # define EOVERFLOW 9940 | |
| 237 | # endif | |
| 238 | # ifndef EOVERFLOW | |
| 239 | # define EOVERFLOW 9940 | |
| 240 | # endif | |
| 238 | 241 | |
| 239 | # ifndef EPROTOTYPE | |
| 240 | # define EPROTOTYPE 9941 | |
| 241 | # endif | |
| 242 | # ifndef EPROTOTYPE | |
| 243 | # define EPROTOTYPE 9941 | |
| 244 | # endif | |
| 242 | 245 | |
| 243 | # ifndef ENOSYS | |
| 244 | # define ENOSYS 9942 | |
| 245 | # endif | |
| 246 | # ifndef ENOSYS | |
| 247 | # define ENOSYS 9942 | |
| 248 | # endif | |
| 246 | 249 | |
| 247 | # ifndef EINVAL | |
| 248 | # define EINVAL 9943 | |
| 249 | # endif | |
| 250 | # ifndef EINVAL | |
| 251 | # define EINVAL 9943 | |
| 252 | # endif | |
| 250 | 253 | |
| 251 | # ifndef ERANGE | |
| 252 | # define ERANGE 9944 | |
| 253 | # endif | |
| 254 | # ifndef ERANGE | |
| 255 | # define ERANGE 9944 | |
| 256 | # endif | |
| 254 | 257 | |
| 255 | # ifndef EILSEQ | |
| 256 | # define EILSEQ 9945 | |
| 257 | # endif | |
| 258 | # ifndef EILSEQ | |
| 259 | # define EILSEQ 9945 | |
| 260 | # endif | |
| 258 | 261 | |
| 259 | 262 | // Windows Mobile doesn't appear to define these: |
| 260 | 263 | |
| 261 | # ifndef E2BIG | |
| 262 | # define E2BIG 9946 | |
| 263 | # endif | |
| 264 | # ifndef E2BIG | |
| 265 | # define E2BIG 9946 | |
| 266 | # endif | |
| 264 | 267 | |
| 265 | # ifndef EDOM | |
| 266 | # define EDOM 9947 | |
| 267 | # endif | |
| 268 | # ifndef EDOM | |
| 269 | # define EDOM 9947 | |
| 270 | # endif | |
| 268 | 271 | |
| 269 | # ifndef EFAULT | |
| 270 | # define EFAULT 9948 | |
| 271 | # endif | |
| 272 | # ifndef EFAULT | |
| 273 | # define EFAULT 9948 | |
| 274 | # endif | |
| 272 | 275 | |
| 273 | # ifndef EBADF | |
| 274 | # define EBADF 9949 | |
| 275 | # endif | |
| 276 | # ifndef EBADF | |
| 277 | # define EBADF 9949 | |
| 278 | # endif | |
| 276 | 279 | |
| 277 | # ifndef EPIPE | |
| 278 | # define EPIPE 9950 | |
| 279 | # endif | |
| 280 | # ifndef EPIPE | |
| 281 | # define EPIPE 9950 | |
| 282 | # endif | |
| 280 | 283 | |
| 281 | # ifndef EXDEV | |
| 282 | # define EXDEV 9951 | |
| 283 | # endif | |
| 284 | # ifndef EXDEV | |
| 285 | # define EXDEV 9951 | |
| 286 | # endif | |
| 284 | 287 | |
| 285 | # ifndef EBUSY | |
| 286 | # define EBUSY 9952 | |
| 287 | # endif | |
| 288 | # ifndef EBUSY | |
| 289 | # define EBUSY 9952 | |
| 290 | # endif | |
| 288 | 291 | |
| 289 | # ifndef ENOTEMPTY | |
| 290 | # define ENOTEMPTY 9953 | |
| 291 | # endif | |
| 292 | # ifndef ENOTEMPTY | |
| 293 | # define ENOTEMPTY 9953 | |
| 294 | # endif | |
| 292 | 295 | |
| 293 | # ifndef ENOEXEC | |
| 294 | # define ENOEXEC 9954 | |
| 295 | # endif | |
| 296 | # ifndef ENOEXEC | |
| 297 | # define ENOEXEC 9954 | |
| 298 | # endif | |
| 296 | 299 | |
| 297 | # ifndef EEXIST | |
| 298 | # define EEXIST 9955 | |
| 299 | # endif | |
| 300 | # ifndef EEXIST | |
| 301 | # define EEXIST 9955 | |
| 302 | # endif | |
| 300 | 303 | |
| 301 | # ifndef EFBIG | |
| 302 | # define EFBIG 9956 | |
| 303 | # endif | |
| 304 | # ifndef EFBIG | |
| 305 | # define EFBIG 9956 | |
| 306 | # endif | |
| 304 | 307 | |
| 305 | # ifndef ENAMETOOLONG | |
| 306 | # define ENAMETOOLONG 9957 | |
| 307 | # endif | |
| 308 | # ifndef ENAMETOOLONG | |
| 309 | # define ENAMETOOLONG 9957 | |
| 310 | # endif | |
| 308 | 311 | |
| 309 | # ifndef ENOTTY | |
| 310 | # define ENOTTY 9958 | |
| 311 | # endif | |
| 312 | # ifndef ENOTTY | |
| 313 | # define ENOTTY 9958 | |
| 314 | # endif | |
| 312 | 315 | |
| 313 | # ifndef EINTR | |
| 314 | # define EINTR 9959 | |
| 315 | # endif | |
| 316 | # ifndef EINTR | |
| 317 | # define EINTR 9959 | |
| 318 | # endif | |
| 316 | 319 | |
| 317 | # ifndef ESPIPE | |
| 318 | # define ESPIPE 9960 | |
| 319 | # endif | |
| 320 | # ifndef ESPIPE | |
| 321 | # define ESPIPE 9960 | |
| 322 | # endif | |
| 320 | 323 | |
| 321 | # ifndef EIO | |
| 322 | # define EIO 9961 | |
| 323 | # endif | |
| 324 | # ifndef EIO | |
| 325 | # define EIO 9961 | |
| 326 | # endif | |
| 324 | 327 | |
| 325 | # ifndef EISDIR | |
| 326 | # define EISDIR 9962 | |
| 327 | # endif | |
| 328 | # ifndef EISDIR | |
| 329 | # define EISDIR 9962 | |
| 330 | # endif | |
| 328 | 331 | |
| 329 | # ifndef ECHILD | |
| 330 | # define ECHILD 9963 | |
| 331 | # endif | |
| 332 | # ifndef ECHILD | |
| 333 | # define ECHILD 9963 | |
| 334 | # endif | |
| 332 | 335 | |
| 333 | # ifndef ENOLCK | |
| 334 | # define ENOLCK 9964 | |
| 335 | # endif | |
| 336 | # ifndef ENOLCK | |
| 337 | # define ENOLCK 9964 | |
| 338 | # endif | |
| 336 | 339 | |
| 337 | # ifndef ENOSPC | |
| 338 | # define ENOSPC 9965 | |
| 339 | # endif | |
| 340 | # ifndef ENOSPC | |
| 341 | # define ENOSPC 9965 | |
| 342 | # endif | |
| 340 | 343 | |
| 341 | # ifndef ENXIO | |
| 342 | # define ENXIO 9966 | |
| 343 | # endif | |
| 344 | # ifndef ENXIO | |
| 345 | # define ENXIO 9966 | |
| 346 | # endif | |
| 344 | 347 | |
| 345 | # ifndef ENODEV | |
| 346 | # define ENODEV 9967 | |
| 347 | # endif | |
| 348 | # ifndef ENODEV | |
| 349 | # define ENODEV 9967 | |
| 350 | # endif | |
| 348 | 351 | |
| 349 | # ifndef ENOENT | |
| 350 | # define ENOENT 9968 | |
| 351 | # endif | |
| 352 | # ifndef ENOENT | |
| 353 | # define ENOENT 9968 | |
| 354 | # endif | |
| 352 | 355 | |
| 353 | # ifndef ESRCH | |
| 354 | # define ESRCH 9969 | |
| 355 | # endif | |
| 356 | # ifndef ESRCH | |
| 357 | # define ESRCH 9969 | |
| 358 | # endif | |
| 356 | 359 | |
| 357 | # ifndef ENOTDIR | |
| 358 | # define ENOTDIR 9970 | |
| 359 | # endif | |
| 360 | # ifndef ENOTDIR | |
| 361 | # define ENOTDIR 9970 | |
| 362 | # endif | |
| 360 | 363 | |
| 361 | # ifndef ENOMEM | |
| 362 | # define ENOMEM 9971 | |
| 363 | # endif | |
| 364 | # ifndef ENOMEM | |
| 365 | # define ENOMEM 9971 | |
| 366 | # endif | |
| 364 | 367 | |
| 365 | # ifndef EPERM | |
| 366 | # define EPERM 9972 | |
| 367 | # endif | |
| 368 | # ifndef EPERM | |
| 369 | # define EPERM 9972 | |
| 370 | # endif | |
| 368 | 371 | |
| 369 | # ifndef EACCES | |
| 370 | # define EACCES 9973 | |
| 371 | # endif | |
| 372 | # ifndef EACCES | |
| 373 | # define EACCES 9973 | |
| 374 | # endif | |
| 372 | 375 | |
| 373 | # ifndef EROFS | |
| 374 | # define EROFS 9974 | |
| 375 | # endif | |
| 376 | # ifndef EROFS | |
| 377 | # define EROFS 9974 | |
| 378 | # endif | |
| 376 | 379 | |
| 377 | # ifndef EDEADLK | |
| 378 | # define EDEADLK 9975 | |
| 379 | # endif | |
| 380 | # ifndef EDEADLK | |
| 381 | # define EDEADLK 9975 | |
| 382 | # endif | |
| 380 | 383 | |
| 381 | # ifndef EAGAIN | |
| 382 | # define EAGAIN 9976 | |
| 383 | # endif | |
| 384 | # ifndef EAGAIN | |
| 385 | # define EAGAIN 9976 | |
| 386 | # endif | |
| 384 | 387 | |
| 385 | # ifndef ENFILE | |
| 386 | # define ENFILE 9977 | |
| 387 | # endif | |
| 388 | # ifndef ENFILE | |
| 389 | # define ENFILE 9977 | |
| 390 | # endif | |
| 388 | 391 | |
| 389 | # ifndef EMFILE | |
| 390 | # define EMFILE 9978 | |
| 391 | # endif | |
| 392 | # ifndef EMFILE | |
| 393 | # define EMFILE 9978 | |
| 394 | # endif | |
| 392 | 395 | |
| 393 | # ifndef EMLINK | |
| 394 | # define EMLINK 9979 | |
| 395 | # endif | |
| 396 | # ifndef EMLINK | |
| 397 | # define EMLINK 9979 | |
| 398 | # endif | |
| 396 | 399 | |
| 397 | #endif // __cplusplus | |
| 400 | # endif // __cplusplus | |
| 401 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 398 | 402 | |
| 399 | 403 | #endif // _LIBCPP_ERRNO_H |
lib/libcxx/include/exception+23-17| ... | ... | @@ -47,7 +47,7 @@ terminate_handler set_terminate(terminate_handler f ) noexcept; |
| 47 | 47 | terminate_handler get_terminate() noexcept; |
| 48 | 48 | [[noreturn]] void terminate() noexcept; |
| 49 | 49 | |
| 50 | bool uncaught_exception() noexcept; | |
| 50 | bool uncaught_exception() noexcept; // deprecated in C++17, removed in C++20 | |
| 51 | 51 | int uncaught_exceptions() noexcept; // C++17 |
| 52 | 52 | |
| 53 | 53 | typedef unspecified exception_ptr; |
| ... | ... | @@ -76,21 +76,27 @@ template <class E> void rethrow_if_nested(const E& e); |
| 76 | 76 | |
| 77 | 77 | */ |
| 78 | 78 | |
| 79 | #include <__config> | |
| 80 | #include <__exception/exception.h> | |
| 81 | #include <__exception/exception_ptr.h> | |
| 82 | #include <__exception/nested_exception.h> | |
| 83 | #include <__exception/operations.h> | |
| 84 | #include <__exception/terminate.h> | |
| 85 | #include <version> | |
| 86 | ||
| 87 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 88 | # pragma GCC system_header | |
| 89 | #endif | |
| 90 | ||
| 91 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 92 | # include <cstdlib> | |
| 93 | # include <type_traits> | |
| 94 | #endif | |
| 79 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 80 | # include <__cxx03/exception> | |
| 81 | #else | |
| 82 | # include <__config> | |
| 83 | # include <__exception/exception.h> | |
| 84 | # include <__exception/exception_ptr.h> | |
| 85 | # include <__exception/nested_exception.h> | |
| 86 | # include <__exception/operations.h> | |
| 87 | # include <__exception/terminate.h> | |
| 88 | # include <version> | |
| 89 | ||
| 90 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 91 | # pragma GCC system_header | |
| 92 | # endif | |
| 93 | ||
| 94 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 95 | # include <cstddef> | |
| 96 | # include <cstdlib> | |
| 97 | # include <new> | |
| 98 | # include <type_traits> | |
| 99 | # endif | |
| 100 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 95 | 101 | |
| 96 | 102 | #endif // _LIBCPP_EXCEPTION |
lib/libcxx/include/execution+33-19| ... | ... | @@ -32,17 +32,20 @@ namespace std { |
| 32 | 32 | } |
| 33 | 33 | */ |
| 34 | 34 | |
| 35 | #include <__config> | |
| 36 | #include <__type_traits/is_execution_policy.h> | |
| 37 | #include <__type_traits/is_same.h> | |
| 38 | #include <__type_traits/remove_cvref.h> | |
| 39 | #include <version> | |
| 40 | ||
| 41 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 42 | # pragma GCC system_header | |
| 43 | #endif | |
| 35 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 36 | # include <__cxx03/execution> | |
| 37 | #else | |
| 38 | # include <__config> | |
| 39 | # include <__type_traits/is_execution_policy.h> | |
| 40 | # include <__type_traits/is_same.h> | |
| 41 | # include <__type_traits/remove_cvref.h> | |
| 42 | # include <version> | |
| 43 | ||
| 44 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 45 | # pragma GCC system_header | |
| 46 | # endif | |
| 44 | 47 | |
| 45 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | |
| 48 | # if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17 | |
| 46 | 49 | |
| 47 | 50 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 51 | |
| ... | ... | @@ -79,7 +82,7 @@ struct __unsequenced_policy { |
| 79 | 82 | |
| 80 | 83 | constexpr __unsequenced_policy __unseq{__disable_user_instantiations_tag{}}; |
| 81 | 84 | |
| 82 | # if _LIBCPP_STD_VER >= 20 | |
| 85 | # if _LIBCPP_STD_VER >= 20 | |
| 83 | 86 | |
| 84 | 87 | struct unsequenced_policy { |
| 85 | 88 | _LIBCPP_HIDE_FROM_ABI constexpr explicit unsequenced_policy(__disable_user_instantiations_tag) {} |
| ... | ... | @@ -89,10 +92,14 @@ struct unsequenced_policy { |
| 89 | 92 | |
| 90 | 93 | inline constexpr unsequenced_policy unseq{__disable_user_instantiations_tag{}}; |
| 91 | 94 | |
| 92 | # endif // _LIBCPP_STD_VER >= 20 | |
| 95 | # endif // _LIBCPP_STD_VER >= 20 | |
| 93 | 96 | |
| 94 | 97 | } // namespace execution |
| 95 | 98 | |
| 99 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 100 | # if __has_warning("-Winvalid-specialization") | |
| 101 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | |
| 102 | # endif | |
| 96 | 103 | template <> |
| 97 | 104 | inline constexpr bool is_execution_policy_v<execution::sequenced_policy> = true; |
| 98 | 105 | |
| ... | ... | @@ -104,6 +111,7 @@ inline constexpr bool is_execution_policy_v<execution::parallel_unsequenced_poli |
| 104 | 111 | |
| 105 | 112 | template <> |
| 106 | 113 | inline constexpr bool is_execution_policy_v<execution::__unsequenced_policy> = true; |
| 114 | _LIBCPP_DIAGNOSTIC_POP | |
| 107 | 115 | |
| 108 | 116 | template <> |
| 109 | 117 | inline constexpr bool __is_parallel_execution_policy_impl<execution::parallel_policy> = true; |
| ... | ... | @@ -117,17 +125,22 @@ inline constexpr bool __is_unsequenced_execution_policy_impl<execution::__unsequ |
| 117 | 125 | template <> |
| 118 | 126 | inline constexpr bool __is_unsequenced_execution_policy_impl<execution::parallel_unsequenced_policy> = true; |
| 119 | 127 | |
| 120 | # if _LIBCPP_STD_VER >= 20 | |
| 128 | # if _LIBCPP_STD_VER >= 20 | |
| 129 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 130 | # if __has_warning("-Winvalid-specialization") | |
| 131 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization") | |
| 132 | # endif | |
| 121 | 133 | template <> |
| 122 | 134 | inline constexpr bool is_execution_policy_v<execution::unsequenced_policy> = true; |
| 135 | _LIBCPP_DIAGNOSTIC_POP | |
| 123 | 136 | |
| 124 | 137 | template <> |
| 125 | 138 | inline constexpr bool __is_unsequenced_execution_policy_impl<execution::unsequenced_policy> = true; |
| 126 | 139 | |
| 127 | # endif | |
| 140 | # endif | |
| 128 | 141 | |
| 129 | 142 | template <class _Tp> |
| 130 | struct is_execution_policy : bool_constant<is_execution_policy_v<_Tp>> {}; | |
| 143 | struct _LIBCPP_NO_SPECIALIZATIONS is_execution_policy : bool_constant<is_execution_policy_v<_Tp>> {}; | |
| 131 | 144 | |
| 132 | 145 | template <class _ExecutionPolicy> |
| 133 | 146 | _LIBCPP_HIDE_FROM_ABI auto __remove_parallel_policy(const _ExecutionPolicy&) { |
| ... | ... | @@ -140,10 +153,11 @@ _LIBCPP_HIDE_FROM_ABI auto __remove_parallel_policy(const _ExecutionPolicy&) { |
| 140 | 153 | |
| 141 | 154 | _LIBCPP_END_NAMESPACE_STD |
| 142 | 155 | |
| 143 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 | |
| 156 | # endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17 | |
| 144 | 157 | |
| 145 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 146 | # include <cstddef> | |
| 147 | #endif | |
| 158 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 159 | # include <cstddef> | |
| 160 | # endif | |
| 161 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 148 | 162 | |
| 149 | 163 | #endif // _LIBCPP_EXECUTION |
lib/libcxx/include/expected+18-20| ... | ... | @@ -38,25 +38,23 @@ namespace std { |
| 38 | 38 | |
| 39 | 39 | */ |
| 40 | 40 | |
| 41 | #include <__config> | |
| 42 | ||
| 43 | #if _LIBCPP_STD_VER >= 23 | |
| 44 | # include <__expected/bad_expected_access.h> | |
| 45 | # include <__expected/expected.h> | |
| 46 | # include <__expected/unexpect.h> | |
| 47 | # include <__expected/unexpected.h> | |
| 48 | #endif | |
| 49 | ||
| 50 | #include <version> | |
| 51 | ||
| 52 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 53 | # pragma GCC system_header | |
| 54 | #endif | |
| 55 | ||
| 56 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 57 | # include <cstddef> | |
| 58 | # include <initializer_list> | |
| 59 | # include <new> | |
| 60 | #endif | |
| 41 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 42 | # include <__cxx03/expected> | |
| 43 | #else | |
| 44 | # include <__config> | |
| 45 | ||
| 46 | # if _LIBCPP_STD_VER >= 23 | |
| 47 | # include <__expected/bad_expected_access.h> | |
| 48 | # include <__expected/expected.h> | |
| 49 | # include <__expected/unexpect.h> | |
| 50 | # include <__expected/unexpected.h> | |
| 51 | # endif | |
| 52 | ||
| 53 | # include <version> | |
| 54 | ||
| 55 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 56 | # pragma GCC system_header | |
| 57 | # endif | |
| 58 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 61 | 59 | |
| 62 | 60 | #endif // _LIBCPP_EXPECTED |
lib/libcxx/include/experimental/__config deleted-45| ... | ... | @@ -1,45 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_EXPERIMENTAL_CONFIG | |
| 11 | #define _LIBCPP_EXPERIMENTAL_CONFIG | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | #define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL \ | |
| 20 | namespace std { \ | |
| 21 | namespace experimental { | |
| 22 | #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL \ | |
| 23 | } \ | |
| 24 | } | |
| 25 | ||
| 26 | #define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 { | |
| 27 | #define _LIBCPP_END_NAMESPACE_LFTS \ | |
| 28 | } \ | |
| 29 | } \ | |
| 30 | } | |
| 31 | ||
| 32 | #define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 { | |
| 33 | #define _LIBCPP_END_NAMESPACE_LFTS_V2 \ | |
| 34 | } \ | |
| 35 | } \ | |
| 36 | } | |
| 37 | ||
| 38 | // TODO: support more targets | |
| 39 | #if defined(__AVX__) | |
| 40 | # define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 | |
| 41 | #else | |
| 42 | # define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 | |
| 43 | #endif | |
| 44 | ||
| 45 | #endif |
lib/libcxx/include/experimental/__simd/aligned_tag.h+2-2| ... | ... | @@ -10,10 +10,10 @@ |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_ALIGNED_TAG_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | #include <__cstddef/size_t.h> | |
| 13 | 15 | #include <__memory/assume_aligned.h> |
| 14 | 16 | #include <__type_traits/remove_const.h> |
| 15 | #include <cstddef> | |
| 16 | #include <experimental/__config> | |
| 17 | 17 | #include <experimental/__simd/traits.h> |
| 18 | 18 | |
| 19 | 19 | #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) |
lib/libcxx/include/experimental/__simd/declaration.h+9-2| ... | ... | @@ -10,11 +10,18 @@ |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_DECLARATION_H |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_DECLARATION_H |
| 12 | 12 | |
| 13 | #include <cstddef> | |
| 14 | #include <experimental/__config> | |
| 13 | #include <__config> | |
| 14 | #include <__cstddef/size_t.h> | |
| 15 | 15 | |
| 16 | 16 | #if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL) |
| 17 | 17 | |
| 18 | // TODO: support more targets | |
| 19 | # if defined(__AVX__) | |
| 20 | # define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 | |
| 21 | # else | |
| 22 | # define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 16 | |
| 23 | # endif | |
| 24 | ||
| 18 | 25 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL |
| 19 | 26 | inline namespace parallelism_v2 { |
| 20 | 27 | namespace simd_abi { |
lib/libcxx/include/experimental/__simd/reference.h+89-2| ... | ... | @@ -10,12 +10,14 @@ |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | #include <__cstddef/size_t.h> | |
| 15 | #include <__type_traits/enable_if.h> | |
| 13 | 16 | #include <__type_traits/is_assignable.h> |
| 14 | 17 | #include <__type_traits/is_same.h> |
| 18 | #include <__utility/declval.h> | |
| 15 | 19 | #include <__utility/forward.h> |
| 16 | 20 | #include <__utility/move.h> |
| 17 | #include <cstddef> | |
| 18 | #include <experimental/__config> | |
| 19 | 21 | #include <experimental/__simd/utility.h> |
| 20 | 22 | |
| 21 | 23 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -71,6 +73,91 @@ public: |
| 71 | 73 | |
| 72 | 74 | template <class _Tp1, class _Storage1, class _Vp1> |
| 73 | 75 | friend void swap(__simd_reference<_Tp1, _Storage1, _Vp1>&& __a, _Vp1& __b) noexcept; |
| 76 | ||
| 77 | template <class _Up, class = decltype(std::declval<value_type&>() += std::declval<_Up>())> | |
| 78 | _LIBCPP_HIDE_FROM_ABI __simd_reference operator+=(_Up&& __v) && noexcept { | |
| 79 | __set(__get() + static_cast<value_type>(std::forward<_Up>(__v))); | |
| 80 | return {__s_, __idx_}; | |
| 81 | } | |
| 82 | ||
| 83 | template <class _Up, class = decltype(std::declval<value_type&>() -= std::declval<_Up>())> | |
| 84 | _LIBCPP_HIDE_FROM_ABI __simd_reference operator-=(_Up&& __v) && noexcept { | |
| 85 | __set(__get() - static_cast<value_type>(std::forward<_Up>(__v))); | |
| 86 | return {__s_, __idx_}; | |
| 87 | } | |
| 88 | ||
| 89 | template <class _Up, class = decltype(std::declval<value_type&>() *= std::declval<_Up>())> | |
| 90 | _LIBCPP_HIDE_FROM_ABI __simd_reference operator*=(_Up&& __v) && noexcept { | |
| 91 | __set(__get() * static_cast<value_type>(std::forward<_Up>(__v))); | |
| 92 | return {__s_, __idx_}; | |
| 93 | } | |
| 94 | ||
| 95 | template <class _Up, class = decltype(std::declval<value_type&>() /= std::declval<_Up>())> | |
| 96 | _LIBCPP_HIDE_FROM_ABI __simd_reference operator/=(_Up&& __v) && noexcept { | |
| 97 | __set(__get() / static_cast<value_type>(std::forward<_Up>(__v))); | |
| 98 | return {__s_, __idx_}; | |
| 99 | } | |
| 100 | ||
| 101 | template <class _Up, class = decltype(std::declval<value_type&>() %= std::declval<_Up>())> | |
| 102 | _LIBCPP_HIDE_FROM_ABI __simd_reference operator%=(_Up&& __v) && noexcept { | |
| 103 | __set(__get() % static_cast<value_type>(std::forward<_Up>(__v))); | |
| 104 | return {__s_, __idx_}; | |
| 105 | } | |
| 106 | ||
| 107 | template <class _Up, class = decltype(std::declval<value_type&>() &= std::declval<_Up>())> | |
| 108 | _LIBCPP_HIDE_FROM_ABI __simd_reference operator&=(_Up&& __v) && noexcept { | |
| 109 | __set(__get() & static_cast<value_type>(std::forward<_Up>(__v))); | |
| 110 | return {__s_, __idx_}; | |
| 111 | } | |
| 112 | ||
| 113 | template <class _Up, class = decltype(std::declval<value_type&>() |= std::declval<_Up>())> | |
| 114 | _LIBCPP_HIDE_FROM_ABI __simd_reference operator|=(_Up&& __v) && noexcept { | |
| 115 | __set(__get() | static_cast<value_type>(std::forward<_Up>(__v))); | |
| 116 | return {__s_, __idx_}; | |
| 117 | } | |
| 118 | ||
| 119 | template <class _Up, class = decltype(std::declval<value_type&>() ^= std::declval<_Up>())> | |
| 120 | _LIBCPP_HIDE_FROM_ABI __simd_reference operator^=(_Up&& __v) && noexcept { | |
| 121 | __set(__get() ^ static_cast<value_type>(std::forward<_Up>(__v))); | |
| 122 | return {__s_, __idx_}; | |
| 123 | } | |
| 124 | ||
| 125 | template <class _Up, class = decltype(std::declval<value_type&>() <<= std::declval<_Up>())> | |
| 126 | _LIBCPP_HIDE_FROM_ABI __simd_reference operator<<=(_Up&& __v) && noexcept { | |
| 127 | __set(__get() << static_cast<value_type>(std::forward<_Up>(__v))); | |
| 128 | return {__s_, __idx_}; | |
| 129 | } | |
| 130 | ||
| 131 | template <class _Up, class = decltype(std::declval<value_type&>() >>= std::declval<_Up>())> | |
| 132 | _LIBCPP_HIDE_FROM_ABI __simd_reference operator>>=(_Up&& __v) && noexcept { | |
| 133 | __set(__get() >> static_cast<value_type>(std::forward<_Up>(__v))); | |
| 134 | return {__s_, __idx_}; | |
| 135 | } | |
| 136 | ||
| 137 | // Note: All legal vectorizable types support operator++/--. | |
| 138 | // There doesn't seem to be a way to trigger the constraint. | |
| 139 | // Therefore, no SFINAE check is added here. | |
| 140 | __simd_reference _LIBCPP_HIDE_FROM_ABI operator++() && noexcept { | |
| 141 | __set(__get() + 1); | |
| 142 | return {__s_, __idx_}; | |
| 143 | } | |
| 144 | ||
| 145 | value_type _LIBCPP_HIDE_FROM_ABI operator++(int) && noexcept { | |
| 146 | auto __r = __get(); | |
| 147 | __set(__get() + 1); | |
| 148 | return __r; | |
| 149 | } | |
| 150 | ||
| 151 | __simd_reference _LIBCPP_HIDE_FROM_ABI operator--() && noexcept { | |
| 152 | __set(__get() - 1); | |
| 153 | return {__s_, __idx_}; | |
| 154 | } | |
| 155 | ||
| 156 | value_type _LIBCPP_HIDE_FROM_ABI operator--(int) && noexcept { | |
| 157 | auto __r = __get(); | |
| 158 | __set(__get() - 1); | |
| 159 | return __r; | |
| 160 | } | |
| 74 | 161 | }; |
| 75 | 162 | |
| 76 | 163 | template <class _Tp, class _Storage, class _Vp> |
lib/libcxx/include/experimental/__simd/scalar.h+20-5| ... | ... | @@ -11,8 +11,9 @@ |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H |
| 12 | 12 | |
| 13 | 13 | #include <__assert> |
| 14 | #include <cstddef> | |
| 15 | #include <experimental/__config> | |
| 14 | #include <__config> | |
| 15 | #include <__cstddef/size_t.h> | |
| 16 | #include <__type_traits/integral_constant.h> | |
| 16 | 17 | #include <experimental/__simd/declaration.h> |
| 17 | 18 | #include <experimental/__simd/traits.h> |
| 18 | 19 | |
| ... | ... | @@ -48,8 +49,8 @@ struct __mask_storage<_Tp, simd_abi::__scalar> : __simd_storage<bool, simd_abi:: |
| 48 | 49 | |
| 49 | 50 | template <class _Tp> |
| 50 | 51 | struct __simd_operations<_Tp, simd_abi::__scalar> { |
| 51 | using _SimdStorage = __simd_storage<_Tp, simd_abi::__scalar>; | |
| 52 | using _MaskStorage = __mask_storage<_Tp, simd_abi::__scalar>; | |
| 52 | using _SimdStorage _LIBCPP_NODEBUG = __simd_storage<_Tp, simd_abi::__scalar>; | |
| 53 | using _MaskStorage _LIBCPP_NODEBUG = __mask_storage<_Tp, simd_abi::__scalar>; | |
| 53 | 54 | |
| 54 | 55 | static _LIBCPP_HIDE_FROM_ABI _SimdStorage __broadcast(_Tp __v) noexcept { return {__v}; } |
| 55 | 56 | |
| ... | ... | @@ -67,11 +68,25 @@ struct __simd_operations<_Tp, simd_abi::__scalar> { |
| 67 | 68 | static _LIBCPP_HIDE_FROM_ABI void __store(_SimdStorage __s, _Up* __mem) noexcept { |
| 68 | 69 | *__mem = static_cast<_Up>(__s.__data); |
| 69 | 70 | } |
| 71 | ||
| 72 | static _LIBCPP_HIDE_FROM_ABI void __increment(_SimdStorage& __s) noexcept { ++__s.__data; } | |
| 73 | ||
| 74 | static _LIBCPP_HIDE_FROM_ABI void __decrement(_SimdStorage& __s) noexcept { --__s.__data; } | |
| 75 | ||
| 76 | static _LIBCPP_HIDE_FROM_ABI _MaskStorage __negate(_SimdStorage __s) noexcept { return {!__s.__data}; } | |
| 77 | ||
| 78 | static _LIBCPP_HIDE_FROM_ABI _SimdStorage __bitwise_not(_SimdStorage __s) noexcept { | |
| 79 | return {static_cast<_Tp>(~__s.__data)}; | |
| 80 | } | |
| 81 | ||
| 82 | static _LIBCPP_HIDE_FROM_ABI _SimdStorage __unary_minus(_SimdStorage __s) noexcept { | |
| 83 | return {static_cast<_Tp>(-__s.__data)}; | |
| 84 | } | |
| 70 | 85 | }; |
| 71 | 86 | |
| 72 | 87 | template <class _Tp> |
| 73 | 88 | struct __mask_operations<_Tp, simd_abi::__scalar> { |
| 74 | using _MaskStorage = __mask_storage<_Tp, simd_abi::__scalar>; | |
| 89 | using _MaskStorage _LIBCPP_NODEBUG = __mask_storage<_Tp, simd_abi::__scalar>; | |
| 75 | 90 | |
| 76 | 91 | static _LIBCPP_HIDE_FROM_ABI _MaskStorage __broadcast(bool __v) noexcept { return {__v}; } |
| 77 | 92 |
lib/libcxx/include/experimental/__simd/simd.h+58-5| ... | ... | @@ -10,11 +10,13 @@ |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | #include <__cstddef/size_t.h> | |
| 15 | #include <__type_traits/enable_if.h> | |
| 16 | #include <__type_traits/is_integral.h> | |
| 13 | 17 | #include <__type_traits/is_same.h> |
| 14 | 18 | #include <__type_traits/remove_cvref.h> |
| 15 | 19 | #include <__utility/forward.h> |
| 16 | #include <cstddef> | |
| 17 | #include <experimental/__config> | |
| 18 | 20 | #include <experimental/__simd/declaration.h> |
| 19 | 21 | #include <experimental/__simd/reference.h> |
| 20 | 22 | #include <experimental/__simd/traits.h> |
| ... | ... | @@ -25,15 +27,29 @@ |
| 25 | 27 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL |
| 26 | 28 | inline namespace parallelism_v2 { |
| 27 | 29 | |
| 30 | template <class _Simd, class _Impl, bool> | |
| 31 | class __simd_int_operators {}; | |
| 32 | ||
| 33 | template <class _Simd, class _Impl> | |
| 34 | class __simd_int_operators<_Simd, _Impl, true> { | |
| 35 | public: | |
| 36 | // unary operators for integral _Tp | |
| 37 | _LIBCPP_HIDE_FROM_ABI _Simd operator~() const noexcept { | |
| 38 | return _Simd(_Impl::__bitwise_not((*static_cast<const _Simd*>(this)).__s_), _Simd::__storage_tag); | |
| 39 | } | |
| 40 | }; | |
| 41 | ||
| 28 | 42 | // class template simd [simd.class] |
| 29 | 43 | // TODO: implement simd class |
| 30 | 44 | template <class _Tp, class _Abi> |
| 31 | class simd { | |
| 32 | using _Impl = __simd_operations<_Tp, _Abi>; | |
| 33 | using _Storage = typename _Impl::_SimdStorage; | |
| 45 | class simd : public __simd_int_operators<simd<_Tp, _Abi>, __simd_operations<_Tp, _Abi>, is_integral_v<_Tp>> { | |
| 46 | using _Impl _LIBCPP_NODEBUG = __simd_operations<_Tp, _Abi>; | |
| 47 | using _Storage _LIBCPP_NODEBUG = typename _Impl::_SimdStorage; | |
| 34 | 48 | |
| 35 | 49 | _Storage __s_; |
| 36 | 50 | |
| 51 | friend class __simd_int_operators<simd, _Impl, true>; | |
| 52 | ||
| 37 | 53 | public: |
| 38 | 54 | using value_type = _Tp; |
| 39 | 55 | using reference = __simd_reference<_Tp, _Storage, value_type>; |
| ... | ... | @@ -44,6 +60,12 @@ public: |
| 44 | 60 | |
| 45 | 61 | _LIBCPP_HIDE_FROM_ABI simd() noexcept = default; |
| 46 | 62 | |
| 63 | // explicit conversion from and to implementation-defined types | |
| 64 | struct __storage_tag_t {}; | |
| 65 | static constexpr __storage_tag_t __storage_tag{}; | |
| 66 | explicit _LIBCPP_HIDE_FROM_ABI operator _Storage() const { return __s_; } | |
| 67 | explicit _LIBCPP_HIDE_FROM_ABI simd(const _Storage& __s, __storage_tag_t) : __s_(__s) {} | |
| 68 | ||
| 47 | 69 | // broadcast constructor |
| 48 | 70 | template <class _Up, enable_if_t<__can_broadcast_v<value_type, __remove_cvref_t<_Up>>, int> = 0> |
| 49 | 71 | _LIBCPP_HIDE_FROM_ABI simd(_Up&& __v) noexcept : __s_(_Impl::__broadcast(static_cast<value_type>(__v))) {} |
| ... | ... | @@ -84,6 +106,37 @@ public: |
| 84 | 106 | // scalar access [simd.subscr] |
| 85 | 107 | _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __i) noexcept { return reference(__s_, __i); } |
| 86 | 108 | _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const noexcept { return __s_.__get(__i); } |
| 109 | ||
| 110 | // simd unary operators | |
| 111 | _LIBCPP_HIDE_FROM_ABI simd& operator++() noexcept { | |
| 112 | _Impl::__increment(__s_); | |
| 113 | return *this; | |
| 114 | } | |
| 115 | ||
| 116 | _LIBCPP_HIDE_FROM_ABI simd operator++(int) noexcept { | |
| 117 | simd __r = *this; | |
| 118 | _Impl::__increment(__s_); | |
| 119 | return __r; | |
| 120 | } | |
| 121 | ||
| 122 | _LIBCPP_HIDE_FROM_ABI simd& operator--() noexcept { | |
| 123 | _Impl::__decrement(__s_); | |
| 124 | return *this; | |
| 125 | } | |
| 126 | ||
| 127 | _LIBCPP_HIDE_FROM_ABI simd operator--(int) noexcept { | |
| 128 | simd __r = *this; | |
| 129 | _Impl::__decrement(__s_); | |
| 130 | return __r; | |
| 131 | } | |
| 132 | ||
| 133 | _LIBCPP_HIDE_FROM_ABI mask_type operator!() const noexcept { | |
| 134 | return mask_type(_Impl::__negate(__s_), mask_type::__storage_tag); | |
| 135 | } | |
| 136 | ||
| 137 | _LIBCPP_HIDE_FROM_ABI simd operator+() const noexcept { return *this; } | |
| 138 | ||
| 139 | _LIBCPP_HIDE_FROM_ABI simd operator-() const noexcept { return simd(_Impl::__unary_minus(__s_), __storage_tag); } | |
| 87 | 140 | }; |
| 88 | 141 | |
| 89 | 142 | template <class _Tp, class _Abi> |
lib/libcxx/include/experimental/__simd/simd_mask.h+11-4| ... | ... | @@ -10,9 +10,10 @@ |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_SIMD_MASK_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | #include <__cstddef/size_t.h> | |
| 15 | #include <__type_traits/enable_if.h> | |
| 13 | 16 | #include <__type_traits/is_same.h> |
| 14 | #include <cstddef> | |
| 15 | #include <experimental/__config> | |
| 16 | 17 | #include <experimental/__simd/declaration.h> |
| 17 | 18 | #include <experimental/__simd/reference.h> |
| 18 | 19 | #include <experimental/__simd/traits.h> |
| ... | ... | @@ -26,8 +27,8 @@ inline namespace parallelism_v2 { |
| 26 | 27 | // TODO: implement simd_mask class |
| 27 | 28 | template <class _Tp, class _Abi> |
| 28 | 29 | class simd_mask { |
| 29 | using _Impl = __mask_operations<_Tp, _Abi>; | |
| 30 | using _Storage = typename _Impl::_MaskStorage; | |
| 30 | using _Impl _LIBCPP_NODEBUG = __mask_operations<_Tp, _Abi>; | |
| 31 | using _Storage _LIBCPP_NODEBUG = typename _Impl::_MaskStorage; | |
| 31 | 32 | |
| 32 | 33 | _Storage __s_; |
| 33 | 34 | |
| ... | ... | @@ -41,6 +42,12 @@ public: |
| 41 | 42 | |
| 42 | 43 | _LIBCPP_HIDE_FROM_ABI simd_mask() noexcept = default; |
| 43 | 44 | |
| 45 | // explicit conversion from and to implementation-defined types | |
| 46 | struct __storage_tag_t {}; | |
| 47 | static constexpr __storage_tag_t __storage_tag{}; | |
| 48 | explicit _LIBCPP_HIDE_FROM_ABI operator _Storage() const { return __s_; } | |
| 49 | explicit _LIBCPP_HIDE_FROM_ABI simd_mask(const _Storage& __s, __storage_tag_t) : __s_(__s) {} | |
| 50 | ||
| 44 | 51 | // broadcast constructor |
| 45 | 52 | _LIBCPP_HIDE_FROM_ABI explicit simd_mask(value_type __v) noexcept : __s_(_Impl::__broadcast(__v)) {} |
| 46 | 53 |
lib/libcxx/include/experimental/__simd/traits.h+2-2| ... | ... | @@ -11,10 +11,10 @@ |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_TRAITS_H |
| 12 | 12 | |
| 13 | 13 | #include <__bit/bit_ceil.h> |
| 14 | #include <__config> | |
| 15 | #include <__cstddef/size_t.h> | |
| 14 | 16 | #include <__type_traits/integral_constant.h> |
| 15 | 17 | #include <__type_traits/is_same.h> |
| 16 | #include <cstddef> | |
| 17 | #include <experimental/__config> | |
| 18 | 18 | #include <experimental/__simd/declaration.h> |
| 19 | 19 | #include <experimental/__simd/utility.h> |
| 20 | 20 |
lib/libcxx/include/experimental/__simd/utility.h+3-3| ... | ... | @@ -10,6 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL___SIMD_UTILITY_H |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL___SIMD_UTILITY_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | #include <__cstddef/size_t.h> | |
| 13 | 15 | #include <__type_traits/is_arithmetic.h> |
| 14 | 16 | #include <__type_traits/is_const.h> |
| 15 | 17 | #include <__type_traits/is_constant_evaluated.h> |
| ... | ... | @@ -20,9 +22,7 @@ |
| 20 | 22 | #include <__type_traits/void_t.h> |
| 21 | 23 | #include <__utility/declval.h> |
| 22 | 24 | #include <__utility/integer_sequence.h> |
| 23 | #include <cstddef> | |
| 24 | 25 | #include <cstdint> |
| 25 | #include <experimental/__config> | |
| 26 | 26 | #include <limits> |
| 27 | 27 | |
| 28 | 28 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -47,7 +47,7 @@ _LIBCPP_HIDE_FROM_ABI auto __choose_mask_type() { |
| 47 | 47 | } else if constexpr (sizeof(_Tp) == 8) { |
| 48 | 48 | return uint64_t{}; |
| 49 | 49 | } |
| 50 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 50 | # if _LIBCPP_HAS_INT128 | |
| 51 | 51 | else if constexpr (sizeof(_Tp) == 16) { |
| 52 | 52 | return __uint128_t{}; |
| 53 | 53 | } |
lib/libcxx/include/experimental/__simd/vec_ext.h+18-7| ... | ... | @@ -12,10 +12,11 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__assert> |
| 14 | 14 | #include <__bit/bit_ceil.h> |
| 15 | #include <__config> | |
| 16 | #include <__cstddef/size_t.h> | |
| 17 | #include <__type_traits/integral_constant.h> | |
| 15 | 18 | #include <__utility/forward.h> |
| 16 | 19 | #include <__utility/integer_sequence.h> |
| 17 | #include <cstddef> | |
| 18 | #include <experimental/__config> | |
| 19 | 20 | #include <experimental/__simd/declaration.h> |
| 20 | 21 | #include <experimental/__simd/traits.h> |
| 21 | 22 | #include <experimental/__simd/utility.h> |
| ... | ... | @@ -39,11 +40,11 @@ struct __simd_storage<_Tp, simd_abi::__vec_ext<_Np>> { |
| 39 | 40 | _Tp __data __attribute__((__vector_size__(std::__bit_ceil((sizeof(_Tp) * _Np))))); |
| 40 | 41 | |
| 41 | 42 | _LIBCPP_HIDE_FROM_ABI _Tp __get(size_t __idx) const noexcept { |
| 42 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds"); | |
| 43 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < _Np, "Index is out of bounds"); | |
| 43 | 44 | return __data[__idx]; |
| 44 | 45 | } |
| 45 | 46 | _LIBCPP_HIDE_FROM_ABI void __set(size_t __idx, _Tp __v) noexcept { |
| 46 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds"); | |
| 47 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < _Np, "Index is out of bounds"); | |
| 47 | 48 | __data[__idx] = __v; |
| 48 | 49 | } |
| 49 | 50 | }; |
| ... | ... | @@ -54,8 +55,8 @@ struct __mask_storage<_Tp, simd_abi::__vec_ext<_Np>> |
| 54 | 55 | |
| 55 | 56 | template <class _Tp, int _Np> |
| 56 | 57 | struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> { |
| 57 | using _SimdStorage = __simd_storage<_Tp, simd_abi::__vec_ext<_Np>>; | |
| 58 | using _MaskStorage = __mask_storage<_Tp, simd_abi::__vec_ext<_Np>>; | |
| 58 | using _SimdStorage _LIBCPP_NODEBUG = __simd_storage<_Tp, simd_abi::__vec_ext<_Np>>; | |
| 59 | using _MaskStorage _LIBCPP_NODEBUG = __mask_storage<_Tp, simd_abi::__vec_ext<_Np>>; | |
| 59 | 60 | |
| 60 | 61 | static _LIBCPP_HIDE_FROM_ABI _SimdStorage __broadcast(_Tp __v) noexcept { |
| 61 | 62 | _SimdStorage __result; |
| ... | ... | @@ -86,11 +87,21 @@ struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> { |
| 86 | 87 | for (size_t __i = 0; __i < _Np; __i++) |
| 87 | 88 | __mem[__i] = static_cast<_Up>(__s.__data[__i]); |
| 88 | 89 | } |
| 90 | ||
| 91 | static _LIBCPP_HIDE_FROM_ABI void __increment(_SimdStorage& __s) noexcept { __s.__data = __s.__data + 1; } | |
| 92 | ||
| 93 | static _LIBCPP_HIDE_FROM_ABI void __decrement(_SimdStorage& __s) noexcept { __s.__data = __s.__data - 1; } | |
| 94 | ||
| 95 | static _LIBCPP_HIDE_FROM_ABI _MaskStorage __negate(_SimdStorage __s) noexcept { return {!__s.__data}; } | |
| 96 | ||
| 97 | static _LIBCPP_HIDE_FROM_ABI _SimdStorage __bitwise_not(_SimdStorage __s) noexcept { return {~__s.__data}; } | |
| 98 | ||
| 99 | static _LIBCPP_HIDE_FROM_ABI _SimdStorage __unary_minus(_SimdStorage __s) noexcept { return {-__s.__data}; } | |
| 89 | 100 | }; |
| 90 | 101 | |
| 91 | 102 | template <class _Tp, int _Np> |
| 92 | 103 | struct __mask_operations<_Tp, simd_abi::__vec_ext<_Np>> { |
| 93 | using _MaskStorage = __mask_storage<_Tp, simd_abi::__vec_ext<_Np>>; | |
| 104 | using _MaskStorage _LIBCPP_NODEBUG = __mask_storage<_Tp, simd_abi::__vec_ext<_Np>>; | |
| 94 | 105 | |
| 95 | 106 | static _LIBCPP_HIDE_FROM_ABI _MaskStorage __broadcast(bool __v) noexcept { |
| 96 | 107 | _MaskStorage __result; |
lib/libcxx/include/experimental/iterator+24-17| ... | ... | @@ -52,21 +52,26 @@ namespace std { |
| 52 | 52 | |
| 53 | 53 | */ |
| 54 | 54 | |
| 55 | #include <__memory/addressof.h> | |
| 56 | #include <__type_traits/decay.h> | |
| 57 | #include <__utility/forward.h> | |
| 58 | #include <__utility/move.h> | |
| 59 | #include <experimental/__config> | |
| 60 | #include <iterator> | |
| 61 | ||
| 62 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 63 | # pragma GCC system_header | |
| 64 | #endif | |
| 55 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 56 | # include <__cxx03/experimental/iterator> | |
| 57 | #else | |
| 58 | # include <__config> | |
| 59 | # include <__memory/addressof.h> | |
| 60 | # include <__ostream/basic_ostream.h> | |
| 61 | # include <__string/char_traits.h> | |
| 62 | # include <__type_traits/decay.h> | |
| 63 | # include <__utility/forward.h> | |
| 64 | # include <__utility/move.h> | |
| 65 | # include <iterator> | |
| 66 | ||
| 67 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 68 | # pragma GCC system_header | |
| 69 | # endif | |
| 65 | 70 | |
| 66 | 71 | _LIBCPP_PUSH_MACROS |
| 67 | #include <__undef_macros> | |
| 72 | # include <__undef_macros> | |
| 68 | 73 | |
| 69 | #if _LIBCPP_STD_VER >= 14 | |
| 74 | # if _LIBCPP_STD_VER >= 14 | |
| 70 | 75 | |
| 71 | 76 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 72 | 77 | |
| ... | ... | @@ -115,13 +120,15 @@ make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim&& __d) { |
| 115 | 120 | |
| 116 | 121 | _LIBCPP_END_NAMESPACE_LFTS |
| 117 | 122 | |
| 118 | #endif // _LIBCPP_STD_VER >= 14 | |
| 123 | # endif // _LIBCPP_STD_VER >= 14 | |
| 119 | 124 | |
| 120 | 125 | _LIBCPP_POP_MACROS |
| 121 | 126 | |
| 122 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 123 | # include <iosfwd> | |
| 124 | # include <type_traits> | |
| 125 | #endif | |
| 127 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 128 | # include <cstddef> | |
| 129 | # include <iosfwd> | |
| 130 | # include <type_traits> | |
| 131 | # endif | |
| 132 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 126 | 133 | |
| 127 | 134 | #endif // _LIBCPP_EXPERIMENTAL_ITERATOR |
lib/libcxx/include/experimental/memory+30-23| ... | ... | @@ -49,25 +49,30 @@ public: |
| 49 | 49 | } |
| 50 | 50 | */ |
| 51 | 51 | |
| 52 | #include <__functional/hash.h> | |
| 53 | #include <__functional/operations.h> | |
| 54 | #include <__type_traits/add_lvalue_reference.h> | |
| 55 | #include <__type_traits/add_pointer.h> | |
| 56 | #include <__type_traits/common_type.h> | |
| 57 | #include <__type_traits/enable_if.h> | |
| 58 | #include <__type_traits/is_convertible.h> | |
| 59 | #include <cstddef> | |
| 60 | #include <experimental/__config> | |
| 61 | ||
| 62 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 63 | # pragma GCC system_header | |
| 64 | #endif | |
| 65 | ||
| 66 | #ifdef _LIBCPP_ENABLE_EXPERIMENTAL | |
| 52 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 53 | # include <__cxx03/experimental/memory> | |
| 54 | #else | |
| 55 | # include <__config> | |
| 56 | # include <__cstddef/nullptr_t.h> | |
| 57 | # include <__cstddef/size_t.h> | |
| 58 | # include <__functional/hash.h> | |
| 59 | # include <__functional/operations.h> | |
| 60 | # include <__type_traits/add_lvalue_reference.h> | |
| 61 | # include <__type_traits/add_pointer.h> | |
| 62 | # include <__type_traits/common_type.h> | |
| 63 | # include <__type_traits/enable_if.h> | |
| 64 | # include <__type_traits/is_convertible.h> | |
| 65 | # include <version> | |
| 66 | ||
| 67 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 68 | # pragma GCC system_header | |
| 69 | # endif | |
| 70 | ||
| 71 | # ifdef _LIBCPP_ENABLE_EXPERIMENTAL | |
| 67 | 72 | |
| 68 | 73 | _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 |
| 69 | 74 | |
| 70 | # if _LIBCPP_STD_VER >= 17 | |
| 75 | # if _LIBCPP_STD_VER >= 17 | |
| 71 | 76 | |
| 72 | 77 | template <class _Wp> |
| 73 | 78 | class observer_ptr { |
| ... | ... | @@ -170,7 +175,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator>=(observer_ptr<_W1> __a, observer_ptr<_W2> _ |
| 170 | 175 | return !(__a < __b); |
| 171 | 176 | } |
| 172 | 177 | |
| 173 | # endif // _LIBCPP_STD_VER >= 17 | |
| 178 | # endif // _LIBCPP_STD_VER >= 17 | |
| 174 | 179 | |
| 175 | 180 | _LIBCPP_END_NAMESPACE_LFTS_V2 |
| 176 | 181 | |
| ... | ... | @@ -178,21 +183,23 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 178 | 183 | |
| 179 | 184 | // hash |
| 180 | 185 | |
| 181 | # if _LIBCPP_STD_VER >= 17 | |
| 186 | # if _LIBCPP_STD_VER >= 17 | |
| 182 | 187 | template <class _Tp> |
| 183 | 188 | struct hash<experimental::observer_ptr<_Tp>> { |
| 184 | 189 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const experimental::observer_ptr<_Tp>& __ptr) const noexcept { |
| 185 | 190 | return hash<_Tp*>()(__ptr.get()); |
| 186 | 191 | } |
| 187 | 192 | }; |
| 188 | # endif // _LIBCPP_STD_VER >= 17 | |
| 193 | # endif // _LIBCPP_STD_VER >= 17 | |
| 189 | 194 | |
| 190 | 195 | _LIBCPP_END_NAMESPACE_STD |
| 191 | 196 | |
| 192 | #endif // _LIBCPP_ENABLE_EXPERIMENTAL | |
| 197 | # endif // _LIBCPP_ENABLE_EXPERIMENTAL | |
| 193 | 198 | |
| 194 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 195 | # include <limits> | |
| 196 | #endif | |
| 199 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 200 | # include <cstddef> | |
| 201 | # include <limits> | |
| 202 | # endif | |
| 203 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 197 | 204 | |
| 198 | 205 | #endif /* _LIBCPP_EXPERIMENTAL_MEMORY */ |
lib/libcxx/include/experimental/propagate_const+39-32| ... | ... | @@ -107,37 +107,42 @@ |
| 107 | 107 | |
| 108 | 108 | */ |
| 109 | 109 | |
| 110 | #include <__functional/operations.h> | |
| 111 | #include <__fwd/functional.h> | |
| 112 | #include <__type_traits/conditional.h> | |
| 113 | #include <__type_traits/decay.h> | |
| 114 | #include <__type_traits/enable_if.h> | |
| 115 | #include <__type_traits/is_array.h> | |
| 116 | #include <__type_traits/is_constructible.h> | |
| 117 | #include <__type_traits/is_convertible.h> | |
| 118 | #include <__type_traits/is_function.h> | |
| 119 | #include <__type_traits/is_pointer.h> | |
| 120 | #include <__type_traits/is_reference.h> | |
| 121 | #include <__type_traits/is_same.h> | |
| 122 | #include <__type_traits/is_swappable.h> | |
| 123 | #include <__type_traits/remove_cv.h> | |
| 124 | #include <__type_traits/remove_pointer.h> | |
| 125 | #include <__type_traits/remove_reference.h> | |
| 126 | #include <__utility/declval.h> | |
| 127 | #include <__utility/forward.h> | |
| 128 | #include <__utility/move.h> | |
| 129 | #include <__utility/swap.h> | |
| 130 | #include <cstddef> | |
| 131 | #include <experimental/__config> | |
| 132 | ||
| 133 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 134 | # pragma GCC system_header | |
| 135 | #endif | |
| 110 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 111 | # include <__cxx03/experimental/propagate_const> | |
| 112 | #else | |
| 113 | # include <__config> | |
| 114 | # include <__cstddef/nullptr_t.h> | |
| 115 | # include <__cstddef/size_t.h> | |
| 116 | # include <__functional/operations.h> | |
| 117 | # include <__fwd/functional.h> | |
| 118 | # include <__type_traits/conditional.h> | |
| 119 | # include <__type_traits/decay.h> | |
| 120 | # include <__type_traits/enable_if.h> | |
| 121 | # include <__type_traits/is_array.h> | |
| 122 | # include <__type_traits/is_constructible.h> | |
| 123 | # include <__type_traits/is_convertible.h> | |
| 124 | # include <__type_traits/is_function.h> | |
| 125 | # include <__type_traits/is_pointer.h> | |
| 126 | # include <__type_traits/is_reference.h> | |
| 127 | # include <__type_traits/is_same.h> | |
| 128 | # include <__type_traits/is_swappable.h> | |
| 129 | # include <__type_traits/remove_cv.h> | |
| 130 | # include <__type_traits/remove_pointer.h> | |
| 131 | # include <__type_traits/remove_reference.h> | |
| 132 | # include <__utility/declval.h> | |
| 133 | # include <__utility/forward.h> | |
| 134 | # include <__utility/move.h> | |
| 135 | # include <__utility/swap.h> | |
| 136 | # include <version> | |
| 137 | ||
| 138 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 139 | # pragma GCC system_header | |
| 140 | # endif | |
| 136 | 141 | |
| 137 | 142 | _LIBCPP_PUSH_MACROS |
| 138 | #include <__undef_macros> | |
| 143 | # include <__undef_macros> | |
| 139 | 144 | |
| 140 | #if _LIBCPP_STD_VER >= 14 | |
| 145 | # if _LIBCPP_STD_VER >= 14 | |
| 141 | 146 | |
| 142 | 147 | _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 |
| 143 | 148 | |
| ... | ... | @@ -479,12 +484,14 @@ struct greater_equal<experimental::propagate_const<_Tp>> { |
| 479 | 484 | |
| 480 | 485 | _LIBCPP_END_NAMESPACE_STD |
| 481 | 486 | |
| 482 | #endif // _LIBCPP_STD_VER >= 14 | |
| 487 | # endif // _LIBCPP_STD_VER >= 14 | |
| 483 | 488 | |
| 484 | 489 | _LIBCPP_POP_MACROS |
| 485 | 490 | |
| 486 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 487 | # include <type_traits> | |
| 488 | #endif | |
| 491 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 492 | # include <cstddef> | |
| 493 | # include <type_traits> | |
| 494 | # endif | |
| 495 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 489 | 496 | |
| 490 | 497 | #endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST |
lib/libcxx/include/experimental/simd+17-9| ... | ... | @@ -75,14 +75,22 @@ inline namespace parallelism_v2 { |
| 75 | 75 | # pragma GCC system_header |
| 76 | 76 | #endif |
| 77 | 77 | |
| 78 | #include <experimental/__config> | |
| 79 | #include <experimental/__simd/aligned_tag.h> | |
| 80 | #include <experimental/__simd/declaration.h> | |
| 81 | #include <experimental/__simd/reference.h> | |
| 82 | #include <experimental/__simd/scalar.h> | |
| 83 | #include <experimental/__simd/simd.h> | |
| 84 | #include <experimental/__simd/simd_mask.h> | |
| 85 | #include <experimental/__simd/traits.h> | |
| 86 | #include <experimental/__simd/vec_ext.h> | |
| 78 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 79 | # include <__cxx03/experimental/simd> | |
| 80 | #else | |
| 81 | # include <__config> | |
| 82 | # include <experimental/__simd/aligned_tag.h> | |
| 83 | # include <experimental/__simd/declaration.h> | |
| 84 | # include <experimental/__simd/reference.h> | |
| 85 | # include <experimental/__simd/scalar.h> | |
| 86 | # include <experimental/__simd/simd.h> | |
| 87 | # include <experimental/__simd/simd_mask.h> | |
| 88 | # include <experimental/__simd/traits.h> | |
| 89 | # include <experimental/__simd/vec_ext.h> | |
| 90 | ||
| 91 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 92 | # include <cstddef> | |
| 93 | # endif | |
| 94 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 87 | 95 | |
| 88 | 96 | #endif /* _LIBCPP_EXPERIMENTAL_SIMD */ |
lib/libcxx/include/experimental/type_traits+16-8| ... | ... | @@ -68,16 +68,19 @@ inline namespace fundamentals_v1 { |
| 68 | 68 | |
| 69 | 69 | */ |
| 70 | 70 | |
| 71 | #include <experimental/__config> | |
| 71 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 72 | # include <__cxx03/experimental/type_traits> | |
| 73 | #else | |
| 74 | # include <__config> | |
| 72 | 75 | |
| 73 | #if _LIBCPP_STD_VER >= 14 | |
| 76 | # if _LIBCPP_STD_VER >= 14 | |
| 74 | 77 | |
| 75 | # include <initializer_list> | |
| 76 | # include <type_traits> | |
| 78 | # include <initializer_list> | |
| 79 | # include <type_traits> | |
| 77 | 80 | |
| 78 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 79 | # pragma GCC system_header | |
| 80 | # endif | |
| 81 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 82 | # pragma GCC system_header | |
| 83 | # endif | |
| 81 | 84 | |
| 82 | 85 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 83 | 86 | |
| ... | ... | @@ -148,6 +151,11 @@ constexpr bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Ar |
| 148 | 151 | |
| 149 | 152 | _LIBCPP_END_NAMESPACE_LFTS |
| 150 | 153 | |
| 151 | #endif /* _LIBCPP_STD_VER >= 14 */ | |
| 154 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 155 | # include <cstddef> | |
| 156 | # endif | |
| 157 | ||
| 158 | # endif /* _LIBCPP_STD_VER >= 14 */ | |
| 159 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 152 | 160 | |
| 153 | 161 | #endif /* _LIBCPP_EXPERIMENTAL_TYPE_TRAITS */ |
lib/libcxx/include/experimental/utility+13-5| ... | ... | @@ -30,12 +30,15 @@ inline namespace fundamentals_v1 { |
| 30 | 30 | |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | #include <experimental/__config> | |
| 34 | #include <utility> | |
| 33 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 34 | # include <__cxx03/experimental/utility> | |
| 35 | #else | |
| 36 | # include <__config> | |
| 37 | # include <utility> | |
| 35 | 38 | |
| 36 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 37 | # pragma GCC system_header | |
| 38 | #endif | |
| 39 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 40 | # pragma GCC system_header | |
| 41 | # endif | |
| 39 | 42 | |
| 40 | 43 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 41 | 44 | |
| ... | ... | @@ -43,4 +46,9 @@ struct _LIBCPP_TEMPLATE_VIS erased_type {}; |
| 43 | 46 | |
| 44 | 47 | _LIBCPP_END_NAMESPACE_LFTS |
| 45 | 48 | |
| 49 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 50 | # include <cstddef> | |
| 51 | # endif | |
| 52 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 53 | ||
| 46 | 54 | #endif /* _LIBCPP_EXPERIMENTAL_UTILITY */ |
lib/libcxx/include/ext/hash_map+26-22| ... | ... | @@ -201,23 +201,26 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 201 | 201 | |
| 202 | 202 | */ |
| 203 | 203 | |
| 204 | #include <__config> | |
| 205 | #include <__hash_table> | |
| 206 | #include <algorithm> | |
| 207 | #include <ext/__hash> | |
| 208 | #include <functional> | |
| 209 | ||
| 210 | #if defined(__DEPRECATED) && __DEPRECATED | |
| 211 | # if defined(_LIBCPP_WARNING) | |
| 204 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 205 | # include <__cxx03/ext/hash_map> | |
| 206 | #else | |
| 207 | # include <__config> | |
| 208 | # include <__hash_table> | |
| 209 | # include <algorithm> | |
| 210 | # include <ext/__hash> | |
| 211 | # include <functional> | |
| 212 | ||
| 213 | # if defined(__DEPRECATED) && __DEPRECATED | |
| 214 | # if defined(_LIBCPP_WARNING) | |
| 212 | 215 | _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>") |
| 213 | # else | |
| 214 | # warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map> | |
| 216 | # else | |
| 217 | # warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map> | |
| 218 | # endif | |
| 215 | 219 | # endif |
| 216 | #endif | |
| 217 | 220 | |
| 218 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 219 | # pragma GCC system_header | |
| 220 | #endif | |
| 221 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 222 | # pragma GCC system_header | |
| 223 | # endif | |
| 221 | 224 | |
| 222 | 225 | namespace __gnu_cxx { |
| 223 | 226 | |
| ... | ... | @@ -312,17 +315,17 @@ public: |
| 312 | 315 | _LIBCPP_HIDE_FROM_ABI explicit __hash_map_node_destructor(allocator_type& __na) |
| 313 | 316 | : __na_(__na), __first_constructed(false), __second_constructed(false) {} |
| 314 | 317 | |
| 315 | #ifndef _LIBCPP_CXX03_LANG | |
| 318 | # ifndef _LIBCPP_CXX03_LANG | |
| 316 | 319 | _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(std::__hash_node_destructor<allocator_type>&& __x) |
| 317 | 320 | : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) { |
| 318 | 321 | __x.__value_constructed = false; |
| 319 | 322 | } |
| 320 | #else // _LIBCPP_CXX03_LANG | |
| 323 | # else // _LIBCPP_CXX03_LANG | |
| 321 | 324 | _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(const std::__hash_node_destructor<allocator_type>& __x) |
| 322 | 325 | : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) { |
| 323 | 326 | const_cast<bool&>(__x.__value_constructed) = false; |
| 324 | 327 | } |
| 325 | #endif // _LIBCPP_CXX03_LANG | |
| 328 | # endif // _LIBCPP_CXX03_LANG | |
| 326 | 329 | |
| 327 | 330 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) { |
| 328 | 331 | if (__second_constructed) |
| ... | ... | @@ -863,10 +866,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const hash_multimap<_Key, _Tp, _Has |
| 863 | 866 | |
| 864 | 867 | } // namespace __gnu_cxx |
| 865 | 868 | |
| 866 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 867 | # include <concepts> | |
| 868 | # include <iterator> | |
| 869 | # include <type_traits> | |
| 870 | #endif | |
| 869 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 870 | # include <concepts> | |
| 871 | # include <iterator> | |
| 872 | # include <type_traits> | |
| 873 | # endif | |
| 874 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 871 | 875 | |
| 872 | 876 | #endif // _LIBCPP_HASH_MAP |
lib/libcxx/include/ext/hash_set+23-19| ... | ... | @@ -192,23 +192,26 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 192 | 192 | |
| 193 | 193 | */ |
| 194 | 194 | |
| 195 | #include <__config> | |
| 196 | #include <__hash_table> | |
| 197 | #include <algorithm> | |
| 198 | #include <ext/__hash> | |
| 199 | #include <functional> | |
| 200 | ||
| 201 | #if defined(__DEPRECATED) && __DEPRECATED | |
| 202 | # if defined(_LIBCPP_WARNING) | |
| 195 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 196 | # include <__cxx03/ext/hash_set> | |
| 197 | #else | |
| 198 | # include <__config> | |
| 199 | # include <__hash_table> | |
| 200 | # include <algorithm> | |
| 201 | # include <ext/__hash> | |
| 202 | # include <functional> | |
| 203 | ||
| 204 | # if defined(__DEPRECATED) && __DEPRECATED | |
| 205 | # if defined(_LIBCPP_WARNING) | |
| 203 | 206 | _LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>") |
| 204 | # else | |
| 205 | # warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set> | |
| 207 | # else | |
| 208 | # warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set> | |
| 209 | # endif | |
| 206 | 210 | # endif |
| 207 | #endif | |
| 208 | 211 | |
| 209 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 210 | # pragma GCC system_header | |
| 211 | #endif | |
| 212 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 213 | # pragma GCC system_header | |
| 214 | # endif | |
| 212 | 215 | |
| 213 | 216 | namespace __gnu_cxx { |
| 214 | 217 | |
| ... | ... | @@ -575,10 +578,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const hash_multiset<_Value, _Hash, |
| 575 | 578 | |
| 576 | 579 | } // namespace __gnu_cxx |
| 577 | 580 | |
| 578 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 579 | # include <concepts> | |
| 580 | # include <iterator> | |
| 581 | # include <type_traits> | |
| 582 | #endif | |
| 581 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 582 | # include <concepts> | |
| 583 | # include <iterator> | |
| 584 | # include <type_traits> | |
| 585 | # endif | |
| 586 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 583 | 587 | |
| 584 | 588 | #endif // _LIBCPP_HASH_SET |
lib/libcxx/include/fenv.h+46-42| ... | ... | @@ -49,66 +49,70 @@ int feupdateenv(const fenv_t* envp); |
| 49 | 49 | |
| 50 | 50 | */ |
| 51 | 51 | |
| 52 | #include <__config> | |
| 52 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 53 | # include <__cxx03/fenv.h> | |
| 54 | #else | |
| 55 | # include <__config> | |
| 53 | 56 | |
| 54 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 55 | # pragma GCC system_header | |
| 56 | #endif | |
| 57 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 58 | # pragma GCC system_header | |
| 59 | # endif | |
| 57 | 60 | |
| 58 | #if __has_include_next(<fenv.h>) | |
| 59 | # include_next <fenv.h> | |
| 60 | #endif | |
| 61 | # if __has_include_next(<fenv.h>) | |
| 62 | # include_next <fenv.h> | |
| 63 | # endif | |
| 61 | 64 | |
| 62 | #ifdef __cplusplus | |
| 65 | # ifdef __cplusplus | |
| 63 | 66 | |
| 64 | 67 | extern "C++" { |
| 65 | 68 | |
| 66 | # ifdef feclearexcept | |
| 67 | # undef feclearexcept | |
| 68 | # endif | |
| 69 | # ifdef feclearexcept | |
| 70 | # undef feclearexcept | |
| 71 | # endif | |
| 69 | 72 | |
| 70 | # ifdef fegetexceptflag | |
| 71 | # undef fegetexceptflag | |
| 72 | # endif | |
| 73 | # ifdef fegetexceptflag | |
| 74 | # undef fegetexceptflag | |
| 75 | # endif | |
| 73 | 76 | |
| 74 | # ifdef feraiseexcept | |
| 75 | # undef feraiseexcept | |
| 76 | # endif | |
| 77 | # ifdef feraiseexcept | |
| 78 | # undef feraiseexcept | |
| 79 | # endif | |
| 77 | 80 | |
| 78 | # ifdef fesetexceptflag | |
| 79 | # undef fesetexceptflag | |
| 80 | # endif | |
| 81 | # ifdef fesetexceptflag | |
| 82 | # undef fesetexceptflag | |
| 83 | # endif | |
| 81 | 84 | |
| 82 | # ifdef fetestexcept | |
| 83 | # undef fetestexcept | |
| 84 | # endif | |
| 85 | # ifdef fetestexcept | |
| 86 | # undef fetestexcept | |
| 87 | # endif | |
| 85 | 88 | |
| 86 | # ifdef fegetround | |
| 87 | # undef fegetround | |
| 88 | # endif | |
| 89 | # ifdef fegetround | |
| 90 | # undef fegetround | |
| 91 | # endif | |
| 89 | 92 | |
| 90 | # ifdef fesetround | |
| 91 | # undef fesetround | |
| 92 | # endif | |
| 93 | # ifdef fesetround | |
| 94 | # undef fesetround | |
| 95 | # endif | |
| 93 | 96 | |
| 94 | # ifdef fegetenv | |
| 95 | # undef fegetenv | |
| 96 | # endif | |
| 97 | # ifdef fegetenv | |
| 98 | # undef fegetenv | |
| 99 | # endif | |
| 97 | 100 | |
| 98 | # ifdef feholdexcept | |
| 99 | # undef feholdexcept | |
| 100 | # endif | |
| 101 | # ifdef feholdexcept | |
| 102 | # undef feholdexcept | |
| 103 | # endif | |
| 101 | 104 | |
| 102 | # ifdef fesetenv | |
| 103 | # undef fesetenv | |
| 104 | # endif | |
| 105 | # ifdef fesetenv | |
| 106 | # undef fesetenv | |
| 107 | # endif | |
| 105 | 108 | |
| 106 | # ifdef feupdateenv | |
| 107 | # undef feupdateenv | |
| 108 | # endif | |
| 109 | # ifdef feupdateenv | |
| 110 | # undef feupdateenv | |
| 111 | # endif | |
| 109 | 112 | |
| 110 | 113 | } // extern "C++" |
| 111 | 114 | |
| 112 | #endif // defined(__cplusplus) | |
| 115 | # endif // defined(__cplusplus) | |
| 116 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 113 | 117 | |
| 114 | 118 | #endif // _LIBCPP_FENV_H |
lib/libcxx/include/filesystem+40-36| ... | ... | @@ -533,45 +533,49 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct |
| 533 | 533 | |
| 534 | 534 | */ |
| 535 | 535 | |
| 536 | #include <__config> | |
| 537 | ||
| 538 | #if _LIBCPP_STD_VER >= 17 | |
| 539 | # include <__filesystem/copy_options.h> | |
| 540 | # include <__filesystem/directory_entry.h> | |
| 541 | # include <__filesystem/directory_iterator.h> | |
| 542 | # include <__filesystem/directory_options.h> | |
| 543 | # include <__filesystem/file_status.h> | |
| 544 | # include <__filesystem/file_time_type.h> | |
| 545 | # include <__filesystem/file_type.h> | |
| 546 | # include <__filesystem/filesystem_error.h> | |
| 547 | # include <__filesystem/operations.h> | |
| 548 | # include <__filesystem/path.h> | |
| 549 | # include <__filesystem/path_iterator.h> | |
| 550 | # include <__filesystem/perm_options.h> | |
| 551 | # include <__filesystem/perms.h> | |
| 552 | # include <__filesystem/recursive_directory_iterator.h> | |
| 553 | # include <__filesystem/space_info.h> | |
| 554 | # include <__filesystem/u8path.h> | |
| 555 | #endif | |
| 556 | ||
| 557 | #include <version> | |
| 536 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 537 | # include <__cxx03/filesystem> | |
| 538 | #else | |
| 539 | # include <__config> | |
| 540 | ||
| 541 | # if _LIBCPP_STD_VER >= 17 | |
| 542 | # include <__filesystem/copy_options.h> | |
| 543 | # include <__filesystem/directory_entry.h> | |
| 544 | # include <__filesystem/directory_iterator.h> | |
| 545 | # include <__filesystem/directory_options.h> | |
| 546 | # include <__filesystem/file_status.h> | |
| 547 | # include <__filesystem/file_time_type.h> | |
| 548 | # include <__filesystem/file_type.h> | |
| 549 | # include <__filesystem/filesystem_error.h> | |
| 550 | # include <__filesystem/operations.h> | |
| 551 | # include <__filesystem/path.h> | |
| 552 | # include <__filesystem/path_iterator.h> | |
| 553 | # include <__filesystem/perm_options.h> | |
| 554 | # include <__filesystem/perms.h> | |
| 555 | # include <__filesystem/recursive_directory_iterator.h> | |
| 556 | # include <__filesystem/space_info.h> | |
| 557 | # include <__filesystem/u8path.h> | |
| 558 | # endif | |
| 559 | ||
| 560 | # include <version> | |
| 558 | 561 | |
| 559 | 562 | // standard-mandated includes |
| 560 | 563 | |
| 561 | 564 | // [fs.filesystem.syn] |
| 562 | #include <compare> | |
| 563 | ||
| 564 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 565 | # pragma GCC system_header | |
| 566 | #endif | |
| 567 | ||
| 568 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 569 | # include <concepts> | |
| 570 | # include <cstdlib> | |
| 571 | # include <cstring> | |
| 572 | # include <iosfwd> | |
| 573 | # include <new> | |
| 574 | # include <system_error> | |
| 575 | #endif | |
| 565 | # include <compare> | |
| 566 | ||
| 567 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 568 | # pragma GCC system_header | |
| 569 | # endif | |
| 570 | ||
| 571 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 572 | # include <concepts> | |
| 573 | # include <cstdlib> | |
| 574 | # include <cstring> | |
| 575 | # include <iosfwd> | |
| 576 | # include <new> | |
| 577 | # include <system_error> | |
| 578 | # endif | |
| 579 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 576 | 580 | |
| 577 | 581 | #endif // _LIBCPP_FILESYSTEM |
lib/libcxx/include/flat_map created+83| ... | ... | @@ -0,0 +1,83 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_FLAT_MAP | |
| 11 | #define _LIBCPP_FLAT_MAP | |
| 12 | ||
| 13 | /* | |
| 14 | Header <flat_map> synopsis | |
| 15 | ||
| 16 | #include <compare> // see [compare.syn] | |
| 17 | #include <initializer_list> // see [initializer.list.syn] | |
| 18 | ||
| 19 | namespace std { | |
| 20 | // [flat.map], class template flat_map | |
| 21 | template<class Key, class T, class Compare = less<Key>, | |
| 22 | class KeyContainer = vector<Key>, class MappedContainer = vector<T>> | |
| 23 | class flat_map; | |
| 24 | ||
| 25 | struct sorted_unique_t { explicit sorted_unique_t() = default; }; | |
| 26 | inline constexpr sorted_unique_t sorted_unique{}; | |
| 27 | ||
| 28 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, | |
| 29 | class Allocator> | |
| 30 | struct uses_allocator<flat_map<Key, T, Compare, KeyContainer, MappedContainer>, | |
| 31 | Allocator>; | |
| 32 | ||
| 33 | // [flat.map.erasure], erasure for flat_map | |
| 34 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, | |
| 35 | class Predicate> | |
| 36 | typename flat_map<Key, T, Compare, KeyContainer, MappedContainer>::size_type | |
| 37 | erase_if(flat_map<Key, T, Compare, KeyContainer, MappedContainer>& c, Predicate pred); | |
| 38 | ||
| 39 | // [flat.multimap], class template flat_multimap | |
| 40 | template<class Key, class T, class Compare = less<Key>, | |
| 41 | class KeyContainer = vector<Key>, class MappedContainer = vector<T>> | |
| 42 | class flat_multimap; | |
| 43 | ||
| 44 | struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; }; | |
| 45 | inline constexpr sorted_equivalent_t sorted_equivalent{}; | |
| 46 | ||
| 47 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, | |
| 48 | class Allocator> | |
| 49 | struct uses_allocator<flat_multimap<Key, T, Compare, KeyContainer, MappedContainer>, | |
| 50 | Allocator>; | |
| 51 | ||
| 52 | // [flat.multimap.erasure], erasure for flat_multimap | |
| 53 | template<class Key, class T, class Compare, class KeyContainer, class MappedContainer, | |
| 54 | class Predicate> | |
| 55 | typename flat_multimap<Key, T, Compare, KeyContainer, MappedContainer>::size_type | |
| 56 | erase_if(flat_multimap<Key, T, Compare, KeyContainer, MappedContainer>& c, Predicate pred); | |
| 57 | */ | |
| 58 | ||
| 59 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 60 | # include <__cxx03/__config> | |
| 61 | #else | |
| 62 | # include <__config> | |
| 63 | ||
| 64 | # if _LIBCPP_STD_VER >= 23 | |
| 65 | # include <__flat_map/flat_map.h> | |
| 66 | # include <__flat_map/flat_multimap.h> | |
| 67 | # include <__flat_map/sorted_equivalent.h> | |
| 68 | # include <__flat_map/sorted_unique.h> | |
| 69 | # endif | |
| 70 | ||
| 71 | // for feature-test macros | |
| 72 | # include <version> | |
| 73 | ||
| 74 | // standard required includes | |
| 75 | # include <compare> | |
| 76 | # include <initializer_list> | |
| 77 | ||
| 78 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 79 | # pragma GCC system_header | |
| 80 | # endif | |
| 81 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 82 | ||
| 83 | #endif // _LIBCPP_FLAT_MAP |
lib/libcxx/include/float.h+19-15| ... | ... | @@ -70,26 +70,30 @@ Macros: |
| 70 | 70 | |
| 71 | 71 | */ |
| 72 | 72 | |
| 73 | #include <__config> | |
| 73 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 74 | # include <__cxx03/float.h> | |
| 75 | #else | |
| 76 | # include <__config> | |
| 74 | 77 | |
| 75 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 76 | # pragma GCC system_header | |
| 77 | #endif | |
| 78 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 79 | # pragma GCC system_header | |
| 80 | # endif | |
| 78 | 81 | |
| 79 | #if __has_include_next(<float.h>) | |
| 80 | # include_next <float.h> | |
| 81 | #endif | |
| 82 | # if __has_include_next(<float.h>) | |
| 83 | # include_next <float.h> | |
| 84 | # endif | |
| 82 | 85 | |
| 83 | #ifdef __cplusplus | |
| 86 | # ifdef __cplusplus | |
| 84 | 87 | |
| 85 | # ifndef FLT_EVAL_METHOD | |
| 86 | # define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ | |
| 87 | # endif | |
| 88 | # ifndef FLT_EVAL_METHOD | |
| 89 | # define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ | |
| 90 | # endif | |
| 88 | 91 | |
| 89 | # ifndef DECIMAL_DIG | |
| 90 | # define DECIMAL_DIG __DECIMAL_DIG__ | |
| 91 | # endif | |
| 92 | # ifndef DECIMAL_DIG | |
| 93 | # define DECIMAL_DIG __DECIMAL_DIG__ | |
| 94 | # endif | |
| 92 | 95 | |
| 93 | #endif // __cplusplus | |
| 96 | # endif // __cplusplus | |
| 97 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 94 | 98 | |
| 95 | 99 | #endif // _LIBCPP_FLOAT_H |
lib/libcxx/include/format+77-70| ... | ... | @@ -126,6 +126,9 @@ namespace std { |
| 126 | 126 | // [format.formatter], formatter |
| 127 | 127 | template<class T, class charT = char> struct formatter; |
| 128 | 128 | |
| 129 | template<class T> | |
| 130 | constexpr bool enable_nonlocking_formatter_optimization = false; // since C++23 | |
| 131 | ||
| 129 | 132 | // [format.parse.ctx], class template basic_format_parse_context |
| 130 | 133 | template<class charT> class basic_format_parse_context; |
| 131 | 134 | using format_parse_context = basic_format_parse_context<char>; |
| ... | ... | @@ -133,7 +136,7 @@ namespace std { |
| 133 | 136 | |
| 134 | 137 | // [format.range], formatting of ranges |
| 135 | 138 | // [format.range.fmtkind], variable template format_kind |
| 136 | enum class range_format { // since C++23 | |
| 139 | enum class range_format { // since C++23 | |
| 137 | 140 | disabled, |
| 138 | 141 | map, |
| 139 | 142 | set, |
| ... | ... | @@ -143,20 +146,20 @@ namespace std { |
| 143 | 146 | }; |
| 144 | 147 | |
| 145 | 148 | template<class R> |
| 146 | constexpr unspecified format_kind = unspecified; // since C++23 | |
| 149 | constexpr unspecified format_kind = unspecified; // since C++23 | |
| 147 | 150 | |
| 148 | 151 | template<ranges::input_range R> |
| 149 | 152 | requires same_as<R, remove_cvref_t<R>> |
| 150 | constexpr range_format format_kind<R> = see below; // since C++23 | |
| 153 | constexpr range_format format_kind<R> = see below; // since C++23 | |
| 151 | 154 | |
| 152 | 155 | // [format.range.formatter], class template range_formatter |
| 153 | 156 | template<class T, class charT = char> |
| 154 | 157 | requires same_as<remove_cvref_t<T>, T> && formattable<T, charT> |
| 155 | class range_formatter; // since C++23 | |
| 158 | class range_formatter; // since C++23 | |
| 156 | 159 | |
| 157 | 160 | // [format.range.fmtdef], class template range-default-formatter |
| 158 | 161 | template<range_format K, ranges::input_range R, class charT> |
| 159 | struct range-default-formatter; // exposition only, since C++23 | |
| 162 | struct range-default-formatter; // exposition only, since C++23 | |
| 160 | 163 | |
| 161 | 164 | // [format.range.fmtmap], [format.range.fmtset], [format.range.fmtstr], |
| 162 | 165 | // specializations for maps, sets, and strings |
| ... | ... | @@ -173,7 +176,7 @@ namespace std { |
| 173 | 176 | see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg); // Deprecated in C++26 |
| 174 | 177 | |
| 175 | 178 | // [format.arg.store], class template format-arg-store |
| 176 | template<class Context, class... Args> struct format-arg-store; // exposition only | |
| 179 | template<class Context, class... Args> struct format-arg-store; // exposition only | |
| 177 | 180 | |
| 178 | 181 | template<class Context = format_context, class... Args> |
| 179 | 182 | format-arg-store<Context, Args...> |
| ... | ... | @@ -188,70 +191,74 @@ namespace std { |
| 188 | 191 | |
| 189 | 192 | */ |
| 190 | 193 | |
| 191 | #include <__config> | |
| 192 | ||
| 193 | #if _LIBCPP_STD_VER >= 20 | |
| 194 | # include <__format/buffer.h> | |
| 195 | # include <__format/concepts.h> | |
| 196 | # include <__format/container_adaptor.h> | |
| 197 | # include <__format/enable_insertable.h> | |
| 198 | # include <__format/escaped_output_table.h> | |
| 199 | # include <__format/extended_grapheme_cluster_table.h> | |
| 200 | # include <__format/format_arg.h> | |
| 201 | # include <__format/format_arg_store.h> | |
| 202 | # include <__format/format_args.h> | |
| 203 | # include <__format/format_context.h> | |
| 204 | # include <__format/format_error.h> | |
| 205 | # include <__format/format_functions.h> | |
| 206 | # include <__format/format_parse_context.h> | |
| 207 | # include <__format/format_string.h> | |
| 208 | # include <__format/format_to_n_result.h> | |
| 209 | # include <__format/formatter.h> | |
| 210 | # include <__format/formatter_bool.h> | |
| 211 | # include <__format/formatter_char.h> | |
| 212 | # include <__format/formatter_floating_point.h> | |
| 213 | # include <__format/formatter_integer.h> | |
| 214 | # include <__format/formatter_pointer.h> | |
| 215 | # include <__format/formatter_string.h> | |
| 216 | # include <__format/formatter_tuple.h> | |
| 217 | # include <__format/parser_std_format_spec.h> | |
| 218 | # include <__format/range_default_formatter.h> | |
| 219 | # include <__format/range_formatter.h> | |
| 220 | # include <__format/unicode.h> | |
| 221 | # include <__fwd/format.h> | |
| 222 | #endif | |
| 223 | ||
| 224 | #include <version> | |
| 225 | ||
| 226 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 227 | # pragma GCC system_header | |
| 228 | #endif | |
| 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 <initializer_list> | |
| 241 | # include <limits> | |
| 242 | # include <locale> | |
| 243 | # include <new> | |
| 244 | # include <optional> | |
| 245 | # include <queue> | |
| 246 | # include <stack> | |
| 247 | # include <stdexcept> | |
| 248 | # include <string> | |
| 249 | # include <string_view> | |
| 250 | # include <tuple> | |
| 251 | ||
| 252 | # if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 253 | # include <cwchar> | |
| 194 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 195 | # include <__cxx03/format> | |
| 196 | #else | |
| 197 | # include <__config> | |
| 198 | ||
| 199 | # if _LIBCPP_STD_VER >= 20 | |
| 200 | # include <__format/buffer.h> | |
| 201 | # include <__format/concepts.h> | |
| 202 | # include <__format/container_adaptor.h> | |
| 203 | # include <__format/enable_insertable.h> | |
| 204 | # include <__format/escaped_output_table.h> | |
| 205 | # include <__format/extended_grapheme_cluster_table.h> | |
| 206 | # include <__format/format_arg.h> | |
| 207 | # include <__format/format_arg_store.h> | |
| 208 | # include <__format/format_args.h> | |
| 209 | # include <__format/format_context.h> | |
| 210 | # include <__format/format_error.h> | |
| 211 | # include <__format/format_functions.h> | |
| 212 | # include <__format/format_parse_context.h> | |
| 213 | # include <__format/format_string.h> | |
| 214 | # include <__format/format_to_n_result.h> | |
| 215 | # include <__format/formatter.h> | |
| 216 | # include <__format/formatter_bool.h> | |
| 217 | # include <__format/formatter_char.h> | |
| 218 | # include <__format/formatter_floating_point.h> | |
| 219 | # include <__format/formatter_integer.h> | |
| 220 | # include <__format/formatter_pointer.h> | |
| 221 | # include <__format/formatter_string.h> | |
| 222 | # include <__format/formatter_tuple.h> | |
| 223 | # include <__format/parser_std_format_spec.h> | |
| 224 | # include <__format/range_default_formatter.h> | |
| 225 | # include <__format/range_formatter.h> | |
| 226 | # include <__format/unicode.h> | |
| 227 | # include <__fwd/format.h> | |
| 228 | # endif | |
| 229 | ||
| 230 | # include <version> | |
| 231 | ||
| 232 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 233 | # pragma GCC system_header | |
| 234 | # endif | |
| 235 | ||
| 236 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 237 | # include <array> | |
| 238 | # include <cctype> | |
| 239 | # include <cerrno> | |
| 240 | # include <clocale> | |
| 241 | # include <cmath> | |
| 242 | # include <cstddef> | |
| 243 | # include <cstdint> | |
| 244 | # include <cstdlib> | |
| 245 | # include <cstring> | |
| 246 | # include <initializer_list> | |
| 247 | # include <limits> | |
| 248 | # include <locale> | |
| 249 | # include <new> | |
| 250 | # include <optional> | |
| 251 | # include <queue> | |
| 252 | # include <stack> | |
| 253 | # include <stdexcept> | |
| 254 | # include <string> | |
| 255 | # include <string_view> | |
| 256 | # include <tuple> | |
| 257 | ||
| 258 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 259 | # include <cwchar> | |
| 260 | # endif | |
| 254 | 261 | # endif |
| 255 | #endif | |
| 262 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 256 | 263 | |
| 257 | 264 | #endif // _LIBCPP_FORMAT |
lib/libcxx/include/forward_list+255-229| ... | ... | @@ -195,62 +195,70 @@ template <class T, class Allocator, class Predicate> |
| 195 | 195 | |
| 196 | 196 | */ |
| 197 | 197 | |
| 198 | #include <__algorithm/comp.h> | |
| 199 | #include <__algorithm/lexicographical_compare.h> | |
| 200 | #include <__algorithm/lexicographical_compare_three_way.h> | |
| 201 | #include <__algorithm/min.h> | |
| 202 | #include <__config> | |
| 203 | #include <__iterator/distance.h> | |
| 204 | #include <__iterator/iterator_traits.h> | |
| 205 | #include <__iterator/move_iterator.h> | |
| 206 | #include <__iterator/next.h> | |
| 207 | #include <__memory/addressof.h> | |
| 208 | #include <__memory/allocation_guard.h> | |
| 209 | #include <__memory/allocator.h> | |
| 210 | #include <__memory/allocator_traits.h> | |
| 211 | #include <__memory/compressed_pair.h> | |
| 212 | #include <__memory/construct_at.h> | |
| 213 | #include <__memory/pointer_traits.h> | |
| 214 | #include <__memory/swap_allocator.h> | |
| 215 | #include <__memory_resource/polymorphic_allocator.h> | |
| 216 | #include <__ranges/access.h> | |
| 217 | #include <__ranges/concepts.h> | |
| 218 | #include <__ranges/container_compatible_range.h> | |
| 219 | #include <__ranges/from_range.h> | |
| 220 | #include <__type_traits/conditional.h> | |
| 221 | #include <__type_traits/is_allocator.h> | |
| 222 | #include <__type_traits/is_const.h> | |
| 223 | #include <__type_traits/is_nothrow_assignable.h> | |
| 224 | #include <__type_traits/is_nothrow_constructible.h> | |
| 225 | #include <__type_traits/is_pointer.h> | |
| 226 | #include <__type_traits/is_same.h> | |
| 227 | #include <__type_traits/is_swappable.h> | |
| 228 | #include <__type_traits/type_identity.h> | |
| 229 | #include <__utility/forward.h> | |
| 230 | #include <__utility/move.h> | |
| 231 | #include <limits> | |
| 232 | #include <new> // __launder | |
| 233 | #include <version> | |
| 198 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 199 | # include <__cxx03/forward_list> | |
| 200 | #else | |
| 201 | # include <__algorithm/comp.h> | |
| 202 | # include <__algorithm/lexicographical_compare.h> | |
| 203 | # include <__algorithm/lexicographical_compare_three_way.h> | |
| 204 | # include <__algorithm/min.h> | |
| 205 | # include <__assert> | |
| 206 | # include <__config> | |
| 207 | # include <__cstddef/nullptr_t.h> | |
| 208 | # include <__iterator/distance.h> | |
| 209 | # include <__iterator/iterator_traits.h> | |
| 210 | # include <__iterator/move_iterator.h> | |
| 211 | # include <__iterator/next.h> | |
| 212 | # include <__memory/addressof.h> | |
| 213 | # include <__memory/allocation_guard.h> | |
| 214 | # include <__memory/allocator.h> | |
| 215 | # include <__memory/allocator_traits.h> | |
| 216 | # include <__memory/compressed_pair.h> | |
| 217 | # include <__memory/construct_at.h> | |
| 218 | # include <__memory/pointer_traits.h> | |
| 219 | # include <__memory/swap_allocator.h> | |
| 220 | # include <__memory_resource/polymorphic_allocator.h> | |
| 221 | # include <__new/launder.h> | |
| 222 | # include <__ranges/access.h> | |
| 223 | # include <__ranges/concepts.h> | |
| 224 | # include <__ranges/container_compatible_range.h> | |
| 225 | # include <__ranges/from_range.h> | |
| 226 | # include <__type_traits/conditional.h> | |
| 227 | # include <__type_traits/container_traits.h> | |
| 228 | # include <__type_traits/enable_if.h> | |
| 229 | # include <__type_traits/is_allocator.h> | |
| 230 | # include <__type_traits/is_const.h> | |
| 231 | # include <__type_traits/is_nothrow_assignable.h> | |
| 232 | # include <__type_traits/is_nothrow_constructible.h> | |
| 233 | # include <__type_traits/is_pointer.h> | |
| 234 | # include <__type_traits/is_same.h> | |
| 235 | # include <__type_traits/is_swappable.h> | |
| 236 | # include <__type_traits/type_identity.h> | |
| 237 | # include <__utility/forward.h> | |
| 238 | # include <__utility/move.h> | |
| 239 | # include <__utility/swap.h> | |
| 240 | # include <limits> | |
| 241 | # include <version> | |
| 234 | 242 | |
| 235 | 243 | // standard-mandated includes |
| 236 | 244 | |
| 237 | 245 | // [iterator.range] |
| 238 | #include <__iterator/access.h> | |
| 239 | #include <__iterator/data.h> | |
| 240 | #include <__iterator/empty.h> | |
| 241 | #include <__iterator/reverse_access.h> | |
| 242 | #include <__iterator/size.h> | |
| 246 | # include <__iterator/access.h> | |
| 247 | # include <__iterator/data.h> | |
| 248 | # include <__iterator/empty.h> | |
| 249 | # include <__iterator/reverse_access.h> | |
| 250 | # include <__iterator/size.h> | |
| 243 | 251 | |
| 244 | 252 | // [forward.list.syn] |
| 245 | #include <compare> | |
| 246 | #include <initializer_list> | |
| 253 | # include <compare> | |
| 254 | # include <initializer_list> | |
| 247 | 255 | |
| 248 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 249 | # pragma GCC system_header | |
| 250 | #endif | |
| 256 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 257 | # pragma GCC system_header | |
| 258 | # endif | |
| 251 | 259 | |
| 252 | 260 | _LIBCPP_PUSH_MACROS |
| 253 | #include <__undef_macros> | |
| 261 | # include <__undef_macros> | |
| 254 | 262 | |
| 255 | 263 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 256 | 264 | |
| ... | ... | @@ -276,18 +284,20 @@ struct __forward_node_traits { |
| 276 | 284 | typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer; |
| 277 | 285 | typedef __rebind_pointer_t<_NodePtr, void> __void_pointer; |
| 278 | 286 | |
| 279 | #if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB) | |
| 280 | typedef __begin_node_pointer __iter_node_pointer; | |
| 281 | #else | |
| 282 | typedef __conditional_t<is_pointer<__void_pointer>::value, __begin_node_pointer, __node_pointer> __iter_node_pointer; | |
| 283 | #endif | |
| 284 | ||
| 285 | typedef __conditional_t<is_same<__iter_node_pointer, __node_pointer>::value, __begin_node_pointer, __node_pointer> | |
| 286 | __non_iter_node_pointer; | |
| 287 | // TODO(LLVM 22): Remove this check | |
| 288 | # ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB | |
| 289 | static_assert(sizeof(__begin_node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__begin_node_pointer) == | |
| 290 | _LIBCPP_ALIGNOF(__node_pointer), | |
| 291 | "It looks like you are using std::forward_list with a fancy pointer type that thas a different " | |
| 292 | "representation depending on whether it points to a forward_list base pointer or a forward_list node " | |
| 293 | "pointer (both of which are implementation details of the standard library). This means that your ABI " | |
| 294 | "is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define " | |
| 295 | "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); | |
| 296 | # endif | |
| 287 | 297 | |
| 288 | _LIBCPP_HIDE_FROM_ABI static __iter_node_pointer __as_iter_node(__iter_node_pointer __p) { return __p; } | |
| 289 | _LIBCPP_HIDE_FROM_ABI static __iter_node_pointer __as_iter_node(__non_iter_node_pointer __p) { | |
| 290 | return static_cast<__iter_node_pointer>(static_cast<__void_pointer>(__p)); | |
| 298 | _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__begin_node_pointer __p) { return __p; } | |
| 299 | _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__node_pointer __p) { | |
| 300 | return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__p)); | |
| 291 | 301 | } |
| 292 | 302 | }; |
| 293 | 303 | |
| ... | ... | @@ -307,7 +317,8 @@ struct __forward_begin_node { |
| 307 | 317 | }; |
| 308 | 318 | |
| 309 | 319 | template <class _Tp, class _VoidPtr> |
| 310 | using __begin_node_of = __forward_begin_node<__rebind_pointer_t<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> > >; | |
| 320 | using __begin_node_of _LIBCPP_NODEBUG = | |
| 321 | __forward_begin_node<__rebind_pointer_t<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> > >; | |
| 311 | 322 | |
| 312 | 323 | template <class _Tp, class _VoidPtr> |
| 313 | 324 | struct __forward_list_node : public __begin_node_of<_Tp, _VoidPtr> { |
| ... | ... | @@ -317,7 +328,7 @@ struct __forward_list_node : public __begin_node_of<_Tp, _VoidPtr> { |
| 317 | 328 | |
| 318 | 329 | // We allow starting the lifetime of nodes without initializing the value held by the node, |
| 319 | 330 | // since that is handled by the list itself in order to be allocator-aware. |
| 320 | #ifndef _LIBCPP_CXX03_LANG | |
| 331 | # ifndef _LIBCPP_CXX03_LANG | |
| 321 | 332 | |
| 322 | 333 | private: |
| 323 | 334 | union { |
| ... | ... | @@ -326,14 +337,14 @@ private: |
| 326 | 337 | |
| 327 | 338 | public: |
| 328 | 339 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } |
| 329 | #else | |
| 340 | # else | |
| 330 | 341 | |
| 331 | 342 | private: |
| 332 | 343 | _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)]; |
| 333 | 344 | |
| 334 | 345 | public: |
| 335 | 346 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); } |
| 336 | #endif | |
| 347 | # endif | |
| 337 | 348 | |
| 338 | 349 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_node(_NodePtr __next) : _Base(__next) {} |
| 339 | 350 | _LIBCPP_HIDE_FROM_ABI ~__forward_list_node() {} |
| ... | ... | @@ -349,10 +360,9 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_iterator { |
| 349 | 360 | typedef __forward_node_traits<_NodePtr> __traits; |
| 350 | 361 | typedef typename __traits::__node_pointer __node_pointer; |
| 351 | 362 | typedef typename __traits::__begin_node_pointer __begin_node_pointer; |
| 352 | typedef typename __traits::__iter_node_pointer __iter_node_pointer; | |
| 353 | 363 | typedef typename __traits::__void_pointer __void_pointer; |
| 354 | 364 | |
| 355 | __iter_node_pointer __ptr_; | |
| 365 | __begin_node_pointer __ptr_; | |
| 356 | 366 | |
| 357 | 367 | _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const { |
| 358 | 368 | return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_)); |
| ... | ... | @@ -415,10 +425,9 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator { |
| 415 | 425 | typedef typename __traits::__node_type __node_type; |
| 416 | 426 | typedef typename __traits::__node_pointer __node_pointer; |
| 417 | 427 | typedef typename __traits::__begin_node_pointer __begin_node_pointer; |
| 418 | typedef typename __traits::__iter_node_pointer __iter_node_pointer; | |
| 419 | 428 | typedef typename __traits::__void_pointer __void_pointer; |
| 420 | 429 | |
| 421 | __iter_node_pointer __ptr_; | |
| 430 | __begin_node_pointer __ptr_; | |
| 422 | 431 | |
| 423 | 432 | _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const { |
| 424 | 433 | return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_)); |
| ... | ... | @@ -490,34 +499,31 @@ protected: |
| 490 | 499 | typedef __rebind_alloc<allocator_traits<allocator_type>, __begin_node> __begin_node_allocator; |
| 491 | 500 | typedef typename allocator_traits<__begin_node_allocator>::pointer __begin_node_pointer; |
| 492 | 501 | |
| 493 | __compressed_pair<__begin_node, __node_allocator> __before_begin_; | |
| 502 | _LIBCPP_COMPRESSED_PAIR(__begin_node, __before_begin_, __node_allocator, __alloc_); | |
| 494 | 503 | |
| 495 | 504 | _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() _NOEXCEPT { |
| 496 | return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_.first()); | |
| 505 | return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_); | |
| 497 | 506 | } |
| 498 | 507 | _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() const _NOEXCEPT { |
| 499 | return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_.first())); | |
| 508 | return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_)); | |
| 500 | 509 | } |
| 501 | 510 | |
| 502 | _LIBCPP_HIDE_FROM_ABI __node_allocator& __alloc() _NOEXCEPT { return __before_begin_.second(); } | |
| 503 | _LIBCPP_HIDE_FROM_ABI const __node_allocator& __alloc() const _NOEXCEPT { return __before_begin_.second(); } | |
| 504 | ||
| 505 | 511 | typedef __forward_list_iterator<__node_pointer> iterator; |
| 506 | 512 | typedef __forward_list_const_iterator<__node_pointer> const_iterator; |
| 507 | 513 | |
| 508 | 514 | _LIBCPP_HIDE_FROM_ABI __forward_list_base() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) |
| 509 | : __before_begin_(__begin_node(), __default_init_tag()) {} | |
| 515 | : __before_begin_(__begin_node()) {} | |
| 510 | 516 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const allocator_type& __a) |
| 511 | : __before_begin_(__begin_node(), __node_allocator(__a)) {} | |
| 517 | : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {} | |
| 512 | 518 | _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a) |
| 513 | : __before_begin_(__begin_node(), __a) {} | |
| 519 | : __before_begin_(__begin_node()), __alloc_(__a) {} | |
| 514 | 520 | |
| 515 | 521 | public: |
| 516 | #ifndef _LIBCPP_CXX03_LANG | |
| 522 | # ifndef _LIBCPP_CXX03_LANG | |
| 517 | 523 | _LIBCPP_HIDE_FROM_ABI |
| 518 | 524 | __forward_list_base(__forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value); |
| 519 | 525 | _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a); |
| 520 | #endif // _LIBCPP_CXX03_LANG | |
| 526 | # endif // _LIBCPP_CXX03_LANG | |
| 521 | 527 | |
| 522 | 528 | __forward_list_base(const __forward_list_base&) = delete; |
| 523 | 529 | __forward_list_base& operator=(const __forward_list_base&) = delete; |
| ... | ... | @@ -537,8 +543,7 @@ protected: |
| 537 | 543 | |
| 538 | 544 | template <class... _Args> |
| 539 | 545 | _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__node_pointer __next, _Args&&... __args) { |
| 540 | __node_allocator& __a = __alloc(); | |
| 541 | __allocation_guard<__node_allocator> __guard(__a, 1); | |
| 546 | __allocation_guard<__node_allocator> __guard(__alloc_, 1); | |
| 542 | 547 | // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value |
| 543 | 548 | // held inside the node, since we need to use the allocator's construct() method for that. |
| 544 | 549 | // |
| ... | ... | @@ -548,26 +553,25 @@ protected: |
| 548 | 553 | std::__construct_at(std::addressof(*__guard.__get()), __next); |
| 549 | 554 | |
| 550 | 555 | // Now construct the value_type using the allocator's construct() method. |
| 551 | __node_traits::construct(__a, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...); | |
| 556 | __node_traits::construct(__alloc_, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...); | |
| 552 | 557 | return __guard.__release_ptr(); |
| 553 | 558 | } |
| 554 | 559 | |
| 555 | 560 | _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { |
| 556 | 561 | // For the same reason as above, we use the allocator's destroy() method for the value_type, |
| 557 | 562 | // but not for the node itself. |
| 558 | __node_allocator& __a = __alloc(); | |
| 559 | __node_traits::destroy(__a, std::addressof(__node->__get_value())); | |
| 563 | __node_traits::destroy(__alloc_, std::addressof(__node->__get_value())); | |
| 560 | 564 | std::__destroy_at(std::addressof(*__node)); |
| 561 | __node_traits::deallocate(__a, __node, 1); | |
| 565 | __node_traits::deallocate(__alloc_, __node, 1); | |
| 562 | 566 | } |
| 563 | 567 | |
| 564 | 568 | public: |
| 565 | 569 | _LIBCPP_HIDE_FROM_ABI void swap(__forward_list_base& __x) |
| 566 | #if _LIBCPP_STD_VER >= 14 | |
| 570 | # if _LIBCPP_STD_VER >= 14 | |
| 567 | 571 | _NOEXCEPT; |
| 568 | #else | |
| 572 | # else | |
| 569 | 573 | _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>); |
| 570 | #endif | |
| 574 | # endif | |
| 571 | 575 | |
| 572 | 576 | protected: |
| 573 | 577 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; |
| ... | ... | @@ -575,37 +579,37 @@ protected: |
| 575 | 579 | private: |
| 576 | 580 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base&, false_type) {} |
| 577 | 581 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base& __x, true_type) { |
| 578 | if (__alloc() != __x.__alloc()) | |
| 582 | if (__alloc_ != __x.__alloc_) | |
| 579 | 583 | clear(); |
| 580 | __alloc() = __x.__alloc(); | |
| 584 | __alloc_ = __x.__alloc_; | |
| 581 | 585 | } |
| 582 | 586 | |
| 583 | 587 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base&, false_type) _NOEXCEPT {} |
| 584 | 588 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x, true_type) |
| 585 | 589 | _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) { |
| 586 | __alloc() = std::move(__x.__alloc()); | |
| 590 | __alloc_ = std::move(__x.__alloc_); | |
| 587 | 591 | } |
| 588 | 592 | }; |
| 589 | 593 | |
| 590 | #ifndef _LIBCPP_CXX03_LANG | |
| 594 | # ifndef _LIBCPP_CXX03_LANG | |
| 591 | 595 | |
| 592 | 596 | template <class _Tp, class _Alloc> |
| 593 | 597 | inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) noexcept( |
| 594 | 598 | is_nothrow_move_constructible<__node_allocator>::value) |
| 595 | : __before_begin_(std::move(__x.__before_begin_)) { | |
| 599 | : __before_begin_(std::move(__x.__before_begin_)), __alloc_(std::move(__x.__alloc_)) { | |
| 596 | 600 | __x.__before_begin()->__next_ = nullptr; |
| 597 | 601 | } |
| 598 | 602 | |
| 599 | 603 | template <class _Tp, class _Alloc> |
| 600 | 604 | inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x, const allocator_type& __a) |
| 601 | : __before_begin_(__begin_node(), __node_allocator(__a)) { | |
| 602 | if (__alloc() == __x.__alloc()) { | |
| 605 | : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) { | |
| 606 | if (__alloc_ == __x.__alloc_) { | |
| 603 | 607 | __before_begin()->__next_ = __x.__before_begin()->__next_; |
| 604 | 608 | __x.__before_begin()->__next_ = nullptr; |
| 605 | 609 | } |
| 606 | 610 | } |
| 607 | 611 | |
| 608 | #endif // _LIBCPP_CXX03_LANG | |
| 612 | # endif // _LIBCPP_CXX03_LANG | |
| 609 | 613 | |
| 610 | 614 | template <class _Tp, class _Alloc> |
| 611 | 615 | __forward_list_base<_Tp, _Alloc>::~__forward_list_base() { |
| ... | ... | @@ -614,14 +618,13 @@ __forward_list_base<_Tp, _Alloc>::~__forward_list_base() { |
| 614 | 618 | |
| 615 | 619 | template <class _Tp, class _Alloc> |
| 616 | 620 | inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x) |
| 617 | #if _LIBCPP_STD_VER >= 14 | |
| 621 | # if _LIBCPP_STD_VER >= 14 | |
| 618 | 622 | _NOEXCEPT |
| 619 | #else | |
| 623 | # else | |
| 620 | 624 | _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>) |
| 621 | #endif | |
| 625 | # endif | |
| 622 | 626 | { |
| 623 | std::__swap_allocator( | |
| 624 | __alloc(), __x.__alloc(), integral_constant<bool, __node_traits::propagate_on_container_swap::value>()); | |
| 627 | std::__swap_allocator(__alloc_, __x.__alloc_); | |
| 625 | 628 | using std::swap; |
| 626 | 629 | swap(__before_begin()->__next_, __x.__before_begin()->__next_); |
| 627 | 630 | } |
| ... | ... | @@ -638,12 +641,12 @@ void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT { |
| 638 | 641 | |
| 639 | 642 | template <class _Tp, class _Alloc /*= allocator<_Tp>*/> |
| 640 | 643 | class _LIBCPP_TEMPLATE_VIS forward_list : private __forward_list_base<_Tp, _Alloc> { |
| 641 | typedef __forward_list_base<_Tp, _Alloc> base; | |
| 642 | typedef typename base::__node_allocator __node_allocator; | |
| 643 | typedef typename base::__node_type __node_type; | |
| 644 | typedef typename base::__node_traits __node_traits; | |
| 645 | typedef typename base::__node_pointer __node_pointer; | |
| 646 | typedef typename base::__begin_node_pointer __begin_node_pointer; | |
| 644 | typedef __forward_list_base<_Tp, _Alloc> __base; | |
| 645 | typedef typename __base::__node_allocator __node_allocator; | |
| 646 | typedef typename __base::__node_type __node_type; | |
| 647 | typedef typename __base::__node_traits __node_traits; | |
| 648 | typedef typename __base::__node_pointer __node_pointer; | |
| 649 | typedef typename __base::__begin_node_pointer __begin_node_pointer; | |
| 647 | 650 | |
| 648 | 651 | public: |
| 649 | 652 | typedef _Tp value_type; |
| ... | ... | @@ -664,25 +667,25 @@ public: |
| 664 | 667 | typedef typename allocator_traits<allocator_type>::size_type size_type; |
| 665 | 668 | typedef typename allocator_traits<allocator_type>::difference_type difference_type; |
| 666 | 669 | |
| 667 | typedef typename base::iterator iterator; | |
| 668 | typedef typename base::const_iterator const_iterator; | |
| 669 | #if _LIBCPP_STD_VER >= 20 | |
| 670 | typedef typename __base::iterator iterator; | |
| 671 | typedef typename __base::const_iterator const_iterator; | |
| 672 | # if _LIBCPP_STD_VER >= 20 | |
| 670 | 673 | typedef size_type __remove_return_type; |
| 671 | #else | |
| 674 | # else | |
| 672 | 675 | typedef void __remove_return_type; |
| 673 | #endif | |
| 676 | # endif | |
| 674 | 677 | |
| 675 | 678 | _LIBCPP_HIDE_FROM_ABI forward_list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) { |
| 676 | 679 | } // = default; |
| 677 | 680 | _LIBCPP_HIDE_FROM_ABI explicit forward_list(const allocator_type& __a); |
| 678 | 681 | _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n); |
| 679 | #if _LIBCPP_STD_VER >= 14 | |
| 682 | # if _LIBCPP_STD_VER >= 14 | |
| 680 | 683 | _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a); |
| 681 | #endif | |
| 684 | # endif | |
| 682 | 685 | _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v); |
| 683 | 686 | |
| 684 | 687 | template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 685 | _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : base(__a) { | |
| 688 | _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : __base(__a) { | |
| 686 | 689 | insert_after(cbefore_begin(), __n, __v); |
| 687 | 690 | } |
| 688 | 691 | |
| ... | ... | @@ -692,22 +695,22 @@ public: |
| 692 | 695 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 693 | 696 | _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a); |
| 694 | 697 | |
| 695 | #if _LIBCPP_STD_VER >= 23 | |
| 698 | # if _LIBCPP_STD_VER >= 23 | |
| 696 | 699 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 697 | 700 | _LIBCPP_HIDE_FROM_ABI forward_list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) |
| 698 | : base(__a) { | |
| 701 | : __base(__a) { | |
| 699 | 702 | prepend_range(std::forward<_Range>(__range)); |
| 700 | 703 | } |
| 701 | #endif | |
| 704 | # endif | |
| 702 | 705 | |
| 703 | 706 | _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x); |
| 704 | 707 | _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a); |
| 705 | 708 | |
| 706 | 709 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x); |
| 707 | 710 | |
| 708 | #ifndef _LIBCPP_CXX03_LANG | |
| 709 | _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<base>::value) | |
| 710 | : base(std::move(__x)) {} | |
| 711 | # ifndef _LIBCPP_CXX03_LANG | |
| 712 | _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<__base>::value) | |
| 713 | : __base(std::move(__x)) {} | |
| 711 | 714 | _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a); |
| 712 | 715 | |
| 713 | 716 | _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il); |
| ... | ... | @@ -720,74 +723,82 @@ public: |
| 720 | 723 | _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il); |
| 721 | 724 | |
| 722 | 725 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il); |
| 723 | #endif // _LIBCPP_CXX03_LANG | |
| 726 | # endif // _LIBCPP_CXX03_LANG | |
| 724 | 727 | |
| 725 | 728 | // ~forward_list() = default; |
| 726 | 729 | |
| 727 | 730 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 728 | 731 | void _LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l); |
| 729 | 732 | |
| 730 | #if _LIBCPP_STD_VER >= 23 | |
| 733 | # if _LIBCPP_STD_VER >= 23 | |
| 731 | 734 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 732 | 735 | _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) { |
| 733 | 736 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); |
| 734 | 737 | } |
| 735 | #endif | |
| 738 | # endif | |
| 736 | 739 | |
| 737 | 740 | _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v); |
| 738 | 741 | |
| 739 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(base::__alloc()); } | |
| 742 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(this->__alloc_); } | |
| 740 | 743 | |
| 741 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(base::__before_begin()->__next_); } | |
| 744 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__base::__before_begin()->__next_); } | |
| 742 | 745 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { |
| 743 | return const_iterator(base::__before_begin()->__next_); | |
| 746 | return const_iterator(__base::__before_begin()->__next_); | |
| 744 | 747 | } |
| 745 | 748 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(nullptr); } |
| 746 | 749 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(nullptr); } |
| 747 | 750 | |
| 748 | 751 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { |
| 749 | return const_iterator(base::__before_begin()->__next_); | |
| 752 | return const_iterator(__base::__before_begin()->__next_); | |
| 750 | 753 | } |
| 751 | 754 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return const_iterator(nullptr); } |
| 752 | 755 | |
| 753 | _LIBCPP_HIDE_FROM_ABI iterator before_begin() _NOEXCEPT { return iterator(base::__before_begin()); } | |
| 754 | _LIBCPP_HIDE_FROM_ABI const_iterator before_begin() const _NOEXCEPT { return const_iterator(base::__before_begin()); } | |
| 756 | _LIBCPP_HIDE_FROM_ABI iterator before_begin() _NOEXCEPT { return iterator(__base::__before_begin()); } | |
| 757 | _LIBCPP_HIDE_FROM_ABI const_iterator before_begin() const _NOEXCEPT { | |
| 758 | return const_iterator(__base::__before_begin()); | |
| 759 | } | |
| 755 | 760 | _LIBCPP_HIDE_FROM_ABI const_iterator cbefore_begin() const _NOEXCEPT { |
| 756 | return const_iterator(base::__before_begin()); | |
| 761 | return const_iterator(__base::__before_begin()); | |
| 757 | 762 | } |
| 758 | 763 | |
| 759 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { | |
| 760 | return base::__before_begin()->__next_ == nullptr; | |
| 764 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { | |
| 765 | return __base::__before_begin()->__next_ == nullptr; | |
| 761 | 766 | } |
| 762 | 767 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 763 | return std::min<size_type>(__node_traits::max_size(base::__alloc()), numeric_limits<difference_type>::max()); | |
| 768 | return std::min<size_type>(__node_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max()); | |
| 764 | 769 | } |
| 765 | 770 | |
| 766 | _LIBCPP_HIDE_FROM_ABI reference front() { return base::__before_begin()->__next_->__get_value(); } | |
| 767 | _LIBCPP_HIDE_FROM_ABI const_reference front() const { return base::__before_begin()->__next_->__get_value(); } | |
| 771 | _LIBCPP_HIDE_FROM_ABI reference front() { | |
| 772 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list"); | |
| 773 | return __base::__before_begin()->__next_->__get_value(); | |
| 774 | } | |
| 775 | _LIBCPP_HIDE_FROM_ABI const_reference front() const { | |
| 776 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list"); | |
| 777 | return __base::__before_begin()->__next_->__get_value(); | |
| 778 | } | |
| 768 | 779 | |
| 769 | #ifndef _LIBCPP_CXX03_LANG | |
| 770 | # if _LIBCPP_STD_VER >= 17 | |
| 780 | # ifndef _LIBCPP_CXX03_LANG | |
| 781 | # if _LIBCPP_STD_VER >= 17 | |
| 771 | 782 | template <class... _Args> |
| 772 | 783 | _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args); |
| 773 | # else | |
| 784 | # else | |
| 774 | 785 | template <class... _Args> |
| 775 | 786 | _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args); |
| 776 | # endif | |
| 787 | # endif | |
| 777 | 788 | _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v); |
| 778 | #endif // _LIBCPP_CXX03_LANG | |
| 789 | # endif // _LIBCPP_CXX03_LANG | |
| 779 | 790 | _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v); |
| 780 | 791 | |
| 781 | #if _LIBCPP_STD_VER >= 23 | |
| 792 | # if _LIBCPP_STD_VER >= 23 | |
| 782 | 793 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 783 | 794 | _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) { |
| 784 | 795 | insert_range_after(cbefore_begin(), std::forward<_Range>(__range)); |
| 785 | 796 | } |
| 786 | #endif | |
| 797 | # endif | |
| 787 | 798 | |
| 788 | 799 | _LIBCPP_HIDE_FROM_ABI void pop_front(); |
| 789 | 800 | |
| 790 | #ifndef _LIBCPP_CXX03_LANG | |
| 801 | # ifndef _LIBCPP_CXX03_LANG | |
| 791 | 802 | template <class... _Args> |
| 792 | 803 | _LIBCPP_HIDE_FROM_ABI iterator emplace_after(const_iterator __p, _Args&&... __args); |
| 793 | 804 | |
| ... | ... | @@ -795,18 +806,18 @@ public: |
| 795 | 806 | _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, initializer_list<value_type> __il) { |
| 796 | 807 | return insert_after(__p, __il.begin(), __il.end()); |
| 797 | 808 | } |
| 798 | #endif // _LIBCPP_CXX03_LANG | |
| 809 | # endif // _LIBCPP_CXX03_LANG | |
| 799 | 810 | _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v); |
| 800 | 811 | _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, size_type __n, const value_type& __v); |
| 801 | 812 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 802 | 813 | _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l); |
| 803 | 814 | |
| 804 | #if _LIBCPP_STD_VER >= 23 | |
| 815 | # if _LIBCPP_STD_VER >= 23 | |
| 805 | 816 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 806 | 817 | _LIBCPP_HIDE_FROM_ABI iterator insert_range_after(const_iterator __position, _Range&& __range) { |
| 807 | 818 | return __insert_after_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); |
| 808 | 819 | } |
| 809 | #endif | |
| 820 | # endif | |
| 810 | 821 | |
| 811 | 822 | template <class _InputIterator, class _Sentinel> |
| 812 | 823 | _LIBCPP_HIDE_FROM_ABI iterator __insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l); |
| ... | ... | @@ -815,18 +826,18 @@ public: |
| 815 | 826 | _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __f, const_iterator __l); |
| 816 | 827 | |
| 817 | 828 | _LIBCPP_HIDE_FROM_ABI void swap(forward_list& __x) |
| 818 | #if _LIBCPP_STD_VER >= 14 | |
| 829 | # if _LIBCPP_STD_VER >= 14 | |
| 819 | 830 | _NOEXCEPT |
| 820 | #else | |
| 831 | # else | |
| 821 | 832 | _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>) |
| 822 | #endif | |
| 833 | # endif | |
| 823 | 834 | { |
| 824 | base::swap(__x); | |
| 835 | __base::swap(__x); | |
| 825 | 836 | } |
| 826 | 837 | |
| 827 | 838 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n); |
| 828 | 839 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v); |
| 829 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { base::clear(); } | |
| 840 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); } | |
| 830 | 841 | |
| 831 | 842 | _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x); |
| 832 | 843 | _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x, const_iterator __i); |
| ... | ... | @@ -842,13 +853,13 @@ public: |
| 842 | 853 | _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); } |
| 843 | 854 | template <class _BinaryPredicate> |
| 844 | 855 | _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPredicate __binary_pred); |
| 845 | #ifndef _LIBCPP_CXX03_LANG | |
| 856 | # ifndef _LIBCPP_CXX03_LANG | |
| 846 | 857 | _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x) { merge(__x, __less<>()); } |
| 847 | 858 | template <class _Compare> |
| 848 | 859 | _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x, _Compare __comp) { |
| 849 | 860 | merge(__x, std::move(__comp)); |
| 850 | 861 | } |
| 851 | #endif // _LIBCPP_CXX03_LANG | |
| 862 | # endif // _LIBCPP_CXX03_LANG | |
| 852 | 863 | _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x) { merge(__x, __less<>()); } |
| 853 | 864 | template <class _Compare> |
| 854 | 865 | _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x, _Compare __comp); |
| ... | ... | @@ -858,11 +869,11 @@ public: |
| 858 | 869 | _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT; |
| 859 | 870 | |
| 860 | 871 | private: |
| 861 | #ifndef _LIBCPP_CXX03_LANG | |
| 872 | # ifndef _LIBCPP_CXX03_LANG | |
| 862 | 873 | _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, true_type) |
| 863 | 874 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); |
| 864 | 875 | _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, false_type); |
| 865 | #endif // _LIBCPP_CXX03_LANG | |
| 876 | # endif // _LIBCPP_CXX03_LANG | |
| 866 | 877 | |
| 867 | 878 | template <class _Iter, class _Sent> |
| 868 | 879 | _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iter __f, _Sent __l); |
| ... | ... | @@ -875,7 +886,7 @@ private: |
| 875 | 886 | static _LIBCPP_HIDDEN __node_pointer __sort(__node_pointer __f, difference_type __sz, _Compare& __comp); |
| 876 | 887 | }; |
| 877 | 888 | |
| 878 | #if _LIBCPP_STD_VER >= 17 | |
| 889 | # if _LIBCPP_STD_VER >= 17 | |
| 879 | 890 | template <class _InputIterator, |
| 880 | 891 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, |
| 881 | 892 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| ... | ... | @@ -887,37 +898,37 @@ template <class _InputIterator, |
| 887 | 898 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 888 | 899 | class = enable_if_t<__is_allocator<_Alloc>::value> > |
| 889 | 900 | forward_list(_InputIterator, _InputIterator, _Alloc) -> forward_list<__iter_value_type<_InputIterator>, _Alloc>; |
| 890 | #endif | |
| 901 | # endif | |
| 891 | 902 | |
| 892 | #if _LIBCPP_STD_VER >= 23 | |
| 903 | # if _LIBCPP_STD_VER >= 23 | |
| 893 | 904 | template <ranges::input_range _Range, |
| 894 | 905 | class _Alloc = allocator<ranges::range_value_t<_Range>>, |
| 895 | 906 | class = enable_if_t<__is_allocator<_Alloc>::value> > |
| 896 | 907 | forward_list(from_range_t, _Range&&, _Alloc = _Alloc()) -> forward_list<ranges::range_value_t<_Range>, _Alloc>; |
| 897 | #endif | |
| 908 | # endif | |
| 898 | 909 | |
| 899 | 910 | template <class _Tp, class _Alloc> |
| 900 | inline forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) : base(__a) {} | |
| 911 | inline forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) : __base(__a) {} | |
| 901 | 912 | |
| 902 | 913 | template <class _Tp, class _Alloc> |
| 903 | 914 | forward_list<_Tp, _Alloc>::forward_list(size_type __n) { |
| 904 | 915 | if (__n > 0) { |
| 905 | for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) { | |
| 916 | for (__begin_node_pointer __p = __base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) { | |
| 906 | 917 | __p->__next_ = this->__create_node(/* next = */ nullptr); |
| 907 | 918 | } |
| 908 | 919 | } |
| 909 | 920 | } |
| 910 | 921 | |
| 911 | #if _LIBCPP_STD_VER >= 14 | |
| 922 | # if _LIBCPP_STD_VER >= 14 | |
| 912 | 923 | template <class _Tp, class _Alloc> |
| 913 | forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc) : base(__base_alloc) { | |
| 924 | forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc) : __base(__base_alloc) { | |
| 914 | 925 | if (__n > 0) { |
| 915 | for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) { | |
| 926 | for (__begin_node_pointer __p = __base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) { | |
| 916 | 927 | __p->__next_ = this->__create_node(/* next = */ nullptr); |
| 917 | 928 | } |
| 918 | 929 | } |
| 919 | 930 | } |
| 920 | #endif | |
| 931 | # endif | |
| 921 | 932 | |
| 922 | 933 | template <class _Tp, class _Alloc> |
| 923 | 934 | forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) { |
| ... | ... | @@ -932,36 +943,37 @@ forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l) |
| 932 | 943 | |
| 933 | 944 | template <class _Tp, class _Alloc> |
| 934 | 945 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > |
| 935 | forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a) : base(__a) { | |
| 946 | forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a) | |
| 947 | : __base(__a) { | |
| 936 | 948 | insert_after(cbefore_begin(), __f, __l); |
| 937 | 949 | } |
| 938 | 950 | |
| 939 | 951 | template <class _Tp, class _Alloc> |
| 940 | 952 | forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x) |
| 941 | : base(__node_traits::select_on_container_copy_construction(__x.__alloc())) { | |
| 953 | : __base(__node_traits::select_on_container_copy_construction(__x.__alloc_)) { | |
| 942 | 954 | insert_after(cbefore_begin(), __x.begin(), __x.end()); |
| 943 | 955 | } |
| 944 | 956 | |
| 945 | 957 | template <class _Tp, class _Alloc> |
| 946 | 958 | forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a) |
| 947 | : base(__a) { | |
| 959 | : __base(__a) { | |
| 948 | 960 | insert_after(cbefore_begin(), __x.begin(), __x.end()); |
| 949 | 961 | } |
| 950 | 962 | |
| 951 | 963 | template <class _Tp, class _Alloc> |
| 952 | 964 | forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_list& __x) { |
| 953 | 965 | if (this != std::addressof(__x)) { |
| 954 | base::__copy_assign_alloc(__x); | |
| 966 | __base::__copy_assign_alloc(__x); | |
| 955 | 967 | assign(__x.begin(), __x.end()); |
| 956 | 968 | } |
| 957 | 969 | return *this; |
| 958 | 970 | } |
| 959 | 971 | |
| 960 | #ifndef _LIBCPP_CXX03_LANG | |
| 972 | # ifndef _LIBCPP_CXX03_LANG | |
| 961 | 973 | template <class _Tp, class _Alloc> |
| 962 | 974 | forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a) |
| 963 | : base(std::move(__x), __a) { | |
| 964 | if (base::__alloc() != __x.__alloc()) { | |
| 975 | : __base(std::move(__x), __a) { | |
| 976 | if (this->__alloc_ != __x.__alloc_) { | |
| 965 | 977 | typedef move_iterator<iterator> _Ip; |
| 966 | 978 | insert_after(cbefore_begin(), _Ip(__x.begin()), _Ip(__x.end())); |
| 967 | 979 | } |
| ... | ... | @@ -973,7 +985,7 @@ forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il) { |
| 973 | 985 | } |
| 974 | 986 | |
| 975 | 987 | template <class _Tp, class _Alloc> |
| 976 | forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il, const allocator_type& __a) : base(__a) { | |
| 988 | forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) { | |
| 977 | 989 | insert_after(cbefore_begin(), __il.begin(), __il.end()); |
| 978 | 990 | } |
| 979 | 991 | |
| ... | ... | @@ -981,14 +993,14 @@ template <class _Tp, class _Alloc> |
| 981 | 993 | void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type) |
| 982 | 994 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { |
| 983 | 995 | clear(); |
| 984 | base::__move_assign_alloc(__x); | |
| 985 | base::__before_begin()->__next_ = __x.__before_begin()->__next_; | |
| 986 | __x.__before_begin()->__next_ = nullptr; | |
| 996 | __base::__move_assign_alloc(__x); | |
| 997 | __base::__before_begin()->__next_ = __x.__before_begin()->__next_; | |
| 998 | __x.__before_begin()->__next_ = nullptr; | |
| 987 | 999 | } |
| 988 | 1000 | |
| 989 | 1001 | template <class _Tp, class _Alloc> |
| 990 | 1002 | void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) { |
| 991 | if (base::__alloc() == __x.__alloc()) | |
| 1003 | if (this->__alloc_ == __x.__alloc_) | |
| 992 | 1004 | __move_assign(__x, true_type()); |
| 993 | 1005 | else { |
| 994 | 1006 | typedef move_iterator<iterator> _Ip; |
| ... | ... | @@ -1009,7 +1021,7 @@ inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializ |
| 1009 | 1021 | return *this; |
| 1010 | 1022 | } |
| 1011 | 1023 | |
| 1012 | #endif // _LIBCPP_CXX03_LANG | |
| 1024 | # endif // _LIBCPP_CXX03_LANG | |
| 1013 | 1025 | |
| 1014 | 1026 | template <class _Tp, class _Alloc> |
| 1015 | 1027 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > |
| ... | ... | @@ -1044,7 +1056,7 @@ void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) { |
| 1044 | 1056 | erase_after(__i, __e); |
| 1045 | 1057 | } |
| 1046 | 1058 | |
| 1047 | #ifndef _LIBCPP_CXX03_LANG | |
| 1059 | # ifndef _LIBCPP_CXX03_LANG | |
| 1048 | 1060 | |
| 1049 | 1061 | template <class _Tp, class _Alloc> |
| 1050 | 1062 | inline void forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il) { |
| ... | ... | @@ -1053,39 +1065,41 @@ inline void forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il) |
| 1053 | 1065 | |
| 1054 | 1066 | template <class _Tp, class _Alloc> |
| 1055 | 1067 | template <class... _Args> |
| 1056 | # if _LIBCPP_STD_VER >= 17 | |
| 1068 | # if _LIBCPP_STD_VER >= 17 | |
| 1057 | 1069 | typename forward_list<_Tp, _Alloc>::reference |
| 1058 | # else | |
| 1070 | # else | |
| 1059 | 1071 | void |
| 1060 | # endif | |
| 1072 | # endif | |
| 1061 | 1073 | forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { |
| 1062 | base::__before_begin()->__next_ = | |
| 1063 | this->__create_node(/* next = */ base::__before_begin()->__next_, std::forward<_Args>(__args)...); | |
| 1064 | # if _LIBCPP_STD_VER >= 17 | |
| 1065 | return base::__before_begin()->__next_->__get_value(); | |
| 1066 | # endif | |
| 1074 | __base::__before_begin()->__next_ = | |
| 1075 | this->__create_node(/* next = */ __base::__before_begin()->__next_, std::forward<_Args>(__args)...); | |
| 1076 | # if _LIBCPP_STD_VER >= 17 | |
| 1077 | return __base::__before_begin()->__next_->__get_value(); | |
| 1078 | # endif | |
| 1067 | 1079 | } |
| 1068 | 1080 | |
| 1069 | 1081 | template <class _Tp, class _Alloc> |
| 1070 | 1082 | void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) { |
| 1071 | base::__before_begin()->__next_ = this->__create_node(/* next = */ base::__before_begin()->__next_, std::move(__v)); | |
| 1083 | __base::__before_begin()->__next_ = | |
| 1084 | this->__create_node(/* next = */ __base::__before_begin()->__next_, std::move(__v)); | |
| 1072 | 1085 | } |
| 1073 | 1086 | |
| 1074 | #endif // _LIBCPP_CXX03_LANG | |
| 1087 | # endif // _LIBCPP_CXX03_LANG | |
| 1075 | 1088 | |
| 1076 | 1089 | template <class _Tp, class _Alloc> |
| 1077 | 1090 | void forward_list<_Tp, _Alloc>::push_front(const value_type& __v) { |
| 1078 | base::__before_begin()->__next_ = this->__create_node(/* next = */ base::__before_begin()->__next_, __v); | |
| 1091 | __base::__before_begin()->__next_ = this->__create_node(/* next = */ __base::__before_begin()->__next_, __v); | |
| 1079 | 1092 | } |
| 1080 | 1093 | |
| 1081 | 1094 | template <class _Tp, class _Alloc> |
| 1082 | 1095 | void forward_list<_Tp, _Alloc>::pop_front() { |
| 1083 | __node_pointer __p = base::__before_begin()->__next_; | |
| 1084 | base::__before_begin()->__next_ = __p->__next_; | |
| 1096 | _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::pop_front called on an empty list"); | |
| 1097 | __node_pointer __p = __base::__before_begin()->__next_; | |
| 1098 | __base::__before_begin()->__next_ = __p->__next_; | |
| 1085 | 1099 | this->__delete_node(__p); |
| 1086 | 1100 | } |
| 1087 | 1101 | |
| 1088 | #ifndef _LIBCPP_CXX03_LANG | |
| 1102 | # ifndef _LIBCPP_CXX03_LANG | |
| 1089 | 1103 | |
| 1090 | 1104 | template <class _Tp, class _Alloc> |
| 1091 | 1105 | template <class... _Args> |
| ... | ... | @@ -1104,7 +1118,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) { |
| 1104 | 1118 | return iterator(__r->__next_); |
| 1105 | 1119 | } |
| 1106 | 1120 | |
| 1107 | #endif // _LIBCPP_CXX03_LANG | |
| 1121 | # endif // _LIBCPP_CXX03_LANG | |
| 1108 | 1122 | |
| 1109 | 1123 | template <class _Tp, class _Alloc> |
| 1110 | 1124 | typename forward_list<_Tp, _Alloc>::iterator |
| ... | ... | @@ -1121,13 +1135,13 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const |
| 1121 | 1135 | if (__n > 0) { |
| 1122 | 1136 | __node_pointer __first = this->__create_node(/* next = */ nullptr, __v); |
| 1123 | 1137 | __node_pointer __last = __first; |
| 1124 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1138 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1125 | 1139 | try { |
| 1126 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1140 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1127 | 1141 | for (--__n; __n != 0; --__n, __last = __last->__next_) { |
| 1128 | 1142 | __last->__next_ = this->__create_node(/* next = */ nullptr, __v); |
| 1129 | 1143 | } |
| 1130 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1144 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1131 | 1145 | } catch (...) { |
| 1132 | 1146 | while (__first != nullptr) { |
| 1133 | 1147 | __node_pointer __next = __first->__next_; |
| ... | ... | @@ -1136,7 +1150,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const |
| 1136 | 1150 | } |
| 1137 | 1151 | throw; |
| 1138 | 1152 | } |
| 1139 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1153 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1140 | 1154 | __last->__next_ = __r->__next_; |
| 1141 | 1155 | __r->__next_ = __first; |
| 1142 | 1156 | __r = static_cast<__begin_node_pointer>(__last); |
| ... | ... | @@ -1161,13 +1175,13 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp |
| 1161 | 1175 | __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f); |
| 1162 | 1176 | __node_pointer __last = __first; |
| 1163 | 1177 | |
| 1164 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1178 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1165 | 1179 | try { |
| 1166 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1180 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1167 | 1181 | for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_))) { |
| 1168 | 1182 | __last->__next_ = this->__create_node(/* next = */ nullptr, *__f); |
| 1169 | 1183 | } |
| 1170 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1184 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1171 | 1185 | } catch (...) { |
| 1172 | 1186 | while (__first != nullptr) { |
| 1173 | 1187 | __node_pointer __next = __first->__next_; |
| ... | ... | @@ -1176,7 +1190,7 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp |
| 1176 | 1190 | } |
| 1177 | 1191 | throw; |
| 1178 | 1192 | } |
| 1179 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1193 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1180 | 1194 | |
| 1181 | 1195 | __last->__next_ = __r->__next_; |
| 1182 | 1196 | __r->__next_ = __first; |
| ... | ... | @@ -1378,8 +1392,9 @@ template <class _Tp, class _Alloc> |
| 1378 | 1392 | template <class _Compare> |
| 1379 | 1393 | void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) { |
| 1380 | 1394 | if (this != std::addressof(__x)) { |
| 1381 | base::__before_begin()->__next_ = __merge(base::__before_begin()->__next_, __x.__before_begin()->__next_, __comp); | |
| 1382 | __x.__before_begin()->__next_ = nullptr; | |
| 1395 | __base::__before_begin()->__next_ = | |
| 1396 | __merge(__base::__before_begin()->__next_, __x.__before_begin()->__next_, __comp); | |
| 1397 | __x.__before_begin()->__next_ = nullptr; | |
| 1383 | 1398 | } |
| 1384 | 1399 | } |
| 1385 | 1400 | |
| ... | ... | @@ -1423,7 +1438,7 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Co |
| 1423 | 1438 | template <class _Tp, class _Alloc> |
| 1424 | 1439 | template <class _Compare> |
| 1425 | 1440 | inline void forward_list<_Tp, _Alloc>::sort(_Compare __comp) { |
| 1426 | base::__before_begin()->__next_ = __sort(base::__before_begin()->__next_, std::distance(begin(), end()), __comp); | |
| 1441 | __base::__before_begin()->__next_ = __sort(__base::__before_begin()->__next_, std::distance(begin(), end()), __comp); | |
| 1427 | 1442 | } |
| 1428 | 1443 | |
| 1429 | 1444 | template <class _Tp, class _Alloc> |
| ... | ... | @@ -1453,7 +1468,7 @@ forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Co |
| 1453 | 1468 | |
| 1454 | 1469 | template <class _Tp, class _Alloc> |
| 1455 | 1470 | void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT { |
| 1456 | __node_pointer __p = base::__before_begin()->__next_; | |
| 1471 | __node_pointer __p = __base::__before_begin()->__next_; | |
| 1457 | 1472 | if (__p != nullptr) { |
| 1458 | 1473 | __node_pointer __f = __p->__next_; |
| 1459 | 1474 | __p->__next_ = nullptr; |
| ... | ... | @@ -1463,7 +1478,7 @@ void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT { |
| 1463 | 1478 | __p = __f; |
| 1464 | 1479 | __f = __t; |
| 1465 | 1480 | } |
| 1466 | base::__before_begin()->__next_ = __p; | |
| 1481 | __base::__before_begin()->__next_ = __p; | |
| 1467 | 1482 | } |
| 1468 | 1483 | } |
| 1469 | 1484 | |
| ... | ... | @@ -1481,7 +1496,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const forward_list<_Tp, _Alloc>& __x, cons |
| 1481 | 1496 | return (__ix == __ex) == (__iy == __ey); |
| 1482 | 1497 | } |
| 1483 | 1498 | |
| 1484 | #if _LIBCPP_STD_VER <= 17 | |
| 1499 | # if _LIBCPP_STD_VER <= 17 | |
| 1485 | 1500 | |
| 1486 | 1501 | template <class _Tp, class _Alloc> |
| 1487 | 1502 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -1513,16 +1528,15 @@ operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc> |
| 1513 | 1528 | return !(__y < __x); |
| 1514 | 1529 | } |
| 1515 | 1530 | |
| 1516 | #else // #if _LIBCPP_STD_VER <= 17 | |
| 1531 | # else // #if _LIBCPP_STD_VER <= 17 | |
| 1517 | 1532 | |
| 1518 | 1533 | template <class _Tp, class _Allocator> |
| 1519 | 1534 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> |
| 1520 | 1535 | operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) { |
| 1521 | return std::lexicographical_compare_three_way( | |
| 1522 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | |
| 1536 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | |
| 1523 | 1537 | } |
| 1524 | 1538 | |
| 1525 | #endif // #if _LIBCPP_STD_VER <= 17 | |
| 1539 | # endif // #if _LIBCPP_STD_VER <= 17 | |
| 1526 | 1540 | |
| 1527 | 1541 | template <class _Tp, class _Alloc> |
| 1528 | 1542 | inline _LIBCPP_HIDE_FROM_ABI void swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y) |
| ... | ... | @@ -1530,7 +1544,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(forward_list<_Tp, _Alloc>& __x, forward_l |
| 1530 | 1544 | __x.swap(__y); |
| 1531 | 1545 | } |
| 1532 | 1546 | |
| 1533 | #if _LIBCPP_STD_VER >= 20 | |
| 1547 | # if _LIBCPP_STD_VER >= 20 | |
| 1534 | 1548 | template <class _Tp, class _Allocator, class _Predicate> |
| 1535 | 1549 | inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type |
| 1536 | 1550 | erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) { |
| ... | ... | @@ -1542,34 +1556,46 @@ inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type |
| 1542 | 1556 | erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) { |
| 1543 | 1557 | return std::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); |
| 1544 | 1558 | } |
| 1545 | #endif | |
| 1559 | # endif | |
| 1560 | ||
| 1561 | template <class _Tp, class _Allocator> | |
| 1562 | struct __container_traits<forward_list<_Tp, _Allocator> > { | |
| 1563 | // http://eel.is/c++draft/container.reqmts | |
| 1564 | // Unless otherwise specified (see [associative.reqmts.except], [unord.req.except], [deque.modifiers], | |
| 1565 | // [inplace.vector.modifiers], and [vector.modifiers]) all container types defined in this Clause meet the following | |
| 1566 | // additional requirements: | |
| 1567 | // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that | |
| 1568 | // function has no effects. | |
| 1569 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | |
| 1570 | }; | |
| 1546 | 1571 | |
| 1547 | 1572 | _LIBCPP_END_NAMESPACE_STD |
| 1548 | 1573 | |
| 1549 | #if _LIBCPP_STD_VER >= 17 | |
| 1574 | # if _LIBCPP_STD_VER >= 17 | |
| 1550 | 1575 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 1551 | 1576 | namespace pmr { |
| 1552 | 1577 | template <class _ValueT> |
| 1553 | 1578 | using forward_list _LIBCPP_AVAILABILITY_PMR = std::forward_list<_ValueT, polymorphic_allocator<_ValueT>>; |
| 1554 | 1579 | } // namespace pmr |
| 1555 | 1580 | _LIBCPP_END_NAMESPACE_STD |
| 1556 | #endif | |
| 1581 | # endif | |
| 1557 | 1582 | |
| 1558 | 1583 | _LIBCPP_POP_MACROS |
| 1559 | 1584 | |
| 1560 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1561 | # include <algorithm> | |
| 1562 | # include <atomic> | |
| 1563 | # include <concepts> | |
| 1564 | # include <cstdint> | |
| 1565 | # include <cstdlib> | |
| 1566 | # include <cstring> | |
| 1567 | # include <functional> | |
| 1568 | # include <iosfwd> | |
| 1569 | # include <iterator> | |
| 1570 | # include <stdexcept> | |
| 1571 | # include <type_traits> | |
| 1572 | # include <typeinfo> | |
| 1573 | #endif | |
| 1585 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1586 | # include <algorithm> | |
| 1587 | # include <atomic> | |
| 1588 | # include <concepts> | |
| 1589 | # include <cstdint> | |
| 1590 | # include <cstdlib> | |
| 1591 | # include <cstring> | |
| 1592 | # include <functional> | |
| 1593 | # include <iosfwd> | |
| 1594 | # include <iterator> | |
| 1595 | # include <stdexcept> | |
| 1596 | # include <type_traits> | |
| 1597 | # include <typeinfo> | |
| 1598 | # endif | |
| 1599 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1574 | 1600 | |
| 1575 | 1601 | #endif // _LIBCPP_FORWARD_LIST |
lib/libcxx/include/fstream+181-159| ... | ... | @@ -186,41 +186,43 @@ typedef basic_fstream<wchar_t> wfstream; |
| 186 | 186 | |
| 187 | 187 | */ |
| 188 | 188 | |
| 189 | #include <__algorithm/max.h> | |
| 190 | #include <__assert> | |
| 191 | #include <__config> | |
| 192 | #include <__fwd/fstream.h> | |
| 193 | #include <__locale> | |
| 194 | #include <__type_traits/enable_if.h> | |
| 195 | #include <__type_traits/is_same.h> | |
| 196 | #include <__utility/move.h> | |
| 197 | #include <__utility/swap.h> | |
| 198 | #include <__utility/unreachable.h> | |
| 199 | #include <cstdio> | |
| 200 | #include <filesystem> | |
| 201 | #include <istream> | |
| 202 | #include <ostream> | |
| 203 | #include <typeinfo> | |
| 204 | #include <version> | |
| 205 | ||
| 206 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 207 | # pragma GCC system_header | |
| 208 | #endif | |
| 189 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 190 | # include <__cxx03/fstream> | |
| 191 | #else | |
| 192 | # include <__algorithm/max.h> | |
| 193 | # include <__assert> | |
| 194 | # include <__config> | |
| 195 | # include <__filesystem/path.h> | |
| 196 | # include <__fwd/fstream.h> | |
| 197 | # include <__locale> | |
| 198 | # include <__memory/addressof.h> | |
| 199 | # include <__memory/unique_ptr.h> | |
| 200 | # include <__ostream/basic_ostream.h> | |
| 201 | # include <__type_traits/enable_if.h> | |
| 202 | # include <__type_traits/is_same.h> | |
| 203 | # include <__utility/move.h> | |
| 204 | # include <__utility/swap.h> | |
| 205 | # include <__utility/unreachable.h> | |
| 206 | # include <cstdio> | |
| 207 | # include <istream> | |
| 208 | # include <streambuf> | |
| 209 | # include <typeinfo> | |
| 210 | # include <version> | |
| 211 | ||
| 212 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 213 | # pragma GCC system_header | |
| 214 | # endif | |
| 209 | 215 | |
| 210 | 216 | _LIBCPP_PUSH_MACROS |
| 211 | #include <__undef_macros> | |
| 212 | ||
| 213 | #if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION) | |
| 214 | # define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS | |
| 215 | #endif | |
| 217 | # include <__undef_macros> | |
| 216 | 218 | |
| 217 | #if !defined(_LIBCPP_HAS_NO_FILESYSTEM) | |
| 219 | # if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 218 | 220 | |
| 219 | 221 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 220 | 222 | |
| 221 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API) | |
| 223 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API) | |
| 222 | 224 | _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) noexcept; |
| 223 | # endif | |
| 225 | # endif | |
| 224 | 226 | |
| 225 | 227 | template <class _CharT, class _Traits> |
| 226 | 228 | class _LIBCPP_TEMPLATE_VIS basic_filebuf : public basic_streambuf<_CharT, _Traits> { |
| ... | ... | @@ -231,15 +233,15 @@ public: |
| 231 | 233 | typedef typename traits_type::pos_type pos_type; |
| 232 | 234 | typedef typename traits_type::off_type off_type; |
| 233 | 235 | typedef typename traits_type::state_type state_type; |
| 234 | # if _LIBCPP_STD_VER >= 26 | |
| 235 | # if defined(_LIBCPP_WIN32API) | |
| 236 | # if _LIBCPP_STD_VER >= 26 | |
| 237 | # if defined(_LIBCPP_WIN32API) | |
| 236 | 238 | using native_handle_type = void*; // HANDLE |
| 237 | # elif __has_include(<unistd.h>) | |
| 239 | # elif __has_include(<unistd.h>) | |
| 238 | 240 | using native_handle_type = int; // POSIX file descriptor |
| 239 | # else | |
| 240 | # error "Provide a native file handle!" | |
| 241 | # else | |
| 242 | # error "Provide a native file handle!" | |
| 243 | # endif | |
| 241 | 244 | # endif |
| 242 | # endif | |
| 243 | 245 | |
| 244 | 246 | // 27.9.1.2 Constructors/destructor: |
| 245 | 247 | basic_filebuf(); |
| ... | ... | @@ -253,36 +255,36 @@ public: |
| 253 | 255 | // 27.9.1.4 Members: |
| 254 | 256 | _LIBCPP_HIDE_FROM_ABI bool is_open() const; |
| 255 | 257 | basic_filebuf* open(const char* __s, ios_base::openmode __mode); |
| 256 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 258 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 257 | 259 | basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode); |
| 258 | # endif | |
| 260 | # endif | |
| 259 | 261 | _LIBCPP_HIDE_FROM_ABI basic_filebuf* open(const string& __s, ios_base::openmode __mode); |
| 260 | 262 | |
| 261 | # if _LIBCPP_STD_VER >= 17 | |
| 263 | # if _LIBCPP_STD_VER >= 17 | |
| 262 | 264 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI basic_filebuf* |
| 263 | 265 | open(const filesystem::path& __p, ios_base::openmode __mode) { |
| 264 | 266 | return open(__p.c_str(), __mode); |
| 265 | 267 | } |
| 266 | # endif | |
| 268 | # endif | |
| 267 | 269 | _LIBCPP_HIDE_FROM_ABI basic_filebuf* __open(int __fd, ios_base::openmode __mode); |
| 268 | 270 | basic_filebuf* close(); |
| 269 | # if _LIBCPP_STD_VER >= 26 | |
| 271 | # if _LIBCPP_STD_VER >= 26 | |
| 270 | 272 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { |
| 271 | 273 | _LIBCPP_ASSERT_UNCATEGORIZED(this->is_open(), "File must be opened"); |
| 272 | # if defined(_LIBCPP_WIN32API) | |
| 274 | # if defined(_LIBCPP_WIN32API) | |
| 273 | 275 | return std::__filebuf_windows_native_handle(__file_); |
| 274 | # elif __has_include(<unistd.h>) | |
| 276 | # elif __has_include(<unistd.h>) | |
| 275 | 277 | return fileno(__file_); |
| 276 | # else | |
| 277 | # error "Provide a way to determine the file native handle!" | |
| 278 | # endif | |
| 278 | # else | |
| 279 | # error "Provide a way to determine the file native handle!" | |
| 280 | # endif | |
| 279 | 281 | } |
| 280 | # endif // _LIBCPP_STD_VER >= 26 | |
| 282 | # endif // _LIBCPP_STD_VER >= 26 | |
| 281 | 283 | |
| 282 | 284 | _LIBCPP_HIDE_FROM_ABI inline static const char* __make_mdstring(ios_base::openmode __mode) _NOEXCEPT; |
| 283 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 285 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 284 | 286 | _LIBCPP_HIDE_FROM_ABI inline static const wchar_t* __make_mdwstring(ios_base::openmode __mode) _NOEXCEPT; |
| 285 | # endif | |
| 287 | # endif | |
| 286 | 288 | |
| 287 | 289 | protected: |
| 288 | 290 | // 27.9.1.5 Overridden virtual functions: |
| ... | ... | @@ -354,6 +356,9 @@ private: |
| 354 | 356 | bool __read_mode(); |
| 355 | 357 | void __write_mode(); |
| 356 | 358 | |
| 359 | _LIBCPP_HIDE_FROM_ABI static int __fseek(FILE* __file, pos_type __offset, int __whence); | |
| 360 | _LIBCPP_HIDE_FROM_ABI static pos_type __ftell(FILE* __file); | |
| 361 | ||
| 357 | 362 | _LIBCPP_EXPORTED_FROM_ABI friend FILE* __get_ostream_file(ostream&); |
| 358 | 363 | |
| 359 | 364 | // There are multiple (__)open function, they use different C-API open |
| ... | ... | @@ -484,14 +489,14 @@ inline basic_filebuf<_CharT, _Traits>& basic_filebuf<_CharT, _Traits>::operator= |
| 484 | 489 | |
| 485 | 490 | template <class _CharT, class _Traits> |
| 486 | 491 | basic_filebuf<_CharT, _Traits>::~basic_filebuf() { |
| 487 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 492 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 488 | 493 | try { |
| 489 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 494 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 490 | 495 | close(); |
| 491 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 496 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 492 | 497 | } catch (...) { |
| 493 | 498 | } |
| 494 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 499 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 495 | 500 | if (__owns_eb_) |
| 496 | 501 | delete[] __extbuf_; |
| 497 | 502 | if (__owns_ib_) |
| ... | ... | @@ -611,7 +616,7 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _ |
| 611 | 616 | case ios_base::in | ios_base::out | ios_base::app | ios_base::binary: |
| 612 | 617 | case ios_base::in | ios_base::app | ios_base::binary: |
| 613 | 618 | return "a+b" _LIBCPP_FOPEN_CLOEXEC_MODE; |
| 614 | # if _LIBCPP_STD_VER >= 23 | |
| 619 | # if _LIBCPP_STD_VER >= 23 | |
| 615 | 620 | case ios_base::out | ios_base::noreplace: |
| 616 | 621 | case ios_base::out | ios_base::trunc | ios_base::noreplace: |
| 617 | 622 | return "wx" _LIBCPP_FOPEN_CLOEXEC_MODE; |
| ... | ... | @@ -622,14 +627,14 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _ |
| 622 | 627 | return "wbx" _LIBCPP_FOPEN_CLOEXEC_MODE; |
| 623 | 628 | case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace: |
| 624 | 629 | return "w+bx" _LIBCPP_FOPEN_CLOEXEC_MODE; |
| 625 | # endif // _LIBCPP_STD_VER >= 23 | |
| 630 | # endif // _LIBCPP_STD_VER >= 23 | |
| 626 | 631 | default: |
| 627 | 632 | return nullptr; |
| 628 | 633 | } |
| 629 | 634 | __libcpp_unreachable(); |
| 630 | 635 | } |
| 631 | 636 | |
| 632 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 637 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 633 | 638 | template <class _CharT, class _Traits> |
| 634 | 639 | const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmode __mode) _NOEXCEPT { |
| 635 | 640 | switch (__mode & ~ios_base::ate) { |
| ... | ... | @@ -663,7 +668,7 @@ const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmo |
| 663 | 668 | case ios_base::in | ios_base::out | ios_base::app | ios_base::binary: |
| 664 | 669 | case ios_base::in | ios_base::app | ios_base::binary: |
| 665 | 670 | return L"a+b"; |
| 666 | # if _LIBCPP_STD_VER >= 23 | |
| 671 | # if _LIBCPP_STD_VER >= 23 | |
| 667 | 672 | case ios_base::out | ios_base::noreplace: |
| 668 | 673 | case ios_base::out | ios_base::trunc | ios_base::noreplace: |
| 669 | 674 | return L"wx"; |
| ... | ... | @@ -674,13 +679,13 @@ const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmo |
| 674 | 679 | return L"wbx"; |
| 675 | 680 | case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace: |
| 676 | 681 | return L"w+bx"; |
| 677 | # endif // _LIBCPP_STD_VER >= 23 | |
| 682 | # endif // _LIBCPP_STD_VER >= 23 | |
| 678 | 683 | default: |
| 679 | 684 | return nullptr; |
| 680 | 685 | } |
| 681 | 686 | __libcpp_unreachable(); |
| 682 | 687 | } |
| 683 | # endif | |
| 688 | # endif | |
| 684 | 689 | |
| 685 | 690 | template <class _CharT, class _Traits> |
| 686 | 691 | basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) { |
| ... | ... | @@ -704,7 +709,7 @@ inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(in |
| 704 | 709 | return __do_open(fdopen(__fd, __mdstr), __mode); |
| 705 | 710 | } |
| 706 | 711 | |
| 707 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 712 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 708 | 713 | // This is basically the same as the char* overload except that it uses _wfopen |
| 709 | 714 | // and long mode strings. |
| 710 | 715 | template <class _CharT, class _Traits> |
| ... | ... | @@ -717,7 +722,7 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const wchar |
| 717 | 722 | |
| 718 | 723 | return __do_open(_wfopen(__s, __mdstr), __mode); |
| 719 | 724 | } |
| 720 | # endif | |
| 725 | # endif | |
| 721 | 726 | |
| 722 | 727 | template <class _CharT, class _Traits> |
| 723 | 728 | inline basic_filebuf<_CharT, _Traits>* |
| ... | ... | @@ -928,31 +933,42 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way, |
| 928 | 933 | default: |
| 929 | 934 | return pos_type(off_type(-1)); |
| 930 | 935 | } |
| 931 | # if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) | |
| 932 | if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence)) | |
| 936 | if (__fseek(__file_, __width > 0 ? __width * __off : 0, __whence)) | |
| 933 | 937 | return pos_type(off_type(-1)); |
| 934 | pos_type __r = ftell(__file_); | |
| 935 | # else | |
| 936 | if (::fseeko(__file_, __width > 0 ? __width * __off : 0, __whence)) | |
| 937 | return pos_type(off_type(-1)); | |
| 938 | pos_type __r = ftello(__file_); | |
| 939 | # endif | |
| 938 | pos_type __r = __ftell(__file_); | |
| 940 | 939 | __r.state(__st_); |
| 941 | 940 | return __r; |
| 942 | 941 | } |
| 943 | 942 | |
| 943 | template <class _CharT, class _Traits> | |
| 944 | int basic_filebuf<_CharT, _Traits>::__fseek(FILE* __file, pos_type __offset, int __whence) { | |
| 945 | # if defined(_LIBCPP_MSVCRT_LIKE) | |
| 946 | return _fseeki64(__file, __offset, __whence); | |
| 947 | # elif defined(_NEWLIB_VERSION) | |
| 948 | return fseek(__file, __offset, __whence); | |
| 949 | # else | |
| 950 | return ::fseeko(__file, __offset, __whence); | |
| 951 | # endif | |
| 952 | } | |
| 953 | ||
| 954 | template <class _CharT, class _Traits> | |
| 955 | typename basic_filebuf<_CharT, _Traits>::pos_type basic_filebuf<_CharT, _Traits>::__ftell(FILE* __file) { | |
| 956 | # if defined(_LIBCPP_MSVCRT_LIKE) | |
| 957 | return _ftelli64(__file); | |
| 958 | # elif defined(_NEWLIB_VERSION) | |
| 959 | return ftell(__file); | |
| 960 | # else | |
| 961 | return ftello(__file); | |
| 962 | # endif | |
| 963 | } | |
| 964 | ||
| 944 | 965 | template <class _CharT, class _Traits> |
| 945 | 966 | typename basic_filebuf<_CharT, _Traits>::pos_type |
| 946 | 967 | basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode) { |
| 947 | 968 | if (__file_ == nullptr || sync()) |
| 948 | 969 | return pos_type(off_type(-1)); |
| 949 | # if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) | |
| 950 | if (fseek(__file_, __sp, SEEK_SET)) | |
| 970 | if (__fseek(__file_, __sp, SEEK_SET)) | |
| 951 | 971 | return pos_type(off_type(-1)); |
| 952 | # else | |
| 953 | if (::fseeko(__file_, __sp, SEEK_SET)) | |
| 954 | return pos_type(off_type(-1)); | |
| 955 | # endif | |
| 956 | 972 | __st_ = __sp.state(); |
| 957 | 973 | return __sp; |
| 958 | 974 | } |
| ... | ... | @@ -999,13 +1015,8 @@ int basic_filebuf<_CharT, _Traits>::sync() { |
| 999 | 1015 | } |
| 1000 | 1016 | } |
| 1001 | 1017 | } |
| 1002 | # if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) | |
| 1003 | if (fseek(__file_, -__c, SEEK_CUR)) | |
| 1004 | return -1; | |
| 1005 | # else | |
| 1006 | if (::fseeko(__file_, -__c, SEEK_CUR)) | |
| 1018 | if (__fseek(__file_, -__c, SEEK_CUR)) | |
| 1007 | 1019 | return -1; |
| 1008 | # endif | |
| 1009 | 1020 | if (__update_st) |
| 1010 | 1021 | __st_ = __state; |
| 1011 | 1022 | __extbufnext_ = __extbufend_ = __extbuf_; |
| ... | ... | @@ -1091,42 +1102,42 @@ public: |
| 1091 | 1102 | typedef typename traits_type::int_type int_type; |
| 1092 | 1103 | typedef typename traits_type::pos_type pos_type; |
| 1093 | 1104 | typedef typename traits_type::off_type off_type; |
| 1094 | # if _LIBCPP_STD_VER >= 26 | |
| 1105 | # if _LIBCPP_STD_VER >= 26 | |
| 1095 | 1106 | using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type; |
| 1096 | # endif | |
| 1107 | # endif | |
| 1097 | 1108 | |
| 1098 | 1109 | _LIBCPP_HIDE_FROM_ABI basic_ifstream(); |
| 1099 | 1110 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in); |
| 1100 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1111 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1101 | 1112 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); |
| 1102 | # endif | |
| 1113 | # endif | |
| 1103 | 1114 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in); |
| 1104 | # if _LIBCPP_STD_VER >= 17 | |
| 1115 | # if _LIBCPP_STD_VER >= 17 | |
| 1105 | 1116 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> |
| 1106 | 1117 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY |
| 1107 | 1118 | _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const _Tp& __p, ios_base::openmode __mode = ios_base::in) |
| 1108 | 1119 | : basic_ifstream(__p.c_str(), __mode) {} |
| 1109 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1120 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1110 | 1121 | _LIBCPP_HIDE_FROM_ABI basic_ifstream(basic_ifstream&& __rhs); |
| 1111 | 1122 | _LIBCPP_HIDE_FROM_ABI basic_ifstream& operator=(basic_ifstream&& __rhs); |
| 1112 | 1123 | _LIBCPP_HIDE_FROM_ABI void swap(basic_ifstream& __rhs); |
| 1113 | 1124 | |
| 1114 | 1125 | _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const; |
| 1115 | # if _LIBCPP_STD_VER >= 26 | |
| 1126 | # if _LIBCPP_STD_VER >= 26 | |
| 1116 | 1127 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); } |
| 1117 | # endif | |
| 1128 | # endif | |
| 1118 | 1129 | _LIBCPP_HIDE_FROM_ABI bool is_open() const; |
| 1119 | 1130 | void open(const char* __s, ios_base::openmode __mode = ios_base::in); |
| 1120 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1131 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1121 | 1132 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); |
| 1122 | # endif | |
| 1133 | # endif | |
| 1123 | 1134 | void open(const string& __s, ios_base::openmode __mode = ios_base::in); |
| 1124 | # if _LIBCPP_STD_VER >= 17 | |
| 1135 | # if _LIBCPP_STD_VER >= 17 | |
| 1125 | 1136 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void |
| 1126 | 1137 | open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in) { |
| 1127 | 1138 | return open(__p.c_str(), __mode); |
| 1128 | 1139 | } |
| 1129 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1140 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1130 | 1141 | |
| 1131 | 1142 | _LIBCPP_HIDE_FROM_ABI void __open(int __fd, ios_base::openmode __mode); |
| 1132 | 1143 | _LIBCPP_HIDE_FROM_ABI void close(); |
| ... | ... | @@ -1136,27 +1147,29 @@ private: |
| 1136 | 1147 | }; |
| 1137 | 1148 | |
| 1138 | 1149 | template <class _CharT, class _Traits> |
| 1139 | inline basic_ifstream<_CharT, _Traits>::basic_ifstream() : basic_istream<char_type, traits_type>(&__sb_) {} | |
| 1150 | inline basic_ifstream<_CharT, _Traits>::basic_ifstream() | |
| 1151 | : basic_istream<char_type, traits_type>(std::addressof(__sb_)) {} | |
| 1140 | 1152 | |
| 1141 | 1153 | template <class _CharT, class _Traits> |
| 1142 | 1154 | inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode) |
| 1143 | : basic_istream<char_type, traits_type>(&__sb_) { | |
| 1155 | : basic_istream<char_type, traits_type>(std::addressof(__sb_)) { | |
| 1144 | 1156 | if (__sb_.open(__s, __mode | ios_base::in) == nullptr) |
| 1145 | 1157 | this->setstate(ios_base::failbit); |
| 1146 | 1158 | } |
| 1147 | 1159 | |
| 1148 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1160 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1149 | 1161 | template <class _CharT, class _Traits> |
| 1150 | 1162 | inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode) |
| 1151 | : basic_istream<char_type, traits_type>(&__sb_) { | |
| 1163 | : basic_istream<char_type, traits_type>(std::addressof(__sb_)) { | |
| 1152 | 1164 | if (__sb_.open(__s, __mode | ios_base::in) == nullptr) |
| 1153 | 1165 | this->setstate(ios_base::failbit); |
| 1154 | 1166 | } |
| 1155 | # endif | |
| 1167 | # endif | |
| 1156 | 1168 | |
| 1169 | // extension | |
| 1157 | 1170 | template <class _CharT, class _Traits> |
| 1158 | 1171 | inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode) |
| 1159 | : basic_istream<char_type, traits_type>(&__sb_) { | |
| 1172 | : basic_istream<char_type, traits_type>(std::addressof(__sb_)) { | |
| 1160 | 1173 | if (__sb_.open(__s, __mode | ios_base::in) == nullptr) |
| 1161 | 1174 | this->setstate(ios_base::failbit); |
| 1162 | 1175 | } |
| ... | ... | @@ -1164,7 +1177,7 @@ inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_ba |
| 1164 | 1177 | template <class _CharT, class _Traits> |
| 1165 | 1178 | inline basic_ifstream<_CharT, _Traits>::basic_ifstream(basic_ifstream&& __rhs) |
| 1166 | 1179 | : basic_istream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { |
| 1167 | this->set_rdbuf(&__sb_); | |
| 1180 | this->set_rdbuf(std::addressof(__sb_)); | |
| 1168 | 1181 | } |
| 1169 | 1182 | |
| 1170 | 1183 | template <class _CharT, class _Traits> |
| ... | ... | @@ -1187,7 +1200,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_ifstream<_CharT, _Traits>& __x, bas |
| 1187 | 1200 | |
| 1188 | 1201 | template <class _CharT, class _Traits> |
| 1189 | 1202 | inline basic_filebuf<_CharT, _Traits>* basic_ifstream<_CharT, _Traits>::rdbuf() const { |
| 1190 | return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_); | |
| 1203 | return const_cast<basic_filebuf<char_type, traits_type>*>(std::addressof(__sb_)); | |
| 1191 | 1204 | } |
| 1192 | 1205 | |
| 1193 | 1206 | template <class _CharT, class _Traits> |
| ... | ... | @@ -1203,7 +1216,7 @@ void basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode _ |
| 1203 | 1216 | this->setstate(ios_base::failbit); |
| 1204 | 1217 | } |
| 1205 | 1218 | |
| 1206 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1219 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1207 | 1220 | template <class _CharT, class _Traits> |
| 1208 | 1221 | void basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { |
| 1209 | 1222 | if (__sb_.open(__s, __mode | ios_base::in)) |
| ... | ... | @@ -1211,7 +1224,7 @@ void basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmod |
| 1211 | 1224 | else |
| 1212 | 1225 | this->setstate(ios_base::failbit); |
| 1213 | 1226 | } |
| 1214 | # endif | |
| 1227 | # endif | |
| 1215 | 1228 | |
| 1216 | 1229 | template <class _CharT, class _Traits> |
| 1217 | 1230 | void basic_ifstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) { |
| ... | ... | @@ -1245,45 +1258,45 @@ public: |
| 1245 | 1258 | typedef typename traits_type::int_type int_type; |
| 1246 | 1259 | typedef typename traits_type::pos_type pos_type; |
| 1247 | 1260 | typedef typename traits_type::off_type off_type; |
| 1248 | # if _LIBCPP_STD_VER >= 26 | |
| 1261 | # if _LIBCPP_STD_VER >= 26 | |
| 1249 | 1262 | using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type; |
| 1250 | # endif | |
| 1263 | # endif | |
| 1251 | 1264 | |
| 1252 | 1265 | _LIBCPP_HIDE_FROM_ABI basic_ofstream(); |
| 1253 | 1266 | _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out); |
| 1254 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1267 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1255 | 1268 | _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); |
| 1256 | # endif | |
| 1269 | # endif | |
| 1257 | 1270 | _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out); |
| 1258 | 1271 | |
| 1259 | # if _LIBCPP_STD_VER >= 17 | |
| 1272 | # if _LIBCPP_STD_VER >= 17 | |
| 1260 | 1273 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> |
| 1261 | 1274 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY |
| 1262 | 1275 | _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const _Tp& __p, ios_base::openmode __mode = ios_base::out) |
| 1263 | 1276 | : basic_ofstream(__p.c_str(), __mode) {} |
| 1264 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1277 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1265 | 1278 | |
| 1266 | 1279 | _LIBCPP_HIDE_FROM_ABI basic_ofstream(basic_ofstream&& __rhs); |
| 1267 | 1280 | _LIBCPP_HIDE_FROM_ABI basic_ofstream& operator=(basic_ofstream&& __rhs); |
| 1268 | 1281 | _LIBCPP_HIDE_FROM_ABI void swap(basic_ofstream& __rhs); |
| 1269 | 1282 | |
| 1270 | 1283 | _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const; |
| 1271 | # if _LIBCPP_STD_VER >= 26 | |
| 1284 | # if _LIBCPP_STD_VER >= 26 | |
| 1272 | 1285 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); } |
| 1273 | # endif | |
| 1286 | # endif | |
| 1274 | 1287 | _LIBCPP_HIDE_FROM_ABI bool is_open() const; |
| 1275 | 1288 | void open(const char* __s, ios_base::openmode __mode = ios_base::out); |
| 1276 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1289 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1277 | 1290 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); |
| 1278 | # endif | |
| 1291 | # endif | |
| 1279 | 1292 | void open(const string& __s, ios_base::openmode __mode = ios_base::out); |
| 1280 | 1293 | |
| 1281 | # if _LIBCPP_STD_VER >= 17 | |
| 1294 | # if _LIBCPP_STD_VER >= 17 | |
| 1282 | 1295 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void |
| 1283 | 1296 | open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out) { |
| 1284 | 1297 | return open(__p.c_str(), __mode); |
| 1285 | 1298 | } |
| 1286 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1299 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1287 | 1300 | |
| 1288 | 1301 | _LIBCPP_HIDE_FROM_ABI void __open(int __fd, ios_base::openmode __mode); |
| 1289 | 1302 | _LIBCPP_HIDE_FROM_ABI void close(); |
| ... | ... | @@ -1293,27 +1306,29 @@ private: |
| 1293 | 1306 | }; |
| 1294 | 1307 | |
| 1295 | 1308 | template <class _CharT, class _Traits> |
| 1296 | inline basic_ofstream<_CharT, _Traits>::basic_ofstream() : basic_ostream<char_type, traits_type>(&__sb_) {} | |
| 1309 | inline basic_ofstream<_CharT, _Traits>::basic_ofstream() | |
| 1310 | : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) {} | |
| 1297 | 1311 | |
| 1298 | 1312 | template <class _CharT, class _Traits> |
| 1299 | 1313 | inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode) |
| 1300 | : basic_ostream<char_type, traits_type>(&__sb_) { | |
| 1314 | : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) { | |
| 1301 | 1315 | if (__sb_.open(__s, __mode | ios_base::out) == nullptr) |
| 1302 | 1316 | this->setstate(ios_base::failbit); |
| 1303 | 1317 | } |
| 1304 | 1318 | |
| 1305 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1319 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1306 | 1320 | template <class _CharT, class _Traits> |
| 1307 | 1321 | inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode) |
| 1308 | : basic_ostream<char_type, traits_type>(&__sb_) { | |
| 1322 | : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) { | |
| 1309 | 1323 | if (__sb_.open(__s, __mode | ios_base::out) == nullptr) |
| 1310 | 1324 | this->setstate(ios_base::failbit); |
| 1311 | 1325 | } |
| 1312 | # endif | |
| 1326 | # endif | |
| 1313 | 1327 | |
| 1328 | // extension | |
| 1314 | 1329 | template <class _CharT, class _Traits> |
| 1315 | 1330 | inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode) |
| 1316 | : basic_ostream<char_type, traits_type>(&__sb_) { | |
| 1331 | : basic_ostream<char_type, traits_type>(std::addressof(__sb_)) { | |
| 1317 | 1332 | if (__sb_.open(__s, __mode | ios_base::out) == nullptr) |
| 1318 | 1333 | this->setstate(ios_base::failbit); |
| 1319 | 1334 | } |
| ... | ... | @@ -1321,7 +1336,7 @@ inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_ba |
| 1321 | 1336 | template <class _CharT, class _Traits> |
| 1322 | 1337 | inline basic_ofstream<_CharT, _Traits>::basic_ofstream(basic_ofstream&& __rhs) |
| 1323 | 1338 | : basic_ostream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { |
| 1324 | this->set_rdbuf(&__sb_); | |
| 1339 | this->set_rdbuf(std::addressof(__sb_)); | |
| 1325 | 1340 | } |
| 1326 | 1341 | |
| 1327 | 1342 | template <class _CharT, class _Traits> |
| ... | ... | @@ -1344,7 +1359,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_ofstream<_CharT, _Traits>& __x, bas |
| 1344 | 1359 | |
| 1345 | 1360 | template <class _CharT, class _Traits> |
| 1346 | 1361 | inline basic_filebuf<_CharT, _Traits>* basic_ofstream<_CharT, _Traits>::rdbuf() const { |
| 1347 | return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_); | |
| 1362 | return const_cast<basic_filebuf<char_type, traits_type>*>(std::addressof(__sb_)); | |
| 1348 | 1363 | } |
| 1349 | 1364 | |
| 1350 | 1365 | template <class _CharT, class _Traits> |
| ... | ... | @@ -1360,7 +1375,7 @@ void basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode _ |
| 1360 | 1375 | this->setstate(ios_base::failbit); |
| 1361 | 1376 | } |
| 1362 | 1377 | |
| 1363 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1378 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1364 | 1379 | template <class _CharT, class _Traits> |
| 1365 | 1380 | void basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { |
| 1366 | 1381 | if (__sb_.open(__s, __mode | ios_base::out)) |
| ... | ... | @@ -1368,7 +1383,7 @@ void basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmod |
| 1368 | 1383 | else |
| 1369 | 1384 | this->setstate(ios_base::failbit); |
| 1370 | 1385 | } |
| 1371 | # endif | |
| 1386 | # endif | |
| 1372 | 1387 | |
| 1373 | 1388 | template <class _CharT, class _Traits> |
| 1374 | 1389 | void basic_ofstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) { |
| ... | ... | @@ -1402,26 +1417,26 @@ public: |
| 1402 | 1417 | typedef typename traits_type::int_type int_type; |
| 1403 | 1418 | typedef typename traits_type::pos_type pos_type; |
| 1404 | 1419 | typedef typename traits_type::off_type off_type; |
| 1405 | # if _LIBCPP_STD_VER >= 26 | |
| 1420 | # if _LIBCPP_STD_VER >= 26 | |
| 1406 | 1421 | using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type; |
| 1407 | # endif | |
| 1422 | # endif | |
| 1408 | 1423 | |
| 1409 | 1424 | _LIBCPP_HIDE_FROM_ABI basic_fstream(); |
| 1410 | 1425 | _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const char* __s, |
| 1411 | 1426 | ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1412 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1427 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1413 | 1428 | _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const wchar_t* __s, |
| 1414 | 1429 | ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1415 | # endif | |
| 1430 | # endif | |
| 1416 | 1431 | _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const string& __s, |
| 1417 | 1432 | ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1418 | 1433 | |
| 1419 | # if _LIBCPP_STD_VER >= 17 | |
| 1434 | # if _LIBCPP_STD_VER >= 17 | |
| 1420 | 1435 | template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>> |
| 1421 | 1436 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_fstream( |
| 1422 | 1437 | const _Tp& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) |
| 1423 | 1438 | : basic_fstream(__p.c_str(), __mode) {} |
| 1424 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1439 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1425 | 1440 | |
| 1426 | 1441 | _LIBCPP_HIDE_FROM_ABI basic_fstream(basic_fstream&& __rhs); |
| 1427 | 1442 | |
| ... | ... | @@ -1430,22 +1445,22 @@ public: |
| 1430 | 1445 | _LIBCPP_HIDE_FROM_ABI void swap(basic_fstream& __rhs); |
| 1431 | 1446 | |
| 1432 | 1447 | _LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf() const; |
| 1433 | # if _LIBCPP_STD_VER >= 26 | |
| 1448 | # if _LIBCPP_STD_VER >= 26 | |
| 1434 | 1449 | _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() const noexcept { return rdbuf()->native_handle(); } |
| 1435 | # endif | |
| 1450 | # endif | |
| 1436 | 1451 | _LIBCPP_HIDE_FROM_ABI bool is_open() const; |
| 1437 | 1452 | _LIBCPP_HIDE_FROM_ABI void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1438 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1453 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1439 | 1454 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1440 | # endif | |
| 1455 | # endif | |
| 1441 | 1456 | _LIBCPP_HIDE_FROM_ABI void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1442 | 1457 | |
| 1443 | # if _LIBCPP_STD_VER >= 17 | |
| 1458 | # if _LIBCPP_STD_VER >= 17 | |
| 1444 | 1459 | _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI void |
| 1445 | 1460 | open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out) { |
| 1446 | 1461 | return open(__p.c_str(), __mode); |
| 1447 | 1462 | } |
| 1448 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1463 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1449 | 1464 | |
| 1450 | 1465 | _LIBCPP_HIDE_FROM_ABI void close(); |
| 1451 | 1466 | |
| ... | ... | @@ -1454,35 +1469,37 @@ private: |
| 1454 | 1469 | }; |
| 1455 | 1470 | |
| 1456 | 1471 | template <class _CharT, class _Traits> |
| 1457 | inline basic_fstream<_CharT, _Traits>::basic_fstream() : basic_iostream<char_type, traits_type>(&__sb_) {} | |
| 1472 | inline basic_fstream<_CharT, _Traits>::basic_fstream() | |
| 1473 | : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) {} | |
| 1458 | 1474 | |
| 1459 | 1475 | template <class _CharT, class _Traits> |
| 1460 | 1476 | inline basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode) |
| 1461 | : basic_iostream<char_type, traits_type>(&__sb_) { | |
| 1477 | : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) { | |
| 1462 | 1478 | if (__sb_.open(__s, __mode) == nullptr) |
| 1463 | 1479 | this->setstate(ios_base::failbit); |
| 1464 | 1480 | } |
| 1465 | 1481 | |
| 1466 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1482 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1467 | 1483 | template <class _CharT, class _Traits> |
| 1468 | 1484 | inline basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode) |
| 1469 | : basic_iostream<char_type, traits_type>(&__sb_) { | |
| 1485 | : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) { | |
| 1470 | 1486 | if (__sb_.open(__s, __mode) == nullptr) |
| 1471 | 1487 | this->setstate(ios_base::failbit); |
| 1472 | 1488 | } |
| 1473 | # endif | |
| 1489 | # endif | |
| 1474 | 1490 | |
| 1475 | 1491 | template <class _CharT, class _Traits> |
| 1476 | 1492 | inline basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode) |
| 1477 | : basic_iostream<char_type, traits_type>(&__sb_) { | |
| 1493 | : basic_iostream<char_type, traits_type>(std::addressof(__sb_)) { | |
| 1478 | 1494 | if (__sb_.open(__s, __mode) == nullptr) |
| 1479 | 1495 | this->setstate(ios_base::failbit); |
| 1480 | 1496 | } |
| 1481 | 1497 | |
| 1498 | // extension | |
| 1482 | 1499 | template <class _CharT, class _Traits> |
| 1483 | 1500 | inline basic_fstream<_CharT, _Traits>::basic_fstream(basic_fstream&& __rhs) |
| 1484 | 1501 | : basic_iostream<char_type, traits_type>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { |
| 1485 | this->set_rdbuf(&__sb_); | |
| 1502 | this->set_rdbuf(std::addressof(__sb_)); | |
| 1486 | 1503 | } |
| 1487 | 1504 | |
| 1488 | 1505 | template <class _CharT, class _Traits> |
| ... | ... | @@ -1505,7 +1522,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(basic_fstream<_CharT, _Traits>& __x, basi |
| 1505 | 1522 | |
| 1506 | 1523 | template <class _CharT, class _Traits> |
| 1507 | 1524 | inline basic_filebuf<_CharT, _Traits>* basic_fstream<_CharT, _Traits>::rdbuf() const { |
| 1508 | return const_cast<basic_filebuf<char_type, traits_type>*>(&__sb_); | |
| 1525 | return const_cast<basic_filebuf<char_type, traits_type>*>(std::addressof(__sb_)); | |
| 1509 | 1526 | } |
| 1510 | 1527 | |
| 1511 | 1528 | template <class _CharT, class _Traits> |
| ... | ... | @@ -1521,7 +1538,7 @@ void basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __ |
| 1521 | 1538 | this->setstate(ios_base::failbit); |
| 1522 | 1539 | } |
| 1523 | 1540 | |
| 1524 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1541 | # if _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 1525 | 1542 | template <class _CharT, class _Traits> |
| 1526 | 1543 | void basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { |
| 1527 | 1544 | if (__sb_.open(__s, __mode)) |
| ... | ... | @@ -1529,7 +1546,7 @@ void basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode |
| 1529 | 1546 | else |
| 1530 | 1547 | this->setstate(ios_base::failbit); |
| 1531 | 1548 | } |
| 1532 | # endif | |
| 1549 | # endif | |
| 1533 | 1550 | |
| 1534 | 1551 | template <class _CharT, class _Traits> |
| 1535 | 1552 | void basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mode) { |
| ... | ... | @@ -1545,28 +1562,33 @@ inline void basic_fstream<_CharT, _Traits>::close() { |
| 1545 | 1562 | this->setstate(ios_base::failbit); |
| 1546 | 1563 | } |
| 1547 | 1564 | |
| 1548 | # if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 | |
| 1565 | # if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 | |
| 1549 | 1566 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>; |
| 1550 | 1567 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>; |
| 1551 | 1568 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>; |
| 1552 | # endif | |
| 1569 | # endif | |
| 1553 | 1570 | |
| 1554 | 1571 | _LIBCPP_END_NAMESPACE_STD |
| 1555 | 1572 | |
| 1556 | #endif // _LIBCPP_HAS_NO_FILESYSTEM | |
| 1573 | # endif // _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 1557 | 1574 | |
| 1558 | 1575 | _LIBCPP_POP_MACROS |
| 1559 | 1576 | |
| 1560 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1561 | # include <atomic> | |
| 1562 | # include <concepts> | |
| 1563 | # include <cstdlib> | |
| 1564 | # include <iosfwd> | |
| 1565 | # include <limits> | |
| 1566 | # include <mutex> | |
| 1567 | # include <new> | |
| 1568 | # include <stdexcept> | |
| 1569 | # include <type_traits> | |
| 1570 | #endif | |
| 1577 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1578 | # include <atomic> | |
| 1579 | # include <concepts> | |
| 1580 | # include <cstdlib> | |
| 1581 | # include <iosfwd> | |
| 1582 | # include <limits> | |
| 1583 | # include <mutex> | |
| 1584 | # include <new> | |
| 1585 | # include <stdexcept> | |
| 1586 | # include <type_traits> | |
| 1587 | # endif | |
| 1588 | ||
| 1589 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 | |
| 1590 | # include <filesystem> | |
| 1591 | # endif | |
| 1592 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1571 | 1593 | |
| 1572 | 1594 | #endif // _LIBCPP_FSTREAM |
lib/libcxx/include/functional+75-69| ... | ... | @@ -214,7 +214,9 @@ template <class Predicate> // deprecated in C++17, removed in C++20 |
| 214 | 214 | binary_negate<Predicate> not2(const Predicate& pred); |
| 215 | 215 | |
| 216 | 216 | template <class F> |
| 217 | 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 | |
| 218 | template <auto f> | |
| 219 | constexpr unspecified not_fn() noexcept; // C++26 | |
| 218 | 220 | |
| 219 | 221 | // [func.bind.partial], function templates bind_front and bind_back |
| 220 | 222 | template<class F, class... Args> |
| ... | ... | @@ -395,7 +397,7 @@ const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); |
| 395 | 397 | template <class S, class T, class A> |
| 396 | 398 | const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); // deprecated in C++11, removed in C++17 |
| 397 | 399 | |
| 398 | template<class R, class T> constexpr unspecified mem_fn(R T::*); // constexpr in C++20 | |
| 400 | template<class R, class T> constexpr unspecified mem_fn(R T::*) noexcept; // constexpr in C++20 | |
| 399 | 401 | |
| 400 | 402 | class bad_function_call |
| 401 | 403 | : public exception |
| ... | ... | @@ -527,72 +529,76 @@ POLICY: For non-variadic implementations, the number of arguments is limited |
| 527 | 529 | |
| 528 | 530 | */ |
| 529 | 531 | |
| 530 | #include <__config> | |
| 531 | ||
| 532 | #include <__functional/binary_function.h> | |
| 533 | #include <__functional/binary_negate.h> | |
| 534 | #include <__functional/bind.h> | |
| 535 | #include <__functional/binder1st.h> | |
| 536 | #include <__functional/binder2nd.h> | |
| 537 | #include <__functional/hash.h> | |
| 538 | #include <__functional/mem_fn.h> // TODO: deprecate | |
| 539 | #include <__functional/mem_fun_ref.h> | |
| 540 | #include <__functional/operations.h> | |
| 541 | #include <__functional/pointer_to_binary_function.h> | |
| 542 | #include <__functional/pointer_to_unary_function.h> | |
| 543 | #include <__functional/reference_wrapper.h> | |
| 544 | #include <__functional/unary_function.h> | |
| 545 | #include <__functional/unary_negate.h> | |
| 546 | ||
| 547 | #ifndef _LIBCPP_CXX03_LANG | |
| 548 | # include <__functional/function.h> | |
| 549 | #endif | |
| 550 | ||
| 551 | #if _LIBCPP_STD_VER >= 17 | |
| 552 | # include <__functional/boyer_moore_searcher.h> | |
| 553 | # include <__functional/default_searcher.h> | |
| 554 | # include <__functional/invoke.h> | |
| 555 | # include <__functional/not_fn.h> | |
| 556 | #endif | |
| 557 | ||
| 558 | #if _LIBCPP_STD_VER >= 20 | |
| 559 | # include <__functional/bind_back.h> | |
| 560 | # include <__functional/bind_front.h> | |
| 561 | # include <__functional/identity.h> | |
| 562 | # include <__functional/ranges_operations.h> | |
| 563 | # include <__type_traits/unwrap_ref.h> | |
| 564 | #endif | |
| 565 | ||
| 566 | #include <version> | |
| 567 | ||
| 568 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 569 | # pragma GCC system_header | |
| 570 | #endif | |
| 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 | ||
| 584 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 585 | # include <atomic> | |
| 586 | # include <concepts> | |
| 587 | # include <cstdlib> | |
| 588 | # include <exception> | |
| 589 | # include <iosfwd> | |
| 590 | # include <memory> | |
| 591 | # include <stdexcept> | |
| 592 | # include <tuple> | |
| 593 | # include <type_traits> | |
| 594 | # include <typeinfo> | |
| 595 | # include <utility> | |
| 596 | #endif | |
| 532 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 533 | # include <__cxx03/functional> | |
| 534 | #else | |
| 535 | # include <__config> | |
| 536 | ||
| 537 | # include <__functional/binary_function.h> | |
| 538 | # include <__functional/binary_negate.h> | |
| 539 | # include <__functional/bind.h> | |
| 540 | # include <__functional/binder1st.h> | |
| 541 | # include <__functional/binder2nd.h> | |
| 542 | # include <__functional/hash.h> | |
| 543 | # include <__functional/mem_fn.h> // TODO: deprecate | |
| 544 | # include <__functional/mem_fun_ref.h> | |
| 545 | # include <__functional/operations.h> | |
| 546 | # include <__functional/pointer_to_binary_function.h> | |
| 547 | # include <__functional/pointer_to_unary_function.h> | |
| 548 | # include <__functional/reference_wrapper.h> | |
| 549 | # include <__functional/unary_function.h> | |
| 550 | # include <__functional/unary_negate.h> | |
| 551 | ||
| 552 | # ifndef _LIBCPP_CXX03_LANG | |
| 553 | # include <__functional/function.h> | |
| 554 | # endif | |
| 555 | ||
| 556 | # if _LIBCPP_STD_VER >= 17 | |
| 557 | # include <__functional/boyer_moore_searcher.h> | |
| 558 | # include <__functional/default_searcher.h> | |
| 559 | # include <__functional/invoke.h> | |
| 560 | # include <__functional/not_fn.h> | |
| 561 | # endif | |
| 562 | ||
| 563 | # if _LIBCPP_STD_VER >= 20 | |
| 564 | # include <__functional/bind_back.h> | |
| 565 | # include <__functional/bind_front.h> | |
| 566 | # include <__functional/identity.h> | |
| 567 | # include <__functional/ranges_operations.h> | |
| 568 | # include <__type_traits/unwrap_ref.h> | |
| 569 | # endif | |
| 570 | ||
| 571 | # include <version> | |
| 572 | ||
| 573 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 574 | # pragma GCC system_header | |
| 575 | # endif | |
| 576 | ||
| 577 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && defined(_LIBCPP_CXX03_LANG) | |
| 578 | # include <limits> | |
| 579 | # include <new> | |
| 580 | # endif | |
| 581 | ||
| 582 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 | |
| 583 | # include <array> | |
| 584 | # include <initializer_list> | |
| 585 | # include <unordered_map> | |
| 586 | # endif | |
| 587 | ||
| 588 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 589 | # include <atomic> | |
| 590 | # include <concepts> | |
| 591 | # include <cstdlib> | |
| 592 | # include <exception> | |
| 593 | # include <iosfwd> | |
| 594 | # include <memory> | |
| 595 | # include <stdexcept> | |
| 596 | # include <tuple> | |
| 597 | # include <type_traits> | |
| 598 | # include <typeinfo> | |
| 599 | # include <utility> | |
| 600 | # include <vector> | |
| 601 | # endif | |
| 602 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 597 | 603 | |
| 598 | 604 | #endif // _LIBCPP_FUNCTIONAL |
lib/libcxx/include/future+153-125| ... | ... | @@ -329,7 +329,7 @@ public: |
| 329 | 329 | template <class F> |
| 330 | 330 | explicit packaged_task(F&& f); |
| 331 | 331 | template <class F, class Allocator> |
| 332 | packaged_task(allocator_arg_t, const Allocator& a, F&& f); | |
| 332 | packaged_task(allocator_arg_t, const Allocator& a, F&& f); // removed in C++17 | |
| 333 | 333 | ~packaged_task(); |
| 334 | 334 | |
| 335 | 335 | // no copy |
| ... | ... | @@ -356,50 +356,68 @@ public: |
| 356 | 356 | template <class R> |
| 357 | 357 | void swap(packaged_task<R(ArgTypes...)&, packaged_task<R(ArgTypes...)>&) noexcept; |
| 358 | 358 | |
| 359 | template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; | |
| 359 | template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; // removed in C++17 | |
| 360 | 360 | |
| 361 | 361 | } // std |
| 362 | 362 | |
| 363 | 363 | */ |
| 364 | 364 | |
| 365 | #include <__config> | |
| 366 | ||
| 367 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 368 | ||
| 369 | # include <__assert> | |
| 370 | # include <__chrono/duration.h> | |
| 371 | # include <__chrono/time_point.h> | |
| 372 | # include <__exception/exception_ptr.h> | |
| 373 | # include <__memory/addressof.h> | |
| 374 | # include <__memory/allocator.h> | |
| 375 | # include <__memory/allocator_arg_t.h> | |
| 376 | # include <__memory/allocator_destructor.h> | |
| 377 | # include <__memory/allocator_traits.h> | |
| 378 | # include <__memory/compressed_pair.h> | |
| 379 | # include <__memory/pointer_traits.h> | |
| 380 | # include <__memory/shared_ptr.h> | |
| 381 | # include <__memory/unique_ptr.h> | |
| 382 | # include <__memory/uses_allocator.h> | |
| 383 | # include <__system_error/error_category.h> | |
| 384 | # include <__system_error/error_code.h> | |
| 385 | # include <__system_error/error_condition.h> | |
| 386 | # include <__type_traits/aligned_storage.h> | |
| 387 | # include <__type_traits/strip_signature.h> | |
| 388 | # include <__utility/auto_cast.h> | |
| 389 | # include <__utility/forward.h> | |
| 390 | # include <__utility/move.h> | |
| 391 | # include <mutex> | |
| 392 | # include <new> | |
| 393 | # include <stdexcept> | |
| 394 | # include <thread> | |
| 395 | # include <version> | |
| 396 | ||
| 397 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 398 | # pragma GCC system_header | |
| 399 | # endif | |
| 365 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 366 | # include <__cxx03/future> | |
| 367 | #else | |
| 368 | # include <__config> | |
| 369 | ||
| 370 | # if _LIBCPP_HAS_THREADS | |
| 371 | ||
| 372 | # include <__assert> | |
| 373 | # include <__chrono/duration.h> | |
| 374 | # include <__chrono/steady_clock.h> | |
| 375 | # include <__chrono/time_point.h> | |
| 376 | # include <__condition_variable/condition_variable.h> | |
| 377 | # include <__cstddef/nullptr_t.h> | |
| 378 | # include <__exception/exception_ptr.h> | |
| 379 | # include <__memory/addressof.h> | |
| 380 | # include <__memory/allocator.h> | |
| 381 | # include <__memory/allocator_arg_t.h> | |
| 382 | # include <__memory/allocator_destructor.h> | |
| 383 | # include <__memory/allocator_traits.h> | |
| 384 | # include <__memory/compressed_pair.h> | |
| 385 | # include <__memory/pointer_traits.h> | |
| 386 | # include <__memory/shared_count.h> | |
| 387 | # include <__memory/unique_ptr.h> | |
| 388 | # include <__memory/uses_allocator.h> | |
| 389 | # include <__mutex/lock_guard.h> | |
| 390 | # include <__mutex/mutex.h> | |
| 391 | # include <__mutex/unique_lock.h> | |
| 392 | # include <__system_error/error_category.h> | |
| 393 | # include <__system_error/error_code.h> | |
| 394 | # include <__system_error/error_condition.h> | |
| 395 | # include <__thread/thread.h> | |
| 396 | # include <__type_traits/add_lvalue_reference.h> | |
| 397 | # include <__type_traits/aligned_storage.h> | |
| 398 | # include <__type_traits/conditional.h> | |
| 399 | # include <__type_traits/decay.h> | |
| 400 | # include <__type_traits/enable_if.h> | |
| 401 | # include <__type_traits/invoke.h> | |
| 402 | # include <__type_traits/is_same.h> | |
| 403 | # include <__type_traits/remove_cvref.h> | |
| 404 | # include <__type_traits/remove_reference.h> | |
| 405 | # include <__type_traits/strip_signature.h> | |
| 406 | # include <__type_traits/underlying_type.h> | |
| 407 | # include <__utility/auto_cast.h> | |
| 408 | # include <__utility/forward.h> | |
| 409 | # include <__utility/move.h> | |
| 410 | # include <__utility/swap.h> | |
| 411 | # include <stdexcept> | |
| 412 | # include <tuple> | |
| 413 | # include <version> | |
| 414 | ||
| 415 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 416 | # pragma GCC system_header | |
| 417 | # endif | |
| 400 | 418 | |
| 401 | 419 | _LIBCPP_PUSH_MACROS |
| 402 | # include <__undef_macros> | |
| 420 | # include <__undef_macros> | |
| 403 | 421 | |
| 404 | 422 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 405 | 423 | |
| ... | ... | @@ -411,16 +429,16 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) |
| 411 | 429 | template <> |
| 412 | 430 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {}; |
| 413 | 431 | |
| 414 | # ifdef _LIBCPP_CXX03_LANG | |
| 432 | # ifdef _LIBCPP_CXX03_LANG | |
| 415 | 433 | template <> |
| 416 | 434 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type {}; |
| 417 | # endif | |
| 435 | # endif | |
| 418 | 436 | |
| 419 | 437 | // enum class launch |
| 420 | 438 | _LIBCPP_DECLARE_STRONG_ENUM(launch){async = 1, deferred = 2, any = async | deferred}; |
| 421 | 439 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch) |
| 422 | 440 | |
| 423 | # ifndef _LIBCPP_CXX03_LANG | |
| 441 | # ifndef _LIBCPP_CXX03_LANG | |
| 424 | 442 | |
| 425 | 443 | typedef underlying_type<launch>::type __launch_underlying_type; |
| 426 | 444 | |
| ... | ... | @@ -455,7 +473,7 @@ inline _LIBCPP_HIDE_FROM_ABI launch& operator^=(launch& __x, launch __y) { |
| 455 | 473 | return __x; |
| 456 | 474 | } |
| 457 | 475 | |
| 458 | # endif // !_LIBCPP_CXX03_LANG | |
| 476 | # endif // !_LIBCPP_CXX03_LANG | |
| 459 | 477 | |
| 460 | 478 | // enum class future_status |
| 461 | 479 | _LIBCPP_DECLARE_STRONG_ENUM(future_status){ready, timeout, deferred}; |
| ... | ... | @@ -471,7 +489,7 @@ inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(future_errc __ |
| 471 | 489 | return error_condition(static_cast<int>(__e), future_category()); |
| 472 | 490 | } |
| 473 | 491 | |
| 474 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_future_error(future_errc __ev); | |
| 492 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_future_error(future_errc __ev); | |
| 475 | 493 | |
| 476 | 494 | class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error { |
| 477 | 495 | error_code __ec_; |
| ... | ... | @@ -482,9 +500,9 @@ class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error { |
| 482 | 500 | friend class promise; |
| 483 | 501 | |
| 484 | 502 | public: |
| 485 | # if _LIBCPP_STD_VER >= 17 | |
| 503 | # if _LIBCPP_STD_VER >= 17 | |
| 486 | 504 | _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {} |
| 487 | # endif | |
| 505 | # endif | |
| 488 | 506 | |
| 489 | 507 | _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } |
| 490 | 508 | |
| ... | ... | @@ -494,12 +512,12 @@ public: |
| 494 | 512 | |
| 495 | 513 | // Declared above std::future_error |
| 496 | 514 | void __throw_future_error(future_errc __ev) { |
| 497 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 515 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 498 | 516 | throw future_error(make_error_code(__ev)); |
| 499 | # else | |
| 517 | # else | |
| 500 | 518 | (void)__ev; |
| 501 | 519 | _LIBCPP_VERBOSE_ABORT("future_error was thrown in -fno-exceptions mode"); |
| 502 | # endif | |
| 520 | # endif | |
| 503 | 521 | } |
| 504 | 522 | |
| 505 | 523 | class _LIBCPP_EXPORTED_FROM_ABI __assoc_sub_state : public __shared_count { |
| ... | ... | @@ -588,7 +606,7 @@ public: |
| 588 | 606 | _LIBCPP_HIDE_FROM_ABI void set_value_at_thread_exit(_Arg&& __arg); |
| 589 | 607 | |
| 590 | 608 | _LIBCPP_HIDE_FROM_ABI _Rp move(); |
| 591 | _LIBCPP_HIDE_FROM_ABI __add_lvalue_reference_t<_Rp> copy(); | |
| 609 | _LIBCPP_HIDE_FROM_ABI _Rp& copy(); | |
| 592 | 610 | }; |
| 593 | 611 | |
| 594 | 612 | template <class _Rp> |
| ... | ... | @@ -630,7 +648,7 @@ _Rp __assoc_state<_Rp>::move() { |
| 630 | 648 | } |
| 631 | 649 | |
| 632 | 650 | template <class _Rp> |
| 633 | __add_lvalue_reference_t<_Rp> __assoc_state<_Rp>::copy() { | |
| 651 | _Rp& __assoc_state<_Rp>::copy() { | |
| 634 | 652 | unique_lock<mutex> __lk(this->__mut_); |
| 635 | 653 | this->__sub_wait(__lk); |
| 636 | 654 | if (this->__exception_ != nullptr) |
| ... | ... | @@ -773,15 +791,15 @@ inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __f |
| 773 | 791 | |
| 774 | 792 | template <class _Rp, class _Fp> |
| 775 | 793 | void __deferred_assoc_state<_Rp, _Fp>::__execute() { |
| 776 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 794 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 777 | 795 | try { |
| 778 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 796 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 779 | 797 | this->set_value(__func_()); |
| 780 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 798 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 781 | 799 | } catch (...) { |
| 782 | 800 | this->set_exception(current_exception()); |
| 783 | 801 | } |
| 784 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 802 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 785 | 803 | } |
| 786 | 804 | |
| 787 | 805 | template <class _Fp> |
| ... | ... | @@ -803,16 +821,16 @@ inline __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f) : __ |
| 803 | 821 | |
| 804 | 822 | template <class _Fp> |
| 805 | 823 | void __deferred_assoc_state<void, _Fp>::__execute() { |
| 806 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 824 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 807 | 825 | try { |
| 808 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 826 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 809 | 827 | __func_(); |
| 810 | 828 | this->set_value(); |
| 811 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 829 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 812 | 830 | } catch (...) { |
| 813 | 831 | this->set_exception(current_exception()); |
| 814 | 832 | } |
| 815 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 833 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 816 | 834 | } |
| 817 | 835 | |
| 818 | 836 | template <class _Rp, class _Fp> |
| ... | ... | @@ -834,15 +852,15 @@ inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(s |
| 834 | 852 | |
| 835 | 853 | template <class _Rp, class _Fp> |
| 836 | 854 | void __async_assoc_state<_Rp, _Fp>::__execute() { |
| 837 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 855 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 838 | 856 | try { |
| 839 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 857 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 840 | 858 | this->set_value(__func_()); |
| 841 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 859 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 842 | 860 | } catch (...) { |
| 843 | 861 | this->set_exception(current_exception()); |
| 844 | 862 | } |
| 845 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 863 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 846 | 864 | } |
| 847 | 865 | |
| 848 | 866 | template <class _Rp, class _Fp> |
| ... | ... | @@ -870,16 +888,16 @@ inline __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f) : __func_( |
| 870 | 888 | |
| 871 | 889 | template <class _Fp> |
| 872 | 890 | void __async_assoc_state<void, _Fp>::__execute() { |
| 873 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 891 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 874 | 892 | try { |
| 875 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 893 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 876 | 894 | __func_(); |
| 877 | 895 | this->set_value(); |
| 878 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 896 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 879 | 897 | } catch (...) { |
| 880 | 898 | this->set_exception(current_exception()); |
| 881 | 899 | } |
| 882 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 900 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 883 | 901 | } |
| 884 | 902 | |
| 885 | 903 | template <class _Fp> |
| ... | ... | @@ -1399,13 +1417,13 @@ class __packaged_task_func; |
| 1399 | 1417 | |
| 1400 | 1418 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> |
| 1401 | 1419 | class __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __packaged_task_base<_Rp(_ArgTypes...)> { |
| 1402 | __compressed_pair<_Fp, _Alloc> __f_; | |
| 1420 | _LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Alloc, __alloc_); | |
| 1403 | 1421 | |
| 1404 | 1422 | public: |
| 1405 | _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(const _Fp& __f) : __f_(__f, __default_init_tag()) {} | |
| 1406 | _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(_Fp&& __f) : __f_(std::move(__f), __default_init_tag()) {} | |
| 1407 | _LIBCPP_HIDE_FROM_ABI __packaged_task_func(const _Fp& __f, const _Alloc& __a) : __f_(__f, __a) {} | |
| 1408 | _LIBCPP_HIDE_FROM_ABI __packaged_task_func(_Fp&& __f, const _Alloc& __a) : __f_(std::move(__f), __a) {} | |
| 1423 | _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(const _Fp& __f) : __func_(__f) {} | |
| 1424 | _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(_Fp&& __f) : __func_(std::move(__f)) {} | |
| 1425 | _LIBCPP_HIDE_FROM_ABI __packaged_task_func(const _Fp& __f, const _Alloc& __a) : __func_(__f), __alloc_(__a) {} | |
| 1426 | _LIBCPP_HIDE_FROM_ABI __packaged_task_func(_Fp&& __f, const _Alloc& __a) : __func_(std::move(__f)), __alloc_(__a) {} | |
| 1409 | 1427 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __move_to(__packaged_task_base<_Rp(_ArgTypes...)>*) _NOEXCEPT; |
| 1410 | 1428 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy(); |
| 1411 | 1429 | _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate(); |
| ... | ... | @@ -1415,12 +1433,13 @@ public: |
| 1415 | 1433 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> |
| 1416 | 1434 | void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to( |
| 1417 | 1435 | __packaged_task_base<_Rp(_ArgTypes...)>* __p) _NOEXCEPT { |
| 1418 | ::new ((void*)__p) __packaged_task_func(std::move(__f_.first()), std::move(__f_.second())); | |
| 1436 | ::new ((void*)__p) __packaged_task_func(std::move(__func_), std::move(__alloc_)); | |
| 1419 | 1437 | } |
| 1420 | 1438 | |
| 1421 | 1439 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> |
| 1422 | 1440 | void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() { |
| 1423 | __f_.~__compressed_pair<_Fp, _Alloc>(); | |
| 1441 | __func_.~_Fp(); | |
| 1442 | __alloc_.~_Alloc(); | |
| 1424 | 1443 | } |
| 1425 | 1444 | |
| 1426 | 1445 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> |
| ... | ... | @@ -1428,14 +1447,15 @@ void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() |
| 1428 | 1447 | typedef typename __allocator_traits_rebind<_Alloc, __packaged_task_func>::type _Ap; |
| 1429 | 1448 | typedef allocator_traits<_Ap> _ATraits; |
| 1430 | 1449 | typedef pointer_traits<typename _ATraits::pointer> _PTraits; |
| 1431 | _Ap __a(__f_.second()); | |
| 1432 | __f_.~__compressed_pair<_Fp, _Alloc>(); | |
| 1450 | _Ap __a(__alloc_); | |
| 1451 | __func_.~_Fp(); | |
| 1452 | __alloc_.~_Alloc(); | |
| 1433 | 1453 | __a.deallocate(_PTraits::pointer_to(*this), 1); |
| 1434 | 1454 | } |
| 1435 | 1455 | |
| 1436 | 1456 | template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes> |
| 1437 | 1457 | _Rp __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) { |
| 1438 | return std::__invoke(__f_.first(), std::forward<_ArgTypes>(__arg)...); | |
| 1458 | return std::__invoke(__func_, std::forward<_ArgTypes>(__arg)...); | |
| 1439 | 1459 | } |
| 1440 | 1460 | |
| 1441 | 1461 | template <class _Callable> |
| ... | ... | @@ -1472,7 +1492,7 @@ public: |
| 1472 | 1492 | |
| 1473 | 1493 | _LIBCPP_HIDE_FROM_ABI void swap(__packaged_task_function&) _NOEXCEPT; |
| 1474 | 1494 | |
| 1475 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes...) const; | |
| 1495 | _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes...) const; | |
| 1476 | 1496 | }; |
| 1477 | 1497 | |
| 1478 | 1498 | template <class _Rp, class... _ArgTypes> |
| ... | ... | @@ -1592,11 +1612,11 @@ inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... |
| 1592 | 1612 | template <class _Rp, class... _ArgTypes> |
| 1593 | 1613 | class _LIBCPP_TEMPLATE_VIS packaged_task<_Rp(_ArgTypes...)> { |
| 1594 | 1614 | public: |
| 1595 | typedef _Rp result_type; // extension | |
| 1615 | using result_type _LIBCPP_DEPRECATED = _Rp; // extension | |
| 1596 | 1616 | |
| 1597 | 1617 | private: |
| 1598 | __packaged_task_function<result_type(_ArgTypes...)> __f_; | |
| 1599 | promise<result_type> __p_; | |
| 1618 | __packaged_task_function<_Rp(_ArgTypes...)> __f_; | |
| 1619 | promise<_Rp> __p_; | |
| 1600 | 1620 | |
| 1601 | 1621 | public: |
| 1602 | 1622 | // construction and destruction |
| ... | ... | @@ -1605,9 +1625,11 @@ public: |
| 1605 | 1625 | template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> |
| 1606 | 1626 | _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {} |
| 1607 | 1627 | |
| 1628 | # if _LIBCPP_STD_VER <= 14 | |
| 1608 | 1629 | template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> |
| 1609 | 1630 | _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) |
| 1610 | 1631 | : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {} |
| 1632 | # endif | |
| 1611 | 1633 | // ~packaged_task() = default; |
| 1612 | 1634 | |
| 1613 | 1635 | // no copy |
| ... | ... | @@ -1631,7 +1653,7 @@ public: |
| 1631 | 1653 | _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; } |
| 1632 | 1654 | |
| 1633 | 1655 | // result retrieval |
| 1634 | _LIBCPP_HIDE_FROM_ABI future<result_type> get_future() { return __p_.get_future(); } | |
| 1656 | _LIBCPP_HIDE_FROM_ABI future<_Rp> get_future() { return __p_.get_future(); } | |
| 1635 | 1657 | |
| 1636 | 1658 | // execution |
| 1637 | 1659 | _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args); |
| ... | ... | @@ -1646,15 +1668,15 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { |
| 1646 | 1668 | __throw_future_error(future_errc::no_state); |
| 1647 | 1669 | if (__p_.__state_->__has_value()) |
| 1648 | 1670 | __throw_future_error(future_errc::promise_already_satisfied); |
| 1649 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1671 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1650 | 1672 | try { |
| 1651 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1673 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1652 | 1674 | __p_.set_value(__f_(std::forward<_ArgTypes>(__args)...)); |
| 1653 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1675 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1654 | 1676 | } catch (...) { |
| 1655 | 1677 | __p_.set_exception(current_exception()); |
| 1656 | 1678 | } |
| 1657 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1679 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1658 | 1680 | } |
| 1659 | 1681 | |
| 1660 | 1682 | template <class _Rp, class... _ArgTypes> |
| ... | ... | @@ -1663,41 +1685,43 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __ |
| 1663 | 1685 | __throw_future_error(future_errc::no_state); |
| 1664 | 1686 | if (__p_.__state_->__has_value()) |
| 1665 | 1687 | __throw_future_error(future_errc::promise_already_satisfied); |
| 1666 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1688 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1667 | 1689 | try { |
| 1668 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1690 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1669 | 1691 | __p_.set_value_at_thread_exit(__f_(std::forward<_ArgTypes>(__args)...)); |
| 1670 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1692 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1671 | 1693 | } catch (...) { |
| 1672 | 1694 | __p_.set_exception_at_thread_exit(current_exception()); |
| 1673 | 1695 | } |
| 1674 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1696 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1675 | 1697 | } |
| 1676 | 1698 | |
| 1677 | 1699 | template <class _Rp, class... _ArgTypes> |
| 1678 | 1700 | void packaged_task<_Rp(_ArgTypes...)>::reset() { |
| 1679 | 1701 | if (!valid()) |
| 1680 | 1702 | __throw_future_error(future_errc::no_state); |
| 1681 | __p_ = promise<result_type>(); | |
| 1703 | __p_ = promise<_Rp>(); | |
| 1682 | 1704 | } |
| 1683 | 1705 | |
| 1684 | 1706 | template <class... _ArgTypes> |
| 1685 | 1707 | class _LIBCPP_TEMPLATE_VIS packaged_task<void(_ArgTypes...)> { |
| 1686 | 1708 | public: |
| 1687 | typedef void result_type; // extension | |
| 1709 | using result_type _LIBCPP_DEPRECATED = void; // extension | |
| 1688 | 1710 | |
| 1689 | 1711 | private: |
| 1690 | __packaged_task_function<result_type(_ArgTypes...)> __f_; | |
| 1691 | promise<result_type> __p_; | |
| 1712 | __packaged_task_function<void(_ArgTypes...)> __f_; | |
| 1713 | promise<void> __p_; | |
| 1692 | 1714 | |
| 1693 | 1715 | public: |
| 1694 | 1716 | // construction and destruction |
| 1695 | 1717 | _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {} |
| 1696 | 1718 | template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> |
| 1697 | 1719 | _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {} |
| 1720 | # if _LIBCPP_STD_VER <= 14 | |
| 1698 | 1721 | template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0> |
| 1699 | 1722 | _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) |
| 1700 | 1723 | : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {} |
| 1724 | # endif | |
| 1701 | 1725 | // ~packaged_task() = default; |
| 1702 | 1726 | |
| 1703 | 1727 | // no copy |
| ... | ... | @@ -1721,7 +1745,7 @@ public: |
| 1721 | 1745 | _LIBCPP_HIDE_FROM_ABI bool valid() const _NOEXCEPT { return __p_.__state_ != nullptr; } |
| 1722 | 1746 | |
| 1723 | 1747 | // result retrieval |
| 1724 | _LIBCPP_HIDE_FROM_ABI future<result_type> get_future() { return __p_.get_future(); } | |
| 1748 | _LIBCPP_HIDE_FROM_ABI future<void> get_future() { return __p_.get_future(); } | |
| 1725 | 1749 | |
| 1726 | 1750 | // execution |
| 1727 | 1751 | _LIBCPP_HIDE_FROM_ABI void operator()(_ArgTypes... __args); |
| ... | ... | @@ -1730,7 +1754,7 @@ public: |
| 1730 | 1754 | _LIBCPP_HIDE_FROM_ABI void reset(); |
| 1731 | 1755 | }; |
| 1732 | 1756 | |
| 1733 | # if _LIBCPP_STD_VER >= 17 | |
| 1757 | # if _LIBCPP_STD_VER >= 17 | |
| 1734 | 1758 | |
| 1735 | 1759 | template <class _Rp, class... _Args> |
| 1736 | 1760 | packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>; |
| ... | ... | @@ -1738,7 +1762,7 @@ packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>; |
| 1738 | 1762 | template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type> |
| 1739 | 1763 | packaged_task(_Fp) -> packaged_task<_Stripped>; |
| 1740 | 1764 | |
| 1741 | # endif | |
| 1765 | # endif | |
| 1742 | 1766 | |
| 1743 | 1767 | template <class... _ArgTypes> |
| 1744 | 1768 | void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { |
| ... | ... | @@ -1746,16 +1770,16 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) { |
| 1746 | 1770 | __throw_future_error(future_errc::no_state); |
| 1747 | 1771 | if (__p_.__state_->__has_value()) |
| 1748 | 1772 | __throw_future_error(future_errc::promise_already_satisfied); |
| 1749 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1773 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1750 | 1774 | try { |
| 1751 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1775 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1752 | 1776 | __f_(std::forward<_ArgTypes>(__args)...); |
| 1753 | 1777 | __p_.set_value(); |
| 1754 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1778 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1755 | 1779 | } catch (...) { |
| 1756 | 1780 | __p_.set_exception(current_exception()); |
| 1757 | 1781 | } |
| 1758 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1782 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1759 | 1783 | } |
| 1760 | 1784 | |
| 1761 | 1785 | template <class... _ArgTypes> |
| ... | ... | @@ -1764,23 +1788,23 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _ |
| 1764 | 1788 | __throw_future_error(future_errc::no_state); |
| 1765 | 1789 | if (__p_.__state_->__has_value()) |
| 1766 | 1790 | __throw_future_error(future_errc::promise_already_satisfied); |
| 1767 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1791 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1768 | 1792 | try { |
| 1769 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1793 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1770 | 1794 | __f_(std::forward<_ArgTypes>(__args)...); |
| 1771 | 1795 | __p_.set_value_at_thread_exit(); |
| 1772 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1796 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1773 | 1797 | } catch (...) { |
| 1774 | 1798 | __p_.set_exception_at_thread_exit(current_exception()); |
| 1775 | 1799 | } |
| 1776 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1800 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1777 | 1801 | } |
| 1778 | 1802 | |
| 1779 | 1803 | template <class... _ArgTypes> |
| 1780 | 1804 | void packaged_task<void(_ArgTypes...)>::reset() { |
| 1781 | 1805 | if (!valid()) |
| 1782 | 1806 | __throw_future_error(future_errc::no_state); |
| 1783 | __p_ = promise<result_type>(); | |
| 1807 | __p_ = promise<void>(); | |
| 1784 | 1808 | } |
| 1785 | 1809 | |
| 1786 | 1810 | template <class _Rp, class... _ArgTypes> |
| ... | ... | @@ -1789,8 +1813,10 @@ swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __ |
| 1789 | 1813 | __x.swap(__y); |
| 1790 | 1814 | } |
| 1791 | 1815 | |
| 1816 | # if _LIBCPP_STD_VER <= 14 | |
| 1792 | 1817 | template <class _Callable, class _Alloc> |
| 1793 | 1818 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc> : public true_type {}; |
| 1819 | # endif | |
| 1794 | 1820 | |
| 1795 | 1821 | template <class _Rp, class _Fp> |
| 1796 | 1822 | _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_deferred_assoc_state(_Fp&& __f) { |
| ... | ... | @@ -1807,14 +1833,14 @@ _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) { |
| 1807 | 1833 | return future<_Rp>(__h.get()); |
| 1808 | 1834 | } |
| 1809 | 1835 | |
| 1810 | # ifndef _LIBCPP_CXX03_LANG | |
| 1836 | # ifndef _LIBCPP_CXX03_LANG | |
| 1811 | 1837 | |
| 1812 | 1838 | template <class _Fp, class... _Args> |
| 1813 | 1839 | class _LIBCPP_HIDDEN __async_func { |
| 1814 | 1840 | tuple<_Fp, _Args...> __f_; |
| 1815 | 1841 | |
| 1816 | 1842 | public: |
| 1817 | typedef typename __invoke_of<_Fp, _Args...>::type _Rp; | |
| 1843 | using _Rp _LIBCPP_NODEBUG = __invoke_result_t<_Fp, _Args...>; | |
| 1818 | 1844 | |
| 1819 | 1845 | _LIBCPP_HIDE_FROM_ABI explicit __async_func(_Fp&& __f, _Args&&... __args) |
| 1820 | 1846 | : __f_(std::move(__f), std::move(__args)...) {} |
| ... | ... | @@ -1838,23 +1864,23 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch |
| 1838 | 1864 | } |
| 1839 | 1865 | |
| 1840 | 1866 | template <class _Fp, class... _Args> |
| 1841 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type> | |
| 1867 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<__invoke_result_t<__decay_t<_Fp>, __decay_t<_Args>...> > | |
| 1842 | 1868 | async(launch __policy, _Fp&& __f, _Args&&... __args) { |
| 1843 | 1869 | typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF; |
| 1844 | 1870 | typedef typename _BF::_Rp _Rp; |
| 1845 | 1871 | |
| 1846 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1872 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1847 | 1873 | try { |
| 1848 | # endif | |
| 1874 | # endif | |
| 1849 | 1875 | if (__does_policy_contain(__policy, launch::async)) |
| 1850 | 1876 | return std::__make_async_assoc_state<_Rp>( |
| 1851 | 1877 | _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...)); |
| 1852 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1878 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1853 | 1879 | } catch (...) { |
| 1854 | 1880 | if (__policy == launch::async) |
| 1855 | 1881 | throw; |
| 1856 | 1882 | } |
| 1857 | # endif | |
| 1883 | # endif | |
| 1858 | 1884 | |
| 1859 | 1885 | if (__does_policy_contain(__policy, launch::deferred)) |
| 1860 | 1886 | return std::__make_deferred_assoc_state<_Rp>( |
| ... | ... | @@ -1863,12 +1889,12 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) { |
| 1863 | 1889 | } |
| 1864 | 1890 | |
| 1865 | 1891 | template <class _Fp, class... _Args> |
| 1866 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type> | |
| 1892 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI future<__invoke_result_t<__decay_t<_Fp>, __decay_t<_Args>...> > | |
| 1867 | 1893 | async(_Fp&& __f, _Args&&... __args) { |
| 1868 | 1894 | return std::async(launch::any, std::forward<_Fp>(__f), std::forward<_Args>(__args)...); |
| 1869 | 1895 | } |
| 1870 | 1896 | |
| 1871 | # endif // C++03 | |
| 1897 | # endif // C++03 | |
| 1872 | 1898 | |
| 1873 | 1899 | // shared_future |
| 1874 | 1900 | |
| ... | ... | @@ -2045,18 +2071,20 @@ _LIBCPP_END_NAMESPACE_STD |
| 2045 | 2071 | |
| 2046 | 2072 | _LIBCPP_POP_MACROS |
| 2047 | 2073 | |
| 2048 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 2074 | # endif // _LIBCPP_HAS_THREADS | |
| 2049 | 2075 | |
| 2050 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 2051 | # include <chrono> | |
| 2052 | #endif | |
| 2076 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 2077 | # include <chrono> | |
| 2078 | # endif | |
| 2053 | 2079 | |
| 2054 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 2055 | # include <atomic> | |
| 2056 | # include <cstdlib> | |
| 2057 | # include <exception> | |
| 2058 | # include <iosfwd> | |
| 2059 | # include <system_error> | |
| 2060 | #endif | |
| 2080 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 2081 | # include <atomic> | |
| 2082 | # include <cstdlib> | |
| 2083 | # include <exception> | |
| 2084 | # include <iosfwd> | |
| 2085 | # include <system_error> | |
| 2086 | # include <thread> | |
| 2087 | # endif | |
| 2088 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 2061 | 2089 | |
| 2062 | 2090 | #endif // _LIBCPP_FUTURE |
lib/libcxx/include/initializer_list+16-7| ... | ... | @@ -42,17 +42,21 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in |
| 42 | 42 | |
| 43 | 43 | */ |
| 44 | 44 | |
| 45 | #include <__config> | |
| 46 | #include <cstddef> | |
| 45 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 46 | # include <__cxx03/initializer_list> | |
| 47 | #else | |
| 48 | # include <__config> | |
| 49 | # include <__cstddef/size_t.h> | |
| 50 | # include <version> | |
| 47 | 51 | |
| 48 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 49 | # pragma GCC system_header | |
| 50 | #endif | |
| 52 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 53 | # pragma GCC system_header | |
| 54 | # endif | |
| 51 | 55 | |
| 52 | 56 | namespace std // purposefully not versioned |
| 53 | 57 | { |
| 54 | 58 | |
| 55 | #ifndef _LIBCPP_CXX03_LANG | |
| 59 | # ifndef _LIBCPP_CXX03_LANG | |
| 56 | 60 | |
| 57 | 61 | template <class _Ep> |
| 58 | 62 | class _LIBCPP_TEMPLATE_VIS initializer_list { |
| ... | ... | @@ -91,8 +95,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end(initia |
| 91 | 95 | return __il.end(); |
| 92 | 96 | } |
| 93 | 97 | |
| 94 | #endif // !defined(_LIBCPP_CXX03_LANG) | |
| 98 | # endif // !defined(_LIBCPP_CXX03_LANG) | |
| 95 | 99 | |
| 96 | 100 | } // namespace std |
| 97 | 101 | |
| 102 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 103 | # include <cstddef> | |
| 104 | # endif | |
| 105 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 106 | ||
| 98 | 107 | #endif // _LIBCPP_INITIALIZER_LIST |
lib/libcxx/include/inttypes.h+19-15| ... | ... | @@ -235,30 +235,34 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int |
| 235 | 235 | |
| 236 | 236 | */ |
| 237 | 237 | |
| 238 | #include <__config> | |
| 238 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 239 | # include <__cxx03/inttypes.h> | |
| 240 | #else | |
| 241 | # include <__config> | |
| 239 | 242 | |
| 240 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 241 | # pragma GCC system_header | |
| 242 | #endif | |
| 243 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 244 | # pragma GCC system_header | |
| 245 | # endif | |
| 243 | 246 | |
| 244 | 247 | /* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed |
| 245 | 248 | for C++11 unless __STDC_FORMAT_MACROS is defined |
| 246 | 249 | */ |
| 247 | #if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) | |
| 248 | # define __STDC_FORMAT_MACROS | |
| 249 | #endif | |
| 250 | # if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) | |
| 251 | # define __STDC_FORMAT_MACROS | |
| 252 | # endif | |
| 250 | 253 | |
| 251 | #if __has_include_next(<inttypes.h>) | |
| 252 | # include_next <inttypes.h> | |
| 253 | #endif | |
| 254 | # if __has_include_next(<inttypes.h>) | |
| 255 | # include_next <inttypes.h> | |
| 256 | # endif | |
| 254 | 257 | |
| 255 | #ifdef __cplusplus | |
| 258 | # ifdef __cplusplus | |
| 256 | 259 | |
| 257 | # include <stdint.h> | |
| 260 | # include <stdint.h> | |
| 258 | 261 | |
| 259 | # undef imaxabs | |
| 260 | # undef imaxdiv | |
| 262 | # undef imaxabs | |
| 263 | # undef imaxdiv | |
| 261 | 264 | |
| 262 | #endif // __cplusplus | |
| 265 | # endif // __cplusplus | |
| 266 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 263 | 267 | |
| 264 | 268 | #endif // _LIBCPP_INTTYPES_H |
lib/libcxx/include/iomanip+51-24| ... | ... | @@ -42,13 +42,22 @@ template <class charT, class traits, class Allocator> |
| 42 | 42 | |
| 43 | 43 | */ |
| 44 | 44 | |
| 45 | #include <__config> | |
| 46 | #include <istream> | |
| 47 | #include <version> | |
| 45 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 46 | # include <__cxx03/iomanip> | |
| 47 | #else | |
| 48 | # include <__config> | |
| 48 | 49 | |
| 49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 50 | # pragma GCC system_header | |
| 51 | #endif | |
| 50 | # if _LIBCPP_HAS_LOCALIZATION | |
| 51 | ||
| 52 | # include <__ostream/put_character_sequence.h> | |
| 53 | # include <ios> | |
| 54 | # include <iosfwd> | |
| 55 | # include <locale> | |
| 56 | # include <version> | |
| 57 | ||
| 58 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 59 | # pragma GCC system_header | |
| 60 | # endif | |
| 52 | 61 | |
| 53 | 62 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 54 | 63 | |
| ... | ... | @@ -231,9 +240,9 @@ public: |
| 231 | 240 | template <class _CharT, class _Traits, class _MoneyT> |
| 232 | 241 | _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
| 233 | 242 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) { |
| 234 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 243 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 235 | 244 | try { |
| 236 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 245 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 237 | 246 | typename basic_istream<_CharT, _Traits>::sentry __s(__is); |
| 238 | 247 | if (__s) { |
| 239 | 248 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; |
| ... | ... | @@ -243,11 +252,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) { |
| 243 | 252 | __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_); |
| 244 | 253 | __is.setstate(__err); |
| 245 | 254 | } |
| 246 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 255 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 247 | 256 | } catch (...) { |
| 248 | 257 | __is.__set_badbit_and_consider_rethrow(); |
| 249 | 258 | } |
| 250 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 259 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 251 | 260 | return __is; |
| 252 | 261 | } |
| 253 | 262 | |
| ... | ... | @@ -280,9 +289,9 @@ public: |
| 280 | 289 | template <class _CharT, class _Traits, class _MoneyT> |
| 281 | 290 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| 282 | 291 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) { |
| 283 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 292 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 284 | 293 | try { |
| 285 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 294 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 286 | 295 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 287 | 296 | if (__s) { |
| 288 | 297 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; |
| ... | ... | @@ -291,11 +300,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) { |
| 291 | 300 | if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed()) |
| 292 | 301 | __os.setstate(ios_base::badbit); |
| 293 | 302 | } |
| 294 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 303 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 295 | 304 | } catch (...) { |
| 296 | 305 | __os.__set_badbit_and_consider_rethrow(); |
| 297 | 306 | } |
| 298 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 307 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 299 | 308 | return __os; |
| 300 | 309 | } |
| 301 | 310 | |
| ... | ... | @@ -328,9 +337,9 @@ public: |
| 328 | 337 | template <class _CharT, class _Traits> |
| 329 | 338 | _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
| 330 | 339 | operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) { |
| 331 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 340 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 332 | 341 | try { |
| 333 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 342 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 334 | 343 | typename basic_istream<_CharT, _Traits>::sentry __s(__is); |
| 335 | 344 | if (__s) { |
| 336 | 345 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; |
| ... | ... | @@ -340,11 +349,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) { |
| 340 | 349 | __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)); |
| 341 | 350 | __is.setstate(__err); |
| 342 | 351 | } |
| 343 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 352 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 344 | 353 | } catch (...) { |
| 345 | 354 | __is.__set_badbit_and_consider_rethrow(); |
| 346 | 355 | } |
| 347 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 356 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 348 | 357 | return __is; |
| 349 | 358 | } |
| 350 | 359 | |
| ... | ... | @@ -377,9 +386,9 @@ public: |
| 377 | 386 | template <class _CharT, class _Traits> |
| 378 | 387 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| 379 | 388 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) { |
| 380 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 389 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 381 | 390 | try { |
| 382 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 391 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 383 | 392 | typename basic_ostream<_CharT, _Traits>::sentry __s(__os); |
| 384 | 393 | if (__s) { |
| 385 | 394 | typedef ostreambuf_iterator<_CharT, _Traits> _Op; |
| ... | ... | @@ -389,11 +398,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) { |
| 389 | 398 | .failed()) |
| 390 | 399 | __os.setstate(ios_base::badbit); |
| 391 | 400 | } |
| 392 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 401 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 393 | 402 | } catch (...) { |
| 394 | 403 | __os.__set_badbit_and_consider_rethrow(); |
| 395 | 404 | } |
| 396 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 405 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 397 | 406 | return __os; |
| 398 | 407 | } |
| 399 | 408 | |
| ... | ... | @@ -505,7 +514,7 @@ __quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT |
| 505 | 514 | return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape); |
| 506 | 515 | } |
| 507 | 516 | |
| 508 | #if _LIBCPP_STD_VER >= 14 | |
| 517 | # if _LIBCPP_STD_VER >= 14 | |
| 509 | 518 | |
| 510 | 519 | template <class _CharT> |
| 511 | 520 | _LIBCPP_HIDE_FROM_ABI auto quoted(const _CharT* __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) { |
| ... | ... | @@ -535,8 +544,26 @@ quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _C |
| 535 | 544 | return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape); |
| 536 | 545 | } |
| 537 | 546 | |
| 538 | #endif // _LIBCPP_STD_VER >= 14 | |
| 547 | # endif // _LIBCPP_STD_VER >= 14 | |
| 539 | 548 | |
| 540 | 549 | _LIBCPP_END_NAMESPACE_STD |
| 541 | 550 | |
| 551 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 552 | ||
| 553 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 554 | # include <array> | |
| 555 | # include <bitset> | |
| 556 | # include <deque> | |
| 557 | # include <format> | |
| 558 | # include <functional> | |
| 559 | # include <istream> | |
| 560 | # include <ostream> | |
| 561 | # include <print> | |
| 562 | # include <queue> | |
| 563 | # include <stack> | |
| 564 | # include <unordered_map> | |
| 565 | # include <vector> | |
| 566 | # endif | |
| 567 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 568 | ||
| 542 | 569 | #endif // _LIBCPP_IOMANIP |
lib/libcxx/include/ios+73-65| ... | ... | @@ -211,36 +211,40 @@ storage-class-specifier const error_category& iostream_category() noexcept; |
| 211 | 211 | |
| 212 | 212 | */ |
| 213 | 213 | |
| 214 | #include <__config> | |
| 215 | ||
| 216 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 217 | ||
| 218 | # include <__fwd/ios.h> | |
| 219 | # include <__ios/fpos.h> | |
| 220 | # include <__locale> | |
| 221 | # include <__system_error/error_category.h> | |
| 222 | # include <__system_error/error_code.h> | |
| 223 | # include <__system_error/error_condition.h> | |
| 224 | # include <__system_error/system_error.h> | |
| 225 | # include <__utility/swap.h> | |
| 226 | # include <__verbose_abort> | |
| 227 | # include <version> | |
| 214 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 215 | # include <__cxx03/ios> | |
| 216 | #else | |
| 217 | # include <__config> | |
| 218 | ||
| 219 | # if _LIBCPP_HAS_LOCALIZATION | |
| 220 | ||
| 221 | # include <__fwd/ios.h> | |
| 222 | # include <__ios/fpos.h> | |
| 223 | # include <__locale> | |
| 224 | # include <__memory/addressof.h> | |
| 225 | # include <__system_error/error_category.h> | |
| 226 | # include <__system_error/error_code.h> | |
| 227 | # include <__system_error/error_condition.h> | |
| 228 | # include <__system_error/system_error.h> | |
| 229 | # include <__utility/swap.h> | |
| 230 | # include <__verbose_abort> | |
| 231 | # include <version> | |
| 228 | 232 | |
| 229 | 233 | // standard-mandated includes |
| 230 | 234 | |
| 231 | 235 | // [ios.syn] |
| 232 | # include <iosfwd> | |
| 236 | # include <iosfwd> | |
| 233 | 237 | |
| 234 | # if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) | |
| 235 | # include <__atomic/atomic.h> // for __xindex_ | |
| 236 | # endif | |
| 238 | # if _LIBCPP_HAS_ATOMIC_HEADER | |
| 239 | # include <__atomic/atomic.h> // for __xindex_ | |
| 240 | # endif | |
| 237 | 241 | |
| 238 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 239 | # pragma GCC system_header | |
| 240 | # endif | |
| 242 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 243 | # pragma GCC system_header | |
| 244 | # endif | |
| 241 | 245 | |
| 242 | 246 | _LIBCPP_PUSH_MACROS |
| 243 | # include <__undef_macros> | |
| 247 | # include <__undef_macros> | |
| 244 | 248 | |
| 245 | 249 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 246 | 250 | |
| ... | ... | @@ -283,20 +287,20 @@ public: |
| 283 | 287 | static const openmode in = 0x08; |
| 284 | 288 | static const openmode out = 0x10; |
| 285 | 289 | static const openmode trunc = 0x20; |
| 286 | # if _LIBCPP_STD_VER >= 23 | |
| 290 | # if _LIBCPP_STD_VER >= 23 | |
| 287 | 291 | static const openmode noreplace = 0x40; |
| 288 | # endif | |
| 292 | # endif | |
| 289 | 293 | |
| 290 | 294 | enum seekdir { beg, cur, end }; |
| 291 | 295 | |
| 292 | # if _LIBCPP_STD_VER <= 14 | |
| 296 | # if _LIBCPP_STD_VER <= 14 | |
| 293 | 297 | typedef iostate io_state; |
| 294 | 298 | typedef openmode open_mode; |
| 295 | 299 | typedef seekdir seek_dir; |
| 296 | 300 | |
| 297 | 301 | typedef std::streamoff streamoff; |
| 298 | 302 | typedef std::streampos streampos; |
| 299 | # endif | |
| 303 | # endif | |
| 300 | 304 | |
| 301 | 305 | class _LIBCPP_EXPORTED_FROM_ABI Init; |
| 302 | 306 | |
| ... | ... | @@ -396,11 +400,11 @@ private: |
| 396 | 400 | size_t __event_cap_; |
| 397 | 401 | // TODO(EricWF): Enable this for both Clang and GCC. Currently it is only |
| 398 | 402 | // enabled with clang. |
| 399 | # if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 403 | # if _LIBCPP_HAS_C_ATOMIC_IMP && _LIBCPP_HAS_THREADS | |
| 400 | 404 | static atomic<int> __xindex_; |
| 401 | # else | |
| 405 | # else | |
| 402 | 406 | static int __xindex_; |
| 403 | # endif | |
| 407 | # endif | |
| 404 | 408 | long* __iarray_; |
| 405 | 409 | size_t __iarray_size_; |
| 406 | 410 | size_t __iarray_cap_; |
| ... | ... | @@ -416,10 +420,10 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) |
| 416 | 420 | template <> |
| 417 | 421 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {}; |
| 418 | 422 | |
| 419 | # ifdef _LIBCPP_CXX03_LANG | |
| 423 | # ifdef _LIBCPP_CXX03_LANG | |
| 420 | 424 | template <> |
| 421 | 425 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {}; |
| 422 | # endif | |
| 426 | # endif | |
| 423 | 427 | |
| 424 | 428 | _LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT; |
| 425 | 429 | |
| ... | ... | @@ -439,12 +443,12 @@ public: |
| 439 | 443 | ~failure() _NOEXCEPT override; |
| 440 | 444 | }; |
| 441 | 445 | |
| 442 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) { | |
| 443 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 446 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) { | |
| 447 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 444 | 448 | throw ios_base::failure(__msg); |
| 445 | # else | |
| 449 | # else | |
| 446 | 450 | _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg); |
| 447 | # endif | |
| 451 | # endif | |
| 448 | 452 | } |
| 449 | 453 | |
| 450 | 454 | class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init { |
| ... | ... | @@ -523,7 +527,10 @@ template <class _Traits> |
| 523 | 527 | // Attribute 'packed' is used to keep the layout compatible with the previous |
| 524 | 528 | // definition of the '__fill_' and '_set_' pair in basic_ios on AIX & z/OS. |
| 525 | 529 | struct _LIBCPP_PACKED _FillHelper { |
| 526 | _LIBCPP_HIDE_FROM_ABI void __init() { __set_ = false; } | |
| 530 | _LIBCPP_HIDE_FROM_ABI void __init() { | |
| 531 | __set_ = false; | |
| 532 | __fill_val_ = _Traits::eof(); | |
| 533 | } | |
| 527 | 534 | _LIBCPP_HIDE_FROM_ABI _FillHelper& operator=(typename _Traits::int_type __x) { |
| 528 | 535 | __set_ = true; |
| 529 | 536 | __fill_val_ = __x; |
| ... | ... | @@ -565,13 +572,13 @@ public: |
| 565 | 572 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, |
| 566 | 573 | "traits_type::char_type must be the same type as CharT"); |
| 567 | 574 | |
| 568 | # ifdef _LIBCPP_CXX03_LANG | |
| 575 | # ifdef _LIBCPP_CXX03_LANG | |
| 569 | 576 | // Preserve the ability to compare with literal 0, |
| 570 | 577 | // and implicitly convert to bool, but not implicitly convert to int. |
| 571 | 578 | _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; } |
| 572 | # else | |
| 579 | # else | |
| 573 | 580 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); } |
| 574 | # endif | |
| 581 | # endif | |
| 575 | 582 | |
| 576 | 583 | _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); } |
| 577 | 584 | _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); } |
| ... | ... | @@ -621,11 +628,11 @@ protected: |
| 621 | 628 | private: |
| 622 | 629 | basic_ostream<char_type, traits_type>* __tie_; |
| 623 | 630 | |
| 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 | |
| 631 | # if defined(_LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE) | |
| 632 | using _FillType _LIBCPP_NODEBUG = _FillHelper<traits_type>; | |
| 633 | # else | |
| 634 | using _FillType _LIBCPP_NODEBUG = _SentinelValueFill<traits_type>; | |
| 635 | # endif | |
| 629 | 636 | mutable _FillType __fill_; |
| 630 | 637 | }; |
| 631 | 638 | |
| ... | ... | @@ -640,7 +647,7 @@ basic_ios<_CharT, _Traits>::~basic_ios() {} |
| 640 | 647 | template <class _CharT, class _Traits> |
| 641 | 648 | inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) { |
| 642 | 649 | ios_base::init(__sb); |
| 643 | __tie_ = nullptr; | |
| 650 | __tie_ = nullptr; | |
| 644 | 651 | __fill_.__init(); |
| 645 | 652 | } |
| 646 | 653 | |
| ... | ... | @@ -707,7 +714,7 @@ inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill(char_type _ |
| 707 | 714 | |
| 708 | 715 | template <class _CharT, class _Traits> |
| 709 | 716 | basic_ios<_CharT, _Traits>& basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) { |
| 710 | if (this != &__rhs) { | |
| 717 | if (this != std::addressof(__rhs)) { | |
| 711 | 718 | __call_callbacks(erase_event); |
| 712 | 719 | ios_base::copyfmt(__rhs); |
| 713 | 720 | __tie_ = __rhs.__tie_; |
| ... | ... | @@ -740,9 +747,9 @@ inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_st |
| 740 | 747 | |
| 741 | 748 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>; |
| 742 | 749 | |
| 743 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 750 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 744 | 751 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>; |
| 745 | # endif | |
| 752 | # endif | |
| 746 | 753 | |
| 747 | 754 | _LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) { |
| 748 | 755 | __str.setf(ios_base::boolalpha); |
| ... | ... | @@ -868,22 +875,23 @@ _LIBCPP_END_NAMESPACE_STD |
| 868 | 875 | |
| 869 | 876 | _LIBCPP_POP_MACROS |
| 870 | 877 | |
| 871 | #endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 872 | ||
| 873 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 874 | # include <atomic> | |
| 875 | # include <concepts> | |
| 876 | # include <cstddef> | |
| 877 | # include <cstdlib> | |
| 878 | # include <cstring> | |
| 879 | # include <initializer_list> | |
| 880 | # include <limits> | |
| 881 | # include <mutex> | |
| 882 | # include <new> | |
| 883 | # include <stdexcept> | |
| 884 | # include <system_error> | |
| 885 | # include <type_traits> | |
| 886 | # include <typeinfo> | |
| 887 | #endif | |
| 878 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 879 | ||
| 880 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 881 | # include <atomic> | |
| 882 | # include <concepts> | |
| 883 | # include <cstddef> | |
| 884 | # include <cstdlib> | |
| 885 | # include <cstring> | |
| 886 | # include <initializer_list> | |
| 887 | # include <limits> | |
| 888 | # include <mutex> | |
| 889 | # include <new> | |
| 890 | # include <stdexcept> | |
| 891 | # include <system_error> | |
| 892 | # include <type_traits> | |
| 893 | # include <typeinfo> | |
| 894 | # endif | |
| 895 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 888 | 896 | |
| 889 | 897 | #endif // _LIBCPP_IOS |
lib/libcxx/include/iosfwd+32-27| ... | ... | @@ -105,21 +105,24 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20 |
| 105 | 105 | |
| 106 | 106 | */ |
| 107 | 107 | |
| 108 | #include <__config> | |
| 109 | #include <__fwd/fstream.h> | |
| 110 | #include <__fwd/ios.h> | |
| 111 | #include <__fwd/istream.h> | |
| 112 | #include <__fwd/memory.h> | |
| 113 | #include <__fwd/ostream.h> | |
| 114 | #include <__fwd/sstream.h> | |
| 115 | #include <__fwd/streambuf.h> | |
| 116 | #include <__fwd/string.h> | |
| 117 | #include <__std_mbstate_t.h> | |
| 118 | #include <version> | |
| 119 | ||
| 120 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 121 | # pragma GCC system_header | |
| 122 | #endif | |
| 108 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 109 | # include <__cxx03/iosfwd> | |
| 110 | #else | |
| 111 | # include <__config> | |
| 112 | # include <__fwd/fstream.h> | |
| 113 | # include <__fwd/ios.h> | |
| 114 | # include <__fwd/istream.h> | |
| 115 | # include <__fwd/memory.h> | |
| 116 | # include <__fwd/ostream.h> | |
| 117 | # include <__fwd/sstream.h> | |
| 118 | # include <__fwd/streambuf.h> | |
| 119 | # include <__fwd/string.h> | |
| 120 | # include <__std_mbstate_t.h> | |
| 121 | # include <version> | |
| 122 | ||
| 123 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 124 | # pragma GCC system_header | |
| 125 | # endif | |
| 123 | 126 | |
| 124 | 127 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 125 | 128 | |
| ... | ... | @@ -131,34 +134,34 @@ class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator; |
| 131 | 134 | template <class _State> |
| 132 | 135 | class _LIBCPP_TEMPLATE_VIS fpos; |
| 133 | 136 | typedef fpos<mbstate_t> streampos; |
| 134 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 137 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 135 | 138 | typedef fpos<mbstate_t> wstreampos; |
| 136 | #endif | |
| 137 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 139 | # endif | |
| 140 | # if _LIBCPP_HAS_CHAR8_T | |
| 138 | 141 | typedef fpos<mbstate_t> u8streampos; |
| 139 | #endif | |
| 142 | # endif | |
| 140 | 143 | typedef fpos<mbstate_t> u16streampos; |
| 141 | 144 | typedef fpos<mbstate_t> u32streampos; |
| 142 | 145 | |
| 143 | #if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) | |
| 146 | # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM | |
| 144 | 147 | |
| 145 | 148 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>> |
| 146 | 149 | class basic_syncbuf; |
| 147 | 150 | |
| 148 | 151 | using syncbuf = basic_syncbuf<char>; |
| 149 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 152 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 150 | 153 | using wsyncbuf = basic_syncbuf<wchar_t>; |
| 151 | # endif | |
| 154 | # endif | |
| 152 | 155 | |
| 153 | 156 | template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>> |
| 154 | 157 | class basic_osyncstream; |
| 155 | 158 | |
| 156 | 159 | using osyncstream = basic_osyncstream<char>; |
| 157 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 160 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 158 | 161 | using wosyncstream = basic_osyncstream<wchar_t>; |
| 159 | # endif | |
| 162 | # endif | |
| 160 | 163 | |
| 161 | #endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) | |
| 164 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM | |
| 162 | 165 | |
| 163 | 166 | template <class _CharT, class _Traits> |
| 164 | 167 | class __save_flags { |
| ... | ... | @@ -170,8 +173,8 @@ class __save_flags { |
| 170 | 173 | _CharT __fill_; |
| 171 | 174 | |
| 172 | 175 | public: |
| 173 | __save_flags(const __save_flags&) = delete; | |
| 174 | __save_flags& operator=(const __save_flags&) = delete; | |
| 176 | __save_flags(const __save_flags&) = delete; | |
| 177 | __save_flags& operator=(const __save_flags&) = delete; | |
| 175 | 178 | |
| 176 | 179 | _LIBCPP_HIDE_FROM_ABI explicit __save_flags(__stream_type& __stream) |
| 177 | 180 | : __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {} |
| ... | ... | @@ -183,4 +186,6 @@ public: |
| 183 | 186 | |
| 184 | 187 | _LIBCPP_END_NAMESPACE_STD |
| 185 | 188 | |
| 189 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 190 | ||
| 186 | 191 | #endif // _LIBCPP_IOSFWD |
lib/libcxx/include/iostream+16-11| ... | ... | @@ -33,20 +33,23 @@ extern wostream wclog; |
| 33 | 33 | |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | #include <__config> | |
| 37 | #include <version> | |
| 36 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 37 | # include <__cxx03/iostream> | |
| 38 | #else | |
| 39 | # include <__config> | |
| 40 | # include <version> | |
| 38 | 41 | |
| 39 | 42 | // standard-mandated includes |
| 40 | 43 | |
| 41 | 44 | // [iostream.syn] |
| 42 | #include <ios> | |
| 43 | #include <istream> | |
| 44 | #include <ostream> | |
| 45 | #include <streambuf> | |
| 45 | # include <ios> | |
| 46 | # include <istream> | |
| 47 | # include <ostream> | |
| 48 | # include <streambuf> | |
| 46 | 49 | |
| 47 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 48 | # pragma GCC system_header | |
| 49 | #endif | |
| 50 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 51 | # pragma GCC system_header | |
| 52 | # endif | |
| 50 | 53 | |
| 51 | 54 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 52 | 55 | |
| ... | ... | @@ -55,13 +58,15 @@ extern _LIBCPP_EXPORTED_FROM_ABI ostream cout; |
| 55 | 58 | extern _LIBCPP_EXPORTED_FROM_ABI ostream cerr; |
| 56 | 59 | extern _LIBCPP_EXPORTED_FROM_ABI ostream clog; |
| 57 | 60 | |
| 58 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 61 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 59 | 62 | extern _LIBCPP_EXPORTED_FROM_ABI wistream wcin; |
| 60 | 63 | extern _LIBCPP_EXPORTED_FROM_ABI wostream wcout; |
| 61 | 64 | extern _LIBCPP_EXPORTED_FROM_ABI wostream wcerr; |
| 62 | 65 | extern _LIBCPP_EXPORTED_FROM_ABI wostream wclog; |
| 63 | #endif | |
| 66 | # endif | |
| 64 | 67 | |
| 65 | 68 | _LIBCPP_END_NAMESPACE_STD |
| 66 | 69 | |
| 70 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 71 | ||
| 67 | 72 | #endif // _LIBCPP_IOSTREAM |
lib/libcxx/include/istream+143-127| ... | ... | @@ -158,26 +158,33 @@ template <class Stream, class T> |
| 158 | 158 | |
| 159 | 159 | */ |
| 160 | 160 | |
| 161 | #include <__config> | |
| 162 | #include <__fwd/istream.h> | |
| 163 | #include <__iterator/istreambuf_iterator.h> | |
| 164 | #include <__ostream/basic_ostream.h> | |
| 165 | #include <__type_traits/conjunction.h> | |
| 166 | #include <__type_traits/enable_if.h> | |
| 167 | #include <__type_traits/is_base_of.h> | |
| 168 | #include <__utility/declval.h> | |
| 169 | #include <__utility/forward.h> | |
| 170 | #include <bitset> | |
| 171 | #include <ios> | |
| 172 | #include <locale> | |
| 173 | #include <version> | |
| 174 | ||
| 175 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 176 | # pragma GCC system_header | |
| 177 | #endif | |
| 161 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 162 | # include <__cxx03/istream> | |
| 163 | #else | |
| 164 | # include <__config> | |
| 165 | ||
| 166 | # if _LIBCPP_HAS_LOCALIZATION | |
| 167 | ||
| 168 | # include <__fwd/istream.h> | |
| 169 | # include <__iterator/istreambuf_iterator.h> | |
| 170 | # include <__ostream/basic_ostream.h> | |
| 171 | # include <__type_traits/conjunction.h> | |
| 172 | # include <__type_traits/enable_if.h> | |
| 173 | # include <__type_traits/is_base_of.h> | |
| 174 | # include <__type_traits/make_unsigned.h> | |
| 175 | # include <__utility/declval.h> | |
| 176 | # include <__utility/forward.h> | |
| 177 | # include <bitset> | |
| 178 | # include <ios> | |
| 179 | # include <locale> | |
| 180 | # include <version> | |
| 181 | ||
| 182 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 183 | # pragma GCC system_header | |
| 184 | # endif | |
| 178 | 185 | |
| 179 | 186 | _LIBCPP_PUSH_MACROS |
| 180 | #include <__undef_macros> | |
| 187 | # include <__undef_macros> | |
| 181 | 188 | |
| 182 | 189 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 183 | 190 | |
| ... | ... | @@ -353,13 +360,13 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) { |
| 353 | 360 | ios_base::iostate __state = ios_base::goodbit; |
| 354 | 361 | typename basic_istream<_CharT, _Traits>::sentry __s(__is); |
| 355 | 362 | if (__s) { |
| 356 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 363 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 357 | 364 | try { |
| 358 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 365 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 359 | 366 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; |
| 360 | 367 | typedef num_get<_CharT, _Ip> _Fp; |
| 361 | 368 | std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n); |
| 362 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 369 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 363 | 370 | } catch (...) { |
| 364 | 371 | __state |= ios_base::badbit; |
| 365 | 372 | __is.__setstate_nothrow(__state); |
| ... | ... | @@ -367,7 +374,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) { |
| 367 | 374 | throw; |
| 368 | 375 | } |
| 369 | 376 | } |
| 370 | #endif | |
| 377 | # endif | |
| 371 | 378 | __is.setstate(__state); |
| 372 | 379 | } |
| 373 | 380 | return __is; |
| ... | ... | @@ -434,9 +441,9 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp |
| 434 | 441 | ios_base::iostate __state = ios_base::goodbit; |
| 435 | 442 | typename basic_istream<_CharT, _Traits>::sentry __s(__is); |
| 436 | 443 | if (__s) { |
| 437 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 444 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 438 | 445 | try { |
| 439 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 446 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 440 | 447 | typedef istreambuf_iterator<_CharT, _Traits> _Ip; |
| 441 | 448 | typedef num_get<_CharT, _Ip> _Fp; |
| 442 | 449 | long __temp; |
| ... | ... | @@ -450,7 +457,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp |
| 450 | 457 | } else { |
| 451 | 458 | __n = static_cast<_Tp>(__temp); |
| 452 | 459 | } |
| 453 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 460 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 454 | 461 | } catch (...) { |
| 455 | 462 | __state |= ios_base::badbit; |
| 456 | 463 | __is.__setstate_nothrow(__state); |
| ... | ... | @@ -458,7 +465,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp |
| 458 | 465 | throw; |
| 459 | 466 | } |
| 460 | 467 | } |
| 461 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 468 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 462 | 469 | __is.setstate(__state); |
| 463 | 470 | } |
| 464 | 471 | return __is; |
| ... | ... | @@ -480,9 +487,9 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) |
| 480 | 487 | ios_base::iostate __state = ios_base::goodbit; |
| 481 | 488 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 482 | 489 | if (__sen) { |
| 483 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 490 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 484 | 491 | try { |
| 485 | #endif | |
| 492 | # endif | |
| 486 | 493 | _CharT* __s = __p; |
| 487 | 494 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc()); |
| 488 | 495 | while (__s != __p + (__n - 1)) { |
| ... | ... | @@ -501,7 +508,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) |
| 501 | 508 | __is.width(0); |
| 502 | 509 | if (__s == __p) |
| 503 | 510 | __state |= ios_base::failbit; |
| 504 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 511 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 505 | 512 | } catch (...) { |
| 506 | 513 | __state |= ios_base::badbit; |
| 507 | 514 | __is.__setstate_nothrow(__state); |
| ... | ... | @@ -509,13 +516,13 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) |
| 509 | 516 | throw; |
| 510 | 517 | } |
| 511 | 518 | } |
| 512 | #endif | |
| 519 | # endif | |
| 513 | 520 | __is.setstate(__state); |
| 514 | 521 | } |
| 515 | 522 | return __is; |
| 516 | 523 | } |
| 517 | 524 | |
| 518 | #if _LIBCPP_STD_VER >= 20 | |
| 525 | # if _LIBCPP_STD_VER >= 20 | |
| 519 | 526 | |
| 520 | 527 | template <class _CharT, class _Traits, size_t _Np> |
| 521 | 528 | inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
| ... | ... | @@ -538,7 +545,7 @@ operator>>(basic_istream<char, _Traits>& __is, signed char (&__buf)[_Np]) { |
| 538 | 545 | return __is >> (char(&)[_Np])__buf; |
| 539 | 546 | } |
| 540 | 547 | |
| 541 | #else | |
| 548 | # else | |
| 542 | 549 | |
| 543 | 550 | template <class _CharT, class _Traits> |
| 544 | 551 | inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
| ... | ... | @@ -561,22 +568,22 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s) { |
| 561 | 568 | return __is >> (char*)__s; |
| 562 | 569 | } |
| 563 | 570 | |
| 564 | #endif // _LIBCPP_STD_VER >= 20 | |
| 571 | # endif // _LIBCPP_STD_VER >= 20 | |
| 565 | 572 | |
| 566 | 573 | template <class _CharT, class _Traits> |
| 567 | 574 | _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) { |
| 568 | 575 | ios_base::iostate __state = ios_base::goodbit; |
| 569 | 576 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 570 | 577 | if (__sen) { |
| 571 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 578 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 572 | 579 | try { |
| 573 | #endif | |
| 580 | # endif | |
| 574 | 581 | typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); |
| 575 | 582 | if (_Traits::eq_int_type(__i, _Traits::eof())) |
| 576 | 583 | __state |= ios_base::eofbit | ios_base::failbit; |
| 577 | 584 | else |
| 578 | 585 | __c = _Traits::to_char_type(__i); |
| 579 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 586 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 580 | 587 | } catch (...) { |
| 581 | 588 | __state |= ios_base::badbit; |
| 582 | 589 | __is.__setstate_nothrow(__state); |
| ... | ... | @@ -584,7 +591,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_ |
| 584 | 591 | throw; |
| 585 | 592 | } |
| 586 | 593 | } |
| 587 | #endif | |
| 594 | # endif | |
| 588 | 595 | __is.setstate(__state); |
| 589 | 596 | } |
| 590 | 597 | return __is; |
| ... | ... | @@ -610,9 +617,9 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ |
| 610 | 617 | sentry __s(*this, true); |
| 611 | 618 | if (__s) { |
| 612 | 619 | if (__sb) { |
| 613 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 620 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 614 | 621 | try { |
| 615 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 622 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 616 | 623 | while (true) { |
| 617 | 624 | typename traits_type::int_type __i = this->rdbuf()->sgetc(); |
| 618 | 625 | if (traits_type::eq_int_type(__i, _Traits::eof())) { |
| ... | ... | @@ -626,7 +633,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ |
| 626 | 633 | } |
| 627 | 634 | if (__gc_ == 0) |
| 628 | 635 | __state |= ios_base::failbit; |
| 629 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 636 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 630 | 637 | } catch (...) { |
| 631 | 638 | __state |= ios_base::badbit; |
| 632 | 639 | if (__gc_ == 0) |
| ... | ... | @@ -637,7 +644,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ |
| 637 | 644 | throw; |
| 638 | 645 | } |
| 639 | 646 | } |
| 640 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 647 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 641 | 648 | } else { |
| 642 | 649 | __state |= ios_base::failbit; |
| 643 | 650 | } |
| ... | ... | @@ -653,22 +660,22 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> |
| 653 | 660 | int_type __r = traits_type::eof(); |
| 654 | 661 | sentry __s(*this, true); |
| 655 | 662 | if (__s) { |
| 656 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 663 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 657 | 664 | try { |
| 658 | #endif | |
| 665 | # endif | |
| 659 | 666 | __r = this->rdbuf()->sbumpc(); |
| 660 | 667 | if (traits_type::eq_int_type(__r, traits_type::eof())) |
| 661 | 668 | __state |= ios_base::failbit | ios_base::eofbit; |
| 662 | 669 | else |
| 663 | 670 | __gc_ = 1; |
| 664 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 671 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 665 | 672 | } catch (...) { |
| 666 | 673 | this->__setstate_nothrow(this->rdstate() | ios_base::badbit); |
| 667 | 674 | if (this->exceptions() & ios_base::badbit) { |
| 668 | 675 | throw; |
| 669 | 676 | } |
| 670 | 677 | } |
| 671 | #endif | |
| 678 | # endif | |
| 672 | 679 | this->setstate(__state); |
| 673 | 680 | } |
| 674 | 681 | return __r; |
| ... | ... | @@ -681,9 +688,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ |
| 681 | 688 | sentry __sen(*this, true); |
| 682 | 689 | if (__sen) { |
| 683 | 690 | if (__n > 0) { |
| 684 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 691 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 685 | 692 | try { |
| 686 | #endif | |
| 693 | # endif | |
| 687 | 694 | while (__gc_ < __n - 1) { |
| 688 | 695 | int_type __i = this->rdbuf()->sgetc(); |
| 689 | 696 | if (traits_type::eq_int_type(__i, traits_type::eof())) { |
| ... | ... | @@ -699,7 +706,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ |
| 699 | 706 | } |
| 700 | 707 | if (__gc_ == 0) |
| 701 | 708 | __state |= ios_base::failbit; |
| 702 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 709 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 703 | 710 | } catch (...) { |
| 704 | 711 | __state |= ios_base::badbit; |
| 705 | 712 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -709,7 +716,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ |
| 709 | 716 | throw; |
| 710 | 717 | } |
| 711 | 718 | } |
| 712 | #endif | |
| 719 | # endif | |
| 713 | 720 | } else { |
| 714 | 721 | __state |= ios_base::failbit; |
| 715 | 722 | } |
| ... | ... | @@ -730,9 +737,9 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s |
| 730 | 737 | __gc_ = 0; |
| 731 | 738 | sentry __sen(*this, true); |
| 732 | 739 | if (__sen) { |
| 733 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 740 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 734 | 741 | try { |
| 735 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 742 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 736 | 743 | while (true) { |
| 737 | 744 | typename traits_type::int_type __i = this->rdbuf()->sgetc(); |
| 738 | 745 | if (traits_type::eq_int_type(__i, traits_type::eof())) { |
| ... | ... | @@ -747,12 +754,12 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s |
| 747 | 754 | __inc_gcount(); |
| 748 | 755 | this->rdbuf()->sbumpc(); |
| 749 | 756 | } |
| 750 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 757 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 751 | 758 | } catch (...) { |
| 752 | 759 | __state |= ios_base::badbit; |
| 753 | 760 | // according to the spec, exceptions here are caught but not rethrown |
| 754 | 761 | } |
| 755 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 762 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 756 | 763 | if (__gc_ == 0) |
| 757 | 764 | __state |= ios_base::failbit; |
| 758 | 765 | this->setstate(__state); |
| ... | ... | @@ -767,9 +774,9 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ |
| 767 | 774 | __gc_ = 0; |
| 768 | 775 | sentry __sen(*this, true); |
| 769 | 776 | if (__sen) { |
| 770 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 777 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 771 | 778 | try { |
| 772 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 779 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 773 | 780 | while (true) { |
| 774 | 781 | typename traits_type::int_type __i = this->rdbuf()->sgetc(); |
| 775 | 782 | if (traits_type::eq_int_type(__i, traits_type::eof())) { |
| ... | ... | @@ -790,7 +797,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ |
| 790 | 797 | this->rdbuf()->sbumpc(); |
| 791 | 798 | __inc_gcount(); |
| 792 | 799 | } |
| 793 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 800 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 794 | 801 | } catch (...) { |
| 795 | 802 | __state |= ios_base::badbit; |
| 796 | 803 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -802,7 +809,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ |
| 802 | 809 | throw; |
| 803 | 810 | } |
| 804 | 811 | } |
| 805 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 812 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 806 | 813 | } |
| 807 | 814 | if (__n > 0) |
| 808 | 815 | *__s = char_type(); |
| ... | ... | @@ -818,9 +825,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz |
| 818 | 825 | __gc_ = 0; |
| 819 | 826 | sentry __sen(*this, true); |
| 820 | 827 | if (__sen) { |
| 821 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 828 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 822 | 829 | try { |
| 823 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 830 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 824 | 831 | if (__n == numeric_limits<streamsize>::max()) { |
| 825 | 832 | while (true) { |
| 826 | 833 | typename traits_type::int_type __i = this->rdbuf()->sbumpc(); |
| ... | ... | @@ -844,7 +851,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz |
| 844 | 851 | break; |
| 845 | 852 | } |
| 846 | 853 | } |
| 847 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 854 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 848 | 855 | } catch (...) { |
| 849 | 856 | __state |= ios_base::badbit; |
| 850 | 857 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -852,7 +859,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz |
| 852 | 859 | throw; |
| 853 | 860 | } |
| 854 | 861 | } |
| 855 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 862 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 856 | 863 | this->setstate(__state); |
| 857 | 864 | } |
| 858 | 865 | return *this; |
| ... | ... | @@ -865,13 +872,13 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> |
| 865 | 872 | int_type __r = traits_type::eof(); |
| 866 | 873 | sentry __sen(*this, true); |
| 867 | 874 | if (__sen) { |
| 868 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 875 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 869 | 876 | try { |
| 870 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 877 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 871 | 878 | __r = this->rdbuf()->sgetc(); |
| 872 | 879 | if (traits_type::eq_int_type(__r, traits_type::eof())) |
| 873 | 880 | __state |= ios_base::eofbit; |
| 874 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 881 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 875 | 882 | } catch (...) { |
| 876 | 883 | __state |= ios_base::badbit; |
| 877 | 884 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -879,7 +886,7 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> |
| 879 | 886 | throw; |
| 880 | 887 | } |
| 881 | 888 | } |
| 882 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 889 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 883 | 890 | this->setstate(__state); |
| 884 | 891 | } |
| 885 | 892 | return __r; |
| ... | ... | @@ -891,13 +898,13 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type* |
| 891 | 898 | __gc_ = 0; |
| 892 | 899 | sentry __sen(*this, true); |
| 893 | 900 | if (__sen) { |
| 894 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 901 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 895 | 902 | try { |
| 896 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 903 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 897 | 904 | __gc_ = this->rdbuf()->sgetn(__s, __n); |
| 898 | 905 | if (__gc_ != __n) |
| 899 | 906 | __state |= ios_base::failbit | ios_base::eofbit; |
| 900 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 907 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 901 | 908 | } catch (...) { |
| 902 | 909 | __state |= ios_base::badbit; |
| 903 | 910 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -905,7 +912,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type* |
| 905 | 912 | throw; |
| 906 | 913 | } |
| 907 | 914 | } |
| 908 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 915 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 909 | 916 | } else { |
| 910 | 917 | __state |= ios_base::failbit; |
| 911 | 918 | } |
| ... | ... | @@ -919,9 +926,9 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ |
| 919 | 926 | __gc_ = 0; |
| 920 | 927 | sentry __sen(*this, true); |
| 921 | 928 | if (__sen) { |
| 922 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 929 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 923 | 930 | try { |
| 924 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 931 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 925 | 932 | streamsize __c = this->rdbuf()->in_avail(); |
| 926 | 933 | switch (__c) { |
| 927 | 934 | case -1: |
| ... | ... | @@ -936,7 +943,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ |
| 936 | 943 | __state |= ios_base::failbit | ios_base::eofbit; |
| 937 | 944 | break; |
| 938 | 945 | } |
| 939 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 946 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 940 | 947 | } catch (...) { |
| 941 | 948 | __state |= ios_base::badbit; |
| 942 | 949 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -944,7 +951,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ |
| 944 | 951 | throw; |
| 945 | 952 | } |
| 946 | 953 | } |
| 947 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 954 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 948 | 955 | } else { |
| 949 | 956 | __state |= ios_base::failbit; |
| 950 | 957 | } |
| ... | ... | @@ -959,12 +966,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ |
| 959 | 966 | this->clear(__state); |
| 960 | 967 | sentry __sen(*this, true); |
| 961 | 968 | if (__sen) { |
| 962 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 969 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 963 | 970 | try { |
| 964 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 971 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 965 | 972 | if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof()) |
| 966 | 973 | __state |= ios_base::badbit; |
| 967 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 974 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 968 | 975 | } catch (...) { |
| 969 | 976 | __state |= ios_base::badbit; |
| 970 | 977 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -972,7 +979,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ |
| 972 | 979 | throw; |
| 973 | 980 | } |
| 974 | 981 | } |
| 975 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 982 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 976 | 983 | } else { |
| 977 | 984 | __state |= ios_base::failbit; |
| 978 | 985 | } |
| ... | ... | @@ -987,12 +994,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { |
| 987 | 994 | this->clear(__state); |
| 988 | 995 | sentry __sen(*this, true); |
| 989 | 996 | if (__sen) { |
| 990 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 997 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 991 | 998 | try { |
| 992 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 999 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 993 | 1000 | if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof()) |
| 994 | 1001 | __state |= ios_base::badbit; |
| 995 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1002 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 996 | 1003 | } catch (...) { |
| 997 | 1004 | __state |= ios_base::badbit; |
| 998 | 1005 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -1000,7 +1007,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { |
| 1000 | 1007 | throw; |
| 1001 | 1008 | } |
| 1002 | 1009 | } |
| 1003 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1010 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1004 | 1011 | } else { |
| 1005 | 1012 | __state |= ios_base::failbit; |
| 1006 | 1013 | } |
| ... | ... | @@ -1017,14 +1024,14 @@ int basic_istream<_CharT, _Traits>::sync() { |
| 1017 | 1024 | |
| 1018 | 1025 | int __r = 0; |
| 1019 | 1026 | if (__sen) { |
| 1020 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1027 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1021 | 1028 | try { |
| 1022 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1029 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1023 | 1030 | if (this->rdbuf()->pubsync() == -1) { |
| 1024 | 1031 | __state |= ios_base::badbit; |
| 1025 | 1032 | __r = -1; |
| 1026 | 1033 | } |
| 1027 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1034 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1028 | 1035 | } catch (...) { |
| 1029 | 1036 | __state |= ios_base::badbit; |
| 1030 | 1037 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -1032,7 +1039,7 @@ int basic_istream<_CharT, _Traits>::sync() { |
| 1032 | 1039 | throw; |
| 1033 | 1040 | } |
| 1034 | 1041 | } |
| 1035 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1042 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1036 | 1043 | this->setstate(__state); |
| 1037 | 1044 | } |
| 1038 | 1045 | return __r; |
| ... | ... | @@ -1044,11 +1051,11 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits> |
| 1044 | 1051 | pos_type __r(-1); |
| 1045 | 1052 | sentry __sen(*this, true); |
| 1046 | 1053 | if (__sen) { |
| 1047 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1054 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1048 | 1055 | try { |
| 1049 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1056 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1050 | 1057 | __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); |
| 1051 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1058 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1052 | 1059 | } catch (...) { |
| 1053 | 1060 | __state |= ios_base::badbit; |
| 1054 | 1061 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -1056,7 +1063,7 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits> |
| 1056 | 1063 | throw; |
| 1057 | 1064 | } |
| 1058 | 1065 | } |
| 1059 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1066 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1060 | 1067 | this->setstate(__state); |
| 1061 | 1068 | } |
| 1062 | 1069 | return __r; |
| ... | ... | @@ -1068,12 +1075,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _ |
| 1068 | 1075 | this->clear(__state); |
| 1069 | 1076 | sentry __sen(*this, true); |
| 1070 | 1077 | if (__sen) { |
| 1071 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1078 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1072 | 1079 | try { |
| 1073 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1080 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1074 | 1081 | if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) |
| 1075 | 1082 | __state |= ios_base::failbit; |
| 1076 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1083 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1077 | 1084 | } catch (...) { |
| 1078 | 1085 | __state |= ios_base::badbit; |
| 1079 | 1086 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -1081,7 +1088,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _ |
| 1081 | 1088 | throw; |
| 1082 | 1089 | } |
| 1083 | 1090 | } |
| 1084 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1091 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1085 | 1092 | this->setstate(__state); |
| 1086 | 1093 | } |
| 1087 | 1094 | return *this; |
| ... | ... | @@ -1093,12 +1100,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _ |
| 1093 | 1100 | this->clear(__state); |
| 1094 | 1101 | sentry __sen(*this, true); |
| 1095 | 1102 | if (__sen) { |
| 1096 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1103 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1097 | 1104 | try { |
| 1098 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1105 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1099 | 1106 | if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) |
| 1100 | 1107 | __state |= ios_base::failbit; |
| 1101 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1108 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1102 | 1109 | } catch (...) { |
| 1103 | 1110 | __state |= ios_base::badbit; |
| 1104 | 1111 | this->__setstate_nothrow(__state); |
| ... | ... | @@ -1106,7 +1113,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _ |
| 1106 | 1113 | throw; |
| 1107 | 1114 | } |
| 1108 | 1115 | } |
| 1109 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1116 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1110 | 1117 | this->setstate(__state); |
| 1111 | 1118 | } |
| 1112 | 1119 | return *this; |
| ... | ... | @@ -1117,9 +1124,9 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ |
| 1117 | 1124 | ios_base::iostate __state = ios_base::goodbit; |
| 1118 | 1125 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); |
| 1119 | 1126 | if (__sen) { |
| 1120 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1127 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1121 | 1128 | try { |
| 1122 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1129 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1123 | 1130 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc()); |
| 1124 | 1131 | while (true) { |
| 1125 | 1132 | typename _Traits::int_type __i = __is.rdbuf()->sgetc(); |
| ... | ... | @@ -1131,7 +1138,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ |
| 1131 | 1138 | break; |
| 1132 | 1139 | __is.rdbuf()->sbumpc(); |
| 1133 | 1140 | } |
| 1134 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1141 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1135 | 1142 | } catch (...) { |
| 1136 | 1143 | __state |= ios_base::badbit; |
| 1137 | 1144 | __is.__setstate_nothrow(__state); |
| ... | ... | @@ -1139,7 +1146,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ |
| 1139 | 1146 | throw; |
| 1140 | 1147 | } |
| 1141 | 1148 | } |
| 1142 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1149 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1143 | 1150 | __is.setstate(__state); |
| 1144 | 1151 | } |
| 1145 | 1152 | return __is; |
| ... | ... | @@ -1207,16 +1214,21 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ |
| 1207 | 1214 | ios_base::iostate __state = ios_base::goodbit; |
| 1208 | 1215 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 1209 | 1216 | if (__sen) { |
| 1210 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1217 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1211 | 1218 | try { |
| 1212 | #endif | |
| 1219 | # endif | |
| 1213 | 1220 | __str.clear(); |
| 1214 | streamsize __n = __is.width(); | |
| 1215 | if (__n <= 0) | |
| 1216 | __n = __str.max_size(); | |
| 1217 | if (__n <= 0) | |
| 1218 | __n = numeric_limits<streamsize>::max(); | |
| 1219 | streamsize __c = 0; | |
| 1221 | using _Size = typename basic_string<_CharT, _Traits, _Allocator>::size_type; | |
| 1222 | streamsize const __width = __is.width(); | |
| 1223 | _Size const __max_size = __str.max_size(); | |
| 1224 | _Size __n; | |
| 1225 | if (__width <= 0) { | |
| 1226 | __n = __max_size; | |
| 1227 | } else { | |
| 1228 | __n = std::__to_unsigned_like(__width) < __max_size ? static_cast<_Size>(__width) : __max_size; | |
| 1229 | } | |
| 1230 | ||
| 1231 | _Size __c = 0; | |
| 1220 | 1232 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc()); |
| 1221 | 1233 | while (__c < __n) { |
| 1222 | 1234 | typename _Traits::int_type __i = __is.rdbuf()->sgetc(); |
| ... | ... | @@ -1234,7 +1246,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ |
| 1234 | 1246 | __is.width(0); |
| 1235 | 1247 | if (__c == 0) |
| 1236 | 1248 | __state |= ios_base::failbit; |
| 1237 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1249 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1238 | 1250 | } catch (...) { |
| 1239 | 1251 | __state |= ios_base::badbit; |
| 1240 | 1252 | __is.__setstate_nothrow(__state); |
| ... | ... | @@ -1242,7 +1254,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ |
| 1242 | 1254 | throw; |
| 1243 | 1255 | } |
| 1244 | 1256 | } |
| 1245 | #endif | |
| 1257 | # endif | |
| 1246 | 1258 | __is.setstate(__state); |
| 1247 | 1259 | } |
| 1248 | 1260 | return __is; |
| ... | ... | @@ -1254,9 +1266,9 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All |
| 1254 | 1266 | ios_base::iostate __state = ios_base::goodbit; |
| 1255 | 1267 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); |
| 1256 | 1268 | if (__sen) { |
| 1257 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1269 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1258 | 1270 | try { |
| 1259 | #endif | |
| 1271 | # endif | |
| 1260 | 1272 | __str.clear(); |
| 1261 | 1273 | streamsize __extr = 0; |
| 1262 | 1274 | while (true) { |
| ... | ... | @@ -1277,7 +1289,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All |
| 1277 | 1289 | } |
| 1278 | 1290 | if (__extr == 0) |
| 1279 | 1291 | __state |= ios_base::failbit; |
| 1280 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1292 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1281 | 1293 | } catch (...) { |
| 1282 | 1294 | __state |= ios_base::badbit; |
| 1283 | 1295 | __is.__setstate_nothrow(__state); |
| ... | ... | @@ -1285,7 +1297,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All |
| 1285 | 1297 | throw; |
| 1286 | 1298 | } |
| 1287 | 1299 | } |
| 1288 | #endif | |
| 1300 | # endif | |
| 1289 | 1301 | __is.setstate(__state); |
| 1290 | 1302 | } |
| 1291 | 1303 | return __is; |
| ... | ... | @@ -1315,9 +1327,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { |
| 1315 | 1327 | ios_base::iostate __state = ios_base::goodbit; |
| 1316 | 1328 | typename basic_istream<_CharT, _Traits>::sentry __sen(__is); |
| 1317 | 1329 | if (__sen) { |
| 1318 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1330 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1319 | 1331 | try { |
| 1320 | #endif | |
| 1332 | # endif | |
| 1321 | 1333 | basic_string<_CharT, _Traits> __str; |
| 1322 | 1334 | const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc()); |
| 1323 | 1335 | size_t __c = 0; |
| ... | ... | @@ -1339,7 +1351,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { |
| 1339 | 1351 | __x = bitset<_Size>(__str); |
| 1340 | 1352 | if (_Size > 0 && __c == 0) |
| 1341 | 1353 | __state |= ios_base::failbit; |
| 1342 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1354 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1343 | 1355 | } catch (...) { |
| 1344 | 1356 | __state |= ios_base::badbit; |
| 1345 | 1357 | __is.__setstate_nothrow(__state); |
| ... | ... | @@ -1347,27 +1359,31 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { |
| 1347 | 1359 | throw; |
| 1348 | 1360 | } |
| 1349 | 1361 | } |
| 1350 | #endif | |
| 1362 | # endif | |
| 1351 | 1363 | __is.setstate(__state); |
| 1352 | 1364 | } |
| 1353 | 1365 | return __is; |
| 1354 | 1366 | } |
| 1355 | 1367 | |
| 1356 | 1368 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>; |
| 1357 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1369 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1358 | 1370 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>; |
| 1359 | #endif | |
| 1371 | # endif | |
| 1360 | 1372 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>; |
| 1361 | 1373 | |
| 1362 | 1374 | _LIBCPP_END_NAMESPACE_STD |
| 1363 | 1375 | |
| 1364 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1365 | # include <concepts> | |
| 1366 | # include <iosfwd> | |
| 1367 | # include <ostream> | |
| 1368 | # include <type_traits> | |
| 1369 | #endif | |
| 1376 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 1377 | ||
| 1378 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1379 | # include <concepts> | |
| 1380 | # include <iosfwd> | |
| 1381 | # include <ostream> | |
| 1382 | # include <type_traits> | |
| 1383 | # endif | |
| 1370 | 1384 | |
| 1371 | 1385 | _LIBCPP_POP_MACROS |
| 1372 | 1386 | |
| 1387 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1388 | ||
| 1373 | 1389 | #endif // _LIBCPP_ISTREAM |
lib/libcxx/include/iterator+72-67| ... | ... | @@ -679,76 +679,81 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; |
| 679 | 679 | |
| 680 | 680 | */ |
| 681 | 681 | |
| 682 | #include <__config> | |
| 683 | #include <__iterator/access.h> | |
| 684 | #include <__iterator/advance.h> | |
| 685 | #include <__iterator/back_insert_iterator.h> | |
| 686 | #include <__iterator/distance.h> | |
| 687 | #include <__iterator/front_insert_iterator.h> | |
| 688 | #include <__iterator/insert_iterator.h> | |
| 689 | #include <__iterator/istream_iterator.h> | |
| 690 | #include <__iterator/istreambuf_iterator.h> | |
| 691 | #include <__iterator/iterator.h> | |
| 692 | #include <__iterator/iterator_traits.h> | |
| 693 | #include <__iterator/move_iterator.h> | |
| 694 | #include <__iterator/next.h> | |
| 695 | #include <__iterator/ostream_iterator.h> | |
| 696 | #include <__iterator/ostreambuf_iterator.h> | |
| 697 | #include <__iterator/prev.h> | |
| 698 | #include <__iterator/reverse_iterator.h> | |
| 699 | #include <__iterator/wrap_iter.h> | |
| 700 | ||
| 701 | #if _LIBCPP_STD_VER >= 14 | |
| 702 | # include <__iterator/reverse_access.h> | |
| 703 | #endif | |
| 704 | ||
| 705 | #if _LIBCPP_STD_VER >= 17 | |
| 706 | # include <__iterator/data.h> | |
| 707 | # include <__iterator/empty.h> | |
| 708 | # include <__iterator/size.h> | |
| 709 | #endif | |
| 710 | ||
| 711 | #if _LIBCPP_STD_VER >= 20 | |
| 712 | # include <__iterator/common_iterator.h> | |
| 713 | # include <__iterator/concepts.h> | |
| 714 | # include <__iterator/counted_iterator.h> | |
| 715 | # include <__iterator/default_sentinel.h> | |
| 716 | # include <__iterator/incrementable_traits.h> | |
| 717 | # include <__iterator/indirectly_comparable.h> | |
| 718 | # include <__iterator/iter_move.h> | |
| 719 | # include <__iterator/iter_swap.h> | |
| 720 | # include <__iterator/mergeable.h> | |
| 721 | # include <__iterator/move_sentinel.h> | |
| 722 | # include <__iterator/permutable.h> | |
| 723 | # include <__iterator/projected.h> | |
| 724 | # include <__iterator/readable_traits.h> | |
| 725 | # include <__iterator/sortable.h> | |
| 726 | # include <__iterator/unreachable_sentinel.h> | |
| 727 | #endif | |
| 728 | ||
| 729 | #include <version> | |
| 682 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 683 | # include <__cxx03/iterator> | |
| 684 | #else | |
| 685 | # include <__config> | |
| 686 | # include <__iterator/access.h> | |
| 687 | # include <__iterator/advance.h> | |
| 688 | # include <__iterator/back_insert_iterator.h> | |
| 689 | # include <__iterator/distance.h> | |
| 690 | # include <__iterator/front_insert_iterator.h> | |
| 691 | # include <__iterator/insert_iterator.h> | |
| 692 | # include <__iterator/istream_iterator.h> | |
| 693 | # include <__iterator/istreambuf_iterator.h> | |
| 694 | # include <__iterator/iterator.h> | |
| 695 | # include <__iterator/iterator_traits.h> | |
| 696 | # include <__iterator/move_iterator.h> | |
| 697 | # include <__iterator/next.h> | |
| 698 | # include <__iterator/ostream_iterator.h> | |
| 699 | # include <__iterator/ostreambuf_iterator.h> | |
| 700 | # include <__iterator/prev.h> | |
| 701 | # include <__iterator/reverse_iterator.h> | |
| 702 | # include <__iterator/wrap_iter.h> | |
| 703 | ||
| 704 | # if _LIBCPP_STD_VER >= 14 | |
| 705 | # include <__iterator/reverse_access.h> | |
| 706 | # endif | |
| 707 | ||
| 708 | # if _LIBCPP_STD_VER >= 17 | |
| 709 | # include <__iterator/data.h> | |
| 710 | # include <__iterator/empty.h> | |
| 711 | # include <__iterator/size.h> | |
| 712 | # endif | |
| 713 | ||
| 714 | # if _LIBCPP_STD_VER >= 20 | |
| 715 | # include <__iterator/common_iterator.h> | |
| 716 | # include <__iterator/concepts.h> | |
| 717 | # include <__iterator/counted_iterator.h> | |
| 718 | # include <__iterator/default_sentinel.h> | |
| 719 | # include <__iterator/incrementable_traits.h> | |
| 720 | # include <__iterator/indirectly_comparable.h> | |
| 721 | # include <__iterator/iter_move.h> | |
| 722 | # include <__iterator/iter_swap.h> | |
| 723 | # include <__iterator/mergeable.h> | |
| 724 | # include <__iterator/move_sentinel.h> | |
| 725 | # include <__iterator/permutable.h> | |
| 726 | # include <__iterator/projected.h> | |
| 727 | # include <__iterator/readable_traits.h> | |
| 728 | # include <__iterator/sortable.h> | |
| 729 | # include <__iterator/unreachable_sentinel.h> | |
| 730 | # endif | |
| 731 | ||
| 732 | # include <version> | |
| 730 | 733 | |
| 731 | 734 | // standard-mandated includes |
| 732 | 735 | |
| 733 | 736 | // [iterator.synopsis] |
| 734 | #include <compare> | |
| 735 | #include <concepts> | |
| 736 | ||
| 737 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 738 | # pragma GCC system_header | |
| 739 | #endif | |
| 740 | ||
| 741 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 742 | # include <variant> | |
| 743 | #endif | |
| 744 | ||
| 745 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 746 | # include <cstdlib> | |
| 747 | # include <exception> | |
| 748 | # include <new> | |
| 749 | # include <type_traits> | |
| 750 | # include <typeinfo> | |
| 751 | # include <utility> | |
| 752 | #endif | |
| 737 | # include <compare> | |
| 738 | # include <concepts> | |
| 739 | ||
| 740 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 741 | # pragma GCC system_header | |
| 742 | # endif | |
| 743 | ||
| 744 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 745 | # include <variant> | |
| 746 | # endif | |
| 747 | ||
| 748 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 749 | # include <cstddef> | |
| 750 | # include <cstdlib> | |
| 751 | # include <exception> | |
| 752 | # include <new> | |
| 753 | # include <type_traits> | |
| 754 | # include <typeinfo> | |
| 755 | # include <utility> | |
| 756 | # endif | |
| 757 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 753 | 758 | |
| 754 | 759 | #endif // _LIBCPP_ITERATOR |
lib/libcxx/include/latch+31-25| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | namespace std |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | class latch | |
| 19 | class latch // since C++20 | |
| 20 | 20 | { |
| 21 | 21 | public: |
| 22 | 22 | static constexpr ptrdiff_t max() noexcept; |
| ... | ... | @@ -40,31 +40,34 @@ namespace std |
| 40 | 40 | |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | #include <__config> | |
| 43 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 44 | # include <__cxx03/latch> | |
| 45 | #else | |
| 46 | # include <__config> | |
| 44 | 47 | |
| 45 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 48 | # if _LIBCPP_HAS_THREADS | |
| 46 | 49 | |
| 47 | # include <__assert> | |
| 48 | # include <__atomic/atomic_base.h> | |
| 49 | # include <__atomic/atomic_sync.h> | |
| 50 | # include <__atomic/memory_order.h> | |
| 51 | # include <cstddef> | |
| 52 | # include <limits> | |
| 53 | # include <version> | |
| 50 | # include <__assert> | |
| 51 | # include <__atomic/atomic.h> | |
| 52 | # include <__atomic/atomic_sync.h> | |
| 53 | # include <__atomic/memory_order.h> | |
| 54 | # include <__cstddef/ptrdiff_t.h> | |
| 55 | # include <limits> | |
| 56 | # include <version> | |
| 54 | 57 | |
| 55 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 56 | # pragma GCC system_header | |
| 57 | # endif | |
| 58 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 59 | # pragma GCC system_header | |
| 60 | # endif | |
| 58 | 61 | |
| 59 | 62 | _LIBCPP_PUSH_MACROS |
| 60 | # include <__undef_macros> | |
| 63 | # include <__undef_macros> | |
| 61 | 64 | |
| 62 | # if _LIBCPP_STD_VER >= 14 | |
| 65 | # if _LIBCPP_STD_VER >= 20 | |
| 63 | 66 | |
| 64 | 67 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 65 | 68 | |
| 66 | class _LIBCPP_DEPRECATED_ATOMIC_SYNC latch { | |
| 67 | __atomic_base<ptrdiff_t> __a_; | |
| 69 | class latch { | |
| 70 | atomic<ptrdiff_t> __a_; | |
| 68 | 71 | |
| 69 | 72 | public: |
| 70 | 73 | static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return numeric_limits<ptrdiff_t>::max(); } |
| ... | ... | @@ -99,8 +102,9 @@ public: |
| 99 | 102 | return try_wait_impl(__value); |
| 100 | 103 | } |
| 101 | 104 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait() const { |
| 102 | std::__atomic_wait_unless( | |
| 103 | __a_, [this](ptrdiff_t& __value) -> bool { return try_wait_impl(__value); }, memory_order_acquire); | |
| 105 | std::__atomic_wait_unless(__a_, memory_order_acquire, [this](ptrdiff_t& __value) -> bool { | |
| 106 | return try_wait_impl(__value); | |
| 107 | }); | |
| 104 | 108 | } |
| 105 | 109 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_wait(ptrdiff_t __update = 1) { |
| 106 | 110 | _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::arrive_and_wait called with a negative value"); |
| ... | ... | @@ -116,14 +120,16 @@ private: |
| 116 | 120 | |
| 117 | 121 | _LIBCPP_END_NAMESPACE_STD |
| 118 | 122 | |
| 119 | # endif // _LIBCPP_STD_VER >= 14 | |
| 123 | # endif // _LIBCPP_STD_VER >= 20 | |
| 120 | 124 | |
| 121 | 125 | _LIBCPP_POP_MACROS |
| 122 | 126 | |
| 123 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 127 | # endif // _LIBCPP_HAS_THREADS | |
| 124 | 128 | |
| 125 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 126 | # include <atomic> | |
| 127 | #endif | |
| 129 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 130 | # include <atomic> | |
| 131 | # include <cstddef> | |
| 132 | # endif | |
| 133 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 128 | 134 | |
| 129 | #endif //_LIBCPP_LATCH | |
| 135 | #endif // _LIBCPP_LATCH |
lib/libcxx/include/limits+118-161| ... | ... | @@ -102,18 +102,21 @@ template<> class numeric_limits<cv long double>; |
| 102 | 102 | |
| 103 | 103 | */ |
| 104 | 104 | |
| 105 | #include <__config> | |
| 106 | #include <__type_traits/is_arithmetic.h> | |
| 107 | #include <__type_traits/is_signed.h> | |
| 108 | #include <__type_traits/remove_cv.h> | |
| 105 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 106 | # include <__cxx03/limits> | |
| 107 | #else | |
| 108 | # include <__config> | |
| 109 | # include <__type_traits/is_arithmetic.h> | |
| 110 | # include <__type_traits/is_signed.h> | |
| 111 | # include <__type_traits/remove_cv.h> | |
| 109 | 112 | |
| 110 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 111 | # pragma GCC system_header | |
| 112 | #endif | |
| 113 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 114 | # pragma GCC system_header | |
| 115 | # endif | |
| 113 | 116 | |
| 114 | 117 | _LIBCPP_PUSH_MACROS |
| 115 | #include <__undef_macros> | |
| 116 | #include <version> | |
| 118 | # include <__undef_macros> | |
| 119 | # include <version> | |
| 117 | 120 | |
| 118 | 121 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 119 | 122 | |
| ... | ... | @@ -137,9 +140,9 @@ protected: |
| 137 | 140 | typedef _Tp type; |
| 138 | 141 | |
| 139 | 142 | static _LIBCPP_CONSTEXPR const bool is_specialized = false; |
| 140 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); } | |
| 141 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); } | |
| 142 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); } | |
| 143 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); } | |
| 144 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); } | |
| 145 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); } | |
| 143 | 146 | |
| 144 | 147 | static _LIBCPP_CONSTEXPR const int digits = 0; |
| 145 | 148 | static _LIBCPP_CONSTEXPR const int digits10 = 0; |
| ... | ... | @@ -148,8 +151,8 @@ protected: |
| 148 | 151 | static _LIBCPP_CONSTEXPR const bool is_integer = false; |
| 149 | 152 | static _LIBCPP_CONSTEXPR const bool is_exact = false; |
| 150 | 153 | static _LIBCPP_CONSTEXPR const int radix = 0; |
| 151 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); } | |
| 152 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); } | |
| 154 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); } | |
| 155 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); } | |
| 153 | 156 | |
| 154 | 157 | static _LIBCPP_CONSTEXPR const int min_exponent = 0; |
| 155 | 158 | static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; |
| ... | ... | @@ -161,10 +164,10 @@ protected: |
| 161 | 164 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; |
| 162 | 165 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; |
| 163 | 166 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 164 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); } | |
| 165 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); } | |
| 166 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); } | |
| 167 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); } | |
| 167 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); } | |
| 168 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); } | |
| 169 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); } | |
| 170 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); } | |
| 168 | 171 | |
| 169 | 172 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; |
| 170 | 173 | static _LIBCPP_CONSTEXPR const bool is_bounded = false; |
| ... | ... | @@ -198,15 +201,15 @@ protected: |
| 198 | 201 | static _LIBCPP_CONSTEXPR const int max_digits10 = 0; |
| 199 | 202 | static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value; |
| 200 | 203 | static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0); |
| 201 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } | |
| 202 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } | |
| 203 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } | |
| 204 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } | |
| 205 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } | |
| 206 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } | |
| 204 | 207 | |
| 205 | 208 | static _LIBCPP_CONSTEXPR const bool is_integer = true; |
| 206 | 209 | static _LIBCPP_CONSTEXPR const bool is_exact = true; |
| 207 | 210 | static _LIBCPP_CONSTEXPR const int radix = 2; |
| 208 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } | |
| 209 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } | |
| 211 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } | |
| 212 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } | |
| 210 | 213 | |
| 211 | 214 | static _LIBCPP_CONSTEXPR const int min_exponent = 0; |
| 212 | 215 | static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; |
| ... | ... | @@ -218,20 +221,20 @@ protected: |
| 218 | 221 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; |
| 219 | 222 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; |
| 220 | 223 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 221 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } | |
| 222 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } | |
| 223 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } | |
| 224 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } | |
| 224 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } | |
| 225 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } | |
| 226 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } | |
| 227 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } | |
| 225 | 228 | |
| 226 | 229 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; |
| 227 | 230 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; |
| 228 | 231 | static _LIBCPP_CONSTEXPR const bool is_modulo = !std::is_signed<_Tp>::value; |
| 229 | 232 | |
| 230 | #if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__) | |
| 233 | # if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__) | |
| 231 | 234 | static _LIBCPP_CONSTEXPR const bool traps = true; |
| 232 | #else | |
| 235 | # else | |
| 233 | 236 | static _LIBCPP_CONSTEXPR const bool traps = false; |
| 234 | #endif | |
| 237 | # endif | |
| 235 | 238 | static _LIBCPP_CONSTEXPR const bool tinyness_before = false; |
| 236 | 239 | static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero; |
| 237 | 240 | }; |
| ... | ... | @@ -249,15 +252,15 @@ protected: |
| 249 | 252 | static _LIBCPP_CONSTEXPR const int max_digits10 = 0; |
| 250 | 253 | static _LIBCPP_CONSTEXPR const type __min = false; |
| 251 | 254 | static _LIBCPP_CONSTEXPR const type __max = true; |
| 252 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } | |
| 253 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } | |
| 254 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } | |
| 255 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } | |
| 256 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } | |
| 257 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } | |
| 255 | 258 | |
| 256 | 259 | static _LIBCPP_CONSTEXPR const bool is_integer = true; |
| 257 | 260 | static _LIBCPP_CONSTEXPR const bool is_exact = true; |
| 258 | 261 | static _LIBCPP_CONSTEXPR const int radix = 2; |
| 259 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } | |
| 260 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } | |
| 262 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } | |
| 263 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } | |
| 261 | 264 | |
| 262 | 265 | static _LIBCPP_CONSTEXPR const int min_exponent = 0; |
| 263 | 266 | static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; |
| ... | ... | @@ -269,10 +272,10 @@ protected: |
| 269 | 272 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; |
| 270 | 273 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; |
| 271 | 274 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 272 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } | |
| 273 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } | |
| 274 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } | |
| 275 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } | |
| 275 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } | |
| 276 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } | |
| 277 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } | |
| 278 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } | |
| 276 | 279 | |
| 277 | 280 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; |
| 278 | 281 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; |
| ... | ... | @@ -294,15 +297,15 @@ protected: |
| 294 | 297 | static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__; |
| 295 | 298 | static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__; |
| 296 | 299 | static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; |
| 297 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; } | |
| 298 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; } | |
| 299 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } | |
| 300 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; } | |
| 301 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; } | |
| 302 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } | |
| 300 | 303 | |
| 301 | 304 | static _LIBCPP_CONSTEXPR const bool is_integer = false; |
| 302 | 305 | static _LIBCPP_CONSTEXPR const bool is_exact = false; |
| 303 | 306 | static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; |
| 304 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; } | |
| 305 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; } | |
| 307 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; } | |
| 308 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; } | |
| 306 | 309 | |
| 307 | 310 | static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__; |
| 308 | 311 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__; |
| ... | ... | @@ -314,16 +317,16 @@ protected: |
| 314 | 317 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; |
| 315 | 318 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; |
| 316 | 319 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 317 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { | |
| 320 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { | |
| 318 | 321 | return __builtin_huge_valf(); |
| 319 | 322 | } |
| 320 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { | |
| 323 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { | |
| 321 | 324 | return __builtin_nanf(""); |
| 322 | 325 | } |
| 323 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | |
| 326 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | |
| 324 | 327 | return __builtin_nansf(""); |
| 325 | 328 | } |
| 326 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | |
| 329 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | |
| 327 | 330 | return __FLT_DENORM_MIN__; |
| 328 | 331 | } |
| 329 | 332 | |
| ... | ... | @@ -332,11 +335,11 @@ protected: |
| 332 | 335 | static _LIBCPP_CONSTEXPR const bool is_modulo = false; |
| 333 | 336 | |
| 334 | 337 | static _LIBCPP_CONSTEXPR const bool traps = false; |
| 335 | #if (defined(__arm__) || defined(__aarch64__)) | |
| 338 | # if (defined(__arm__) || defined(__aarch64__)) | |
| 336 | 339 | static _LIBCPP_CONSTEXPR const bool tinyness_before = true; |
| 337 | #else | |
| 340 | # else | |
| 338 | 341 | static _LIBCPP_CONSTEXPR const bool tinyness_before = false; |
| 339 | #endif | |
| 342 | # endif | |
| 340 | 343 | static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; |
| 341 | 344 | }; |
| 342 | 345 | |
| ... | ... | @@ -351,15 +354,15 @@ protected: |
| 351 | 354 | static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__; |
| 352 | 355 | static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__; |
| 353 | 356 | static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; |
| 354 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; } | |
| 355 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; } | |
| 356 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } | |
| 357 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; } | |
| 358 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; } | |
| 359 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } | |
| 357 | 360 | |
| 358 | 361 | static _LIBCPP_CONSTEXPR const bool is_integer = false; |
| 359 | 362 | static _LIBCPP_CONSTEXPR const bool is_exact = false; |
| 360 | 363 | static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; |
| 361 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; } | |
| 362 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; } | |
| 364 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; } | |
| 365 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; } | |
| 363 | 366 | |
| 364 | 367 | static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__; |
| 365 | 368 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__; |
| ... | ... | @@ -371,16 +374,16 @@ protected: |
| 371 | 374 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; |
| 372 | 375 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; |
| 373 | 376 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 374 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { | |
| 377 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { | |
| 375 | 378 | return __builtin_huge_val(); |
| 376 | 379 | } |
| 377 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { | |
| 380 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { | |
| 378 | 381 | return __builtin_nan(""); |
| 379 | 382 | } |
| 380 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | |
| 383 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | |
| 381 | 384 | return __builtin_nans(""); |
| 382 | 385 | } |
| 383 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | |
| 386 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | |
| 384 | 387 | return __DBL_DENORM_MIN__; |
| 385 | 388 | } |
| 386 | 389 | |
| ... | ... | @@ -389,11 +392,11 @@ protected: |
| 389 | 392 | static _LIBCPP_CONSTEXPR const bool is_modulo = false; |
| 390 | 393 | |
| 391 | 394 | static _LIBCPP_CONSTEXPR const bool traps = false; |
| 392 | #if (defined(__arm__) || defined(__aarch64__)) | |
| 395 | # if (defined(__arm__) || defined(__aarch64__)) | |
| 393 | 396 | static _LIBCPP_CONSTEXPR const bool tinyness_before = true; |
| 394 | #else | |
| 397 | # else | |
| 395 | 398 | static _LIBCPP_CONSTEXPR const bool tinyness_before = false; |
| 396 | #endif | |
| 399 | # endif | |
| 397 | 400 | static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; |
| 398 | 401 | }; |
| 399 | 402 | |
| ... | ... | @@ -408,15 +411,15 @@ protected: |
| 408 | 411 | static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__; |
| 409 | 412 | static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__; |
| 410 | 413 | static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; |
| 411 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; } | |
| 412 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; } | |
| 413 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } | |
| 414 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; } | |
| 415 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; } | |
| 416 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } | |
| 414 | 417 | |
| 415 | 418 | static _LIBCPP_CONSTEXPR const bool is_integer = false; |
| 416 | 419 | static _LIBCPP_CONSTEXPR const bool is_exact = false; |
| 417 | 420 | static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; |
| 418 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; } | |
| 419 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; } | |
| 421 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; } | |
| 422 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; } | |
| 420 | 423 | |
| 421 | 424 | static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__; |
| 422 | 425 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__; |
| ... | ... | @@ -428,33 +431,33 @@ protected: |
| 428 | 431 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; |
| 429 | 432 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; |
| 430 | 433 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; |
| 431 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { | |
| 434 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { | |
| 432 | 435 | return __builtin_huge_vall(); |
| 433 | 436 | } |
| 434 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { | |
| 437 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { | |
| 435 | 438 | return __builtin_nanl(""); |
| 436 | 439 | } |
| 437 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | |
| 440 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | |
| 438 | 441 | return __builtin_nansl(""); |
| 439 | 442 | } |
| 440 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | |
| 443 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | |
| 441 | 444 | return __LDBL_DENORM_MIN__; |
| 442 | 445 | } |
| 443 | 446 | |
| 444 | #if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__) | |
| 447 | # if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__) | |
| 445 | 448 | static _LIBCPP_CONSTEXPR const bool is_iec559 = false; |
| 446 | #else | |
| 449 | # else | |
| 447 | 450 | static _LIBCPP_CONSTEXPR const bool is_iec559 = true; |
| 448 | #endif | |
| 451 | # endif | |
| 449 | 452 | static _LIBCPP_CONSTEXPR const bool is_bounded = true; |
| 450 | 453 | static _LIBCPP_CONSTEXPR const bool is_modulo = false; |
| 451 | 454 | |
| 452 | 455 | static _LIBCPP_CONSTEXPR const bool traps = false; |
| 453 | #if (defined(__arm__) || defined(__aarch64__)) | |
| 456 | # if (defined(__arm__) || defined(__aarch64__)) | |
| 454 | 457 | static _LIBCPP_CONSTEXPR const bool tinyness_before = true; |
| 455 | #else | |
| 458 | # else | |
| 456 | 459 | static _LIBCPP_CONSTEXPR const bool tinyness_before = false; |
| 457 | #endif | |
| 460 | # endif | |
| 458 | 461 | static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; |
| 459 | 462 | }; |
| 460 | 463 | |
| ... | ... | @@ -464,106 +467,59 @@ class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> |
| 464 | 467 | typedef typename __base::type type; |
| 465 | 468 | |
| 466 | 469 | public: |
| 467 | static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; | |
| 468 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } | |
| 469 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } | |
| 470 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } | |
| 471 | ||
| 472 | static _LIBCPP_CONSTEXPR const int digits = __base::digits; | |
| 473 | static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; | |
| 474 | static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10; | |
| 475 | static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed; | |
| 476 | static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; | |
| 477 | static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; | |
| 478 | static _LIBCPP_CONSTEXPR const int radix = __base::radix; | |
| 479 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { | |
| 470 | static inline _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; | |
| 471 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } | |
| 472 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } | |
| 473 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } | |
| 474 | ||
| 475 | static inline _LIBCPP_CONSTEXPR const int digits = __base::digits; | |
| 476 | static inline _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; | |
| 477 | static inline _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10; | |
| 478 | static inline _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed; | |
| 479 | static inline _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; | |
| 480 | static inline _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; | |
| 481 | static inline _LIBCPP_CONSTEXPR const int radix = __base::radix; | |
| 482 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { | |
| 480 | 483 | return __base::epsilon(); |
| 481 | 484 | } |
| 482 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { | |
| 485 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { | |
| 483 | 486 | return __base::round_error(); |
| 484 | 487 | } |
| 485 | 488 | |
| 486 | static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; | |
| 487 | static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; | |
| 488 | static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent; | |
| 489 | static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10; | |
| 489 | static inline _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; | |
| 490 | static inline _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; | |
| 491 | static inline _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent; | |
| 492 | static inline _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10; | |
| 490 | 493 | |
| 491 | static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; | |
| 492 | static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; | |
| 493 | static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; | |
| 494 | static inline _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; | |
| 495 | static inline _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; | |
| 496 | static inline _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; | |
| 494 | 497 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 495 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; | |
| 496 | static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; | |
| 498 | static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; | |
| 499 | static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; | |
| 497 | 500 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 498 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { | |
| 501 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { | |
| 499 | 502 | return __base::infinity(); |
| 500 | 503 | } |
| 501 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { | |
| 504 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { | |
| 502 | 505 | return __base::quiet_NaN(); |
| 503 | 506 | } |
| 504 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | |
| 507 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { | |
| 505 | 508 | return __base::signaling_NaN(); |
| 506 | 509 | } |
| 507 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | |
| 510 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { | |
| 508 | 511 | return __base::denorm_min(); |
| 509 | 512 | } |
| 510 | 513 | |
| 511 | static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559; | |
| 512 | static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded; | |
| 513 | static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo; | |
| 514 | static inline _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559; | |
| 515 | static inline _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded; | |
| 516 | static inline _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo; | |
| 514 | 517 | |
| 515 | static _LIBCPP_CONSTEXPR const bool traps = __base::traps; | |
| 516 | static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before; | |
| 517 | static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style; | |
| 518 | static inline _LIBCPP_CONSTEXPR const bool traps = __base::traps; | |
| 519 | static inline _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before; | |
| 520 | static inline _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style; | |
| 518 | 521 | }; |
| 519 | 522 | |
| 520 | template <class _Tp> | |
| 521 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized; | |
| 522 | template <class _Tp> | |
| 523 | _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits; | |
| 524 | template <class _Tp> | |
| 525 | _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10; | |
| 526 | template <class _Tp> | |
| 527 | _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10; | |
| 528 | template <class _Tp> | |
| 529 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed; | |
| 530 | template <class _Tp> | |
| 531 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer; | |
| 532 | template <class _Tp> | |
| 533 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact; | |
| 534 | template <class _Tp> | |
| 535 | _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix; | |
| 536 | template <class _Tp> | |
| 537 | _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent; | |
| 538 | template <class _Tp> | |
| 539 | _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10; | |
| 540 | template <class _Tp> | |
| 541 | _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent; | |
| 542 | template <class _Tp> | |
| 543 | _LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10; | |
| 544 | template <class _Tp> | |
| 545 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity; | |
| 546 | template <class _Tp> | |
| 547 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN; | |
| 548 | template <class _Tp> | |
| 549 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN; | |
| 550 | template <class _Tp> | |
| 551 | _LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm; | |
| 552 | template <class _Tp> | |
| 553 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss; | |
| 554 | template <class _Tp> | |
| 555 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559; | |
| 556 | template <class _Tp> | |
| 557 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded; | |
| 558 | template <class _Tp> | |
| 559 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo; | |
| 560 | template <class _Tp> | |
| 561 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps; | |
| 562 | template <class _Tp> | |
| 563 | _LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before; | |
| 564 | template <class _Tp> | |
| 565 | _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style; | |
| 566 | ||
| 567 | 523 | template <class _Tp> |
| 568 | 524 | class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {}; |
| 569 | 525 | |
| ... | ... | @@ -577,8 +533,9 @@ _LIBCPP_END_NAMESPACE_STD |
| 577 | 533 | |
| 578 | 534 | _LIBCPP_POP_MACROS |
| 579 | 535 | |
| 580 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 581 | # include <type_traits> | |
| 582 | #endif | |
| 536 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 537 | # include <type_traits> | |
| 538 | # endif | |
| 539 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 583 | 540 | |
| 584 | 541 | #endif // _LIBCPP_LIMITS |
lib/libcxx/include/list+369-357| ... | ... | @@ -197,67 +197,72 @@ template <class T, class Allocator, class Predicate> |
| 197 | 197 | |
| 198 | 198 | */ |
| 199 | 199 | |
| 200 | #include <__algorithm/comp.h> | |
| 201 | #include <__algorithm/equal.h> | |
| 202 | #include <__algorithm/lexicographical_compare.h> | |
| 203 | #include <__algorithm/lexicographical_compare_three_way.h> | |
| 204 | #include <__algorithm/min.h> | |
| 205 | #include <__assert> | |
| 206 | #include <__config> | |
| 207 | #include <__format/enable_insertable.h> | |
| 208 | #include <__iterator/distance.h> | |
| 209 | #include <__iterator/iterator_traits.h> | |
| 210 | #include <__iterator/move_iterator.h> | |
| 211 | #include <__iterator/next.h> | |
| 212 | #include <__iterator/prev.h> | |
| 213 | #include <__iterator/reverse_iterator.h> | |
| 214 | #include <__memory/addressof.h> | |
| 215 | #include <__memory/allocation_guard.h> | |
| 216 | #include <__memory/allocator.h> | |
| 217 | #include <__memory/allocator_traits.h> | |
| 218 | #include <__memory/compressed_pair.h> | |
| 219 | #include <__memory/construct_at.h> | |
| 220 | #include <__memory/pointer_traits.h> | |
| 221 | #include <__memory/swap_allocator.h> | |
| 222 | #include <__memory_resource/polymorphic_allocator.h> | |
| 223 | #include <__ranges/access.h> | |
| 224 | #include <__ranges/concepts.h> | |
| 225 | #include <__ranges/container_compatible_range.h> | |
| 226 | #include <__ranges/from_range.h> | |
| 227 | #include <__type_traits/conditional.h> | |
| 228 | #include <__type_traits/is_allocator.h> | |
| 229 | #include <__type_traits/is_nothrow_assignable.h> | |
| 230 | #include <__type_traits/is_nothrow_constructible.h> | |
| 231 | #include <__type_traits/is_pointer.h> | |
| 232 | #include <__type_traits/is_same.h> | |
| 233 | #include <__type_traits/type_identity.h> | |
| 234 | #include <__utility/forward.h> | |
| 235 | #include <__utility/move.h> | |
| 236 | #include <__utility/swap.h> | |
| 237 | #include <cstring> | |
| 238 | #include <limits> | |
| 239 | #include <new> // __launder | |
| 240 | #include <version> | |
| 200 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 201 | # include <__cxx03/list> | |
| 202 | #else | |
| 203 | # include <__algorithm/comp.h> | |
| 204 | # include <__algorithm/equal.h> | |
| 205 | # include <__algorithm/lexicographical_compare.h> | |
| 206 | # include <__algorithm/lexicographical_compare_three_way.h> | |
| 207 | # include <__algorithm/min.h> | |
| 208 | # include <__assert> | |
| 209 | # include <__config> | |
| 210 | # include <__format/enable_insertable.h> | |
| 211 | # include <__iterator/distance.h> | |
| 212 | # include <__iterator/iterator_traits.h> | |
| 213 | # include <__iterator/move_iterator.h> | |
| 214 | # include <__iterator/next.h> | |
| 215 | # include <__iterator/prev.h> | |
| 216 | # include <__iterator/reverse_iterator.h> | |
| 217 | # include <__memory/addressof.h> | |
| 218 | # include <__memory/allocation_guard.h> | |
| 219 | # include <__memory/allocator.h> | |
| 220 | # include <__memory/allocator_traits.h> | |
| 221 | # include <__memory/compressed_pair.h> | |
| 222 | # include <__memory/construct_at.h> | |
| 223 | # include <__memory/pointer_traits.h> | |
| 224 | # include <__memory/swap_allocator.h> | |
| 225 | # include <__memory_resource/polymorphic_allocator.h> | |
| 226 | # include <__new/launder.h> | |
| 227 | # include <__ranges/access.h> | |
| 228 | # include <__ranges/concepts.h> | |
| 229 | # include <__ranges/container_compatible_range.h> | |
| 230 | # include <__ranges/from_range.h> | |
| 231 | # include <__type_traits/conditional.h> | |
| 232 | # include <__type_traits/container_traits.h> | |
| 233 | # include <__type_traits/enable_if.h> | |
| 234 | # include <__type_traits/is_allocator.h> | |
| 235 | # include <__type_traits/is_nothrow_assignable.h> | |
| 236 | # include <__type_traits/is_nothrow_constructible.h> | |
| 237 | # include <__type_traits/is_pointer.h> | |
| 238 | # include <__type_traits/is_same.h> | |
| 239 | # include <__type_traits/type_identity.h> | |
| 240 | # include <__utility/forward.h> | |
| 241 | # include <__utility/move.h> | |
| 242 | # include <__utility/swap.h> | |
| 243 | # include <cstring> | |
| 244 | # include <limits> | |
| 245 | # include <version> | |
| 241 | 246 | |
| 242 | 247 | // standard-mandated includes |
| 243 | 248 | |
| 244 | 249 | // [iterator.range] |
| 245 | #include <__iterator/access.h> | |
| 246 | #include <__iterator/data.h> | |
| 247 | #include <__iterator/empty.h> | |
| 248 | #include <__iterator/reverse_access.h> | |
| 249 | #include <__iterator/size.h> | |
| 250 | # include <__iterator/access.h> | |
| 251 | # include <__iterator/data.h> | |
| 252 | # include <__iterator/empty.h> | |
| 253 | # include <__iterator/reverse_access.h> | |
| 254 | # include <__iterator/size.h> | |
| 250 | 255 | |
| 251 | 256 | // [list.syn] |
| 252 | #include <compare> | |
| 253 | #include <initializer_list> | |
| 257 | # include <compare> | |
| 258 | # include <initializer_list> | |
| 254 | 259 | |
| 255 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 256 | # pragma GCC system_header | |
| 257 | #endif | |
| 260 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 261 | # pragma GCC system_header | |
| 262 | # endif | |
| 258 | 263 | |
| 259 | 264 | _LIBCPP_PUSH_MACROS |
| 260 | #include <__undef_macros> | |
| 265 | # include <__undef_macros> | |
| 261 | 266 | |
| 262 | 267 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 263 | 268 | |
| ... | ... | @@ -271,19 +276,21 @@ struct __list_node_pointer_traits { |
| 271 | 276 | typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> > __node_pointer; |
| 272 | 277 | typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> > __base_pointer; |
| 273 | 278 | |
| 274 | #if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB) | |
| 275 | typedef __base_pointer __link_pointer; | |
| 276 | #else | |
| 277 | typedef __conditional_t<is_pointer<_VoidPtr>::value, __base_pointer, __node_pointer> __link_pointer; | |
| 278 | #endif | |
| 279 | ||
| 280 | typedef __conditional_t<is_same<__link_pointer, __node_pointer>::value, __base_pointer, __node_pointer> | |
| 281 | __non_link_pointer; | |
| 279 | // TODO(LLVM 22): Remove this check | |
| 280 | # ifndef _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB | |
| 281 | static_assert(sizeof(__node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__base_pointer) == | |
| 282 | _LIBCPP_ALIGNOF(__node_pointer), | |
| 283 | "It looks like you are using std::list with a fancy pointer type that thas a different representation " | |
| 284 | "depending on whether it points to a list base pointer or a list node pointer (both of which are " | |
| 285 | "implementation details of the standard library). This means that your ABI is being broken between " | |
| 286 | "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the " | |
| 287 | "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); | |
| 288 | # endif | |
| 282 | 289 | |
| 283 | static _LIBCPP_HIDE_FROM_ABI __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) { return __p; } | |
| 290 | static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__base_pointer __p) { return __p; } | |
| 284 | 291 | |
| 285 | static _LIBCPP_HIDE_FROM_ABI __link_pointer __unsafe_link_pointer_cast(__non_link_pointer __p) { | |
| 286 | return static_cast<__link_pointer>(static_cast<_VoidPtr>(__p)); | |
| 292 | static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__node_pointer __p) { | |
| 293 | return static_cast<__base_pointer>(static_cast<_VoidPtr>(__p)); | |
| 287 | 294 | } |
| 288 | 295 | }; |
| 289 | 296 | |
| ... | ... | @@ -292,16 +299,13 @@ struct __list_node_base { |
| 292 | 299 | typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; |
| 293 | 300 | typedef typename _NodeTraits::__node_pointer __node_pointer; |
| 294 | 301 | typedef typename _NodeTraits::__base_pointer __base_pointer; |
| 295 | typedef typename _NodeTraits::__link_pointer __link_pointer; | |
| 296 | 302 | |
| 297 | __link_pointer __prev_; | |
| 298 | __link_pointer __next_; | |
| 303 | __base_pointer __prev_; | |
| 304 | __base_pointer __next_; | |
| 299 | 305 | |
| 300 | _LIBCPP_HIDE_FROM_ABI __list_node_base() | |
| 301 | : __prev_(_NodeTraits::__unsafe_link_pointer_cast(__self())), | |
| 302 | __next_(_NodeTraits::__unsafe_link_pointer_cast(__self())) {} | |
| 306 | _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {} | |
| 303 | 307 | |
| 304 | _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__link_pointer __prev, __link_pointer __next) | |
| 308 | _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__base_pointer __prev, __base_pointer __next) | |
| 305 | 309 | : __prev_(__prev), __next_(__next) {} |
| 306 | 310 | |
| 307 | 311 | _LIBCPP_HIDE_FROM_ABI __base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); } |
| ... | ... | @@ -313,7 +317,7 @@ template <class _Tp, class _VoidPtr> |
| 313 | 317 | struct __list_node : public __list_node_base<_Tp, _VoidPtr> { |
| 314 | 318 | // We allow starting the lifetime of nodes without initializing the value held by the node, |
| 315 | 319 | // since that is handled by the list itself in order to be allocator-aware. |
| 316 | #ifndef _LIBCPP_CXX03_LANG | |
| 320 | # ifndef _LIBCPP_CXX03_LANG | |
| 317 | 321 | |
| 318 | 322 | private: |
| 319 | 323 | union { |
| ... | ... | @@ -322,22 +326,22 @@ private: |
| 322 | 326 | |
| 323 | 327 | public: |
| 324 | 328 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } |
| 325 | #else | |
| 329 | # else | |
| 326 | 330 | |
| 327 | 331 | private: |
| 328 | 332 | _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)]; |
| 329 | 333 | |
| 330 | 334 | public: |
| 331 | 335 | _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); } |
| 332 | #endif | |
| 336 | # endif | |
| 333 | 337 | |
| 334 | 338 | typedef __list_node_base<_Tp, _VoidPtr> __base; |
| 335 | typedef typename __base::__link_pointer __link_pointer; | |
| 339 | typedef typename __base::__base_pointer __base_pointer; | |
| 336 | 340 | |
| 337 | _LIBCPP_HIDE_FROM_ABI explicit __list_node(__link_pointer __prev, __link_pointer __next) : __base(__prev, __next) {} | |
| 341 | _LIBCPP_HIDE_FROM_ABI explicit __list_node(__base_pointer __prev, __base_pointer __next) : __base(__prev, __next) {} | |
| 338 | 342 | _LIBCPP_HIDE_FROM_ABI ~__list_node() {} |
| 339 | 343 | |
| 340 | _LIBCPP_HIDE_FROM_ABI __link_pointer __as_link() { return static_cast<__link_pointer>(__base::__self()); } | |
| 344 | _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() { return __base::__self(); } | |
| 341 | 345 | }; |
| 342 | 346 | |
| 343 | 347 | template <class _Tp, class _Alloc = allocator<_Tp> > |
| ... | ... | @@ -350,11 +354,11 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator; |
| 350 | 354 | template <class _Tp, class _VoidPtr> |
| 351 | 355 | class _LIBCPP_TEMPLATE_VIS __list_iterator { |
| 352 | 356 | typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; |
| 353 | typedef typename _NodeTraits::__link_pointer __link_pointer; | |
| 357 | typedef typename _NodeTraits::__base_pointer __base_pointer; | |
| 354 | 358 | |
| 355 | __link_pointer __ptr_; | |
| 359 | __base_pointer __ptr_; | |
| 356 | 360 | |
| 357 | _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {} | |
| 361 | _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {} | |
| 358 | 362 | |
| 359 | 363 | template <class, class> |
| 360 | 364 | friend class list; |
| ... | ... | @@ -408,11 +412,11 @@ public: |
| 408 | 412 | template <class _Tp, class _VoidPtr> |
| 409 | 413 | class _LIBCPP_TEMPLATE_VIS __list_const_iterator { |
| 410 | 414 | typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; |
| 411 | typedef typename _NodeTraits::__link_pointer __link_pointer; | |
| 415 | typedef typename _NodeTraits::__base_pointer __base_pointer; | |
| 412 | 416 | |
| 413 | __link_pointer __ptr_; | |
| 417 | __base_pointer __ptr_; | |
| 414 | 418 | |
| 415 | _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {} | |
| 419 | _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {} | |
| 416 | 420 | |
| 417 | 421 | template <class, class> |
| 418 | 422 | friend class list; |
| ... | ... | @@ -466,7 +470,7 @@ public: |
| 466 | 470 | template <class _Tp, class _Alloc> |
| 467 | 471 | class __list_imp { |
| 468 | 472 | public: |
| 469 | __list_imp(const __list_imp&) = delete; | |
| 473 | __list_imp(const __list_imp&) = delete; | |
| 470 | 474 | __list_imp& operator=(const __list_imp&) = delete; |
| 471 | 475 | |
| 472 | 476 | typedef _Alloc allocator_type; |
| ... | ... | @@ -485,8 +489,8 @@ protected: |
| 485 | 489 | typedef typename __node_alloc_traits::pointer __node_pointer; |
| 486 | 490 | typedef typename __node_alloc_traits::pointer __node_const_pointer; |
| 487 | 491 | typedef __list_node_pointer_traits<value_type, __void_pointer> __node_pointer_traits; |
| 488 | typedef typename __node_pointer_traits::__link_pointer __link_pointer; | |
| 489 | typedef __link_pointer __link_const_pointer; | |
| 492 | typedef typename __node_pointer_traits::__base_pointer __base_pointer; | |
| 493 | typedef __base_pointer __link_const_pointer; | |
| 490 | 494 | typedef typename __alloc_traits::pointer pointer; |
| 491 | 495 | typedef typename __alloc_traits::const_pointer const_pointer; |
| 492 | 496 | typedef typename __alloc_traits::difference_type difference_type; |
| ... | ... | @@ -497,31 +501,26 @@ protected: |
| 497 | 501 | "internal allocator type must differ from user-specified type; otherwise overload resolution breaks"); |
| 498 | 502 | |
| 499 | 503 | __node_base __end_; |
| 500 | __compressed_pair<size_type, __node_allocator> __size_alloc_; | |
| 504 | _LIBCPP_COMPRESSED_PAIR(size_type, __size_, __node_allocator, __node_alloc_); | |
| 501 | 505 | |
| 502 | _LIBCPP_HIDE_FROM_ABI __link_pointer __end_as_link() const _NOEXCEPT { | |
| 506 | _LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT { | |
| 503 | 507 | return __node_pointer_traits::__unsafe_link_pointer_cast(const_cast<__node_base&>(__end_).__self()); |
| 504 | 508 | } |
| 505 | 509 | |
| 506 | _LIBCPP_HIDE_FROM_ABI size_type& __sz() _NOEXCEPT { return __size_alloc_.first(); } | |
| 507 | _LIBCPP_HIDE_FROM_ABI const size_type& __sz() const _NOEXCEPT { return __size_alloc_.first(); } | |
| 508 | _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __size_alloc_.second(); } | |
| 509 | _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __size_alloc_.second(); } | |
| 510 | ||
| 511 | 510 | _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT { |
| 512 | return __node_alloc_traits::max_size(__node_alloc()); | |
| 511 | return __node_alloc_traits::max_size(__node_alloc_); | |
| 513 | 512 | } |
| 514 | _LIBCPP_HIDE_FROM_ABI static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT; | |
| 513 | _LIBCPP_HIDE_FROM_ABI static void __unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT; | |
| 515 | 514 | |
| 516 | 515 | _LIBCPP_HIDE_FROM_ABI __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value); |
| 517 | 516 | _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a); |
| 518 | 517 | _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a); |
| 519 | #ifndef _LIBCPP_CXX03_LANG | |
| 518 | # ifndef _LIBCPP_CXX03_LANG | |
| 520 | 519 | _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT; |
| 521 | #endif | |
| 520 | # endif | |
| 522 | 521 | _LIBCPP_HIDE_FROM_ABI ~__list_imp(); |
| 523 | 522 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT; |
| 524 | _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __sz() == 0; } | |
| 523 | _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __size_ == 0; } | |
| 525 | 524 | |
| 526 | 525 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__end_.__next_); } |
| 527 | 526 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__end_.__next_); } |
| ... | ... | @@ -529,11 +528,11 @@ protected: |
| 529 | 528 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_as_link()); } |
| 530 | 529 | |
| 531 | 530 | _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c) |
| 532 | #if _LIBCPP_STD_VER >= 14 | |
| 531 | # if _LIBCPP_STD_VER >= 14 | |
| 533 | 532 | _NOEXCEPT; |
| 534 | #else | |
| 533 | # else | |
| 535 | 534 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 536 | #endif | |
| 535 | # endif | |
| 537 | 536 | |
| 538 | 537 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) { |
| 539 | 538 | __copy_assign_alloc( |
| ... | ... | @@ -548,9 +547,8 @@ protected: |
| 548 | 547 | } |
| 549 | 548 | |
| 550 | 549 | template <class... _Args> |
| 551 | _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__link_pointer __prev, __link_pointer __next, _Args&&... __args) { | |
| 552 | __node_allocator& __alloc = __node_alloc(); | |
| 553 | __allocation_guard<__node_allocator> __guard(__alloc, 1); | |
| 550 | _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__base_pointer __prev, __base_pointer __next, _Args&&... __args) { | |
| 551 | __allocation_guard<__node_allocator> __guard(__node_alloc_, 1); | |
| 554 | 552 | // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value |
| 555 | 553 | // held inside the node, since we need to use the allocator's construct() method for that. |
| 556 | 554 | // |
| ... | ... | @@ -561,31 +559,30 @@ protected: |
| 561 | 559 | |
| 562 | 560 | // Now construct the value_type using the allocator's construct() method. |
| 563 | 561 | __node_alloc_traits::construct( |
| 564 | __alloc, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...); | |
| 562 | __node_alloc_, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...); | |
| 565 | 563 | return __guard.__release_ptr(); |
| 566 | 564 | } |
| 567 | 565 | |
| 568 | 566 | _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { |
| 569 | 567 | // For the same reason as above, we use the allocator's destroy() method for the value_type, |
| 570 | 568 | // but not for the node itself. |
| 571 | __node_allocator& __alloc = __node_alloc(); | |
| 572 | __node_alloc_traits::destroy(__alloc, std::addressof(__node->__get_value())); | |
| 569 | __node_alloc_traits::destroy(__node_alloc_, std::addressof(__node->__get_value())); | |
| 573 | 570 | std::__destroy_at(std::addressof(*__node)); |
| 574 | __node_alloc_traits::deallocate(__alloc, __node, 1); | |
| 571 | __node_alloc_traits::deallocate(__node_alloc_, __node, 1); | |
| 575 | 572 | } |
| 576 | 573 | |
| 577 | 574 | private: |
| 578 | 575 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c, true_type) { |
| 579 | if (__node_alloc() != __c.__node_alloc()) | |
| 576 | if (__node_alloc_ != __c.__node_alloc_) | |
| 580 | 577 | clear(); |
| 581 | __node_alloc() = __c.__node_alloc(); | |
| 578 | __node_alloc_ = __c.__node_alloc_; | |
| 582 | 579 | } |
| 583 | 580 | |
| 584 | 581 | _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp&, false_type) {} |
| 585 | 582 | |
| 586 | 583 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c, true_type) |
| 587 | 584 | _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) { |
| 588 | __node_alloc() = std::move(__c.__node_alloc()); | |
| 585 | __node_alloc_ = std::move(__c.__node_alloc_); | |
| 589 | 586 | } |
| 590 | 587 | |
| 591 | 588 | _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {} |
| ... | ... | @@ -593,25 +590,28 @@ private: |
| 593 | 590 | |
| 594 | 591 | // Unlink nodes [__f, __l] |
| 595 | 592 | template <class _Tp, class _Alloc> |
| 596 | inline void __list_imp<_Tp, _Alloc>::__unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT { | |
| 593 | inline void __list_imp<_Tp, _Alloc>::__unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT { | |
| 597 | 594 | __f->__prev_->__next_ = __l->__next_; |
| 598 | 595 | __l->__next_->__prev_ = __f->__prev_; |
| 599 | 596 | } |
| 600 | 597 | |
| 601 | 598 | template <class _Tp, class _Alloc> |
| 602 | 599 | inline __list_imp<_Tp, _Alloc>::__list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) |
| 603 | : __size_alloc_(0, __default_init_tag()) {} | |
| 600 | : __size_(0) {} | |
| 604 | 601 | |
| 605 | 602 | template <class _Tp, class _Alloc> |
| 606 | inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a) : __size_alloc_(0, __node_allocator(__a)) {} | |
| 603 | inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a) | |
| 604 | : __size_(0), __node_alloc_(__node_allocator(__a)) {} | |
| 607 | 605 | |
| 608 | 606 | template <class _Tp, class _Alloc> |
| 609 | inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_alloc_(0, __a) {} | |
| 607 | inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_(0), __node_alloc_(__a) {} | |
| 610 | 608 | |
| 611 | #ifndef _LIBCPP_CXX03_LANG | |
| 609 | # ifndef _LIBCPP_CXX03_LANG | |
| 612 | 610 | template <class _Tp, class _Alloc> |
| 613 | inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT : __size_alloc_(0, std::move(__a)) {} | |
| 614 | #endif | |
| 611 | inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT | |
| 612 | : __size_(0), | |
| 613 | __node_alloc_(std::move(__a)) {} | |
| 614 | # endif | |
| 615 | 615 | |
| 616 | 616 | template <class _Tp, class _Alloc> |
| 617 | 617 | __list_imp<_Tp, _Alloc>::~__list_imp() { |
| ... | ... | @@ -621,10 +621,10 @@ __list_imp<_Tp, _Alloc>::~__list_imp() { |
| 621 | 621 | template <class _Tp, class _Alloc> |
| 622 | 622 | void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT { |
| 623 | 623 | if (!empty()) { |
| 624 | __link_pointer __f = __end_.__next_; | |
| 625 | __link_pointer __l = __end_as_link(); | |
| 624 | __base_pointer __f = __end_.__next_; | |
| 625 | __base_pointer __l = __end_as_link(); | |
| 626 | 626 | __unlink_nodes(__f, __l->__prev_); |
| 627 | __sz() = 0; | |
| 627 | __size_ = 0; | |
| 628 | 628 | while (__f != __l) { |
| 629 | 629 | __node_pointer __np = __f->__as_node(); |
| 630 | 630 | __f = __f->__next_; |
| ... | ... | @@ -635,25 +635,25 @@ void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT { |
| 635 | 635 | |
| 636 | 636 | template <class _Tp, class _Alloc> |
| 637 | 637 | void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) |
| 638 | #if _LIBCPP_STD_VER >= 14 | |
| 638 | # if _LIBCPP_STD_VER >= 14 | |
| 639 | 639 | _NOEXCEPT |
| 640 | #else | |
| 640 | # else | |
| 641 | 641 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) |
| 642 | #endif | |
| 642 | # endif | |
| 643 | 643 | { |
| 644 | 644 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( |
| 645 | __alloc_traits::propagate_on_container_swap::value || this->__node_alloc() == __c.__node_alloc(), | |
| 645 | __alloc_traits::propagate_on_container_swap::value || this->__node_alloc_ == __c.__node_alloc_, | |
| 646 | 646 | "list::swap: Either propagate_on_container_swap must be true" |
| 647 | 647 | " or the allocators must compare equal"); |
| 648 | 648 | using std::swap; |
| 649 | std::__swap_allocator(__node_alloc(), __c.__node_alloc()); | |
| 650 | swap(__sz(), __c.__sz()); | |
| 649 | std::__swap_allocator(__node_alloc_, __c.__node_alloc_); | |
| 650 | swap(__size_, __c.__size_); | |
| 651 | 651 | swap(__end_, __c.__end_); |
| 652 | if (__sz() == 0) | |
| 652 | if (__size_ == 0) | |
| 653 | 653 | __end_.__next_ = __end_.__prev_ = __end_as_link(); |
| 654 | 654 | else |
| 655 | 655 | __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_as_link(); |
| 656 | if (__c.__sz() == 0) | |
| 656 | if (__c.__size_ == 0) | |
| 657 | 657 | __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_as_link(); |
| 658 | 658 | else |
| 659 | 659 | __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link(); |
| ... | ... | @@ -661,14 +661,14 @@ void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) |
| 661 | 661 | |
| 662 | 662 | template <class _Tp, class _Alloc /*= allocator<_Tp>*/> |
| 663 | 663 | class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> { |
| 664 | typedef __list_imp<_Tp, _Alloc> base; | |
| 665 | typedef typename base::__node_type __node_type; | |
| 666 | typedef typename base::__node_allocator __node_allocator; | |
| 667 | typedef typename base::__node_pointer __node_pointer; | |
| 668 | typedef typename base::__node_alloc_traits __node_alloc_traits; | |
| 669 | typedef typename base::__node_base __node_base; | |
| 670 | typedef typename base::__node_base_pointer __node_base_pointer; | |
| 671 | typedef typename base::__link_pointer __link_pointer; | |
| 664 | typedef __list_imp<_Tp, _Alloc> __base; | |
| 665 | typedef typename __base::__node_type __node_type; | |
| 666 | typedef typename __base::__node_allocator __node_allocator; | |
| 667 | typedef typename __base::__node_pointer __node_pointer; | |
| 668 | typedef typename __base::__node_alloc_traits __node_alloc_traits; | |
| 669 | typedef typename __base::__node_base __node_base; | |
| 670 | typedef typename __base::__node_base_pointer __node_base_pointer; | |
| 671 | typedef typename __base::__base_pointer __base_pointer; | |
| 672 | 672 | |
| 673 | 673 | public: |
| 674 | 674 | typedef _Tp value_type; |
| ... | ... | @@ -678,29 +678,29 @@ public: |
| 678 | 678 | "Allocator::value_type must be same type as value_type"); |
| 679 | 679 | typedef value_type& reference; |
| 680 | 680 | typedef const value_type& const_reference; |
| 681 | typedef typename base::pointer pointer; | |
| 682 | typedef typename base::const_pointer const_pointer; | |
| 683 | typedef typename base::size_type size_type; | |
| 684 | typedef typename base::difference_type difference_type; | |
| 685 | typedef typename base::iterator iterator; | |
| 686 | typedef typename base::const_iterator const_iterator; | |
| 681 | typedef typename __base::pointer pointer; | |
| 682 | typedef typename __base::const_pointer const_pointer; | |
| 683 | typedef typename __base::size_type size_type; | |
| 684 | typedef typename __base::difference_type difference_type; | |
| 685 | typedef typename __base::iterator iterator; | |
| 686 | typedef typename __base::const_iterator const_iterator; | |
| 687 | 687 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 688 | 688 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 689 | #if _LIBCPP_STD_VER >= 20 | |
| 689 | # if _LIBCPP_STD_VER >= 20 | |
| 690 | 690 | typedef size_type __remove_return_type; |
| 691 | #else | |
| 691 | # else | |
| 692 | 692 | typedef void __remove_return_type; |
| 693 | #endif | |
| 693 | # endif | |
| 694 | 694 | |
| 695 | 695 | _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} |
| 696 | _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) {} | |
| 697 | 697 | _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n); |
| 698 | #if _LIBCPP_STD_VER >= 14 | |
| 698 | # if _LIBCPP_STD_VER >= 14 | |
| 699 | 699 | _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a); |
| 700 | #endif | |
| 700 | # endif | |
| 701 | 701 | _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x); |
| 702 | 702 | template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0> |
| 703 | _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : base(__a) { | |
| 703 | _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : __base(__a) { | |
| 704 | 704 | for (; __n > 0; --__n) |
| 705 | 705 | push_back(__x); |
| 706 | 706 | } |
| ... | ... | @@ -711,17 +711,18 @@ public: |
| 711 | 711 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 712 | 712 | _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a); |
| 713 | 713 | |
| 714 | #if _LIBCPP_STD_VER >= 23 | |
| 714 | # if _LIBCPP_STD_VER >= 23 | |
| 715 | 715 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 716 | _LIBCPP_HIDE_FROM_ABI list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) : base(__a) { | |
| 716 | _LIBCPP_HIDE_FROM_ABI list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) | |
| 717 | : __base(__a) { | |
| 717 | 718 | prepend_range(std::forward<_Range>(__range)); |
| 718 | 719 | } |
| 719 | #endif | |
| 720 | # endif | |
| 720 | 721 | |
| 721 | 722 | _LIBCPP_HIDE_FROM_ABI list(const list& __c); |
| 722 | 723 | _LIBCPP_HIDE_FROM_ABI list(const list& __c, const __type_identity_t<allocator_type>& __a); |
| 723 | 724 | _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c); |
| 724 | #ifndef _LIBCPP_CXX03_LANG | |
| 725 | # ifndef _LIBCPP_CXX03_LANG | |
| 725 | 726 | _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il); |
| 726 | 727 | _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il, const allocator_type& __a); |
| 727 | 728 | |
| ... | ... | @@ -737,34 +738,34 @@ public: |
| 737 | 738 | } |
| 738 | 739 | |
| 739 | 740 | _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); } |
| 740 | #endif // _LIBCPP_CXX03_LANG | |
| 741 | # endif // _LIBCPP_CXX03_LANG | |
| 741 | 742 | |
| 742 | 743 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 743 | 744 | _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l); |
| 744 | 745 | |
| 745 | #if _LIBCPP_STD_VER >= 23 | |
| 746 | # if _LIBCPP_STD_VER >= 23 | |
| 746 | 747 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 747 | 748 | _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) { |
| 748 | 749 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); |
| 749 | 750 | } |
| 750 | #endif | |
| 751 | # endif | |
| 751 | 752 | |
| 752 | 753 | _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x); |
| 753 | 754 | |
| 754 | 755 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT; |
| 755 | 756 | |
| 756 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return base::__sz(); } | |
| 757 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return base::empty(); } | |
| 757 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return this->__size_; } | |
| 758 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __base::empty(); } | |
| 758 | 759 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { |
| 759 | return std::min<size_type>(base::__node_alloc_max_size(), numeric_limits<difference_type >::max()); | |
| 760 | return std::min<size_type>(this->__node_alloc_max_size(), numeric_limits<difference_type >::max()); | |
| 760 | 761 | } |
| 761 | 762 | |
| 762 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return base::begin(); } | |
| 763 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return base::begin(); } | |
| 764 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return base::end(); } | |
| 765 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return base::end(); } | |
| 766 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return base::begin(); } | |
| 767 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return base::end(); } | |
| 763 | _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __base::begin(); } | |
| 764 | _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __base::begin(); } | |
| 765 | _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __base::end(); } | |
| 766 | _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __base::end(); } | |
| 767 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __base::begin(); } | |
| 768 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __base::end(); } | |
| 768 | 769 | |
| 769 | 770 | _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } |
| 770 | 771 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } |
| ... | ... | @@ -775,26 +776,26 @@ public: |
| 775 | 776 | |
| 776 | 777 | _LIBCPP_HIDE_FROM_ABI reference front() { |
| 777 | 778 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); |
| 778 | return base::__end_.__next_->__as_node()->__get_value(); | |
| 779 | return __base::__end_.__next_->__as_node()->__get_value(); | |
| 779 | 780 | } |
| 780 | 781 | _LIBCPP_HIDE_FROM_ABI const_reference front() const { |
| 781 | 782 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); |
| 782 | return base::__end_.__next_->__as_node()->__get_value(); | |
| 783 | return __base::__end_.__next_->__as_node()->__get_value(); | |
| 783 | 784 | } |
| 784 | 785 | _LIBCPP_HIDE_FROM_ABI reference back() { |
| 785 | 786 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); |
| 786 | return base::__end_.__prev_->__as_node()->__get_value(); | |
| 787 | return __base::__end_.__prev_->__as_node()->__get_value(); | |
| 787 | 788 | } |
| 788 | 789 | _LIBCPP_HIDE_FROM_ABI const_reference back() const { |
| 789 | 790 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); |
| 790 | return base::__end_.__prev_->__as_node()->__get_value(); | |
| 791 | return __base::__end_.__prev_->__as_node()->__get_value(); | |
| 791 | 792 | } |
| 792 | 793 | |
| 793 | #ifndef _LIBCPP_CXX03_LANG | |
| 794 | # ifndef _LIBCPP_CXX03_LANG | |
| 794 | 795 | _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x); |
| 795 | 796 | _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x); |
| 796 | 797 | |
| 797 | # if _LIBCPP_STD_VER >= 23 | |
| 798 | # if _LIBCPP_STD_VER >= 23 | |
| 798 | 799 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 799 | 800 | _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) { |
| 800 | 801 | insert_range(begin(), std::forward<_Range>(__range)); |
| ... | ... | @@ -804,20 +805,20 @@ public: |
| 804 | 805 | _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) { |
| 805 | 806 | insert_range(end(), std::forward<_Range>(__range)); |
| 806 | 807 | } |
| 807 | # endif | |
| 808 | # endif | |
| 808 | 809 | |
| 809 | 810 | template <class... _Args> |
| 810 | # if _LIBCPP_STD_VER >= 17 | |
| 811 | # if _LIBCPP_STD_VER >= 17 | |
| 811 | 812 | _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args); |
| 812 | # else | |
| 813 | # else | |
| 813 | 814 | _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args); |
| 814 | # endif | |
| 815 | # endif | |
| 815 | 816 | template <class... _Args> |
| 816 | # if _LIBCPP_STD_VER >= 17 | |
| 817 | # if _LIBCPP_STD_VER >= 17 | |
| 817 | 818 | _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args); |
| 818 | # else | |
| 819 | # else | |
| 819 | 820 | _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args); |
| 820 | # endif | |
| 821 | # endif | |
| 821 | 822 | template <class... _Args> |
| 822 | 823 | _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args); |
| 823 | 824 | |
| ... | ... | @@ -826,19 +827,19 @@ public: |
| 826 | 827 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) { |
| 827 | 828 | return insert(__p, __il.begin(), __il.end()); |
| 828 | 829 | } |
| 829 | #endif // _LIBCPP_CXX03_LANG | |
| 830 | # endif // _LIBCPP_CXX03_LANG | |
| 830 | 831 | |
| 831 | 832 | _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x); |
| 832 | 833 | _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x); |
| 833 | 834 | |
| 834 | #ifndef _LIBCPP_CXX03_LANG | |
| 835 | # ifndef _LIBCPP_CXX03_LANG | |
| 835 | 836 | template <class _Arg> |
| 836 | 837 | _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) { |
| 837 | 838 | emplace_back(std::forward<_Arg>(__arg)); |
| 838 | 839 | } |
| 839 | #else | |
| 840 | # else | |
| 840 | 841 | _LIBCPP_HIDE_FROM_ABI void __emplace_back(value_type const& __arg) { push_back(__arg); } |
| 841 | #endif | |
| 842 | # endif | |
| 842 | 843 | |
| 843 | 844 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x); |
| 844 | 845 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x); |
| ... | ... | @@ -846,23 +847,23 @@ public: |
| 846 | 847 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0> |
| 847 | 848 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l); |
| 848 | 849 | |
| 849 | #if _LIBCPP_STD_VER >= 23 | |
| 850 | # if _LIBCPP_STD_VER >= 23 | |
| 850 | 851 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 851 | 852 | _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) { |
| 852 | 853 | return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); |
| 853 | 854 | } |
| 854 | #endif | |
| 855 | # endif | |
| 855 | 856 | |
| 856 | 857 | _LIBCPP_HIDE_FROM_ABI void swap(list& __c) |
| 857 | #if _LIBCPP_STD_VER >= 14 | |
| 858 | # if _LIBCPP_STD_VER >= 14 | |
| 858 | 859 | _NOEXCEPT |
| 859 | #else | |
| 860 | # else | |
| 860 | 861 | _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>) |
| 861 | #endif | |
| 862 | # endif | |
| 862 | 863 | { |
| 863 | base::swap(__c); | |
| 864 | __base::swap(__c); | |
| 864 | 865 | } |
| 865 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { base::clear(); } | |
| 866 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); } | |
| 866 | 867 | |
| 867 | 868 | _LIBCPP_HIDE_FROM_ABI void pop_front(); |
| 868 | 869 | _LIBCPP_HIDE_FROM_ABI void pop_back(); |
| ... | ... | @@ -874,13 +875,13 @@ public: |
| 874 | 875 | _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x); |
| 875 | 876 | |
| 876 | 877 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c); |
| 877 | #ifndef _LIBCPP_CXX03_LANG | |
| 878 | # ifndef _LIBCPP_CXX03_LANG | |
| 878 | 879 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); } |
| 879 | 880 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) { splice(__p, __c, __i); } |
| 880 | 881 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) { |
| 881 | 882 | splice(__p, __c, __f, __l); |
| 882 | 883 | } |
| 883 | #endif | |
| 884 | # endif | |
| 884 | 885 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i); |
| 885 | 886 | _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l); |
| 886 | 887 | |
| ... | ... | @@ -891,14 +892,14 @@ public: |
| 891 | 892 | template <class _BinaryPred> |
| 892 | 893 | _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred); |
| 893 | 894 | _LIBCPP_HIDE_FROM_ABI void merge(list& __c); |
| 894 | #ifndef _LIBCPP_CXX03_LANG | |
| 895 | # ifndef _LIBCPP_CXX03_LANG | |
| 895 | 896 | _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); } |
| 896 | 897 | |
| 897 | 898 | template <class _Comp> |
| 898 | 899 | _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) { |
| 899 | 900 | merge(__c, __comp); |
| 900 | 901 | } |
| 901 | #endif | |
| 902 | # endif | |
| 902 | 903 | template <class _Comp> |
| 903 | 904 | _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp); |
| 904 | 905 | |
| ... | ... | @@ -917,9 +918,9 @@ private: |
| 917 | 918 | template <class _Iterator, class _Sentinel> |
| 918 | 919 | _LIBCPP_HIDE_FROM_ABI iterator __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l); |
| 919 | 920 | |
| 920 | _LIBCPP_HIDE_FROM_ABI static void __link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l); | |
| 921 | _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_front(__link_pointer __f, __link_pointer __l); | |
| 922 | _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__link_pointer __f, __link_pointer __l); | |
| 921 | _LIBCPP_HIDE_FROM_ABI static void __link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l); | |
| 922 | _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_front(__base_pointer __f, __base_pointer __l); | |
| 923 | _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__base_pointer __f, __base_pointer __l); | |
| 923 | 924 | _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n); |
| 924 | 925 | // TODO: Make this _LIBCPP_HIDE_FROM_ABI |
| 925 | 926 | template <class _Comp> |
| ... | ... | @@ -930,7 +931,7 @@ private: |
| 930 | 931 | _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type); |
| 931 | 932 | }; |
| 932 | 933 | |
| 933 | #if _LIBCPP_STD_VER >= 17 | |
| 934 | # if _LIBCPP_STD_VER >= 17 | |
| 934 | 935 | template <class _InputIterator, |
| 935 | 936 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, |
| 936 | 937 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| ... | ... | @@ -942,18 +943,18 @@ template <class _InputIterator, |
| 942 | 943 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, |
| 943 | 944 | class = enable_if_t<__is_allocator<_Alloc>::value> > |
| 944 | 945 | list(_InputIterator, _InputIterator, _Alloc) -> list<__iter_value_type<_InputIterator>, _Alloc>; |
| 945 | #endif | |
| 946 | # endif | |
| 946 | 947 | |
| 947 | #if _LIBCPP_STD_VER >= 23 | |
| 948 | # if _LIBCPP_STD_VER >= 23 | |
| 948 | 949 | template <ranges::input_range _Range, |
| 949 | 950 | class _Alloc = allocator<ranges::range_value_t<_Range>>, |
| 950 | 951 | class = enable_if_t<__is_allocator<_Alloc>::value> > |
| 951 | 952 | list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_Range>, _Alloc>; |
| 952 | #endif | |
| 953 | # endif | |
| 953 | 954 | |
| 954 | 955 | // Link in nodes [__f, __l] just prior to __p |
| 955 | 956 | template <class _Tp, class _Alloc> |
| 956 | inline void list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l) { | |
| 957 | inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l) { | |
| 957 | 958 | __p->__prev_->__next_ = __f; |
| 958 | 959 | __f->__prev_ = __p->__prev_; |
| 959 | 960 | __p->__prev_ = __l; |
| ... | ... | @@ -962,44 +963,44 @@ inline void list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer _ |
| 962 | 963 | |
| 963 | 964 | // Link in nodes [__f, __l] at the front of the list |
| 964 | 965 | template <class _Tp, class _Alloc> |
| 965 | inline void list<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_pointer __l) { | |
| 966 | __f->__prev_ = base::__end_as_link(); | |
| 967 | __l->__next_ = base::__end_.__next_; | |
| 968 | __l->__next_->__prev_ = __l; | |
| 969 | base::__end_.__next_ = __f; | |
| 966 | inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_pointer __l) { | |
| 967 | __f->__prev_ = __base::__end_as_link(); | |
| 968 | __l->__next_ = __base::__end_.__next_; | |
| 969 | __l->__next_->__prev_ = __l; | |
| 970 | __base::__end_.__next_ = __f; | |
| 970 | 971 | } |
| 971 | 972 | |
| 972 | 973 | // Link in nodes [__f, __l] at the back of the list |
| 973 | 974 | template <class _Tp, class _Alloc> |
| 974 | inline void list<_Tp, _Alloc>::__link_nodes_at_back(__link_pointer __f, __link_pointer __l) { | |
| 975 | __l->__next_ = base::__end_as_link(); | |
| 976 | __f->__prev_ = base::__end_.__prev_; | |
| 977 | __f->__prev_->__next_ = __f; | |
| 978 | base::__end_.__prev_ = __l; | |
| 975 | inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_pointer __l) { | |
| 976 | __l->__next_ = __base::__end_as_link(); | |
| 977 | __f->__prev_ = __base::__end_.__prev_; | |
| 978 | __f->__prev_->__next_ = __f; | |
| 979 | __base::__end_.__prev_ = __l; | |
| 979 | 980 | } |
| 980 | 981 | |
| 981 | 982 | template <class _Tp, class _Alloc> |
| 982 | 983 | inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_type __n) { |
| 983 | return __n <= base::__sz() / 2 ? std::next(begin(), __n) : std::prev(end(), base::__sz() - __n); | |
| 984 | return __n <= this->__size_ / 2 ? std::next(begin(), __n) : std::prev(end(), this->__size_ - __n); | |
| 984 | 985 | } |
| 985 | 986 | |
| 986 | 987 | template <class _Tp, class _Alloc> |
| 987 | 988 | list<_Tp, _Alloc>::list(size_type __n) { |
| 988 | 989 | for (; __n > 0; --__n) |
| 989 | #ifndef _LIBCPP_CXX03_LANG | |
| 990 | # ifndef _LIBCPP_CXX03_LANG | |
| 990 | 991 | emplace_back(); |
| 991 | #else | |
| 992 | # else | |
| 992 | 993 | push_back(value_type()); |
| 993 | #endif | |
| 994 | # endif | |
| 994 | 995 | } |
| 995 | 996 | |
| 996 | #if _LIBCPP_STD_VER >= 14 | |
| 997 | # if _LIBCPP_STD_VER >= 14 | |
| 997 | 998 | template <class _Tp, class _Alloc> |
| 998 | list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a) { | |
| 999 | list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) { | |
| 999 | 1000 | for (; __n > 0; --__n) |
| 1000 | 1001 | emplace_back(); |
| 1001 | 1002 | } |
| 1002 | #endif | |
| 1003 | # endif | |
| 1003 | 1004 | |
| 1004 | 1005 | template <class _Tp, class _Alloc> |
| 1005 | 1006 | list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) { |
| ... | ... | @@ -1016,28 +1017,28 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) { |
| 1016 | 1017 | |
| 1017 | 1018 | template <class _Tp, class _Alloc> |
| 1018 | 1019 | template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> > |
| 1019 | list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) : base(__a) { | |
| 1020 | list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) : __base(__a) { | |
| 1020 | 1021 | for (; __f != __l; ++__f) |
| 1021 | 1022 | __emplace_back(*__f); |
| 1022 | 1023 | } |
| 1023 | 1024 | |
| 1024 | 1025 | template <class _Tp, class _Alloc> |
| 1025 | 1026 | list<_Tp, _Alloc>::list(const list& __c) |
| 1026 | : base(__node_alloc_traits::select_on_container_copy_construction(__c.__node_alloc())) { | |
| 1027 | : __base(__node_alloc_traits::select_on_container_copy_construction(__c.__node_alloc_)) { | |
| 1027 | 1028 | for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i) |
| 1028 | 1029 | push_back(*__i); |
| 1029 | 1030 | } |
| 1030 | 1031 | |
| 1031 | 1032 | template <class _Tp, class _Alloc> |
| 1032 | list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a) : base(__a) { | |
| 1033 | list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) { | |
| 1033 | 1034 | for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i) |
| 1034 | 1035 | push_back(*__i); |
| 1035 | 1036 | } |
| 1036 | 1037 | |
| 1037 | #ifndef _LIBCPP_CXX03_LANG | |
| 1038 | # ifndef _LIBCPP_CXX03_LANG | |
| 1038 | 1039 | |
| 1039 | 1040 | template <class _Tp, class _Alloc> |
| 1040 | list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a) : base(__a) { | |
| 1041 | list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) { | |
| 1041 | 1042 | for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i) |
| 1042 | 1043 | push_back(*__i); |
| 1043 | 1044 | } |
| ... | ... | @@ -1050,12 +1051,12 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il) { |
| 1050 | 1051 | |
| 1051 | 1052 | template <class _Tp, class _Alloc> |
| 1052 | 1053 | inline list<_Tp, _Alloc>::list(list&& __c) noexcept(is_nothrow_move_constructible<__node_allocator>::value) |
| 1053 | : base(std::move(__c.__node_alloc())) { | |
| 1054 | : __base(std::move(__c.__node_alloc_)) { | |
| 1054 | 1055 | splice(end(), __c); |
| 1055 | 1056 | } |
| 1056 | 1057 | |
| 1057 | 1058 | template <class _Tp, class _Alloc> |
| 1058 | inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a) : base(__a) { | |
| 1059 | inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) { | |
| 1059 | 1060 | if (__a == __c.get_allocator()) |
| 1060 | 1061 | splice(end(), __c); |
| 1061 | 1062 | else { |
| ... | ... | @@ -1074,7 +1075,7 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept( |
| 1074 | 1075 | |
| 1075 | 1076 | template <class _Tp, class _Alloc> |
| 1076 | 1077 | void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) { |
| 1077 | if (base::__node_alloc() != __c.__node_alloc()) { | |
| 1078 | if (this->__node_alloc_ != __c.__node_alloc_) { | |
| 1078 | 1079 | typedef move_iterator<iterator> _Ip; |
| 1079 | 1080 | assign(_Ip(__c.begin()), _Ip(__c.end())); |
| 1080 | 1081 | } else |
| ... | ... | @@ -1085,16 +1086,16 @@ template <class _Tp, class _Alloc> |
| 1085 | 1086 | void list<_Tp, _Alloc>::__move_assign(list& __c, |
| 1086 | 1087 | true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) { |
| 1087 | 1088 | clear(); |
| 1088 | base::__move_assign_alloc(__c); | |
| 1089 | __base::__move_assign_alloc(__c); | |
| 1089 | 1090 | splice(end(), __c); |
| 1090 | 1091 | } |
| 1091 | 1092 | |
| 1092 | #endif // _LIBCPP_CXX03_LANG | |
| 1093 | # endif // _LIBCPP_CXX03_LANG | |
| 1093 | 1094 | |
| 1094 | 1095 | template <class _Tp, class _Alloc> |
| 1095 | 1096 | inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) { |
| 1096 | 1097 | if (this != std::addressof(__c)) { |
| 1097 | base::__copy_assign_alloc(__c); | |
| 1098 | __base::__copy_assign_alloc(__c); | |
| 1098 | 1099 | assign(__c.begin(), __c.end()); |
| 1099 | 1100 | } |
| 1100 | 1101 | return *this; |
| ... | ... | @@ -1133,14 +1134,14 @@ void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) { |
| 1133 | 1134 | |
| 1134 | 1135 | template <class _Tp, class _Alloc> |
| 1135 | 1136 | inline _Alloc list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT { |
| 1136 | return allocator_type(base::__node_alloc()); | |
| 1137 | return allocator_type(this->__node_alloc_); | |
| 1137 | 1138 | } |
| 1138 | 1139 | |
| 1139 | 1140 | template <class _Tp, class _Alloc> |
| 1140 | 1141 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) { |
| 1141 | 1142 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); |
| 1142 | 1143 | __link_nodes(__p.__ptr_, __node->__as_link(), __node->__as_link()); |
| 1143 | ++base::__sz(); | |
| 1144 | ++this->__size_; | |
| 1144 | 1145 | return iterator(__node->__as_link()); |
| 1145 | 1146 | } |
| 1146 | 1147 | |
| ... | ... | @@ -1154,16 +1155,16 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ |
| 1154 | 1155 | ++__ds; |
| 1155 | 1156 | __r = iterator(__node->__as_link()); |
| 1156 | 1157 | iterator __e = __r; |
| 1157 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1158 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1158 | 1159 | try { |
| 1159 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1160 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1160 | 1161 | for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { |
| 1161 | 1162 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link(); |
| 1162 | 1163 | } |
| 1163 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1164 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1164 | 1165 | } catch (...) { |
| 1165 | 1166 | while (true) { |
| 1166 | __link_pointer __prev = __e.__ptr_->__prev_; | |
| 1167 | __base_pointer __prev = __e.__ptr_->__prev_; | |
| 1167 | 1168 | __node_pointer __current = __e.__ptr_->__as_node(); |
| 1168 | 1169 | this->__delete_node(__current); |
| 1169 | 1170 | if (__prev == 0) |
| ... | ... | @@ -1172,9 +1173,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ |
| 1172 | 1173 | } |
| 1173 | 1174 | throw; |
| 1174 | 1175 | } |
| 1175 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1176 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1176 | 1177 | __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_); |
| 1177 | base::__sz() += __ds; | |
| 1178 | this->__size_ += __ds; | |
| 1178 | 1179 | } |
| 1179 | 1180 | return __r; |
| 1180 | 1181 | } |
| ... | ... | @@ -1196,16 +1197,16 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se |
| 1196 | 1197 | ++__ds; |
| 1197 | 1198 | __r = iterator(__node->__as_link()); |
| 1198 | 1199 | iterator __e = __r; |
| 1199 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1200 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1200 | 1201 | try { |
| 1201 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1202 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1202 | 1203 | for (++__f; __f != __l; ++__f, (void)++__e, ++__ds) { |
| 1203 | 1204 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, *__f)->__as_link(); |
| 1204 | 1205 | } |
| 1205 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1206 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1206 | 1207 | } catch (...) { |
| 1207 | 1208 | while (true) { |
| 1208 | __link_pointer __prev = __e.__ptr_->__prev_; | |
| 1209 | __base_pointer __prev = __e.__ptr_->__prev_; | |
| 1209 | 1210 | __node_pointer __current = __e.__ptr_->__as_node(); |
| 1210 | 1211 | this->__delete_node(__current); |
| 1211 | 1212 | if (__prev == 0) |
| ... | ... | @@ -1214,9 +1215,9 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se |
| 1214 | 1215 | } |
| 1215 | 1216 | throw; |
| 1216 | 1217 | } |
| 1217 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1218 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1218 | 1219 | __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_); |
| 1219 | base::__sz() += __ds; | |
| 1220 | this->__size_ += __ds; | |
| 1220 | 1221 | } |
| 1221 | 1222 | return __r; |
| 1222 | 1223 | } |
| ... | ... | @@ -1224,71 +1225,71 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se |
| 1224 | 1225 | template <class _Tp, class _Alloc> |
| 1225 | 1226 | void list<_Tp, _Alloc>::push_front(const value_type& __x) { |
| 1226 | 1227 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); |
| 1227 | __link_pointer __nl = __node->__as_link(); | |
| 1228 | __base_pointer __nl = __node->__as_link(); | |
| 1228 | 1229 | __link_nodes_at_front(__nl, __nl); |
| 1229 | ++base::__sz(); | |
| 1230 | ++this->__size_; | |
| 1230 | 1231 | } |
| 1231 | 1232 | |
| 1232 | 1233 | template <class _Tp, class _Alloc> |
| 1233 | 1234 | void list<_Tp, _Alloc>::push_back(const value_type& __x) { |
| 1234 | 1235 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); |
| 1235 | __link_pointer __nl = __node->__as_link(); | |
| 1236 | __base_pointer __nl = __node->__as_link(); | |
| 1236 | 1237 | __link_nodes_at_back(__nl, __nl); |
| 1237 | ++base::__sz(); | |
| 1238 | ++this->__size_; | |
| 1238 | 1239 | } |
| 1239 | 1240 | |
| 1240 | #ifndef _LIBCPP_CXX03_LANG | |
| 1241 | # ifndef _LIBCPP_CXX03_LANG | |
| 1241 | 1242 | |
| 1242 | 1243 | template <class _Tp, class _Alloc> |
| 1243 | 1244 | void list<_Tp, _Alloc>::push_front(value_type&& __x) { |
| 1244 | 1245 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); |
| 1245 | __link_pointer __nl = __node->__as_link(); | |
| 1246 | __base_pointer __nl = __node->__as_link(); | |
| 1246 | 1247 | __link_nodes_at_front(__nl, __nl); |
| 1247 | ++base::__sz(); | |
| 1248 | ++this->__size_; | |
| 1248 | 1249 | } |
| 1249 | 1250 | |
| 1250 | 1251 | template <class _Tp, class _Alloc> |
| 1251 | 1252 | void list<_Tp, _Alloc>::push_back(value_type&& __x) { |
| 1252 | 1253 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); |
| 1253 | __link_pointer __nl = __node->__as_link(); | |
| 1254 | __base_pointer __nl = __node->__as_link(); | |
| 1254 | 1255 | __link_nodes_at_back(__nl, __nl); |
| 1255 | ++base::__sz(); | |
| 1256 | ++this->__size_; | |
| 1256 | 1257 | } |
| 1257 | 1258 | |
| 1258 | 1259 | template <class _Tp, class _Alloc> |
| 1259 | 1260 | template <class... _Args> |
| 1260 | # if _LIBCPP_STD_VER >= 17 | |
| 1261 | # if _LIBCPP_STD_VER >= 17 | |
| 1261 | 1262 | typename list<_Tp, _Alloc>::reference |
| 1262 | # else | |
| 1263 | # else | |
| 1263 | 1264 | void |
| 1264 | # endif | |
| 1265 | # endif | |
| 1265 | 1266 | list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { |
| 1266 | 1267 | __node_pointer __node = |
| 1267 | 1268 | this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); |
| 1268 | __link_pointer __nl = __node->__as_link(); | |
| 1269 | __base_pointer __nl = __node->__as_link(); | |
| 1269 | 1270 | __link_nodes_at_front(__nl, __nl); |
| 1270 | ++base::__sz(); | |
| 1271 | # if _LIBCPP_STD_VER >= 17 | |
| 1271 | ++this->__size_; | |
| 1272 | # if _LIBCPP_STD_VER >= 17 | |
| 1272 | 1273 | return __node->__get_value(); |
| 1273 | # endif | |
| 1274 | # endif | |
| 1274 | 1275 | } |
| 1275 | 1276 | |
| 1276 | 1277 | template <class _Tp, class _Alloc> |
| 1277 | 1278 | template <class... _Args> |
| 1278 | # if _LIBCPP_STD_VER >= 17 | |
| 1279 | # if _LIBCPP_STD_VER >= 17 | |
| 1279 | 1280 | typename list<_Tp, _Alloc>::reference |
| 1280 | # else | |
| 1281 | # else | |
| 1281 | 1282 | void |
| 1282 | # endif | |
| 1283 | # endif | |
| 1283 | 1284 | list<_Tp, _Alloc>::emplace_back(_Args&&... __args) { |
| 1284 | 1285 | __node_pointer __node = |
| 1285 | 1286 | this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); |
| 1286 | __link_pointer __nl = __node->__as_link(); | |
| 1287 | __base_pointer __nl = __node->__as_link(); | |
| 1287 | 1288 | __link_nodes_at_back(__nl, __nl); |
| 1288 | ++base::__sz(); | |
| 1289 | # if _LIBCPP_STD_VER >= 17 | |
| 1289 | ++this->__size_; | |
| 1290 | # if _LIBCPP_STD_VER >= 17 | |
| 1290 | 1291 | return __node->__get_value(); |
| 1291 | # endif | |
| 1292 | # endif | |
| 1292 | 1293 | } |
| 1293 | 1294 | |
| 1294 | 1295 | template <class _Tp, class _Alloc> |
| ... | ... | @@ -1296,48 +1297,48 @@ template <class... _Args> |
| 1296 | 1297 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) { |
| 1297 | 1298 | __node_pointer __node = |
| 1298 | 1299 | this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...); |
| 1299 | __link_pointer __nl = __node->__as_link(); | |
| 1300 | __base_pointer __nl = __node->__as_link(); | |
| 1300 | 1301 | __link_nodes(__p.__ptr_, __nl, __nl); |
| 1301 | ++base::__sz(); | |
| 1302 | ++this->__size_; | |
| 1302 | 1303 | return iterator(__nl); |
| 1303 | 1304 | } |
| 1304 | 1305 | |
| 1305 | 1306 | template <class _Tp, class _Alloc> |
| 1306 | 1307 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) { |
| 1307 | 1308 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x)); |
| 1308 | __link_pointer __nl = __node->__as_link(); | |
| 1309 | __base_pointer __nl = __node->__as_link(); | |
| 1309 | 1310 | __link_nodes(__p.__ptr_, __nl, __nl); |
| 1310 | ++base::__sz(); | |
| 1311 | ++this->__size_; | |
| 1311 | 1312 | return iterator(__nl); |
| 1312 | 1313 | } |
| 1313 | 1314 | |
| 1314 | #endif // _LIBCPP_CXX03_LANG | |
| 1315 | # endif // _LIBCPP_CXX03_LANG | |
| 1315 | 1316 | |
| 1316 | 1317 | template <class _Tp, class _Alloc> |
| 1317 | 1318 | void list<_Tp, _Alloc>::pop_front() { |
| 1318 | 1319 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list"); |
| 1319 | __link_pointer __n = base::__end_.__next_; | |
| 1320 | base::__unlink_nodes(__n, __n); | |
| 1321 | --base::__sz(); | |
| 1320 | __base_pointer __n = __base::__end_.__next_; | |
| 1321 | __base::__unlink_nodes(__n, __n); | |
| 1322 | --this->__size_; | |
| 1322 | 1323 | this->__delete_node(__n->__as_node()); |
| 1323 | 1324 | } |
| 1324 | 1325 | |
| 1325 | 1326 | template <class _Tp, class _Alloc> |
| 1326 | 1327 | void list<_Tp, _Alloc>::pop_back() { |
| 1327 | 1328 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list"); |
| 1328 | __link_pointer __n = base::__end_.__prev_; | |
| 1329 | base::__unlink_nodes(__n, __n); | |
| 1330 | --base::__sz(); | |
| 1329 | __base_pointer __n = __base::__end_.__prev_; | |
| 1330 | __base::__unlink_nodes(__n, __n); | |
| 1331 | --this->__size_; | |
| 1331 | 1332 | this->__delete_node(__n->__as_node()); |
| 1332 | 1333 | } |
| 1333 | 1334 | |
| 1334 | 1335 | template <class _Tp, class _Alloc> |
| 1335 | 1336 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) { |
| 1336 | 1337 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator"); |
| 1337 | __link_pointer __n = __p.__ptr_; | |
| 1338 | __link_pointer __r = __n->__next_; | |
| 1339 | base::__unlink_nodes(__n, __n); | |
| 1340 | --base::__sz(); | |
| 1338 | __base_pointer __n = __p.__ptr_; | |
| 1339 | __base_pointer __r = __n->__next_; | |
| 1340 | __base::__unlink_nodes(__n, __n); | |
| 1341 | --this->__size_; | |
| 1341 | 1342 | this->__delete_node(__n->__as_node()); |
| 1342 | 1343 | return iterator(__r); |
| 1343 | 1344 | } |
| ... | ... | @@ -1345,11 +1346,11 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p |
| 1345 | 1346 | template <class _Tp, class _Alloc> |
| 1346 | 1347 | typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) { |
| 1347 | 1348 | if (__f != __l) { |
| 1348 | base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_); | |
| 1349 | __base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_); | |
| 1349 | 1350 | while (__f != __l) { |
| 1350 | __link_pointer __n = __f.__ptr_; | |
| 1351 | __base_pointer __n = __f.__ptr_; | |
| 1351 | 1352 | ++__f; |
| 1352 | --base::__sz(); | |
| 1353 | --this->__size_; | |
| 1353 | 1354 | this->__delete_node(__n->__as_node()); |
| 1354 | 1355 | } |
| 1355 | 1356 | } |
| ... | ... | @@ -1358,25 +1359,25 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f |
| 1358 | 1359 | |
| 1359 | 1360 | template <class _Tp, class _Alloc> |
| 1360 | 1361 | void list<_Tp, _Alloc>::resize(size_type __n) { |
| 1361 | if (__n < base::__sz()) | |
| 1362 | if (__n < this->__size_) | |
| 1362 | 1363 | erase(__iterator(__n), end()); |
| 1363 | else if (__n > base::__sz()) { | |
| 1364 | __n -= base::__sz(); | |
| 1364 | else if (__n > this->__size_) { | |
| 1365 | __n -= this->__size_; | |
| 1365 | 1366 | size_type __ds = 0; |
| 1366 | 1367 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr); |
| 1367 | 1368 | ++__ds; |
| 1368 | 1369 | iterator __r = iterator(__node->__as_link()); |
| 1369 | 1370 | iterator __e = __r; |
| 1370 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1371 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1371 | 1372 | try { |
| 1372 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1373 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1373 | 1374 | for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { |
| 1374 | 1375 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr)->__as_link(); |
| 1375 | 1376 | } |
| 1376 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1377 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1377 | 1378 | } catch (...) { |
| 1378 | 1379 | while (true) { |
| 1379 | __link_pointer __prev = __e.__ptr_->__prev_; | |
| 1380 | __base_pointer __prev = __e.__ptr_->__prev_; | |
| 1380 | 1381 | __node_pointer __current = __e.__ptr_->__as_node(); |
| 1381 | 1382 | this->__delete_node(__current); |
| 1382 | 1383 | if (__prev == 0) |
| ... | ... | @@ -1385,34 +1386,34 @@ void list<_Tp, _Alloc>::resize(size_type __n) { |
| 1385 | 1386 | } |
| 1386 | 1387 | throw; |
| 1387 | 1388 | } |
| 1388 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1389 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1389 | 1390 | __link_nodes_at_back(__r.__ptr_, __e.__ptr_); |
| 1390 | base::__sz() += __ds; | |
| 1391 | this->__size_ += __ds; | |
| 1391 | 1392 | } |
| 1392 | 1393 | } |
| 1393 | 1394 | |
| 1394 | 1395 | template <class _Tp, class _Alloc> |
| 1395 | 1396 | void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { |
| 1396 | if (__n < base::__sz()) | |
| 1397 | if (__n < this->__size_) | |
| 1397 | 1398 | erase(__iterator(__n), end()); |
| 1398 | else if (__n > base::__sz()) { | |
| 1399 | __n -= base::__sz(); | |
| 1399 | else if (__n > this->__size_) { | |
| 1400 | __n -= this->__size_; | |
| 1400 | 1401 | size_type __ds = 0; |
| 1401 | 1402 | __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x); |
| 1402 | 1403 | ++__ds; |
| 1403 | __link_pointer __nl = __node->__as_link(); | |
| 1404 | __base_pointer __nl = __node->__as_link(); | |
| 1404 | 1405 | iterator __r = iterator(__nl); |
| 1405 | 1406 | iterator __e = __r; |
| 1406 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1407 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1407 | 1408 | try { |
| 1408 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1409 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1409 | 1410 | for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { |
| 1410 | 1411 | __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link(); |
| 1411 | 1412 | } |
| 1412 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1413 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1413 | 1414 | } catch (...) { |
| 1414 | 1415 | while (true) { |
| 1415 | __link_pointer __prev = __e.__ptr_->__prev_; | |
| 1416 | __base_pointer __prev = __e.__ptr_->__prev_; | |
| 1416 | 1417 | __node_pointer __current = __e.__ptr_->__as_node(); |
| 1417 | 1418 | this->__delete_node(__current); |
| 1418 | 1419 | if (__prev == 0) |
| ... | ... | @@ -1421,9 +1422,9 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { |
| 1421 | 1422 | } |
| 1422 | 1423 | throw; |
| 1423 | 1424 | } |
| 1424 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1425 | __link_nodes(base::__end_as_link(), __r.__ptr_, __e.__ptr_); | |
| 1426 | base::__sz() += __ds; | |
| 1425 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1426 | __link_nodes(__base::__end_as_link(), __r.__ptr_, __e.__ptr_); | |
| 1427 | this->__size_ += __ds; | |
| 1427 | 1428 | } |
| 1428 | 1429 | } |
| 1429 | 1430 | |
| ... | ... | @@ -1432,38 +1433,38 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) { |
| 1432 | 1433 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( |
| 1433 | 1434 | this != std::addressof(__c), "list::splice(iterator, list) called with this == &list"); |
| 1434 | 1435 | if (!__c.empty()) { |
| 1435 | __link_pointer __f = __c.__end_.__next_; | |
| 1436 | __link_pointer __l = __c.__end_.__prev_; | |
| 1437 | base::__unlink_nodes(__f, __l); | |
| 1436 | __base_pointer __f = __c.__end_.__next_; | |
| 1437 | __base_pointer __l = __c.__end_.__prev_; | |
| 1438 | __base::__unlink_nodes(__f, __l); | |
| 1438 | 1439 | __link_nodes(__p.__ptr_, __f, __l); |
| 1439 | base::__sz() += __c.__sz(); | |
| 1440 | __c.__sz() = 0; | |
| 1440 | this->__size_ += __c.__size_; | |
| 1441 | __c.__size_ = 0; | |
| 1441 | 1442 | } |
| 1442 | 1443 | } |
| 1443 | 1444 | |
| 1444 | 1445 | template <class _Tp, class _Alloc> |
| 1445 | 1446 | void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) { |
| 1446 | 1447 | if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) { |
| 1447 | __link_pointer __f = __i.__ptr_; | |
| 1448 | base::__unlink_nodes(__f, __f); | |
| 1448 | __base_pointer __f = __i.__ptr_; | |
| 1449 | __base::__unlink_nodes(__f, __f); | |
| 1449 | 1450 | __link_nodes(__p.__ptr_, __f, __f); |
| 1450 | --__c.__sz(); | |
| 1451 | ++base::__sz(); | |
| 1451 | --__c.__size_; | |
| 1452 | ++this->__size_; | |
| 1452 | 1453 | } |
| 1453 | 1454 | } |
| 1454 | 1455 | |
| 1455 | 1456 | template <class _Tp, class _Alloc> |
| 1456 | 1457 | void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) { |
| 1457 | 1458 | if (__f != __l) { |
| 1458 | __link_pointer __first = __f.__ptr_; | |
| 1459 | __base_pointer __first = __f.__ptr_; | |
| 1459 | 1460 | --__l; |
| 1460 | __link_pointer __last = __l.__ptr_; | |
| 1461 | __base_pointer __last = __l.__ptr_; | |
| 1461 | 1462 | if (this != std::addressof(__c)) { |
| 1462 | 1463 | size_type __s = std::distance(__f, __l) + 1; |
| 1463 | __c.__sz() -= __s; | |
| 1464 | base::__sz() += __s; | |
| 1464 | __c.__size_ -= __s; | |
| 1465 | this->__size_ += __s; | |
| 1465 | 1466 | } |
| 1466 | base::__unlink_nodes(__first, __last); | |
| 1467 | __base::__unlink_nodes(__first, __last); | |
| 1467 | 1468 | __link_nodes(__p.__ptr_, __first, __last); |
| 1468 | 1469 | } |
| 1469 | 1470 | } |
| ... | ... | @@ -1543,12 +1544,12 @@ void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) { |
| 1543 | 1544 | iterator __m2 = std::next(__f2); |
| 1544 | 1545 | for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2, (void)++__ds) |
| 1545 | 1546 | ; |
| 1546 | base::__sz() += __ds; | |
| 1547 | __c.__sz() -= __ds; | |
| 1548 | __link_pointer __f = __f2.__ptr_; | |
| 1549 | __link_pointer __l = __m2.__ptr_->__prev_; | |
| 1547 | this->__size_ += __ds; | |
| 1548 | __c.__size_ -= __ds; | |
| 1549 | __base_pointer __f = __f2.__ptr_; | |
| 1550 | __base_pointer __l = __m2.__ptr_->__prev_; | |
| 1550 | 1551 | __f2 = __m2; |
| 1551 | base::__unlink_nodes(__f, __l); | |
| 1552 | __base::__unlink_nodes(__f, __l); | |
| 1552 | 1553 | __m2 = std::next(__f1); |
| 1553 | 1554 | __link_nodes(__f1.__ptr_, __f, __l); |
| 1554 | 1555 | __f1 = __m2; |
| ... | ... | @@ -1567,7 +1568,7 @@ inline void list<_Tp, _Alloc>::sort() { |
| 1567 | 1568 | template <class _Tp, class _Alloc> |
| 1568 | 1569 | template <class _Comp> |
| 1569 | 1570 | inline void list<_Tp, _Alloc>::sort(_Comp __comp) { |
| 1570 | __sort(begin(), end(), base::__sz(), __comp); | |
| 1571 | __sort(begin(), end(), this->__size_, __comp); | |
| 1571 | 1572 | } |
| 1572 | 1573 | |
| 1573 | 1574 | template <class _Tp, class _Alloc> |
| ... | ... | @@ -1580,8 +1581,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ |
| 1580 | 1581 | return __f1; |
| 1581 | 1582 | case 2: |
| 1582 | 1583 | if (__comp(*--__e2, *__f1)) { |
| 1583 | __link_pointer __f = __e2.__ptr_; | |
| 1584 | base::__unlink_nodes(__f, __f); | |
| 1584 | __base_pointer __f = __e2.__ptr_; | |
| 1585 | __base::__unlink_nodes(__f, __f); | |
| 1585 | 1586 | __link_nodes(__f1.__ptr_, __f, __f); |
| 1586 | 1587 | return __e2; |
| 1587 | 1588 | } |
| ... | ... | @@ -1595,11 +1596,11 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ |
| 1595 | 1596 | iterator __m2 = std::next(__f2); |
| 1596 | 1597 | for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2) |
| 1597 | 1598 | ; |
| 1598 | __link_pointer __f = __f2.__ptr_; | |
| 1599 | __link_pointer __l = __m2.__ptr_->__prev_; | |
| 1599 | __base_pointer __f = __f2.__ptr_; | |
| 1600 | __base_pointer __l = __m2.__ptr_->__prev_; | |
| 1600 | 1601 | __r = __f2; |
| 1601 | 1602 | __e1 = __f2 = __m2; |
| 1602 | base::__unlink_nodes(__f, __l); | |
| 1603 | __base::__unlink_nodes(__f, __l); | |
| 1603 | 1604 | __m2 = std::next(__f1); |
| 1604 | 1605 | __link_nodes(__f1.__ptr_, __f, __l); |
| 1605 | 1606 | __f1 = __m2; |
| ... | ... | @@ -1610,12 +1611,12 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ |
| 1610 | 1611 | iterator __m2 = std::next(__f2); |
| 1611 | 1612 | for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2) |
| 1612 | 1613 | ; |
| 1613 | __link_pointer __f = __f2.__ptr_; | |
| 1614 | __link_pointer __l = __m2.__ptr_->__prev_; | |
| 1614 | __base_pointer __f = __f2.__ptr_; | |
| 1615 | __base_pointer __l = __m2.__ptr_->__prev_; | |
| 1615 | 1616 | if (__e1 == __f2) |
| 1616 | 1617 | __e1 = __m2; |
| 1617 | 1618 | __f2 = __m2; |
| 1618 | base::__unlink_nodes(__f, __l); | |
| 1619 | __base::__unlink_nodes(__f, __l); | |
| 1619 | 1620 | __m2 = std::next(__f1); |
| 1620 | 1621 | __link_nodes(__f1.__ptr_, __f, __l); |
| 1621 | 1622 | __f1 = __m2; |
| ... | ... | @@ -1627,7 +1628,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ |
| 1627 | 1628 | |
| 1628 | 1629 | template <class _Tp, class _Alloc> |
| 1629 | 1630 | void list<_Tp, _Alloc>::reverse() _NOEXCEPT { |
| 1630 | if (base::__sz() > 1) { | |
| 1631 | if (this->__size_ > 1) { | |
| 1631 | 1632 | iterator __e = end(); |
| 1632 | 1633 | for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;) { |
| 1633 | 1634 | std::swap(__i.__ptr_->__prev_, __i.__ptr_->__next_); |
| ... | ... | @@ -1647,7 +1648,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const list<_Tp, _Alloc>& __x, const |
| 1647 | 1648 | return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); |
| 1648 | 1649 | } |
| 1649 | 1650 | |
| 1650 | #if _LIBCPP_STD_VER <= 17 | |
| 1651 | # if _LIBCPP_STD_VER <= 17 | |
| 1651 | 1652 | |
| 1652 | 1653 | template <class _Tp, class _Alloc> |
| 1653 | 1654 | inline _LIBCPP_HIDE_FROM_ABI bool operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) { |
| ... | ... | @@ -1674,16 +1675,15 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const list<_Tp, _Alloc>& __x, const |
| 1674 | 1675 | return !(__y < __x); |
| 1675 | 1676 | } |
| 1676 | 1677 | |
| 1677 | #else // _LIBCPP_STD_VER <= 17 | |
| 1678 | # else // _LIBCPP_STD_VER <= 17 | |
| 1678 | 1679 | |
| 1679 | 1680 | template <class _Tp, class _Allocator> |
| 1680 | 1681 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp> |
| 1681 | 1682 | operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) { |
| 1682 | return std::lexicographical_compare_three_way( | |
| 1683 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | |
| 1683 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | |
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | #endif // _LIBCPP_STD_VER <= 17 | |
| 1686 | # endif // _LIBCPP_STD_VER <= 17 | |
| 1687 | 1687 | |
| 1688 | 1688 | template <class _Tp, class _Alloc> |
| 1689 | 1689 | inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y) |
| ... | ... | @@ -1691,7 +1691,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc> |
| 1691 | 1691 | __x.swap(__y); |
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | #if _LIBCPP_STD_VER >= 20 | |
| 1694 | # if _LIBCPP_STD_VER >= 20 | |
| 1695 | 1695 | template <class _Tp, class _Allocator, class _Predicate> |
| 1696 | 1696 | inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type |
| 1697 | 1697 | erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) { |
| ... | ... | @@ -1706,38 +1706,50 @@ erase(list<_Tp, _Allocator>& __c, const _Up& __v) { |
| 1706 | 1706 | |
| 1707 | 1707 | template <> |
| 1708 | 1708 | inline constexpr bool __format::__enable_insertable<std::list<char>> = true; |
| 1709 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1709 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1710 | 1710 | template <> |
| 1711 | 1711 | inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true; |
| 1712 | # endif | |
| 1712 | # endif | |
| 1713 | 1713 | |
| 1714 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1714 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1715 | ||
| 1716 | template <class _Tp, class _Allocator> | |
| 1717 | struct __container_traits<list<_Tp, _Allocator> > { | |
| 1718 | // http://eel.is/c++draft/container.reqmts | |
| 1719 | // Unless otherwise specified (see [associative.reqmts.except], [unord.req.except], [deque.modifiers], | |
| 1720 | // [inplace.vector.modifiers], and [vector.modifiers]) all container types defined in this Clause meet the following | |
| 1721 | // additional requirements: | |
| 1722 | // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that | |
| 1723 | // function has no effects. | |
| 1724 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | |
| 1725 | }; | |
| 1715 | 1726 | |
| 1716 | 1727 | _LIBCPP_END_NAMESPACE_STD |
| 1717 | 1728 | |
| 1718 | #if _LIBCPP_STD_VER >= 17 | |
| 1729 | # if _LIBCPP_STD_VER >= 17 | |
| 1719 | 1730 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 1720 | 1731 | namespace pmr { |
| 1721 | 1732 | template <class _ValueT> |
| 1722 | 1733 | using list _LIBCPP_AVAILABILITY_PMR = std::list<_ValueT, polymorphic_allocator<_ValueT>>; |
| 1723 | 1734 | } // namespace pmr |
| 1724 | 1735 | _LIBCPP_END_NAMESPACE_STD |
| 1725 | #endif | |
| 1736 | # endif | |
| 1726 | 1737 | |
| 1727 | 1738 | _LIBCPP_POP_MACROS |
| 1728 | 1739 | |
| 1729 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1730 | # include <algorithm> | |
| 1731 | # include <atomic> | |
| 1732 | # include <concepts> | |
| 1733 | # include <cstdint> | |
| 1734 | # include <cstdlib> | |
| 1735 | # include <functional> | |
| 1736 | # include <iosfwd> | |
| 1737 | # include <iterator> | |
| 1738 | # include <stdexcept> | |
| 1739 | # include <type_traits> | |
| 1740 | # include <typeinfo> | |
| 1741 | #endif | |
| 1740 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1741 | # include <algorithm> | |
| 1742 | # include <atomic> | |
| 1743 | # include <concepts> | |
| 1744 | # include <cstdint> | |
| 1745 | # include <cstdlib> | |
| 1746 | # include <functional> | |
| 1747 | # include <iosfwd> | |
| 1748 | # include <iterator> | |
| 1749 | # include <stdexcept> | |
| 1750 | # include <type_traits> | |
| 1751 | # include <typeinfo> | |
| 1752 | # endif | |
| 1753 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1742 | 1754 | |
| 1743 | 1755 | #endif // _LIBCPP_LIST |
lib/libcxx/include/locale+179-240| ... | ... | @@ -187,74 +187,72 @@ template <class charT> class messages_byname; |
| 187 | 187 | |
| 188 | 188 | */ |
| 189 | 189 | |
| 190 | #include <__config> | |
| 191 | ||
| 192 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 193 | ||
| 194 | # include <__algorithm/copy.h> | |
| 195 | # include <__algorithm/equal.h> | |
| 196 | # include <__algorithm/find.h> | |
| 197 | # include <__algorithm/max.h> | |
| 198 | # include <__algorithm/reverse.h> | |
| 199 | # include <__algorithm/unwrap_iter.h> | |
| 200 | # include <__assert> | |
| 201 | # include <__iterator/access.h> | |
| 202 | # include <__iterator/back_insert_iterator.h> | |
| 203 | # include <__iterator/istreambuf_iterator.h> | |
| 204 | # include <__iterator/ostreambuf_iterator.h> | |
| 205 | # include <__locale> | |
| 206 | # include <__memory/unique_ptr.h> | |
| 207 | # include <__type_traits/make_unsigned.h> | |
| 208 | # include <cerrno> | |
| 209 | # include <cstdio> | |
| 210 | # include <cstdlib> | |
| 211 | # include <ctime> | |
| 212 | # include <ios> | |
| 213 | # include <limits> | |
| 214 | # include <new> | |
| 215 | # include <streambuf> | |
| 216 | # include <version> | |
| 217 | ||
| 218 | // TODO: Fix __bsd_locale_defaults.h | |
| 190 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 191 | # include <__cxx03/locale> | |
| 192 | #else | |
| 193 | # include <__config> | |
| 194 | ||
| 195 | # if _LIBCPP_HAS_LOCALIZATION | |
| 196 | ||
| 197 | # include <__algorithm/copy.h> | |
| 198 | # include <__algorithm/equal.h> | |
| 199 | # include <__algorithm/find.h> | |
| 200 | # include <__algorithm/max.h> | |
| 201 | # include <__algorithm/reverse.h> | |
| 202 | # include <__algorithm/unwrap_iter.h> | |
| 203 | # include <__assert> | |
| 204 | # include <__iterator/access.h> | |
| 205 | # include <__iterator/back_insert_iterator.h> | |
| 206 | # include <__iterator/istreambuf_iterator.h> | |
| 207 | # include <__iterator/ostreambuf_iterator.h> | |
| 208 | # include <__locale> | |
| 209 | # include <__locale_dir/pad_and_output.h> | |
| 210 | # include <__memory/unique_ptr.h> | |
| 211 | # include <__new/exceptions.h> | |
| 212 | # include <__type_traits/make_unsigned.h> | |
| 213 | # include <cerrno> | |
| 214 | # include <cstdio> | |
| 215 | # include <cstdlib> | |
| 216 | # include <ctime> | |
| 217 | # include <ios> | |
| 218 | # include <limits> | |
| 219 | # include <streambuf> | |
| 220 | # include <version> | |
| 221 | ||
| 222 | // TODO: Properly qualify calls now that the locale base API defines functions instead of macros | |
| 219 | 223 | // NOLINTBEGIN(libcpp-robust-against-adl) |
| 220 | 224 | |
| 221 | # if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) | |
| 225 | # if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) | |
| 222 | 226 | // Most unix variants have catopen. These are the specific ones that don't. |
| 223 | # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) | |
| 224 | # define _LIBCPP_HAS_CATOPEN 1 | |
| 225 | # include <nl_types.h> | |
| 227 | # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) | |
| 228 | # define _LIBCPP_HAS_CATOPEN 1 | |
| 229 | # include <nl_types.h> | |
| 230 | # else | |
| 231 | # define _LIBCPP_HAS_CATOPEN 0 | |
| 232 | # endif | |
| 233 | # else | |
| 234 | # define _LIBCPP_HAS_CATOPEN 0 | |
| 226 | 235 | # endif |
| 227 | # endif | |
| 228 | ||
| 229 | # ifdef _LIBCPP_LOCALE__L_EXTENSIONS | |
| 230 | # include <__locale_dir/locale_base_api/bsd_locale_defaults.h> | |
| 231 | # else | |
| 232 | # include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h> | |
| 233 | # endif | |
| 234 | ||
| 235 | # if defined(__APPLE__) || defined(__FreeBSD__) | |
| 236 | # include <xlocale.h> | |
| 237 | # endif | |
| 238 | 236 | |
| 239 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 240 | # pragma GCC system_header | |
| 241 | # endif | |
| 237 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 238 | # pragma GCC system_header | |
| 239 | # endif | |
| 242 | 240 | |
| 243 | 241 | _LIBCPP_PUSH_MACROS |
| 244 | # include <__undef_macros> | |
| 242 | # include <__undef_macros> | |
| 245 | 243 | |
| 246 | 244 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 247 | 245 | |
| 248 | # if defined(__APPLE__) || defined(__FreeBSD__) | |
| 249 | # define _LIBCPP_GET_C_LOCALE 0 | |
| 250 | # elif defined(__NetBSD__) | |
| 251 | # define _LIBCPP_GET_C_LOCALE LC_C_LOCALE | |
| 252 | # else | |
| 253 | # define _LIBCPP_GET_C_LOCALE __cloc() | |
| 246 | # if defined(__APPLE__) || defined(__FreeBSD__) | |
| 247 | # define _LIBCPP_GET_C_LOCALE 0 | |
| 248 | # elif defined(__NetBSD__) | |
| 249 | # define _LIBCPP_GET_C_LOCALE LC_C_LOCALE | |
| 250 | # else | |
| 251 | # define _LIBCPP_GET_C_LOCALE __cloc() | |
| 254 | 252 | // Get the C locale object |
| 255 | _LIBCPP_EXPORTED_FROM_ABI locale_t __cloc(); | |
| 256 | # define __cloc_defined | |
| 257 | # endif | |
| 253 | _LIBCPP_EXPORTED_FROM_ABI __locale::__locale_t __cloc(); | |
| 254 | # define __cloc_defined | |
| 255 | # endif | |
| 258 | 256 | |
| 259 | 257 | // __scan_keyword |
| 260 | 258 | // Scans [__b, __e) until a match is found in the basic_strings range |
| ... | ... | @@ -402,7 +400,7 @@ struct __num_get : protected __num_get_base { |
| 402 | 400 | unsigned*& __g_end, |
| 403 | 401 | unsigned& __dc, |
| 404 | 402 | _CharT* __atoms); |
| 405 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 403 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 406 | 404 | static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep); |
| 407 | 405 | static int __stage2_int_loop( |
| 408 | 406 | _CharT __ct, |
| ... | ... | @@ -416,7 +414,7 @@ struct __num_get : protected __num_get_base { |
| 416 | 414 | unsigned*& __g_end, |
| 417 | 415 | _CharT* __atoms); |
| 418 | 416 | |
| 419 | # else | |
| 417 | # else | |
| 420 | 418 | static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) { |
| 421 | 419 | locale __loc = __iob.getloc(); |
| 422 | 420 | const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); |
| ... | ... | @@ -451,10 +449,10 @@ private: |
| 451 | 449 | (void)__atoms; |
| 452 | 450 | return __src; |
| 453 | 451 | } |
| 454 | # endif | |
| 452 | # endif | |
| 455 | 453 | }; |
| 456 | 454 | |
| 457 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 455 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 458 | 456 | template <class _CharT> |
| 459 | 457 | string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) { |
| 460 | 458 | locale __loc = __iob.getloc(); |
| ... | ... | @@ -463,7 +461,7 @@ string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _C |
| 463 | 461 | __thousands_sep = __np.thousands_sep(); |
| 464 | 462 | return __np.grouping(); |
| 465 | 463 | } |
| 466 | # endif | |
| 464 | # endif | |
| 467 | 465 | |
| 468 | 466 | template <class _CharT> |
| 469 | 467 | string __num_get<_CharT>::__stage2_float_prep( |
| ... | ... | @@ -478,16 +476,16 @@ string __num_get<_CharT>::__stage2_float_prep( |
| 478 | 476 | |
| 479 | 477 | template <class _CharT> |
| 480 | 478 | int |
| 481 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 479 | # ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 482 | 480 | __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, |
| 483 | 481 | unsigned& __dc, _CharT __thousands_sep, const string& __grouping, |
| 484 | 482 | unsigned* __g, unsigned*& __g_end, _CharT* __atoms) |
| 485 | # else | |
| 483 | # else | |
| 486 | 484 | __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end, |
| 487 | 485 | unsigned& __dc, _CharT __thousands_sep, const string& __grouping, |
| 488 | 486 | unsigned* __g, unsigned*& __g_end, const _CharT* __atoms) |
| 489 | 487 | |
| 490 | # endif | |
| 488 | # endif | |
| 491 | 489 | { |
| 492 | 490 | if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) { |
| 493 | 491 | *__a_end++ = __ct == __atoms[24] ? '+' : '-'; |
| ... | ... | @@ -586,9 +584,9 @@ int __num_get<_CharT>::__stage2_float_loop( |
| 586 | 584 | } |
| 587 | 585 | |
| 588 | 586 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>; |
| 589 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 587 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 590 | 588 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>; |
| 591 | # endif | |
| 589 | # endif | |
| 592 | 590 | |
| 593 | 591 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 594 | 592 | class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> { |
| ... | ... | @@ -727,7 +725,7 @@ __num_get_signed_integral(const char* __a, const char* __a_end, ios_base::iostat |
| 727 | 725 | __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno; |
| 728 | 726 | errno = 0; |
| 729 | 727 | char* __p2; |
| 730 | long long __ll = strtoll_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); | |
| 728 | long long __ll = __locale::__strtoll(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); | |
| 731 | 729 | __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno; |
| 732 | 730 | if (__current_errno == 0) |
| 733 | 731 | errno = __save_errno; |
| ... | ... | @@ -759,7 +757,7 @@ __num_get_unsigned_integral(const char* __a, const char* __a_end, ios_base::iost |
| 759 | 757 | __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno; |
| 760 | 758 | errno = 0; |
| 761 | 759 | char* __p2; |
| 762 | unsigned long long __ll = strtoull_l(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); | |
| 760 | unsigned long long __ll = __locale::__strtoull(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE); | |
| 763 | 761 | __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno; |
| 764 | 762 | if (__current_errno == 0) |
| 765 | 763 | errno = __save_errno; |
| ... | ... | @@ -784,17 +782,17 @@ _LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2); |
| 784 | 782 | |
| 785 | 783 | template <> |
| 786 | 784 | inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) { |
| 787 | return strtof_l(__a, __p2, _LIBCPP_GET_C_LOCALE); | |
| 785 | return __locale::__strtof(__a, __p2, _LIBCPP_GET_C_LOCALE); | |
| 788 | 786 | } |
| 789 | 787 | |
| 790 | 788 | template <> |
| 791 | 789 | inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) { |
| 792 | return strtod_l(__a, __p2, _LIBCPP_GET_C_LOCALE); | |
| 790 | return __locale::__strtod(__a, __p2, _LIBCPP_GET_C_LOCALE); | |
| 793 | 791 | } |
| 794 | 792 | |
| 795 | 793 | template <> |
| 796 | 794 | inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) { |
| 797 | return strtold_l(__a, __p2, _LIBCPP_GET_C_LOCALE); | |
| 795 | return __locale::__strtold(__a, __p2, _LIBCPP_GET_C_LOCALE); | |
| 798 | 796 | } |
| 799 | 797 | |
| 800 | 798 | template <class _Tp> |
| ... | ... | @@ -858,14 +856,14 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_signed( |
| 858 | 856 | // Stage 2 |
| 859 | 857 | char_type __thousands_sep; |
| 860 | 858 | const int __atoms_size = __num_get_base::__int_chr_cnt; |
| 861 | # ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 859 | # ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 862 | 860 | char_type __atoms1[__atoms_size]; |
| 863 | 861 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); |
| 864 | 862 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); |
| 865 | # else | |
| 863 | # else | |
| 866 | 864 | char_type __atoms[__atoms_size]; |
| 867 | 865 | string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); |
| 868 | # endif | |
| 866 | # endif | |
| 869 | 867 | string __buf; |
| 870 | 868 | __buf.resize(__buf.capacity()); |
| 871 | 869 | char* __a = &__buf[0]; |
| ... | ... | @@ -907,14 +905,14 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned( |
| 907 | 905 | // Stage 2 |
| 908 | 906 | char_type __thousands_sep; |
| 909 | 907 | const int __atoms_size = __num_get_base::__int_chr_cnt; |
| 910 | # ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 908 | # ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 911 | 909 | char_type __atoms1[__atoms_size]; |
| 912 | 910 | const char_type* __atoms = this->__do_widen(__iob, __atoms1); |
| 913 | 911 | string __grouping = this->__stage2_int_prep(__iob, __thousands_sep); |
| 914 | # else | |
| 912 | # else | |
| 915 | 913 | char_type __atoms[__atoms_size]; |
| 916 | 914 | string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); |
| 917 | # endif | |
| 915 | # endif | |
| 918 | 916 | string __buf; |
| 919 | 917 | __buf.resize(__buf.capacity()); |
| 920 | 918 | char* __a = &__buf[0]; |
| ... | ... | @@ -1048,7 +1046,7 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get( |
| 1048 | 1046 | } |
| 1049 | 1047 | // Stage 3 |
| 1050 | 1048 | __buf.resize(__a_end - __a); |
| 1051 | if (__libcpp_sscanf_l(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1) | |
| 1049 | if (__locale::__sscanf(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1) | |
| 1052 | 1050 | __err = ios_base::failbit; |
| 1053 | 1051 | // EOF checked |
| 1054 | 1052 | if (__b == __e) |
| ... | ... | @@ -1057,9 +1055,9 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get( |
| 1057 | 1055 | } |
| 1058 | 1056 | |
| 1059 | 1057 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>; |
| 1060 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1058 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1061 | 1059 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>; |
| 1062 | # endif | |
| 1060 | # endif | |
| 1063 | 1061 | |
| 1064 | 1062 | struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base { |
| 1065 | 1063 | protected: |
| ... | ... | @@ -1131,11 +1129,11 @@ void __num_put<_CharT>::__widen_and_group_float( |
| 1131 | 1129 | *__oe++ = __ct.widen(*__nf++); |
| 1132 | 1130 | *__oe++ = __ct.widen(*__nf++); |
| 1133 | 1131 | for (__ns = __nf; __ns < __ne; ++__ns) |
| 1134 | if (!isxdigit_l(*__ns, _LIBCPP_GET_C_LOCALE)) | |
| 1132 | if (!__locale::__isxdigit(*__ns, _LIBCPP_GET_C_LOCALE)) | |
| 1135 | 1133 | break; |
| 1136 | 1134 | } else { |
| 1137 | 1135 | for (__ns = __nf; __ns < __ne; ++__ns) |
| 1138 | if (!isdigit_l(*__ns, _LIBCPP_GET_C_LOCALE)) | |
| 1136 | if (!__locale::__isdigit(*__ns, _LIBCPP_GET_C_LOCALE)) | |
| 1139 | 1137 | break; |
| 1140 | 1138 | } |
| 1141 | 1139 | if (__grouping.empty()) { |
| ... | ... | @@ -1175,9 +1173,9 @@ void __num_put<_CharT>::__widen_and_group_float( |
| 1175 | 1173 | } |
| 1176 | 1174 | |
| 1177 | 1175 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>; |
| 1178 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1176 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1179 | 1177 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>; |
| 1180 | # endif | |
| 1178 | # endif | |
| 1181 | 1179 | |
| 1182 | 1180 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| 1183 | 1181 | class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> { |
| ... | ... | @@ -1245,66 +1243,6 @@ protected: |
| 1245 | 1243 | template <class _CharT, class _OutputIterator> |
| 1246 | 1244 | locale::id num_put<_CharT, _OutputIterator>::id; |
| 1247 | 1245 | |
| 1248 | template <class _CharT, class _OutputIterator> | |
| 1249 | _LIBCPP_HIDE_FROM_ABI _OutputIterator __pad_and_output( | |
| 1250 | _OutputIterator __s, const _CharT* __ob, const _CharT* __op, const _CharT* __oe, ios_base& __iob, _CharT __fl) { | |
| 1251 | streamsize __sz = __oe - __ob; | |
| 1252 | streamsize __ns = __iob.width(); | |
| 1253 | if (__ns > __sz) | |
| 1254 | __ns -= __sz; | |
| 1255 | else | |
| 1256 | __ns = 0; | |
| 1257 | for (; __ob < __op; ++__ob, ++__s) | |
| 1258 | *__s = *__ob; | |
| 1259 | for (; __ns; --__ns, ++__s) | |
| 1260 | *__s = __fl; | |
| 1261 | for (; __ob < __oe; ++__ob, ++__s) | |
| 1262 | *__s = *__ob; | |
| 1263 | __iob.width(0); | |
| 1264 | return __s; | |
| 1265 | } | |
| 1266 | ||
| 1267 | template <class _CharT, class _Traits> | |
| 1268 | _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_CharT, _Traits> __pad_and_output( | |
| 1269 | ostreambuf_iterator<_CharT, _Traits> __s, | |
| 1270 | const _CharT* __ob, | |
| 1271 | const _CharT* __op, | |
| 1272 | const _CharT* __oe, | |
| 1273 | ios_base& __iob, | |
| 1274 | _CharT __fl) { | |
| 1275 | if (__s.__sbuf_ == nullptr) | |
| 1276 | return __s; | |
| 1277 | streamsize __sz = __oe - __ob; | |
| 1278 | streamsize __ns = __iob.width(); | |
| 1279 | if (__ns > __sz) | |
| 1280 | __ns -= __sz; | |
| 1281 | else | |
| 1282 | __ns = 0; | |
| 1283 | streamsize __np = __op - __ob; | |
| 1284 | if (__np > 0) { | |
| 1285 | if (__s.__sbuf_->sputn(__ob, __np) != __np) { | |
| 1286 | __s.__sbuf_ = nullptr; | |
| 1287 | return __s; | |
| 1288 | } | |
| 1289 | } | |
| 1290 | if (__ns > 0) { | |
| 1291 | basic_string<_CharT, _Traits> __sp(__ns, __fl); | |
| 1292 | if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns) { | |
| 1293 | __s.__sbuf_ = nullptr; | |
| 1294 | return __s; | |
| 1295 | } | |
| 1296 | } | |
| 1297 | __np = __oe - __op; | |
| 1298 | if (__np > 0) { | |
| 1299 | if (__s.__sbuf_->sputn(__op, __np) != __np) { | |
| 1300 | __s.__sbuf_ = nullptr; | |
| 1301 | return __s; | |
| 1302 | } | |
| 1303 | } | |
| 1304 | __iob.width(0); | |
| 1305 | return __s; | |
| 1306 | } | |
| 1307 | ||
| 1308 | 1246 | template <class _CharT, class _OutputIterator> |
| 1309 | 1247 | _OutputIterator |
| 1310 | 1248 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const { |
| ... | ... | @@ -1336,7 +1274,7 @@ _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::_ |
| 1336 | 1274 | _LIBCPP_DIAGNOSTIC_PUSH |
| 1337 | 1275 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") |
| 1338 | 1276 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") |
| 1339 | int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1277 | int __nc = __locale::__snprintf(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1340 | 1278 | _LIBCPP_DIAGNOSTIC_POP |
| 1341 | 1279 | char* __ne = __nar + __nc; |
| 1342 | 1280 | char* __np = this->__identify_padding(__nar, __ne, __iob); |
| ... | ... | @@ -1389,15 +1327,15 @@ _LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::_ |
| 1389 | 1327 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") |
| 1390 | 1328 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") |
| 1391 | 1329 | if (__specify_precision) |
| 1392 | __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); | |
| 1330 | __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); | |
| 1393 | 1331 | else |
| 1394 | __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1332 | __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1395 | 1333 | unique_ptr<char, void (*)(void*)> __nbh(nullptr, free); |
| 1396 | 1334 | if (__nc > static_cast<int>(__nbuf - 1)) { |
| 1397 | 1335 | if (__specify_precision) |
| 1398 | __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); | |
| 1336 | __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); | |
| 1399 | 1337 | else |
| 1400 | __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1338 | __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1401 | 1339 | if (__nc == -1) |
| 1402 | 1340 | __throw_bad_alloc(); |
| 1403 | 1341 | __nbh.reset(__nb); |
| ... | ... | @@ -1442,7 +1380,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty |
| 1442 | 1380 | // Stage 1 - Get pointer in narrow char |
| 1443 | 1381 | const unsigned __nbuf = 20; |
| 1444 | 1382 | char __nar[__nbuf]; |
| 1445 | int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, "%p", __v); | |
| 1383 | int __nc = __locale::__snprintf(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, "%p", __v); | |
| 1446 | 1384 | char* __ne = __nar + __nc; |
| 1447 | 1385 | char* __np = this->__identify_padding(__nar, __ne, __iob); |
| 1448 | 1386 | // Stage 2 - Widen __nar |
| ... | ... | @@ -1462,9 +1400,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty |
| 1462 | 1400 | } |
| 1463 | 1401 | |
| 1464 | 1402 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>; |
| 1465 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1403 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1466 | 1404 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>; |
| 1467 | # endif | |
| 1405 | # endif | |
| 1468 | 1406 | |
| 1469 | 1407 | template <class _CharT, class _InputIterator> |
| 1470 | 1408 | _LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits( |
| ... | ... | @@ -1529,7 +1467,7 @@ _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const; |
| 1529 | 1467 | template <> |
| 1530 | 1468 | _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const; |
| 1531 | 1469 | |
| 1532 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1470 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1533 | 1471 | template <> |
| 1534 | 1472 | _LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const; |
| 1535 | 1473 | template <> |
| ... | ... | @@ -1544,7 +1482,7 @@ template <> |
| 1544 | 1482 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const; |
| 1545 | 1483 | template <> |
| 1546 | 1484 | _LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const; |
| 1547 | # endif | |
| 1485 | # endif | |
| 1548 | 1486 | |
| 1549 | 1487 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 1550 | 1488 | class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> { |
| ... | ... | @@ -1998,13 +1936,13 @@ _InputIterator time_get<_CharT, _InputIterator>::do_get( |
| 1998 | 1936 | } |
| 1999 | 1937 | |
| 2000 | 1938 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>; |
| 2001 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1939 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2002 | 1940 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>; |
| 2003 | # endif | |
| 1941 | # endif | |
| 2004 | 1942 | |
| 2005 | 1943 | class _LIBCPP_EXPORTED_FROM_ABI __time_get { |
| 2006 | 1944 | protected: |
| 2007 | locale_t __loc_; | |
| 1945 | __locale::__locale_t __loc_; | |
| 2008 | 1946 | |
| 2009 | 1947 | __time_get(const char* __nm); |
| 2010 | 1948 | __time_get(const string& __nm); |
| ... | ... | @@ -2036,32 +1974,32 @@ private: |
| 2036 | 1974 | string_type __analyze(char __fmt, const ctype<_CharT>&); |
| 2037 | 1975 | }; |
| 2038 | 1976 | |
| 2039 | # define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \ | |
| 2040 | template <> \ | |
| 2041 | _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ | |
| 2042 | template <> \ | |
| 2043 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | |
| 2044 | template <> \ | |
| 2045 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | |
| 2046 | template <> \ | |
| 2047 | _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | |
| 2048 | template <> \ | |
| 2049 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ | |
| 2050 | char, const ctype<_CharT>&); \ | |
| 2051 | extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \ | |
| 2052 | const; \ | |
| 2053 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | |
| 2054 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | |
| 2055 | extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | |
| 2056 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ | |
| 2057 | __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \ | |
| 2058 | /**/ | |
| 1977 | # define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \ | |
| 1978 | template <> \ | |
| 1979 | _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \ | |
| 1980 | template <> \ | |
| 1981 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | |
| 1982 | template <> \ | |
| 1983 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | |
| 1984 | template <> \ | |
| 1985 | _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | |
| 1986 | template <> \ | |
| 1987 | _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \ | |
| 1988 | char, const ctype<_CharT>&); \ | |
| 1989 | extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \ | |
| 1990 | const; \ | |
| 1991 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \ | |
| 1992 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \ | |
| 1993 | extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \ | |
| 1994 | extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \ | |
| 1995 | __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \ | |
| 1996 | /**/ | |
| 2059 | 1997 | |
| 2060 | 1998 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char) |
| 2061 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1999 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2062 | 2000 | _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t) |
| 2063 | # endif | |
| 2064 | # undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION | |
| 2001 | # endif | |
| 2002 | # undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION | |
| 2065 | 2003 | |
| 2066 | 2004 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 2067 | 2005 | class _LIBCPP_TEMPLATE_VIS time_get_byname |
| ... | ... | @@ -2094,12 +2032,12 @@ private: |
| 2094 | 2032 | }; |
| 2095 | 2033 | |
| 2096 | 2034 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>; |
| 2097 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2035 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2098 | 2036 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>; |
| 2099 | # endif | |
| 2037 | # endif | |
| 2100 | 2038 | |
| 2101 | 2039 | class _LIBCPP_EXPORTED_FROM_ABI __time_put { |
| 2102 | locale_t __loc_; | |
| 2040 | __locale::__locale_t __loc_; | |
| 2103 | 2041 | |
| 2104 | 2042 | protected: |
| 2105 | 2043 | _LIBCPP_HIDE_FROM_ABI __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {} |
| ... | ... | @@ -2107,9 +2045,9 @@ protected: |
| 2107 | 2045 | __time_put(const string& __nm); |
| 2108 | 2046 | ~__time_put(); |
| 2109 | 2047 | void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const; |
| 2110 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2048 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2111 | 2049 | void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const; |
| 2112 | # endif | |
| 2050 | # endif | |
| 2113 | 2051 | }; |
| 2114 | 2052 | |
| 2115 | 2053 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| ... | ... | @@ -2183,9 +2121,9 @@ _OutputIterator time_put<_CharT, _OutputIterator>::do_put( |
| 2183 | 2121 | } |
| 2184 | 2122 | |
| 2185 | 2123 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>; |
| 2186 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2124 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2187 | 2125 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>; |
| 2188 | # endif | |
| 2126 | # endif | |
| 2189 | 2127 | |
| 2190 | 2128 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| 2191 | 2129 | class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> { |
| ... | ... | @@ -2201,9 +2139,9 @@ protected: |
| 2201 | 2139 | }; |
| 2202 | 2140 | |
| 2203 | 2141 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>; |
| 2204 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2142 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2205 | 2143 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>; |
| 2206 | # endif | |
| 2144 | # endif | |
| 2207 | 2145 | |
| 2208 | 2146 | // money_base |
| 2209 | 2147 | |
| ... | ... | @@ -2268,10 +2206,10 @@ const bool moneypunct<_CharT, _International>::intl; |
| 2268 | 2206 | |
| 2269 | 2207 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>; |
| 2270 | 2208 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>; |
| 2271 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2209 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2272 | 2210 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>; |
| 2273 | 2211 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>; |
| 2274 | # endif | |
| 2212 | # endif | |
| 2275 | 2213 | |
| 2276 | 2214 | // moneypunct_byname |
| 2277 | 2215 | |
| ... | ... | @@ -2326,14 +2264,14 @@ _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*); |
| 2326 | 2264 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>; |
| 2327 | 2265 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>; |
| 2328 | 2266 | |
| 2329 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2267 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2330 | 2268 | template <> |
| 2331 | 2269 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*); |
| 2332 | 2270 | template <> |
| 2333 | 2271 | _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*); |
| 2334 | 2272 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>; |
| 2335 | 2273 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>; |
| 2336 | # endif | |
| 2274 | # endif | |
| 2337 | 2275 | |
| 2338 | 2276 | // money_get |
| 2339 | 2277 | |
| ... | ... | @@ -2394,9 +2332,9 @@ void __money_get<_CharT>::__gather_info( |
| 2394 | 2332 | } |
| 2395 | 2333 | |
| 2396 | 2334 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>; |
| 2397 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2335 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2398 | 2336 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>; |
| 2399 | # endif | |
| 2337 | # endif | |
| 2400 | 2338 | |
| 2401 | 2339 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 2402 | 2340 | class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> { |
| ... | ... | @@ -2704,9 +2642,9 @@ _InputIterator money_get<_CharT, _InputIterator>::do_get( |
| 2704 | 2642 | } |
| 2705 | 2643 | |
| 2706 | 2644 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>; |
| 2707 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2645 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2708 | 2646 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>; |
| 2709 | # endif | |
| 2647 | # endif | |
| 2710 | 2648 | |
| 2711 | 2649 | // money_put |
| 2712 | 2650 | |
| ... | ... | @@ -2882,9 +2820,9 @@ void __money_put<_CharT>::__format( |
| 2882 | 2820 | } |
| 2883 | 2821 | |
| 2884 | 2822 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>; |
| 2885 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2823 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2886 | 2824 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>; |
| 2887 | # endif | |
| 2825 | # endif | |
| 2888 | 2826 | |
| 2889 | 2827 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| 2890 | 2828 | class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> { |
| ... | ... | @@ -2932,7 +2870,7 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put( |
| 2932 | 2870 | unique_ptr<char_type, void (*)(void*)> __hd(0, free); |
| 2933 | 2871 | // secure memory for digit storage |
| 2934 | 2872 | if (static_cast<size_t>(__n) > __bs - 1) { |
| 2935 | __n = __libcpp_asprintf_l(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units); | |
| 2873 | __n = __locale::__asprintf(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units); | |
| 2936 | 2874 | if (__n == -1) |
| 2937 | 2875 | __throw_bad_alloc(); |
| 2938 | 2876 | __hn.reset(__bb); |
| ... | ... | @@ -3028,9 +2966,9 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put( |
| 3028 | 2966 | } |
| 3029 | 2967 | |
| 3030 | 2968 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>; |
| 3031 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2969 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3032 | 2970 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>; |
| 3033 | # endif | |
| 2971 | # endif | |
| 3034 | 2972 | |
| 3035 | 2973 | // messages |
| 3036 | 2974 | |
| ... | ... | @@ -3074,18 +3012,18 @@ locale::id messages<_CharT>::id; |
| 3074 | 3012 | |
| 3075 | 3013 | template <class _CharT> |
| 3076 | 3014 | typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const { |
| 3077 | # ifdef _LIBCPP_HAS_CATOPEN | |
| 3015 | # if _LIBCPP_HAS_CATOPEN | |
| 3078 | 3016 | return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); |
| 3079 | # else // !_LIBCPP_HAS_CATOPEN | |
| 3017 | # else // !_LIBCPP_HAS_CATOPEN | |
| 3080 | 3018 | (void)__nm; |
| 3081 | 3019 | return -1; |
| 3082 | # endif // _LIBCPP_HAS_CATOPEN | |
| 3020 | # endif // _LIBCPP_HAS_CATOPEN | |
| 3083 | 3021 | } |
| 3084 | 3022 | |
| 3085 | 3023 | template <class _CharT> |
| 3086 | 3024 | typename messages<_CharT>::string_type |
| 3087 | 3025 | messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { |
| 3088 | # ifdef _LIBCPP_HAS_CATOPEN | |
| 3026 | # if _LIBCPP_HAS_CATOPEN | |
| 3089 | 3027 | string __ndflt; |
| 3090 | 3028 | __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()( |
| 3091 | 3029 | std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); |
| ... | ... | @@ -3095,27 +3033,27 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& |
| 3095 | 3033 | string_type __w; |
| 3096 | 3034 | __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n)); |
| 3097 | 3035 | return __w; |
| 3098 | # else // !_LIBCPP_HAS_CATOPEN | |
| 3036 | # else // !_LIBCPP_HAS_CATOPEN | |
| 3099 | 3037 | (void)__c; |
| 3100 | 3038 | (void)__set; |
| 3101 | 3039 | (void)__msgid; |
| 3102 | 3040 | return __dflt; |
| 3103 | # endif // _LIBCPP_HAS_CATOPEN | |
| 3041 | # endif // _LIBCPP_HAS_CATOPEN | |
| 3104 | 3042 | } |
| 3105 | 3043 | |
| 3106 | 3044 | template <class _CharT> |
| 3107 | 3045 | void messages<_CharT>::do_close(catalog __c) const { |
| 3108 | # ifdef _LIBCPP_HAS_CATOPEN | |
| 3046 | # if _LIBCPP_HAS_CATOPEN | |
| 3109 | 3047 | catclose((nl_catd)__c); |
| 3110 | # else // !_LIBCPP_HAS_CATOPEN | |
| 3048 | # else // !_LIBCPP_HAS_CATOPEN | |
| 3111 | 3049 | (void)__c; |
| 3112 | # endif // _LIBCPP_HAS_CATOPEN | |
| 3050 | # endif // _LIBCPP_HAS_CATOPEN | |
| 3113 | 3051 | } |
| 3114 | 3052 | |
| 3115 | 3053 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>; |
| 3116 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3054 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3117 | 3055 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>; |
| 3118 | # endif | |
| 3056 | # endif | |
| 3119 | 3057 | |
| 3120 | 3058 | template <class _CharT> |
| 3121 | 3059 | class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> { |
| ... | ... | @@ -3132,11 +3070,11 @@ protected: |
| 3132 | 3070 | }; |
| 3133 | 3071 | |
| 3134 | 3072 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>; |
| 3135 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3073 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3136 | 3074 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>; |
| 3137 | # endif | |
| 3075 | # endif | |
| 3138 | 3076 | |
| 3139 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | |
| 3077 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | |
| 3140 | 3078 | |
| 3141 | 3079 | template <class _Codecvt, |
| 3142 | 3080 | class _Elem = wchar_t, |
| ... | ... | @@ -3157,19 +3095,19 @@ private: |
| 3157 | 3095 | size_t __cvtcount_; |
| 3158 | 3096 | |
| 3159 | 3097 | public: |
| 3160 | # ifndef _LIBCPP_CXX03_LANG | |
| 3098 | # ifndef _LIBCPP_CXX03_LANG | |
| 3161 | 3099 | _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {} |
| 3162 | 3100 | _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt); |
| 3163 | # else | |
| 3101 | # else | |
| 3164 | 3102 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt); |
| 3165 | # endif | |
| 3103 | # endif | |
| 3166 | 3104 | |
| 3167 | 3105 | _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state); |
| 3168 | 3106 | _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI |
| 3169 | 3107 | wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); |
| 3170 | # ifndef _LIBCPP_CXX03_LANG | |
| 3108 | # ifndef _LIBCPP_CXX03_LANG | |
| 3171 | 3109 | _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc); |
| 3172 | # endif | |
| 3110 | # endif | |
| 3173 | 3111 | _LIBCPP_HIDE_FROM_ABI ~wstring_convert(); |
| 3174 | 3112 | |
| 3175 | 3113 | wstring_convert(const wstring_convert& __wc) = delete; |
| ... | ... | @@ -3214,7 +3152,7 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert( |
| 3214 | 3152 | __cvtptr_ = new _Codecvt; |
| 3215 | 3153 | } |
| 3216 | 3154 | |
| 3217 | # ifndef _LIBCPP_CXX03_LANG | |
| 3155 | # ifndef _LIBCPP_CXX03_LANG | |
| 3218 | 3156 | |
| 3219 | 3157 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> |
| 3220 | 3158 | inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc) |
| ... | ... | @@ -3226,7 +3164,7 @@ inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert |
| 3226 | 3164 | __wc.__cvtptr_ = nullptr; |
| 3227 | 3165 | } |
| 3228 | 3166 | |
| 3229 | # endif // _LIBCPP_CXX03_LANG | |
| 3167 | # endif // _LIBCPP_CXX03_LANG | |
| 3230 | 3168 | |
| 3231 | 3169 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 3232 | 3170 | template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc> |
| ... | ... | @@ -3380,14 +3318,14 @@ private: |
| 3380 | 3318 | bool __always_noconv_; |
| 3381 | 3319 | |
| 3382 | 3320 | public: |
| 3383 | # ifndef _LIBCPP_CXX03_LANG | |
| 3321 | # ifndef _LIBCPP_CXX03_LANG | |
| 3384 | 3322 | _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {} |
| 3385 | 3323 | explicit _LIBCPP_HIDE_FROM_ABI |
| 3386 | 3324 | wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); |
| 3387 | # else | |
| 3325 | # else | |
| 3388 | 3326 | _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI |
| 3389 | 3327 | wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); |
| 3390 | # endif | |
| 3328 | # endif | |
| 3391 | 3329 | |
| 3392 | 3330 | _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert(); |
| 3393 | 3331 | |
| ... | ... | @@ -3743,7 +3681,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__ |
| 3743 | 3681 | |
| 3744 | 3682 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 3745 | 3683 | |
| 3746 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | |
| 3684 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT) | |
| 3747 | 3685 | |
| 3748 | 3686 | _LIBCPP_END_NAMESPACE_STD |
| 3749 | 3687 | |
| ... | ... | @@ -3751,17 +3689,18 @@ _LIBCPP_POP_MACROS |
| 3751 | 3689 | |
| 3752 | 3690 | // NOLINTEND(libcpp-robust-against-adl) |
| 3753 | 3691 | |
| 3754 | #endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 3755 | ||
| 3756 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 3757 | # include <atomic> | |
| 3758 | # include <concepts> | |
| 3759 | # include <cstdarg> | |
| 3760 | # include <iterator> | |
| 3761 | # include <mutex> | |
| 3762 | # include <stdexcept> | |
| 3763 | # include <type_traits> | |
| 3764 | # include <typeinfo> | |
| 3765 | #endif | |
| 3692 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 3693 | ||
| 3694 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 3695 | # include <atomic> | |
| 3696 | # include <concepts> | |
| 3697 | # include <cstdarg> | |
| 3698 | # include <iterator> | |
| 3699 | # include <mutex> | |
| 3700 | # include <stdexcept> | |
| 3701 | # include <type_traits> | |
| 3702 | # include <typeinfo> | |
| 3703 | # endif | |
| 3704 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 3766 | 3705 | |
| 3767 | 3706 | #endif // _LIBCPP_LOCALE |
lib/libcxx/include/locale.h deleted-46| ... | ... | @@ -1,46 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_LOCALE_H | |
| 11 | #define _LIBCPP_LOCALE_H | |
| 12 | ||
| 13 | /* | |
| 14 | locale.h synopsis | |
| 15 | ||
| 16 | Macros: | |
| 17 | ||
| 18 | LC_ALL | |
| 19 | LC_COLLATE | |
| 20 | LC_CTYPE | |
| 21 | LC_MONETARY | |
| 22 | LC_NUMERIC | |
| 23 | LC_TIME | |
| 24 | ||
| 25 | Types: | |
| 26 | ||
| 27 | lconv | |
| 28 | ||
| 29 | Functions: | |
| 30 | ||
| 31 | setlocale | |
| 32 | localeconv | |
| 33 | ||
| 34 | */ | |
| 35 | ||
| 36 | #include <__config> | |
| 37 | ||
| 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 39 | # pragma GCC system_header | |
| 40 | #endif | |
| 41 | ||
| 42 | #if __has_include_next(<locale.h>) | |
| 43 | # include_next <locale.h> | |
| 44 | #endif | |
| 45 | ||
| 46 | #endif // _LIBCPP_LOCALE_H |
lib/libcxx/include/map+194-166| ... | ... | @@ -571,53 +571,64 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 |
| 571 | 571 | |
| 572 | 572 | */ |
| 573 | 573 | |
| 574 | #include <__algorithm/equal.h> | |
| 575 | #include <__algorithm/lexicographical_compare.h> | |
| 576 | #include <__algorithm/lexicographical_compare_three_way.h> | |
| 577 | #include <__assert> | |
| 578 | #include <__config> | |
| 579 | #include <__functional/binary_function.h> | |
| 580 | #include <__functional/is_transparent.h> | |
| 581 | #include <__functional/operations.h> | |
| 582 | #include <__iterator/erase_if_container.h> | |
| 583 | #include <__iterator/iterator_traits.h> | |
| 584 | #include <__iterator/ranges_iterator_traits.h> | |
| 585 | #include <__iterator/reverse_iterator.h> | |
| 586 | #include <__memory/addressof.h> | |
| 587 | #include <__memory/allocator.h> | |
| 588 | #include <__memory_resource/polymorphic_allocator.h> | |
| 589 | #include <__node_handle> | |
| 590 | #include <__ranges/concepts.h> | |
| 591 | #include <__ranges/container_compatible_range.h> | |
| 592 | #include <__ranges/from_range.h> | |
| 593 | #include <__tree> | |
| 594 | #include <__type_traits/is_allocator.h> | |
| 595 | #include <__utility/forward.h> | |
| 596 | #include <__utility/piecewise_construct.h> | |
| 597 | #include <__utility/swap.h> | |
| 598 | #include <stdexcept> | |
| 599 | #include <tuple> | |
| 600 | #include <version> | |
| 574 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 575 | # include <__cxx03/map> | |
| 576 | #else | |
| 577 | # include <__algorithm/equal.h> | |
| 578 | # include <__algorithm/lexicographical_compare.h> | |
| 579 | # include <__algorithm/lexicographical_compare_three_way.h> | |
| 580 | # include <__assert> | |
| 581 | # include <__config> | |
| 582 | # include <__functional/binary_function.h> | |
| 583 | # include <__functional/is_transparent.h> | |
| 584 | # include <__functional/operations.h> | |
| 585 | # include <__iterator/erase_if_container.h> | |
| 586 | # include <__iterator/iterator_traits.h> | |
| 587 | # include <__iterator/ranges_iterator_traits.h> | |
| 588 | # include <__iterator/reverse_iterator.h> | |
| 589 | # include <__memory/addressof.h> | |
| 590 | # include <__memory/allocator.h> | |
| 591 | # include <__memory/allocator_traits.h> | |
| 592 | # include <__memory/pointer_traits.h> | |
| 593 | # include <__memory/unique_ptr.h> | |
| 594 | # include <__memory_resource/polymorphic_allocator.h> | |
| 595 | # include <__new/launder.h> | |
| 596 | # include <__node_handle> | |
| 597 | # include <__ranges/concepts.h> | |
| 598 | # include <__ranges/container_compatible_range.h> | |
| 599 | # include <__ranges/from_range.h> | |
| 600 | # include <__tree> | |
| 601 | # include <__type_traits/container_traits.h> | |
| 602 | # include <__type_traits/is_allocator.h> | |
| 603 | # include <__type_traits/remove_const.h> | |
| 604 | # include <__type_traits/type_identity.h> | |
| 605 | # include <__utility/forward.h> | |
| 606 | # include <__utility/pair.h> | |
| 607 | # include <__utility/piecewise_construct.h> | |
| 608 | # include <__utility/swap.h> | |
| 609 | # include <stdexcept> | |
| 610 | # include <tuple> | |
| 611 | # include <version> | |
| 601 | 612 | |
| 602 | 613 | // standard-mandated includes |
| 603 | 614 | |
| 604 | 615 | // [iterator.range] |
| 605 | #include <__iterator/access.h> | |
| 606 | #include <__iterator/data.h> | |
| 607 | #include <__iterator/empty.h> | |
| 608 | #include <__iterator/reverse_access.h> | |
| 609 | #include <__iterator/size.h> | |
| 616 | # include <__iterator/access.h> | |
| 617 | # include <__iterator/data.h> | |
| 618 | # include <__iterator/empty.h> | |
| 619 | # include <__iterator/reverse_access.h> | |
| 620 | # include <__iterator/size.h> | |
| 610 | 621 | |
| 611 | 622 | // [associative.map.syn] |
| 612 | #include <compare> | |
| 613 | #include <initializer_list> | |
| 623 | # include <compare> | |
| 624 | # include <initializer_list> | |
| 614 | 625 | |
| 615 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 616 | # pragma GCC system_header | |
| 617 | #endif | |
| 626 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 627 | # pragma GCC system_header | |
| 628 | # endif | |
| 618 | 629 | |
| 619 | 630 | _LIBCPP_PUSH_MACROS |
| 620 | #include <__undef_macros> | |
| 631 | # include <__undef_macros> | |
| 621 | 632 | |
| 622 | 633 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 623 | 634 | |
| ... | ... | @@ -646,7 +657,7 @@ public: |
| 646 | 657 | swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y)); |
| 647 | 658 | } |
| 648 | 659 | |
| 649 | #if _LIBCPP_STD_VER >= 14 | |
| 660 | # if _LIBCPP_STD_VER >= 14 | |
| 650 | 661 | template <typename _K2> |
| 651 | 662 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const { |
| 652 | 663 | return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first); |
| ... | ... | @@ -656,7 +667,7 @@ public: |
| 656 | 667 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const { |
| 657 | 668 | return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y); |
| 658 | 669 | } |
| 659 | #endif | |
| 670 | # endif | |
| 660 | 671 | }; |
| 661 | 672 | |
| 662 | 673 | template <class _Key, class _CP, class _Compare> |
| ... | ... | @@ -684,7 +695,7 @@ public: |
| 684 | 695 | swap(__comp_, __y.__comp_); |
| 685 | 696 | } |
| 686 | 697 | |
| 687 | #if _LIBCPP_STD_VER >= 14 | |
| 698 | # if _LIBCPP_STD_VER >= 14 | |
| 688 | 699 | template <typename _K2> |
| 689 | 700 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const { |
| 690 | 701 | return __comp_(__x, __y.__get_value().first); |
| ... | ... | @@ -694,7 +705,7 @@ public: |
| 694 | 705 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const { |
| 695 | 706 | return __comp_(__x.__get_value().first, __y); |
| 696 | 707 | } |
| 697 | #endif | |
| 708 | # endif | |
| 698 | 709 | }; |
| 699 | 710 | |
| 700 | 711 | template <class _Key, class _CP, class _Compare, bool __b> |
| ... | ... | @@ -724,14 +735,14 @@ public: |
| 724 | 735 | __first_constructed(false), |
| 725 | 736 | __second_constructed(false) {} |
| 726 | 737 | |
| 727 | #ifndef _LIBCPP_CXX03_LANG | |
| 738 | # ifndef _LIBCPP_CXX03_LANG | |
| 728 | 739 | _LIBCPP_HIDE_FROM_ABI __map_node_destructor(__tree_node_destructor<allocator_type>&& __x) _NOEXCEPT |
| 729 | 740 | : __na_(__x.__na_), |
| 730 | 741 | __first_constructed(__x.__value_constructed), |
| 731 | 742 | __second_constructed(__x.__value_constructed) { |
| 732 | 743 | __x.__value_constructed = false; |
| 733 | 744 | } |
| 734 | #endif // _LIBCPP_CXX03_LANG | |
| 745 | # endif // _LIBCPP_CXX03_LANG | |
| 735 | 746 | |
| 736 | 747 | __map_node_destructor& operator=(const __map_node_destructor&) = delete; |
| 737 | 748 | |
| ... | ... | @@ -752,7 +763,7 @@ class multimap; |
| 752 | 763 | template <class _TreeIterator> |
| 753 | 764 | class __map_const_iterator; |
| 754 | 765 | |
| 755 | #ifndef _LIBCPP_CXX03_LANG | |
| 766 | # ifndef _LIBCPP_CXX03_LANG | |
| 756 | 767 | |
| 757 | 768 | template <class _Key, class _Tp> |
| 758 | 769 | struct _LIBCPP_STANDALONE_DEBUG __value_type { |
| ... | ... | @@ -767,19 +778,19 @@ private: |
| 767 | 778 | |
| 768 | 779 | public: |
| 769 | 780 | _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { |
| 770 | # if _LIBCPP_STD_VER >= 17 | |
| 781 | # if _LIBCPP_STD_VER >= 17 | |
| 771 | 782 | return *std::launder(std::addressof(__cc_)); |
| 772 | # else | |
| 783 | # else | |
| 773 | 784 | return __cc_; |
| 774 | # endif | |
| 785 | # endif | |
| 775 | 786 | } |
| 776 | 787 | |
| 777 | 788 | _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { |
| 778 | # if _LIBCPP_STD_VER >= 17 | |
| 789 | # if _LIBCPP_STD_VER >= 17 | |
| 779 | 790 | return *std::launder(std::addressof(__cc_)); |
| 780 | # else | |
| 791 | # else | |
| 781 | 792 | return __cc_; |
| 782 | # endif | |
| 793 | # endif | |
| 783 | 794 | } |
| 784 | 795 | |
| 785 | 796 | _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() { |
| ... | ... | @@ -814,7 +825,7 @@ public: |
| 814 | 825 | __value_type(__value_type&&) = delete; |
| 815 | 826 | }; |
| 816 | 827 | |
| 817 | #else | |
| 828 | # else | |
| 818 | 829 | |
| 819 | 830 | template <class _Key, class _Tp> |
| 820 | 831 | struct __value_type { |
| ... | ... | @@ -835,7 +846,7 @@ public: |
| 835 | 846 | ~__value_type() = delete; |
| 836 | 847 | }; |
| 837 | 848 | |
| 838 | #endif // _LIBCPP_CXX03_LANG | |
| 849 | # endif // _LIBCPP_CXX03_LANG | |
| 839 | 850 | |
| 840 | 851 | template <class _Tp> |
| 841 | 852 | struct __extract_key_value_types; |
| ... | ... | @@ -1011,10 +1022,10 @@ public: |
| 1011 | 1022 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 1012 | 1023 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 1013 | 1024 | |
| 1014 | #if _LIBCPP_STD_VER >= 17 | |
| 1025 | # if _LIBCPP_STD_VER >= 17 | |
| 1015 | 1026 | typedef __map_node_handle<typename __base::__node, allocator_type> node_type; |
| 1016 | 1027 | typedef __insert_return_type<iterator, node_type> insert_return_type; |
| 1017 | #endif | |
| 1028 | # endif | |
| 1018 | 1029 | |
| 1019 | 1030 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1020 | 1031 | friend class _LIBCPP_TEMPLATE_VIS map; |
| ... | ... | @@ -1046,7 +1057,7 @@ public: |
| 1046 | 1057 | insert(__f, __l); |
| 1047 | 1058 | } |
| 1048 | 1059 | |
| 1049 | #if _LIBCPP_STD_VER >= 23 | |
| 1060 | # if _LIBCPP_STD_VER >= 23 | |
| 1050 | 1061 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1051 | 1062 | _LIBCPP_HIDE_FROM_ABI |
| 1052 | 1063 | map(from_range_t, |
| ... | ... | @@ -1056,37 +1067,37 @@ public: |
| 1056 | 1067 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) { |
| 1057 | 1068 | insert_range(std::forward<_Range>(__range)); |
| 1058 | 1069 | } |
| 1059 | #endif | |
| 1070 | # endif | |
| 1060 | 1071 | |
| 1061 | #if _LIBCPP_STD_VER >= 14 | |
| 1072 | # if _LIBCPP_STD_VER >= 14 | |
| 1062 | 1073 | template <class _InputIterator> |
| 1063 | 1074 | _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 1064 | 1075 | : map(__f, __l, key_compare(), __a) {} |
| 1065 | #endif | |
| 1076 | # endif | |
| 1066 | 1077 | |
| 1067 | #if _LIBCPP_STD_VER >= 23 | |
| 1078 | # if _LIBCPP_STD_VER >= 23 | |
| 1068 | 1079 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1069 | 1080 | _LIBCPP_HIDE_FROM_ABI map(from_range_t, _Range&& __range, const allocator_type& __a) |
| 1070 | 1081 | : map(from_range, std::forward<_Range>(__range), key_compare(), __a) {} |
| 1071 | #endif | |
| 1082 | # endif | |
| 1072 | 1083 | |
| 1073 | 1084 | _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); } |
| 1074 | 1085 | |
| 1075 | 1086 | _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) { |
| 1076 | #ifndef _LIBCPP_CXX03_LANG | |
| 1087 | # ifndef _LIBCPP_CXX03_LANG | |
| 1077 | 1088 | __tree_ = __m.__tree_; |
| 1078 | #else | |
| 1089 | # else | |
| 1079 | 1090 | if (this != std::addressof(__m)) { |
| 1080 | 1091 | __tree_.clear(); |
| 1081 | 1092 | __tree_.value_comp() = __m.__tree_.value_comp(); |
| 1082 | 1093 | __tree_.__copy_assign_alloc(__m.__tree_); |
| 1083 | 1094 | insert(__m.begin(), __m.end()); |
| 1084 | 1095 | } |
| 1085 | #endif | |
| 1096 | # endif | |
| 1086 | 1097 | return *this; |
| 1087 | 1098 | } |
| 1088 | 1099 | |
| 1089 | #ifndef _LIBCPP_CXX03_LANG | |
| 1100 | # ifndef _LIBCPP_CXX03_LANG | |
| 1090 | 1101 | |
| 1091 | 1102 | _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value) |
| 1092 | 1103 | : __tree_(std::move(__m.__tree_)) {} |
| ... | ... | @@ -1108,17 +1119,17 @@ public: |
| 1108 | 1119 | insert(__il.begin(), __il.end()); |
| 1109 | 1120 | } |
| 1110 | 1121 | |
| 1111 | # if _LIBCPP_STD_VER >= 14 | |
| 1122 | # if _LIBCPP_STD_VER >= 14 | |
| 1112 | 1123 | _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const allocator_type& __a) |
| 1113 | 1124 | : map(__il, key_compare(), __a) {} |
| 1114 | # endif | |
| 1125 | # endif | |
| 1115 | 1126 | |
| 1116 | 1127 | _LIBCPP_HIDE_FROM_ABI map& operator=(initializer_list<value_type> __il) { |
| 1117 | 1128 | __tree_.__assign_unique(__il.begin(), __il.end()); |
| 1118 | 1129 | return *this; |
| 1119 | 1130 | } |
| 1120 | 1131 | |
| 1121 | #endif // _LIBCPP_CXX03_LANG | |
| 1132 | # endif // _LIBCPP_CXX03_LANG | |
| 1122 | 1133 | |
| 1123 | 1134 | _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} |
| 1124 | 1135 | |
| ... | ... | @@ -1144,14 +1155,14 @@ public: |
| 1144 | 1155 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 1145 | 1156 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 1146 | 1157 | |
| 1147 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | |
| 1158 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | |
| 1148 | 1159 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 1149 | 1160 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 1150 | 1161 | |
| 1151 | 1162 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k); |
| 1152 | #ifndef _LIBCPP_CXX03_LANG | |
| 1163 | # ifndef _LIBCPP_CXX03_LANG | |
| 1153 | 1164 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k); |
| 1154 | #endif | |
| 1165 | # endif | |
| 1155 | 1166 | |
| 1156 | 1167 | _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k); |
| 1157 | 1168 | _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const; |
| ... | ... | @@ -1160,7 +1171,7 @@ public: |
| 1160 | 1171 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } |
| 1161 | 1172 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); } |
| 1162 | 1173 | |
| 1163 | #ifndef _LIBCPP_CXX03_LANG | |
| 1174 | # ifndef _LIBCPP_CXX03_LANG | |
| 1164 | 1175 | template <class... _Args> |
| 1165 | 1176 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) { |
| 1166 | 1177 | return __tree_.__emplace_unique(std::forward<_Args>(__args)...); |
| ... | ... | @@ -1181,7 +1192,7 @@ public: |
| 1181 | 1192 | return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p)); |
| 1182 | 1193 | } |
| 1183 | 1194 | |
| 1184 | #endif // _LIBCPP_CXX03_LANG | |
| 1195 | # endif // _LIBCPP_CXX03_LANG | |
| 1185 | 1196 | |
| 1186 | 1197 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); } |
| 1187 | 1198 | |
| ... | ... | @@ -1189,7 +1200,7 @@ public: |
| 1189 | 1200 | return __tree_.__insert_unique(__p.__i_, __v); |
| 1190 | 1201 | } |
| 1191 | 1202 | |
| 1192 | #ifndef _LIBCPP_CXX03_LANG | |
| 1203 | # ifndef _LIBCPP_CXX03_LANG | |
| 1193 | 1204 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) { |
| 1194 | 1205 | return __tree_.__insert_unique(std::move(__v)); |
| 1195 | 1206 | } |
| ... | ... | @@ -1199,7 +1210,7 @@ public: |
| 1199 | 1210 | } |
| 1200 | 1211 | |
| 1201 | 1212 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 1202 | #endif | |
| 1213 | # endif | |
| 1203 | 1214 | |
| 1204 | 1215 | template <class _InputIterator> |
| 1205 | 1216 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { |
| ... | ... | @@ -1207,7 +1218,7 @@ public: |
| 1207 | 1218 | insert(__e.__i_, *__f); |
| 1208 | 1219 | } |
| 1209 | 1220 | |
| 1210 | #if _LIBCPP_STD_VER >= 23 | |
| 1221 | # if _LIBCPP_STD_VER >= 23 | |
| 1211 | 1222 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1212 | 1223 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1213 | 1224 | const_iterator __end = cend(); |
| ... | ... | @@ -1215,9 +1226,9 @@ public: |
| 1215 | 1226 | insert(__end.__i_, std::forward<decltype(__element)>(__element)); |
| 1216 | 1227 | } |
| 1217 | 1228 | } |
| 1218 | #endif | |
| 1229 | # endif | |
| 1219 | 1230 | |
| 1220 | #if _LIBCPP_STD_VER >= 17 | |
| 1231 | # if _LIBCPP_STD_VER >= 17 | |
| 1221 | 1232 | |
| 1222 | 1233 | template <class... _Args> |
| 1223 | 1234 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) { |
| ... | ... | @@ -1302,7 +1313,7 @@ public: |
| 1302 | 1313 | return __r; |
| 1303 | 1314 | } |
| 1304 | 1315 | |
| 1305 | #endif // _LIBCPP_STD_VER >= 17 | |
| 1316 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1306 | 1317 | |
| 1307 | 1318 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); } |
| 1308 | 1319 | _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); } |
| ... | ... | @@ -1312,7 +1323,7 @@ public: |
| 1312 | 1323 | } |
| 1313 | 1324 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } |
| 1314 | 1325 | |
| 1315 | #if _LIBCPP_STD_VER >= 17 | |
| 1326 | # if _LIBCPP_STD_VER >= 17 | |
| 1316 | 1327 | _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) { |
| 1317 | 1328 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1318 | 1329 | "node_type with incompatible allocator passed to map::insert()"); |
| ... | ... | @@ -1353,13 +1364,13 @@ public: |
| 1353 | 1364 | __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); |
| 1354 | 1365 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 1355 | 1366 | } |
| 1356 | #endif | |
| 1367 | # endif | |
| 1357 | 1368 | |
| 1358 | 1369 | _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); } |
| 1359 | 1370 | |
| 1360 | 1371 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 1361 | 1372 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 1362 | #if _LIBCPP_STD_VER >= 14 | |
| 1373 | # if _LIBCPP_STD_VER >= 14 | |
| 1363 | 1374 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1364 | 1375 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1365 | 1376 | return __tree_.find(__k); |
| ... | ... | @@ -1368,27 +1379,27 @@ public: |
| 1368 | 1379 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1369 | 1380 | return __tree_.find(__k); |
| 1370 | 1381 | } |
| 1371 | #endif | |
| 1382 | # endif | |
| 1372 | 1383 | |
| 1373 | 1384 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } |
| 1374 | #if _LIBCPP_STD_VER >= 14 | |
| 1385 | # if _LIBCPP_STD_VER >= 14 | |
| 1375 | 1386 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1376 | 1387 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1377 | 1388 | return __tree_.__count_multi(__k); |
| 1378 | 1389 | } |
| 1379 | #endif | |
| 1390 | # endif | |
| 1380 | 1391 | |
| 1381 | #if _LIBCPP_STD_VER >= 20 | |
| 1392 | # if _LIBCPP_STD_VER >= 20 | |
| 1382 | 1393 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1383 | 1394 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1384 | 1395 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1385 | 1396 | return find(__k) != end(); |
| 1386 | 1397 | } |
| 1387 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1398 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1388 | 1399 | |
| 1389 | 1400 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } |
| 1390 | 1401 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } |
| 1391 | #if _LIBCPP_STD_VER >= 14 | |
| 1402 | # if _LIBCPP_STD_VER >= 14 | |
| 1392 | 1403 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1393 | 1404 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 1394 | 1405 | return __tree_.lower_bound(__k); |
| ... | ... | @@ -1398,11 +1409,11 @@ public: |
| 1398 | 1409 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 1399 | 1410 | return __tree_.lower_bound(__k); |
| 1400 | 1411 | } |
| 1401 | #endif | |
| 1412 | # endif | |
| 1402 | 1413 | |
| 1403 | 1414 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } |
| 1404 | 1415 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } |
| 1405 | #if _LIBCPP_STD_VER >= 14 | |
| 1416 | # if _LIBCPP_STD_VER >= 14 | |
| 1406 | 1417 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1407 | 1418 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 1408 | 1419 | return __tree_.upper_bound(__k); |
| ... | ... | @@ -1411,7 +1422,7 @@ public: |
| 1411 | 1422 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 1412 | 1423 | return __tree_.upper_bound(__k); |
| 1413 | 1424 | } |
| 1414 | #endif | |
| 1425 | # endif | |
| 1415 | 1426 | |
| 1416 | 1427 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 1417 | 1428 | return __tree_.__equal_range_unique(__k); |
| ... | ... | @@ -1419,7 +1430,7 @@ public: |
| 1419 | 1430 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 1420 | 1431 | return __tree_.__equal_range_unique(__k); |
| 1421 | 1432 | } |
| 1422 | #if _LIBCPP_STD_VER >= 14 | |
| 1433 | # if _LIBCPP_STD_VER >= 14 | |
| 1423 | 1434 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1424 | 1435 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1425 | 1436 | return __tree_.__equal_range_multi(__k); |
| ... | ... | @@ -1428,7 +1439,7 @@ public: |
| 1428 | 1439 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1429 | 1440 | return __tree_.__equal_range_multi(__k); |
| 1430 | 1441 | } |
| 1431 | #endif | |
| 1442 | # endif | |
| 1432 | 1443 | |
| 1433 | 1444 | private: |
| 1434 | 1445 | typedef typename __base::__node __node; |
| ... | ... | @@ -1440,12 +1451,12 @@ private: |
| 1440 | 1451 | typedef __map_node_destructor<__node_allocator> _Dp; |
| 1441 | 1452 | typedef unique_ptr<__node, _Dp> __node_holder; |
| 1442 | 1453 | |
| 1443 | #ifdef _LIBCPP_CXX03_LANG | |
| 1454 | # ifdef _LIBCPP_CXX03_LANG | |
| 1444 | 1455 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k); |
| 1445 | #endif | |
| 1456 | # endif | |
| 1446 | 1457 | }; |
| 1447 | 1458 | |
| 1448 | #if _LIBCPP_STD_VER >= 17 | |
| 1459 | # if _LIBCPP_STD_VER >= 17 | |
| 1449 | 1460 | template <class _InputIterator, |
| 1450 | 1461 | class _Compare = less<__iter_key_type<_InputIterator>>, |
| 1451 | 1462 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
| ... | ... | @@ -1455,7 +1466,7 @@ template <class _InputIterator, |
| 1455 | 1466 | map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1456 | 1467 | -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; |
| 1457 | 1468 | |
| 1458 | # if _LIBCPP_STD_VER >= 23 | |
| 1469 | # if _LIBCPP_STD_VER >= 23 | |
| 1459 | 1470 | template <ranges::input_range _Range, |
| 1460 | 1471 | class _Compare = less<__range_key_type<_Range>>, |
| 1461 | 1472 | class _Allocator = allocator<__range_to_alloc_type<_Range>>, |
| ... | ... | @@ -1463,7 +1474,7 @@ template <ranges::input_range _Range, |
| 1463 | 1474 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 1464 | 1475 | map(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1465 | 1476 | -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>; |
| 1466 | # endif | |
| 1477 | # endif | |
| 1467 | 1478 | |
| 1468 | 1479 | template <class _Key, |
| 1469 | 1480 | class _Tp, |
| ... | ... | @@ -1485,18 +1496,18 @@ map(_InputIterator, _InputIterator, _Allocator) |
| 1485 | 1496 | less<__iter_key_type<_InputIterator>>, |
| 1486 | 1497 | _Allocator>; |
| 1487 | 1498 | |
| 1488 | # if _LIBCPP_STD_VER >= 23 | |
| 1499 | # if _LIBCPP_STD_VER >= 23 | |
| 1489 | 1500 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 1490 | 1501 | map(from_range_t, _Range&&, _Allocator) |
| 1491 | 1502 | -> map<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>; |
| 1492 | # endif | |
| 1503 | # endif | |
| 1493 | 1504 | |
| 1494 | 1505 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 1495 | 1506 | map(initializer_list<pair<_Key, _Tp>>, |
| 1496 | 1507 | _Allocator) -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; |
| 1497 | #endif | |
| 1508 | # endif | |
| 1498 | 1509 | |
| 1499 | #ifndef _LIBCPP_CXX03_LANG | |
| 1510 | # ifndef _LIBCPP_CXX03_LANG | |
| 1500 | 1511 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1501 | 1512 | map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) |
| 1502 | 1513 | : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) { |
| ... | ... | @@ -1527,7 +1538,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) { |
| 1527 | 1538 | // NOLINTEND(bugprone-use-after-move) |
| 1528 | 1539 | } |
| 1529 | 1540 | |
| 1530 | #else // _LIBCPP_CXX03_LANG | |
| 1541 | # else // _LIBCPP_CXX03_LANG | |
| 1531 | 1542 | |
| 1532 | 1543 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1533 | 1544 | typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder |
| ... | ... | @@ -1554,7 +1565,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { |
| 1554 | 1565 | return __r->__value_.__get_value().second; |
| 1555 | 1566 | } |
| 1556 | 1567 | |
| 1557 | #endif // _LIBCPP_CXX03_LANG | |
| 1568 | # endif // _LIBCPP_CXX03_LANG | |
| 1558 | 1569 | |
| 1559 | 1570 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1560 | 1571 | _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) { |
| ... | ... | @@ -1580,7 +1591,7 @@ operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, |
| 1580 | 1591 | return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); |
| 1581 | 1592 | } |
| 1582 | 1593 | |
| 1583 | #if _LIBCPP_STD_VER <= 17 | |
| 1594 | # if _LIBCPP_STD_VER <= 17 | |
| 1584 | 1595 | |
| 1585 | 1596 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1586 | 1597 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -1612,7 +1623,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, |
| 1612 | 1623 | return !(__y < __x); |
| 1613 | 1624 | } |
| 1614 | 1625 | |
| 1615 | #else // #if _LIBCPP_STD_VER <= 17 | |
| 1626 | # else // #if _LIBCPP_STD_VER <= 17 | |
| 1616 | 1627 | |
| 1617 | 1628 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1618 | 1629 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>> |
| ... | ... | @@ -1620,7 +1631,7 @@ operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp |
| 1620 | 1631 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 1621 | 1632 | } |
| 1622 | 1633 | |
| 1623 | #endif // #if _LIBCPP_STD_VER <= 17 | |
| 1634 | # endif // #if _LIBCPP_STD_VER <= 17 | |
| 1624 | 1635 | |
| 1625 | 1636 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 1626 | 1637 | inline _LIBCPP_HIDE_FROM_ABI void |
| ... | ... | @@ -1629,13 +1640,21 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x, map<_Key, _Tp, _Compare, _Alloca |
| 1629 | 1640 | __x.swap(__y); |
| 1630 | 1641 | } |
| 1631 | 1642 | |
| 1632 | #if _LIBCPP_STD_VER >= 20 | |
| 1643 | # if _LIBCPP_STD_VER >= 20 | |
| 1633 | 1644 | template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate> |
| 1634 | 1645 | inline _LIBCPP_HIDE_FROM_ABI typename map<_Key, _Tp, _Compare, _Allocator>::size_type |
| 1635 | 1646 | erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) { |
| 1636 | 1647 | return std::__libcpp_erase_if_container(__c, __pred); |
| 1637 | 1648 | } |
| 1638 | #endif | |
| 1649 | # endif | |
| 1650 | ||
| 1651 | template <class _Key, class _Tp, class _Compare, class _Allocator> | |
| 1652 | struct __container_traits<map<_Key, _Tp, _Compare, _Allocator> > { | |
| 1653 | // http://eel.is/c++draft/associative.reqmts.except#2 | |
| 1654 | // For associative containers, if an exception is thrown by any operation from within | |
| 1655 | // an insert or emplace function inserting a single element, the insertion has no effect. | |
| 1656 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | |
| 1657 | }; | |
| 1639 | 1658 | |
| 1640 | 1659 | template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > |
| 1641 | 1660 | class _LIBCPP_TEMPLATE_VIS multimap { |
| ... | ... | @@ -1687,9 +1706,9 @@ public: |
| 1687 | 1706 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 1688 | 1707 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 1689 | 1708 | |
| 1690 | #if _LIBCPP_STD_VER >= 17 | |
| 1709 | # if _LIBCPP_STD_VER >= 17 | |
| 1691 | 1710 | typedef __map_node_handle<typename __base::__node, allocator_type> node_type; |
| 1692 | #endif | |
| 1711 | # endif | |
| 1693 | 1712 | |
| 1694 | 1713 | template <class _Key2, class _Value2, class _Comp2, class _Alloc2> |
| 1695 | 1714 | friend class _LIBCPP_TEMPLATE_VIS map; |
| ... | ... | @@ -1721,7 +1740,7 @@ public: |
| 1721 | 1740 | insert(__f, __l); |
| 1722 | 1741 | } |
| 1723 | 1742 | |
| 1724 | #if _LIBCPP_STD_VER >= 23 | |
| 1743 | # if _LIBCPP_STD_VER >= 23 | |
| 1725 | 1744 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1726 | 1745 | _LIBCPP_HIDE_FROM_ABI |
| 1727 | 1746 | multimap(from_range_t, |
| ... | ... | @@ -1731,19 +1750,19 @@ public: |
| 1731 | 1750 | : __tree_(__vc(__comp), typename __base::allocator_type(__a)) { |
| 1732 | 1751 | insert_range(std::forward<_Range>(__range)); |
| 1733 | 1752 | } |
| 1734 | #endif | |
| 1753 | # endif | |
| 1735 | 1754 | |
| 1736 | #if _LIBCPP_STD_VER >= 14 | |
| 1755 | # if _LIBCPP_STD_VER >= 14 | |
| 1737 | 1756 | template <class _InputIterator> |
| 1738 | 1757 | _LIBCPP_HIDE_FROM_ABI multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 1739 | 1758 | : multimap(__f, __l, key_compare(), __a) {} |
| 1740 | #endif | |
| 1759 | # endif | |
| 1741 | 1760 | |
| 1742 | #if _LIBCPP_STD_VER >= 23 | |
| 1761 | # if _LIBCPP_STD_VER >= 23 | |
| 1743 | 1762 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1744 | 1763 | _LIBCPP_HIDE_FROM_ABI multimap(from_range_t, _Range&& __range, const allocator_type& __a) |
| 1745 | 1764 | : multimap(from_range, std::forward<_Range>(__range), key_compare(), __a) {} |
| 1746 | #endif | |
| 1765 | # endif | |
| 1747 | 1766 | |
| 1748 | 1767 | _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m) |
| 1749 | 1768 | : __tree_(__m.__tree_.value_comp(), |
| ... | ... | @@ -1752,20 +1771,20 @@ public: |
| 1752 | 1771 | } |
| 1753 | 1772 | |
| 1754 | 1773 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) { |
| 1755 | #ifndef _LIBCPP_CXX03_LANG | |
| 1774 | # ifndef _LIBCPP_CXX03_LANG | |
| 1756 | 1775 | __tree_ = __m.__tree_; |
| 1757 | #else | |
| 1776 | # else | |
| 1758 | 1777 | if (this != std::addressof(__m)) { |
| 1759 | 1778 | __tree_.clear(); |
| 1760 | 1779 | __tree_.value_comp() = __m.__tree_.value_comp(); |
| 1761 | 1780 | __tree_.__copy_assign_alloc(__m.__tree_); |
| 1762 | 1781 | insert(__m.begin(), __m.end()); |
| 1763 | 1782 | } |
| 1764 | #endif | |
| 1783 | # endif | |
| 1765 | 1784 | return *this; |
| 1766 | 1785 | } |
| 1767 | 1786 | |
| 1768 | #ifndef _LIBCPP_CXX03_LANG | |
| 1787 | # ifndef _LIBCPP_CXX03_LANG | |
| 1769 | 1788 | |
| 1770 | 1789 | _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value) |
| 1771 | 1790 | : __tree_(std::move(__m.__tree_)) {} |
| ... | ... | @@ -1788,17 +1807,17 @@ public: |
| 1788 | 1807 | insert(__il.begin(), __il.end()); |
| 1789 | 1808 | } |
| 1790 | 1809 | |
| 1791 | # if _LIBCPP_STD_VER >= 14 | |
| 1810 | # if _LIBCPP_STD_VER >= 14 | |
| 1792 | 1811 | _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const allocator_type& __a) |
| 1793 | 1812 | : multimap(__il, key_compare(), __a) {} |
| 1794 | # endif | |
| 1813 | # endif | |
| 1795 | 1814 | |
| 1796 | 1815 | _LIBCPP_HIDE_FROM_ABI multimap& operator=(initializer_list<value_type> __il) { |
| 1797 | 1816 | __tree_.__assign_multi(__il.begin(), __il.end()); |
| 1798 | 1817 | return *this; |
| 1799 | 1818 | } |
| 1800 | 1819 | |
| 1801 | #endif // _LIBCPP_CXX03_LANG | |
| 1820 | # endif // _LIBCPP_CXX03_LANG | |
| 1802 | 1821 | |
| 1803 | 1822 | _LIBCPP_HIDE_FROM_ABI explicit multimap(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} |
| 1804 | 1823 | |
| ... | ... | @@ -1824,7 +1843,7 @@ public: |
| 1824 | 1843 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 1825 | 1844 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 1826 | 1845 | |
| 1827 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | |
| 1846 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | |
| 1828 | 1847 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 1829 | 1848 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 1830 | 1849 | |
| ... | ... | @@ -1832,7 +1851,7 @@ public: |
| 1832 | 1851 | _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } |
| 1833 | 1852 | _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); } |
| 1834 | 1853 | |
| 1835 | #ifndef _LIBCPP_CXX03_LANG | |
| 1854 | # ifndef _LIBCPP_CXX03_LANG | |
| 1836 | 1855 | |
| 1837 | 1856 | template <class... _Args> |
| 1838 | 1857 | _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { |
| ... | ... | @@ -1862,7 +1881,7 @@ public: |
| 1862 | 1881 | |
| 1863 | 1882 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 1864 | 1883 | |
| 1865 | #endif // _LIBCPP_CXX03_LANG | |
| 1884 | # endif // _LIBCPP_CXX03_LANG | |
| 1866 | 1885 | |
| 1867 | 1886 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); } |
| 1868 | 1887 | |
| ... | ... | @@ -1876,7 +1895,7 @@ public: |
| 1876 | 1895 | __tree_.__insert_multi(__e.__i_, *__f); |
| 1877 | 1896 | } |
| 1878 | 1897 | |
| 1879 | #if _LIBCPP_STD_VER >= 23 | |
| 1898 | # if _LIBCPP_STD_VER >= 23 | |
| 1880 | 1899 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1881 | 1900 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1882 | 1901 | const_iterator __end = cend(); |
| ... | ... | @@ -1884,7 +1903,7 @@ public: |
| 1884 | 1903 | __tree_.__insert_multi(__end.__i_, std::forward<decltype(__element)>(__element)); |
| 1885 | 1904 | } |
| 1886 | 1905 | } |
| 1887 | #endif | |
| 1906 | # endif | |
| 1888 | 1907 | |
| 1889 | 1908 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); } |
| 1890 | 1909 | _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); } |
| ... | ... | @@ -1893,7 +1912,7 @@ public: |
| 1893 | 1912 | return __tree_.erase(__f.__i_, __l.__i_); |
| 1894 | 1913 | } |
| 1895 | 1914 | |
| 1896 | #if _LIBCPP_STD_VER >= 17 | |
| 1915 | # if _LIBCPP_STD_VER >= 17 | |
| 1897 | 1916 | _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) { |
| 1898 | 1917 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1899 | 1918 | "node_type with incompatible allocator passed to multimap::insert()"); |
| ... | ... | @@ -1934,7 +1953,7 @@ public: |
| 1934 | 1953 | __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); |
| 1935 | 1954 | return __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1936 | 1955 | } |
| 1937 | #endif | |
| 1956 | # endif | |
| 1938 | 1957 | |
| 1939 | 1958 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } |
| 1940 | 1959 | |
| ... | ... | @@ -1944,7 +1963,7 @@ public: |
| 1944 | 1963 | |
| 1945 | 1964 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 1946 | 1965 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 1947 | #if _LIBCPP_STD_VER >= 14 | |
| 1966 | # if _LIBCPP_STD_VER >= 14 | |
| 1948 | 1967 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1949 | 1968 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1950 | 1969 | return __tree_.find(__k); |
| ... | ... | @@ -1953,27 +1972,27 @@ public: |
| 1953 | 1972 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1954 | 1973 | return __tree_.find(__k); |
| 1955 | 1974 | } |
| 1956 | #endif | |
| 1975 | # endif | |
| 1957 | 1976 | |
| 1958 | 1977 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } |
| 1959 | #if _LIBCPP_STD_VER >= 14 | |
| 1978 | # if _LIBCPP_STD_VER >= 14 | |
| 1960 | 1979 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1961 | 1980 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1962 | 1981 | return __tree_.__count_multi(__k); |
| 1963 | 1982 | } |
| 1964 | #endif | |
| 1983 | # endif | |
| 1965 | 1984 | |
| 1966 | #if _LIBCPP_STD_VER >= 20 | |
| 1985 | # if _LIBCPP_STD_VER >= 20 | |
| 1967 | 1986 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1968 | 1987 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1969 | 1988 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1970 | 1989 | return find(__k) != end(); |
| 1971 | 1990 | } |
| 1972 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1991 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1973 | 1992 | |
| 1974 | 1993 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } |
| 1975 | 1994 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } |
| 1976 | #if _LIBCPP_STD_VER >= 14 | |
| 1995 | # if _LIBCPP_STD_VER >= 14 | |
| 1977 | 1996 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1978 | 1997 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 1979 | 1998 | return __tree_.lower_bound(__k); |
| ... | ... | @@ -1983,11 +2002,11 @@ public: |
| 1983 | 2002 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 1984 | 2003 | return __tree_.lower_bound(__k); |
| 1985 | 2004 | } |
| 1986 | #endif | |
| 2005 | # endif | |
| 1987 | 2006 | |
| 1988 | 2007 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } |
| 1989 | 2008 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } |
| 1990 | #if _LIBCPP_STD_VER >= 14 | |
| 2009 | # if _LIBCPP_STD_VER >= 14 | |
| 1991 | 2010 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1992 | 2011 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 1993 | 2012 | return __tree_.upper_bound(__k); |
| ... | ... | @@ -1996,7 +2015,7 @@ public: |
| 1996 | 2015 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 1997 | 2016 | return __tree_.upper_bound(__k); |
| 1998 | 2017 | } |
| 1999 | #endif | |
| 2018 | # endif | |
| 2000 | 2019 | |
| 2001 | 2020 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 2002 | 2021 | return __tree_.__equal_range_multi(__k); |
| ... | ... | @@ -2004,7 +2023,7 @@ public: |
| 2004 | 2023 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 2005 | 2024 | return __tree_.__equal_range_multi(__k); |
| 2006 | 2025 | } |
| 2007 | #if _LIBCPP_STD_VER >= 14 | |
| 2026 | # if _LIBCPP_STD_VER >= 14 | |
| 2008 | 2027 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 2009 | 2028 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 2010 | 2029 | return __tree_.__equal_range_multi(__k); |
| ... | ... | @@ -2013,7 +2032,7 @@ public: |
| 2013 | 2032 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 2014 | 2033 | return __tree_.__equal_range_multi(__k); |
| 2015 | 2034 | } |
| 2016 | #endif | |
| 2035 | # endif | |
| 2017 | 2036 | |
| 2018 | 2037 | private: |
| 2019 | 2038 | typedef typename __base::__node __node; |
| ... | ... | @@ -2024,7 +2043,7 @@ private: |
| 2024 | 2043 | typedef unique_ptr<__node, _Dp> __node_holder; |
| 2025 | 2044 | }; |
| 2026 | 2045 | |
| 2027 | #if _LIBCPP_STD_VER >= 17 | |
| 2046 | # if _LIBCPP_STD_VER >= 17 | |
| 2028 | 2047 | template <class _InputIterator, |
| 2029 | 2048 | class _Compare = less<__iter_key_type<_InputIterator>>, |
| 2030 | 2049 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
| ... | ... | @@ -2034,7 +2053,7 @@ template <class _InputIterator, |
| 2034 | 2053 | multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 2035 | 2054 | -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; |
| 2036 | 2055 | |
| 2037 | # if _LIBCPP_STD_VER >= 23 | |
| 2056 | # if _LIBCPP_STD_VER >= 23 | |
| 2038 | 2057 | template <ranges::input_range _Range, |
| 2039 | 2058 | class _Compare = less<__range_key_type<_Range>>, |
| 2040 | 2059 | class _Allocator = allocator<__range_to_alloc_type<_Range>>, |
| ... | ... | @@ -2042,7 +2061,7 @@ template <ranges::input_range _Range, |
| 2042 | 2061 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 2043 | 2062 | multimap(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) |
| 2044 | 2063 | -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Compare, _Allocator>; |
| 2045 | # endif | |
| 2064 | # endif | |
| 2046 | 2065 | |
| 2047 | 2066 | template <class _Key, |
| 2048 | 2067 | class _Tp, |
| ... | ... | @@ -2064,18 +2083,18 @@ multimap(_InputIterator, _InputIterator, _Allocator) |
| 2064 | 2083 | less<__iter_key_type<_InputIterator>>, |
| 2065 | 2084 | _Allocator>; |
| 2066 | 2085 | |
| 2067 | # if _LIBCPP_STD_VER >= 23 | |
| 2086 | # if _LIBCPP_STD_VER >= 23 | |
| 2068 | 2087 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 2069 | 2088 | multimap(from_range_t, _Range&&, _Allocator) |
| 2070 | 2089 | -> multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, less<__range_key_type<_Range>>, _Allocator>; |
| 2071 | # endif | |
| 2090 | # endif | |
| 2072 | 2091 | |
| 2073 | 2092 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 2074 | 2093 | multimap(initializer_list<pair<_Key, _Tp>>, |
| 2075 | 2094 | _Allocator) -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; |
| 2076 | #endif | |
| 2095 | # endif | |
| 2077 | 2096 | |
| 2078 | #ifndef _LIBCPP_CXX03_LANG | |
| 2097 | # ifndef _LIBCPP_CXX03_LANG | |
| 2079 | 2098 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 2080 | 2099 | multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a) |
| 2081 | 2100 | : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) { |
| ... | ... | @@ -2085,7 +2104,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const alloca |
| 2085 | 2104 | __tree_.__insert_multi(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move())); |
| 2086 | 2105 | } |
| 2087 | 2106 | } |
| 2088 | #endif | |
| 2107 | # endif | |
| 2089 | 2108 | |
| 2090 | 2109 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 2091 | 2110 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -2093,7 +2112,7 @@ operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap< |
| 2093 | 2112 | return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); |
| 2094 | 2113 | } |
| 2095 | 2114 | |
| 2096 | #if _LIBCPP_STD_VER <= 17 | |
| 2115 | # if _LIBCPP_STD_VER <= 17 | |
| 2097 | 2116 | |
| 2098 | 2117 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 2099 | 2118 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -2125,7 +2144,7 @@ operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap< |
| 2125 | 2144 | return !(__y < __x); |
| 2126 | 2145 | } |
| 2127 | 2146 | |
| 2128 | #else // #if _LIBCPP_STD_VER <= 17 | |
| 2147 | # else // #if _LIBCPP_STD_VER <= 17 | |
| 2129 | 2148 | |
| 2130 | 2149 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 2131 | 2150 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>> |
| ... | ... | @@ -2134,7 +2153,7 @@ operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, |
| 2134 | 2153 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); |
| 2135 | 2154 | } |
| 2136 | 2155 | |
| 2137 | #endif // #if _LIBCPP_STD_VER <= 17 | |
| 2156 | # endif // #if _LIBCPP_STD_VER <= 17 | |
| 2138 | 2157 | |
| 2139 | 2158 | template <class _Key, class _Tp, class _Compare, class _Allocator> |
| 2140 | 2159 | inline _LIBCPP_HIDE_FROM_ABI void |
| ... | ... | @@ -2143,17 +2162,25 @@ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, multimap<_Key, _Tp, _Compar |
| 2143 | 2162 | __x.swap(__y); |
| 2144 | 2163 | } |
| 2145 | 2164 | |
| 2146 | #if _LIBCPP_STD_VER >= 20 | |
| 2165 | # if _LIBCPP_STD_VER >= 20 | |
| 2147 | 2166 | template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate> |
| 2148 | 2167 | inline _LIBCPP_HIDE_FROM_ABI typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type |
| 2149 | 2168 | erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) { |
| 2150 | 2169 | return std::__libcpp_erase_if_container(__c, __pred); |
| 2151 | 2170 | } |
| 2152 | #endif | |
| 2171 | # endif | |
| 2172 | ||
| 2173 | template <class _Key, class _Tp, class _Compare, class _Allocator> | |
| 2174 | struct __container_traits<multimap<_Key, _Tp, _Compare, _Allocator> > { | |
| 2175 | // http://eel.is/c++draft/associative.reqmts.except#2 | |
| 2176 | // For associative containers, if an exception is thrown by any operation from within | |
| 2177 | // an insert or emplace function inserting a single element, the insertion has no effect. | |
| 2178 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | |
| 2179 | }; | |
| 2153 | 2180 | |
| 2154 | 2181 | _LIBCPP_END_NAMESPACE_STD |
| 2155 | 2182 | |
| 2156 | #if _LIBCPP_STD_VER >= 17 | |
| 2183 | # if _LIBCPP_STD_VER >= 17 | |
| 2157 | 2184 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 2158 | 2185 | namespace pmr { |
| 2159 | 2186 | template <class _KeyT, class _ValueT, class _CompareT = std::less<_KeyT>> |
| ... | ... | @@ -2165,17 +2192,18 @@ using multimap _LIBCPP_AVAILABILITY_PMR = |
| 2165 | 2192 | std::multimap<_KeyT, _ValueT, _CompareT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>; |
| 2166 | 2193 | } // namespace pmr |
| 2167 | 2194 | _LIBCPP_END_NAMESPACE_STD |
| 2168 | #endif | |
| 2195 | # endif | |
| 2169 | 2196 | |
| 2170 | 2197 | _LIBCPP_POP_MACROS |
| 2171 | 2198 | |
| 2172 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 2173 | # include <concepts> | |
| 2174 | # include <cstdlib> | |
| 2175 | # include <functional> | |
| 2176 | # include <iterator> | |
| 2177 | # include <type_traits> | |
| 2178 | # include <utility> | |
| 2179 | #endif | |
| 2199 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 2200 | # include <concepts> | |
| 2201 | # include <cstdlib> | |
| 2202 | # include <functional> | |
| 2203 | # include <iterator> | |
| 2204 | # include <type_traits> | |
| 2205 | # include <utility> | |
| 2206 | # endif | |
| 2207 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 2180 | 2208 | |
| 2181 | 2209 | #endif // _LIBCPP_MAP |
lib/libcxx/include/math.h+90-86| ... | ... | @@ -291,93 +291,96 @@ long double truncl(long double x); |
| 291 | 291 | |
| 292 | 292 | */ |
| 293 | 293 | |
| 294 | # include <__config> | |
| 294 | # if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 295 | # include <__cxx03/math.h> | |
| 296 | # else | |
| 297 | # include <__config> | |
| 295 | 298 | |
| 296 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 297 | # pragma GCC system_header | |
| 298 | # endif | |
| 299 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 300 | # pragma GCC system_header | |
| 301 | # endif | |
| 299 | 302 | |
| 300 | # if __has_include_next(<math.h>) | |
| 301 | # include_next <math.h> | |
| 302 | # endif | |
| 303 | # if __has_include_next(<math.h>) | |
| 304 | # include_next <math.h> | |
| 305 | # endif | |
| 303 | 306 | |
| 304 | # ifdef __cplusplus | |
| 307 | # ifdef __cplusplus | |
| 305 | 308 | |
| 306 | 309 | // We support including .h headers inside 'extern "C"' contexts, so switch |
| 307 | 310 | // back to C++ linkage before including these C++ headers. |
| 308 | 311 | extern "C++" { |
| 309 | 312 | |
| 310 | # ifdef fpclassify | |
| 311 | # undef fpclassify | |
| 312 | # endif | |
| 313 | ||
| 314 | # ifdef signbit | |
| 315 | # undef signbit | |
| 316 | # endif | |
| 317 | ||
| 318 | # ifdef isfinite | |
| 319 | # undef isfinite | |
| 320 | # endif | |
| 321 | ||
| 322 | # ifdef isinf | |
| 323 | # undef isinf | |
| 324 | # endif | |
| 325 | ||
| 326 | # ifdef isnan | |
| 327 | # undef isnan | |
| 328 | # endif | |
| 329 | ||
| 330 | # ifdef isnormal | |
| 331 | # undef isnormal | |
| 332 | # endif | |
| 333 | ||
| 334 | # ifdef isgreater | |
| 335 | # undef isgreater | |
| 336 | # endif | |
| 337 | ||
| 338 | # ifdef isgreaterequal | |
| 339 | # undef isgreaterequal | |
| 340 | # endif | |
| 341 | ||
| 342 | # ifdef isless | |
| 343 | # undef isless | |
| 344 | # endif | |
| 345 | ||
| 346 | # ifdef islessequal | |
| 347 | # undef islessequal | |
| 348 | # endif | |
| 349 | ||
| 350 | # ifdef islessgreater | |
| 351 | # undef islessgreater | |
| 352 | # endif | |
| 353 | ||
| 354 | # ifdef isunordered | |
| 355 | # undef isunordered | |
| 356 | # endif | |
| 357 | ||
| 358 | # include <__math/abs.h> | |
| 359 | # include <__math/copysign.h> | |
| 360 | # include <__math/error_functions.h> | |
| 361 | # include <__math/exponential_functions.h> | |
| 362 | # include <__math/fdim.h> | |
| 363 | # include <__math/fma.h> | |
| 364 | # include <__math/gamma.h> | |
| 365 | # include <__math/hyperbolic_functions.h> | |
| 366 | # include <__math/hypot.h> | |
| 367 | # include <__math/inverse_hyperbolic_functions.h> | |
| 368 | # include <__math/inverse_trigonometric_functions.h> | |
| 369 | # include <__math/logarithms.h> | |
| 370 | # include <__math/min_max.h> | |
| 371 | # include <__math/modulo.h> | |
| 372 | # include <__math/remainder.h> | |
| 373 | # include <__math/roots.h> | |
| 374 | # include <__math/rounding_functions.h> | |
| 375 | # include <__math/traits.h> | |
| 376 | # include <__math/trigonometric_functions.h> | |
| 377 | # include <__type_traits/enable_if.h> | |
| 378 | # include <__type_traits/is_floating_point.h> | |
| 379 | # include <__type_traits/is_integral.h> | |
| 380 | # include <stdlib.h> | |
| 313 | # ifdef fpclassify | |
| 314 | # undef fpclassify | |
| 315 | # endif | |
| 316 | ||
| 317 | # ifdef signbit | |
| 318 | # undef signbit | |
| 319 | # endif | |
| 320 | ||
| 321 | # ifdef isfinite | |
| 322 | # undef isfinite | |
| 323 | # endif | |
| 324 | ||
| 325 | # ifdef isinf | |
| 326 | # undef isinf | |
| 327 | # endif | |
| 328 | ||
| 329 | # ifdef isnan | |
| 330 | # undef isnan | |
| 331 | # endif | |
| 332 | ||
| 333 | # ifdef isnormal | |
| 334 | # undef isnormal | |
| 335 | # endif | |
| 336 | ||
| 337 | # ifdef isgreater | |
| 338 | # undef isgreater | |
| 339 | # endif | |
| 340 | ||
| 341 | # ifdef isgreaterequal | |
| 342 | # undef isgreaterequal | |
| 343 | # endif | |
| 344 | ||
| 345 | # ifdef isless | |
| 346 | # undef isless | |
| 347 | # endif | |
| 348 | ||
| 349 | # ifdef islessequal | |
| 350 | # undef islessequal | |
| 351 | # endif | |
| 352 | ||
| 353 | # ifdef islessgreater | |
| 354 | # undef islessgreater | |
| 355 | # endif | |
| 356 | ||
| 357 | # ifdef isunordered | |
| 358 | # undef isunordered | |
| 359 | # endif | |
| 360 | ||
| 361 | # include <__math/abs.h> | |
| 362 | # include <__math/copysign.h> | |
| 363 | # include <__math/error_functions.h> | |
| 364 | # include <__math/exponential_functions.h> | |
| 365 | # include <__math/fdim.h> | |
| 366 | # include <__math/fma.h> | |
| 367 | # include <__math/gamma.h> | |
| 368 | # include <__math/hyperbolic_functions.h> | |
| 369 | # include <__math/hypot.h> | |
| 370 | # include <__math/inverse_hyperbolic_functions.h> | |
| 371 | # include <__math/inverse_trigonometric_functions.h> | |
| 372 | # include <__math/logarithms.h> | |
| 373 | # include <__math/min_max.h> | |
| 374 | # include <__math/modulo.h> | |
| 375 | # include <__math/remainder.h> | |
| 376 | # include <__math/roots.h> | |
| 377 | # include <__math/rounding_functions.h> | |
| 378 | # include <__math/traits.h> | |
| 379 | # include <__math/trigonometric_functions.h> | |
| 380 | # include <__type_traits/enable_if.h> | |
| 381 | # include <__type_traits/is_floating_point.h> | |
| 382 | # include <__type_traits/is_integral.h> | |
| 383 | # include <stdlib.h> | |
| 381 | 384 | |
| 382 | 385 | // fpclassify relies on implementation-defined constants, so we can't move it to a detail header |
| 383 | 386 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -388,22 +391,22 @@ namespace __math { |
| 388 | 391 | |
| 389 | 392 | // template on non-double overloads to make them weaker than same overloads from MSVC runtime |
| 390 | 393 | template <class = int> |
| 391 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT { | |
| 394 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT { | |
| 392 | 395 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); |
| 393 | 396 | } |
| 394 | 397 | |
| 395 | 398 | template <class = int> |
| 396 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT { | |
| 399 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT { | |
| 397 | 400 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); |
| 398 | 401 | } |
| 399 | 402 | |
| 400 | 403 | template <class = int> |
| 401 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT { | |
| 404 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT { | |
| 402 | 405 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); |
| 403 | 406 | } |
| 404 | 407 | |
| 405 | 408 | template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> |
| 406 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { | |
| 409 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { | |
| 407 | 410 | return __x == 0 ? FP_ZERO : FP_NORMAL; |
| 408 | 411 | } |
| 409 | 412 | |
| ... | ... | @@ -415,7 +418,7 @@ using std::__math::fpclassify; |
| 415 | 418 | using std::__math::signbit; |
| 416 | 419 | |
| 417 | 420 | // The MSVC runtime already provides these functions as templates |
| 418 | # ifndef _LIBCPP_MSVCRT | |
| 421 | # ifndef _LIBCPP_MSVCRT | |
| 419 | 422 | using std::__math::isfinite; |
| 420 | 423 | using std::__math::isgreater; |
| 421 | 424 | using std::__math::isgreaterequal; |
| ... | ... | @@ -426,7 +429,7 @@ using std::__math::islessgreater; |
| 426 | 429 | using std::__math::isnan; |
| 427 | 430 | using std::__math::isnormal; |
| 428 | 431 | using std::__math::isunordered; |
| 429 | # endif // _LIBCPP_MSVCRT | |
| 432 | # endif // _LIBCPP_MSVCRT | |
| 430 | 433 | |
| 431 | 434 | // abs |
| 432 | 435 | // |
| ... | ... | @@ -501,7 +504,8 @@ using std::__math::trunc; |
| 501 | 504 | |
| 502 | 505 | } // extern "C++" |
| 503 | 506 | |
| 504 | # endif // __cplusplus | |
| 507 | # endif // __cplusplus | |
| 508 | # endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 505 | 509 | |
| 506 | 510 | #else // _LIBCPP_MATH_H |
| 507 | 511 |
lib/libcxx/include/mdspan+21-26| ... | ... | @@ -408,31 +408,26 @@ namespace std { |
| 408 | 408 | #ifndef _LIBCPP_MDSPAN |
| 409 | 409 | #define _LIBCPP_MDSPAN |
| 410 | 410 | |
| 411 | #include <__config> | |
| 412 | ||
| 413 | #if _LIBCPP_STD_VER >= 23 | |
| 414 | # include <__fwd/mdspan.h> | |
| 415 | # include <__mdspan/default_accessor.h> | |
| 416 | # include <__mdspan/extents.h> | |
| 417 | # include <__mdspan/layout_left.h> | |
| 418 | # include <__mdspan/layout_right.h> | |
| 419 | # include <__mdspan/layout_stride.h> | |
| 420 | # include <__mdspan/mdspan.h> | |
| 421 | #endif | |
| 422 | ||
| 423 | #include <version> | |
| 424 | ||
| 425 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 426 | # pragma GCC system_header | |
| 427 | #endif | |
| 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 | |
| 411 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 412 | # include <__cxx03/mdspan> | |
| 413 | #else | |
| 414 | # include <__config> | |
| 415 | ||
| 416 | # if _LIBCPP_STD_VER >= 23 | |
| 417 | # include <__fwd/mdspan.h> | |
| 418 | # include <__mdspan/default_accessor.h> | |
| 419 | # include <__mdspan/extents.h> | |
| 420 | # include <__mdspan/layout_left.h> | |
| 421 | # include <__mdspan/layout_right.h> | |
| 422 | # include <__mdspan/layout_stride.h> | |
| 423 | # include <__mdspan/mdspan.h> | |
| 424 | # endif | |
| 425 | ||
| 426 | # include <version> | |
| 427 | ||
| 428 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 429 | # pragma GCC system_header | |
| 430 | # endif | |
| 431 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 437 | 432 | |
| 438 | 433 | #endif // _LIBCPP_MDSPAN |
lib/libcxx/include/memory+58-54| ... | ... | @@ -182,8 +182,8 @@ public: |
| 182 | 182 | raw_storage_iterator operator++(int); |
| 183 | 183 | }; |
| 184 | 184 | |
| 185 | template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept; | |
| 186 | template <class T> void return_temporary_buffer(T* p) noexcept; | |
| 185 | template <class T> pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) noexcept; // deprecated in C++17, removed in C++20 | |
| 186 | template <class T> void return_temporary_buffer(T* p) noexcept; // deprecated in C++17, removed in C++20 | |
| 187 | 187 | |
| 188 | 188 | template <class T> T* addressof(T& r) noexcept; |
| 189 | 189 | template <class T> T* addressof(const T&& r) noexcept = delete; |
| ... | ... | @@ -934,65 +934,69 @@ template<class Pointer = void, class Smart, class... Args> |
| 934 | 934 | |
| 935 | 935 | // clang-format on |
| 936 | 936 | |
| 937 | #include <__config> | |
| 938 | #include <__memory/addressof.h> | |
| 939 | #include <__memory/align.h> | |
| 940 | #include <__memory/allocator.h> | |
| 941 | #include <__memory/allocator_arg_t.h> | |
| 942 | #include <__memory/allocator_traits.h> | |
| 943 | #include <__memory/auto_ptr.h> | |
| 944 | #include <__memory/inout_ptr.h> | |
| 945 | #include <__memory/out_ptr.h> | |
| 946 | #include <__memory/pointer_traits.h> | |
| 947 | #include <__memory/raw_storage_iterator.h> | |
| 948 | #include <__memory/shared_ptr.h> | |
| 949 | #include <__memory/temporary_buffer.h> | |
| 950 | #include <__memory/uninitialized_algorithms.h> | |
| 951 | #include <__memory/unique_ptr.h> | |
| 952 | #include <__memory/uses_allocator.h> | |
| 937 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 938 | # include <__cxx03/memory> | |
| 939 | #else | |
| 940 | # include <__config> | |
| 941 | # include <__memory/addressof.h> | |
| 942 | # include <__memory/align.h> | |
| 943 | # include <__memory/allocator.h> | |
| 944 | # include <__memory/allocator_arg_t.h> | |
| 945 | # include <__memory/allocator_traits.h> | |
| 946 | # include <__memory/auto_ptr.h> | |
| 947 | # include <__memory/inout_ptr.h> | |
| 948 | # include <__memory/out_ptr.h> | |
| 949 | # include <__memory/pointer_traits.h> | |
| 950 | # include <__memory/raw_storage_iterator.h> | |
| 951 | # include <__memory/shared_ptr.h> | |
| 952 | # include <__memory/temporary_buffer.h> | |
| 953 | # include <__memory/uninitialized_algorithms.h> | |
| 954 | # include <__memory/unique_ptr.h> | |
| 955 | # include <__memory/uses_allocator.h> | |
| 953 | 956 | |
| 954 | 957 | // standard-mandated includes |
| 955 | 958 | |
| 956 | #if _LIBCPP_STD_VER >= 17 | |
| 957 | # include <__memory/construct_at.h> | |
| 958 | #endif | |
| 959 | # if _LIBCPP_STD_VER >= 17 | |
| 960 | # include <__memory/construct_at.h> | |
| 961 | # endif | |
| 959 | 962 | |
| 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 | |
| 963 | # if _LIBCPP_STD_VER >= 20 | |
| 964 | # include <__memory/assume_aligned.h> | |
| 965 | # include <__memory/concepts.h> | |
| 966 | # include <__memory/ranges_construct_at.h> | |
| 967 | # include <__memory/ranges_uninitialized_algorithms.h> | |
| 968 | # include <__memory/uses_allocator_construction.h> | |
| 969 | # endif | |
| 967 | 970 | |
| 968 | #if _LIBCPP_STD_VER >= 23 | |
| 969 | # include <__memory/allocate_at_least.h> | |
| 970 | #endif | |
| 971 | # if _LIBCPP_STD_VER >= 23 | |
| 972 | # include <__memory/allocate_at_least.h> | |
| 973 | # endif | |
| 971 | 974 | |
| 972 | #include <version> | |
| 975 | # include <version> | |
| 973 | 976 | |
| 974 | 977 | // [memory.syn] |
| 975 | #include <compare> | |
| 976 | ||
| 977 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 978 | # pragma GCC system_header | |
| 979 | #endif | |
| 980 | ||
| 981 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 982 | # include <atomic> | |
| 983 | # include <concepts> | |
| 984 | # include <cstddef> | |
| 985 | # include <cstdint> | |
| 986 | # include <cstdlib> | |
| 987 | # include <cstring> | |
| 988 | # include <iosfwd> | |
| 989 | # include <iterator> | |
| 990 | # include <new> | |
| 991 | # include <stdexcept> | |
| 992 | # include <tuple> | |
| 993 | # include <type_traits> | |
| 994 | # include <typeinfo> | |
| 995 | # include <utility> | |
| 996 | #endif | |
| 978 | # include <compare> | |
| 979 | ||
| 980 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 981 | # pragma GCC system_header | |
| 982 | # endif | |
| 983 | ||
| 984 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 985 | # include <atomic> | |
| 986 | # include <concepts> | |
| 987 | # include <cstddef> | |
| 988 | # include <cstdint> | |
| 989 | # include <cstdlib> | |
| 990 | # include <cstring> | |
| 991 | # include <iosfwd> | |
| 992 | # include <iterator> | |
| 993 | # include <new> | |
| 994 | # include <stdexcept> | |
| 995 | # include <tuple> | |
| 996 | # include <type_traits> | |
| 997 | # include <typeinfo> | |
| 998 | # include <utility> | |
| 999 | # endif | |
| 1000 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 997 | 1001 | |
| 998 | 1002 | #endif // _LIBCPP_MEMORY |
lib/libcxx/include/memory_resource+28-30| ... | ... | @@ -49,35 +49,33 @@ namespace std::pmr { |
| 49 | 49 | |
| 50 | 50 | */ |
| 51 | 51 | |
| 52 | #include <__config> | |
| 53 | ||
| 54 | #if _LIBCPP_STD_VER >= 17 | |
| 55 | # include <__memory_resource/memory_resource.h> | |
| 56 | # include <__memory_resource/monotonic_buffer_resource.h> | |
| 57 | # include <__memory_resource/polymorphic_allocator.h> | |
| 58 | # include <__memory_resource/pool_options.h> | |
| 59 | # include <__memory_resource/synchronized_pool_resource.h> | |
| 60 | # include <__memory_resource/unsynchronized_pool_resource.h> | |
| 61 | #endif | |
| 62 | ||
| 63 | #include <version> | |
| 64 | ||
| 65 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 66 | # pragma GCC system_header | |
| 67 | #endif | |
| 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 | ||
| 79 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 80 | # include <stdexcept> | |
| 81 | #endif | |
| 52 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 53 | # include <__cxx03/memory_resource> | |
| 54 | #else | |
| 55 | # include <__config> | |
| 56 | ||
| 57 | # if _LIBCPP_STD_VER >= 17 | |
| 58 | # include <__memory_resource/memory_resource.h> | |
| 59 | # include <__memory_resource/monotonic_buffer_resource.h> | |
| 60 | # include <__memory_resource/polymorphic_allocator.h> | |
| 61 | # include <__memory_resource/pool_options.h> | |
| 62 | # include <__memory_resource/synchronized_pool_resource.h> | |
| 63 | # include <__memory_resource/unsynchronized_pool_resource.h> | |
| 64 | # endif | |
| 65 | ||
| 66 | # include <version> | |
| 67 | ||
| 68 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 69 | # pragma GCC system_header | |
| 70 | # endif | |
| 71 | ||
| 72 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER >= 17 && _LIBCPP_STD_VER <= 20 | |
| 73 | # include <mutex> | |
| 74 | # endif | |
| 75 | ||
| 76 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 77 | # include <stdexcept> | |
| 78 | # endif | |
| 79 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 82 | 80 | |
| 83 | 81 | #endif /* _LIBCPP_MEMORY_RESOURCE */ |
lib/libcxx/include/mutex+48-46| ... | ... | @@ -186,36 +186,37 @@ template<class Callable, class ...Args> |
| 186 | 186 | |
| 187 | 187 | */ |
| 188 | 188 | |
| 189 | #include <__chrono/steady_clock.h> | |
| 190 | #include <__chrono/time_point.h> | |
| 191 | #include <__condition_variable/condition_variable.h> | |
| 192 | #include <__config> | |
| 193 | #include <__memory/shared_ptr.h> | |
| 194 | #include <__mutex/lock_guard.h> | |
| 195 | #include <__mutex/mutex.h> | |
| 196 | #include <__mutex/once_flag.h> | |
| 197 | #include <__mutex/tag_types.h> | |
| 198 | #include <__mutex/unique_lock.h> | |
| 199 | #include <__thread/id.h> | |
| 200 | #include <__thread/support.h> | |
| 201 | #include <__utility/forward.h> | |
| 202 | #include <cstddef> | |
| 203 | #include <limits> | |
| 204 | #ifndef _LIBCPP_CXX03_LANG | |
| 205 | # include <tuple> | |
| 206 | #endif | |
| 207 | #include <version> | |
| 208 | ||
| 209 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 210 | # pragma GCC system_header | |
| 211 | #endif | |
| 189 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 190 | # include <__cxx03/mutex> | |
| 191 | #else | |
| 192 | # include <__chrono/steady_clock.h> | |
| 193 | # include <__chrono/time_point.h> | |
| 194 | # include <__condition_variable/condition_variable.h> | |
| 195 | # include <__config> | |
| 196 | # include <__mutex/lock_guard.h> | |
| 197 | # include <__mutex/mutex.h> | |
| 198 | # include <__mutex/once_flag.h> | |
| 199 | # include <__mutex/tag_types.h> | |
| 200 | # include <__mutex/unique_lock.h> | |
| 201 | # include <__thread/id.h> | |
| 202 | # include <__thread/support.h> | |
| 203 | # include <__utility/forward.h> | |
| 204 | # include <limits> | |
| 205 | # ifndef _LIBCPP_CXX03_LANG | |
| 206 | # include <tuple> | |
| 207 | # endif | |
| 208 | # include <version> | |
| 209 | ||
| 210 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 211 | # pragma GCC system_header | |
| 212 | # endif | |
| 212 | 213 | |
| 213 | 214 | _LIBCPP_PUSH_MACROS |
| 214 | #include <__undef_macros> | |
| 215 | # include <__undef_macros> | |
| 215 | 216 | |
| 216 | 217 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 217 | 218 | |
| 218 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 219 | # if _LIBCPP_HAS_THREADS | |
| 219 | 220 | |
| 220 | 221 | class _LIBCPP_EXPORTED_FROM_ABI recursive_mutex { |
| 221 | 222 | __libcpp_recursive_mutex_t __m_; |
| ... | ... | @@ -335,7 +336,7 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) { |
| 335 | 336 | return 0; |
| 336 | 337 | } |
| 337 | 338 | |
| 338 | # ifndef _LIBCPP_CXX03_LANG | |
| 339 | # ifndef _LIBCPP_CXX03_LANG | |
| 339 | 340 | |
| 340 | 341 | template <class _L0, class _L1, class _L2, class... _L3> |
| 341 | 342 | _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { |
| ... | ... | @@ -351,7 +352,7 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3 |
| 351 | 352 | return __r; |
| 352 | 353 | } |
| 353 | 354 | |
| 354 | # endif // _LIBCPP_CXX03_LANG | |
| 355 | # endif // _LIBCPP_CXX03_LANG | |
| 355 | 356 | |
| 356 | 357 | template <class _L0, class _L1> |
| 357 | 358 | _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) { |
| ... | ... | @@ -375,7 +376,7 @@ _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) { |
| 375 | 376 | } |
| 376 | 377 | } |
| 377 | 378 | |
| 378 | # ifndef _LIBCPP_CXX03_LANG | |
| 379 | # ifndef _LIBCPP_CXX03_LANG | |
| 379 | 380 | |
| 380 | 381 | template <class _L0, class _L1, class _L2, class... _L3> |
| 381 | 382 | void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) { |
| ... | ... | @@ -418,9 +419,9 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... |
| 418 | 419 | std::__lock_first(0, __l0, __l1, __l2, __l3...); |
| 419 | 420 | } |
| 420 | 421 | |
| 421 | # endif // _LIBCPP_CXX03_LANG | |
| 422 | # endif // _LIBCPP_CXX03_LANG | |
| 422 | 423 | |
| 423 | # if _LIBCPP_STD_VER >= 17 | |
| 424 | # if _LIBCPP_STD_VER >= 17 | |
| 424 | 425 | template <class... _Mutexes> |
| 425 | 426 | class _LIBCPP_TEMPLATE_VIS scoped_lock; |
| 426 | 427 | |
| ... | ... | @@ -491,26 +492,27 @@ private: |
| 491 | 492 | }; |
| 492 | 493 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock); |
| 493 | 494 | |
| 494 | # endif // _LIBCPP_STD_VER >= 17 | |
| 495 | #endif // !_LIBCPP_HAS_NO_THREADS | |
| 495 | # endif // _LIBCPP_STD_VER >= 17 | |
| 496 | # endif // _LIBCPP_HAS_THREADS | |
| 496 | 497 | |
| 497 | 498 | _LIBCPP_END_NAMESPACE_STD |
| 498 | 499 | |
| 499 | 500 | _LIBCPP_POP_MACROS |
| 500 | 501 | |
| 501 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 502 | # include <atomic> | |
| 503 | # include <concepts> | |
| 504 | # include <cstdlib> | |
| 505 | # include <cstring> | |
| 506 | # include <ctime> | |
| 507 | # include <initializer_list> | |
| 508 | # include <iosfwd> | |
| 509 | # include <new> | |
| 510 | # include <stdexcept> | |
| 511 | # include <system_error> | |
| 512 | # include <type_traits> | |
| 513 | # include <typeinfo> | |
| 514 | #endif | |
| 502 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 503 | # include <atomic> | |
| 504 | # include <concepts> | |
| 505 | # include <cstdlib> | |
| 506 | # include <cstring> | |
| 507 | # include <ctime> | |
| 508 | # include <initializer_list> | |
| 509 | # include <iosfwd> | |
| 510 | # include <new> | |
| 511 | # include <stdexcept> | |
| 512 | # include <system_error> | |
| 513 | # include <type_traits> | |
| 514 | # include <typeinfo> | |
| 515 | # endif | |
| 516 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 515 | 517 | |
| 516 | 518 | #endif // _LIBCPP_MUTEX |
lib/libcxx/include/new+28-266| ... | ... | @@ -79,284 +79,46 @@ void operator delete[](void* ptr, const std::nothrow_t&) noexcept; // repla |
| 79 | 79 | void operator delete[](void* ptr, std::align_val_t alignment, |
| 80 | 80 | const std::nothrow_t&) noexcept; // replaceable, C++17 |
| 81 | 81 | |
| 82 | void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++20 | |
| 83 | void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++20 | |
| 82 | void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++20, constexpr since C++26 | |
| 83 | void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++20, constexpr since C++26 | |
| 84 | 84 | void operator delete (void* ptr, void*) noexcept; |
| 85 | 85 | void operator delete[](void* ptr, void*) noexcept; |
| 86 | 86 | |
| 87 | 87 | */ |
| 88 | 88 | |
| 89 | #include <__config> | |
| 90 | #include <__exception/exception.h> | |
| 91 | #include <__type_traits/is_function.h> | |
| 92 | #include <__type_traits/is_same.h> | |
| 93 | #include <__type_traits/remove_cv.h> | |
| 94 | #include <__verbose_abort> | |
| 95 | #include <cstddef> | |
| 96 | #include <version> | |
| 97 | ||
| 98 | #if defined(_LIBCPP_ABI_VCRUNTIME) | |
| 99 | # include <new.h> | |
| 100 | #endif | |
| 101 | ||
| 102 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 103 | # pragma GCC system_header | |
| 104 | #endif | |
| 105 | ||
| 106 | #if !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309L | |
| 107 | # define _LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION | |
| 108 | #endif | |
| 109 | ||
| 110 | #if !defined(_LIBCPP_BUILDING_LIBRARY) && _LIBCPP_STD_VER < 14 && defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION) | |
| 111 | # define _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION | |
| 112 | #endif | |
| 113 | ||
| 114 | #if defined(_LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION) || defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION) | |
| 115 | # define _LIBCPP_HAS_NO_SIZED_DEALLOCATION | |
| 116 | #endif | |
| 117 | ||
| 118 | namespace std // purposefully not using versioning namespace | |
| 119 | { | |
| 120 | ||
| 121 | #if !defined(_LIBCPP_ABI_VCRUNTIME) | |
| 122 | struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t { | |
| 123 | explicit nothrow_t() = default; | |
| 124 | }; | |
| 125 | extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow; | |
| 126 | ||
| 127 | class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception { | |
| 128 | public: | |
| 129 | bad_alloc() _NOEXCEPT; | |
| 130 | _LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default; | |
| 131 | _LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default; | |
| 132 | ~bad_alloc() _NOEXCEPT override; | |
| 133 | const char* what() const _NOEXCEPT override; | |
| 134 | }; | |
| 135 | ||
| 136 | class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length : public bad_alloc { | |
| 137 | public: | |
| 138 | bad_array_new_length() _NOEXCEPT; | |
| 139 | _LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default; | |
| 140 | _LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default; | |
| 141 | ~bad_array_new_length() _NOEXCEPT override; | |
| 142 | const char* what() const _NOEXCEPT override; | |
| 143 | }; | |
| 144 | ||
| 145 | typedef void (*new_handler)(); | |
| 146 | _LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT; | |
| 147 | _LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT; | |
| 148 | ||
| 149 | #elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 // !_LIBCPP_ABI_VCRUNTIME | |
| 150 | ||
| 151 | // When _HAS_EXCEPTIONS == 0, these complete definitions are needed, | |
| 152 | // since they would normally be provided in vcruntime_exception.h | |
| 153 | class bad_alloc : public exception { | |
| 154 | public: | |
| 155 | bad_alloc() noexcept : exception("bad allocation") {} | |
| 156 | ||
| 157 | private: | |
| 158 | friend class bad_array_new_length; | |
| 159 | ||
| 160 | bad_alloc(char const* const __message) noexcept : exception(__message) {} | |
| 161 | }; | |
| 162 | ||
| 163 | class bad_array_new_length : public bad_alloc { | |
| 164 | public: | |
| 165 | bad_array_new_length() noexcept : bad_alloc("bad array new length") {} | |
| 166 | }; | |
| 167 | #endif // defined(_LIBCPP_ABI_VCRUNTIME) && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS == 0 | |
| 168 | ||
| 169 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_bad_alloc(); // not in C++ spec | |
| 170 | ||
| 171 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_array_new_length() { | |
| 172 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 173 | throw bad_array_new_length(); | |
| 174 | #else | |
| 175 | _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode"); | |
| 176 | #endif | |
| 177 | } | |
| 178 | ||
| 179 | #if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) && !defined(_LIBCPP_ABI_VCRUNTIME) | |
| 180 | # ifndef _LIBCPP_CXX03_LANG | |
| 181 | enum class align_val_t : size_t {}; | |
| 182 | # else | |
| 183 | enum align_val_t { __zero = 0, __max = (size_t)-1 }; | |
| 184 | # endif | |
| 185 | #endif | |
| 186 | ||
| 187 | #if _LIBCPP_STD_VER >= 20 | |
| 188 | // Enable the declaration even if the compiler doesn't support the language | |
| 189 | // feature. | |
| 190 | struct destroying_delete_t { | |
| 191 | explicit destroying_delete_t() = default; | |
| 192 | }; | |
| 193 | inline constexpr destroying_delete_t destroying_delete{}; | |
| 194 | #endif // _LIBCPP_STD_VER >= 20 | |
| 195 | ||
| 196 | } // namespace std | |
| 197 | ||
| 198 | #if defined(_LIBCPP_CXX03_LANG) | |
| 199 | # define _THROW_BAD_ALLOC throw(std::bad_alloc) | |
| 89 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 90 | # include <__cxx03/new> | |
| 200 | 91 | #else |
| 201 | # define _THROW_BAD_ALLOC | |
| 202 | #endif | |
| 203 | ||
| 204 | #if !defined(_LIBCPP_ABI_VCRUNTIME) | |
| 205 | ||
| 206 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC; | |
| 207 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT | |
| 208 | _LIBCPP_NOALIAS; | |
| 209 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; | |
| 210 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; | |
| 211 | # ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION | |
| 212 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; | |
| 92 | # include <__config> | |
| 93 | # include <__new/align_val_t.h> | |
| 94 | # include <__new/allocate.h> | |
| 95 | # include <__new/exceptions.h> | |
| 96 | # include <__new/global_new_delete.h> | |
| 97 | # include <__new/new_handler.h> | |
| 98 | # include <__new/nothrow_t.h> | |
| 99 | # include <__new/placement_new_delete.h> | |
| 100 | ||
| 101 | # if _LIBCPP_STD_VER >= 17 | |
| 102 | # include <__new/interference_size.h> | |
| 103 | # include <__new/launder.h> | |
| 213 | 104 | # endif |
| 214 | 105 | |
| 215 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC; | |
| 216 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT | |
| 217 | _LIBCPP_NOALIAS; | |
| 218 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; | |
| 219 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; | |
| 220 | # ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION | |
| 221 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT; | |
| 106 | # if _LIBCPP_STD_VER >= 20 | |
| 107 | # include <__new/destroying_delete_t.h> | |
| 222 | 108 | # endif |
| 223 | 109 | |
| 224 | # ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 225 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; | |
| 226 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* | |
| 227 | operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; | |
| 228 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; | |
| 229 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; | |
| 230 | # ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION | |
| 231 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; | |
| 232 | # endif | |
| 110 | // feature-test macros | |
| 111 | # include <version> | |
| 233 | 112 | |
| 234 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* | |
| 235 | operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; | |
| 236 | _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* | |
| 237 | operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; | |
| 238 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; | |
| 239 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; | |
| 240 | # ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION | |
| 241 | _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; | |
| 242 | # endif | |
| 113 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 114 | # pragma GCC system_header | |
| 243 | 115 | # endif |
| 244 | 116 | |
| 245 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI void* operator new(std::size_t, void* __p) _NOEXCEPT { return __p; } | |
| 246 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI void* operator new[](std::size_t, void* __p) _NOEXCEPT { return __p; } | |
| 247 | inline _LIBCPP_HIDE_FROM_ABI void operator delete(void*, void*) _NOEXCEPT {} | |
| 248 | inline _LIBCPP_HIDE_FROM_ABI void operator delete[](void*, void*) _NOEXCEPT {} | |
| 249 | ||
| 250 | #endif // !_LIBCPP_ABI_VCRUNTIME | |
| 251 | ||
| 252 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 253 | ||
| 254 | _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(size_t __align) _NOEXCEPT { | |
| 255 | #ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__ | |
| 256 | return __align > __STDCPP_DEFAULT_NEW_ALIGNMENT__; | |
| 257 | #else | |
| 258 | return __align > _LIBCPP_ALIGNOF(max_align_t); | |
| 259 | #endif | |
| 260 | } | |
| 261 | ||
| 262 | template <class... _Args> | |
| 263 | _LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) { | |
| 264 | #if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) | |
| 265 | return __builtin_operator_new(__args...); | |
| 266 | #else | |
| 267 | return ::operator new(__args...); | |
| 268 | #endif | |
| 269 | } | |
| 270 | ||
| 271 | template <class... _Args> | |
| 272 | _LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) { | |
| 273 | #if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete) | |
| 274 | __builtin_operator_delete(__args...); | |
| 275 | #else | |
| 276 | ::operator delete(__args...); | |
| 277 | #endif | |
| 278 | } | |
| 279 | ||
| 280 | inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __align) { | |
| 281 | #ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION | |
| 282 | if (__is_overaligned_for_new(__align)) { | |
| 283 | const align_val_t __align_val = static_cast<align_val_t>(__align); | |
| 284 | return __libcpp_operator_new(__size, __align_val); | |
| 285 | } | |
| 286 | #endif | |
| 287 | ||
| 288 | (void)__align; | |
| 289 | return __libcpp_operator_new(__size); | |
| 290 | } | |
| 291 | ||
| 292 | template <class... _Args> | |
| 293 | _LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) { | |
| 294 | #ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION | |
| 295 | (void)__size; | |
| 296 | return std::__libcpp_operator_delete(__ptr, __args...); | |
| 297 | #else | |
| 298 | return std::__libcpp_operator_delete(__ptr, __size, __args...); | |
| 299 | #endif | |
| 300 | } | |
| 301 | ||
| 302 | inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) { | |
| 303 | #if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) | |
| 304 | (void)__align; | |
| 305 | return __do_deallocate_handle_size(__ptr, __size); | |
| 306 | #else | |
| 307 | if (__is_overaligned_for_new(__align)) { | |
| 308 | const align_val_t __align_val = static_cast<align_val_t>(__align); | |
| 309 | return __do_deallocate_handle_size(__ptr, __size, __align_val); | |
| 310 | } else { | |
| 311 | return __do_deallocate_handle_size(__ptr, __size); | |
| 312 | } | |
| 313 | #endif | |
| 314 | } | |
| 315 | ||
| 316 | inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) { | |
| 317 | #if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) | |
| 318 | (void)__align; | |
| 319 | return __libcpp_operator_delete(__ptr); | |
| 320 | #else | |
| 321 | if (__is_overaligned_for_new(__align)) { | |
| 322 | const align_val_t __align_val = static_cast<align_val_t>(__align); | |
| 323 | return __libcpp_operator_delete(__ptr, __align_val); | |
| 324 | } else { | |
| 325 | return __libcpp_operator_delete(__ptr); | |
| 326 | } | |
| 327 | #endif | |
| 328 | } | |
| 329 | ||
| 330 | template <class _Tp> | |
| 331 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT { | |
| 332 | static_assert(!(is_function<_Tp>::value), "can't launder functions"); | |
| 333 | static_assert(!(is_same<void, __remove_cv_t<_Tp> >::value), "can't launder cv-void"); | |
| 334 | return __builtin_launder(__p); | |
| 335 | } | |
| 336 | ||
| 337 | #if _LIBCPP_STD_VER >= 17 | |
| 338 | template <class _Tp> | |
| 339 | [[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept { | |
| 340 | return std::__launder(__p); | |
| 341 | } | |
| 342 | #endif | |
| 343 | ||
| 344 | #if _LIBCPP_STD_VER >= 17 | |
| 345 | ||
| 346 | # if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) | |
| 347 | ||
| 348 | inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE; | |
| 349 | inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE; | |
| 350 | ||
| 351 | # endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) | |
| 352 | ||
| 353 | #endif // _LIBCPP_STD_VER >= 17 | |
| 354 | ||
| 355 | _LIBCPP_END_NAMESPACE_STD | |
| 356 | ||
| 357 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 358 | # include <cstdlib> | |
| 359 | # include <type_traits> | |
| 360 | #endif | |
| 117 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 118 | # include <cstddef> | |
| 119 | # include <cstdlib> | |
| 120 | # include <type_traits> | |
| 121 | # endif | |
| 122 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 361 | 123 | |
| 362 | 124 | #endif // _LIBCPP_NEW |
lib/libcxx/include/numbers+17-12| ... | ... | @@ -58,15 +58,18 @@ namespace std::numbers { |
| 58 | 58 | } |
| 59 | 59 | */ |
| 60 | 60 | |
| 61 | #include <__concepts/arithmetic.h> | |
| 62 | #include <__config> | |
| 63 | #include <version> | |
| 61 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 62 | # include <__cxx03/numbers> | |
| 63 | #else | |
| 64 | # include <__concepts/arithmetic.h> | |
| 65 | # include <__config> | |
| 66 | # include <version> | |
| 64 | 67 | |
| 65 | #if _LIBCPP_STD_VER >= 20 | |
| 68 | # if _LIBCPP_STD_VER >= 20 | |
| 66 | 69 | |
| 67 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 68 | # pragma GCC system_header | |
| 69 | # endif | |
| 70 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 71 | # pragma GCC system_header | |
| 72 | # endif | |
| 70 | 73 | |
| 71 | 74 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 72 | 75 | |
| ... | ... | @@ -154,11 +157,13 @@ inline constexpr double phi = phi_v<double>; |
| 154 | 157 | |
| 155 | 158 | _LIBCPP_END_NAMESPACE_STD |
| 156 | 159 | |
| 157 | #endif // _LIBCPP_STD_VER >= 20 | |
| 160 | # endif // _LIBCPP_STD_VER >= 20 | |
| 158 | 161 | |
| 159 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 160 | # include <concepts> | |
| 161 | # include <type_traits> | |
| 162 | #endif | |
| 162 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 163 | # include <concepts> | |
| 164 | # include <cstddef> | |
| 165 | # include <type_traits> | |
| 166 | # endif | |
| 167 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 163 | 168 | |
| 164 | 169 | #endif // _LIBCPP_NUMBERS |
lib/libcxx/include/numeric+51-47| ... | ... | @@ -156,52 +156,56 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin |
| 156 | 156 | |
| 157 | 157 | */ |
| 158 | 158 | |
| 159 | #include <__config> | |
| 160 | ||
| 161 | #include <__numeric/accumulate.h> | |
| 162 | #include <__numeric/adjacent_difference.h> | |
| 163 | #include <__numeric/inner_product.h> | |
| 164 | #include <__numeric/iota.h> | |
| 165 | #include <__numeric/partial_sum.h> | |
| 166 | ||
| 167 | #if _LIBCPP_STD_VER >= 17 | |
| 168 | # include <__numeric/exclusive_scan.h> | |
| 169 | # include <__numeric/gcd_lcm.h> | |
| 170 | # include <__numeric/inclusive_scan.h> | |
| 171 | # include <__numeric/pstl.h> | |
| 172 | # include <__numeric/reduce.h> | |
| 173 | # include <__numeric/transform_exclusive_scan.h> | |
| 174 | # include <__numeric/transform_inclusive_scan.h> | |
| 175 | # include <__numeric/transform_reduce.h> | |
| 176 | #endif | |
| 177 | ||
| 178 | #if _LIBCPP_STD_VER >= 20 | |
| 179 | # include <__numeric/midpoint.h> | |
| 180 | # include <__numeric/saturation_arithmetic.h> | |
| 181 | #endif | |
| 182 | ||
| 183 | #include <version> | |
| 184 | ||
| 185 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 186 | # pragma GCC system_header | |
| 187 | #endif | |
| 188 | ||
| 189 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 | |
| 190 | # include <initializer_list> | |
| 191 | # include <limits> | |
| 192 | #endif | |
| 193 | ||
| 194 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 195 | # include <climits> | |
| 196 | # include <cmath> | |
| 197 | # include <concepts> | |
| 198 | # include <cstdint> | |
| 199 | # include <execution> | |
| 200 | # include <functional> | |
| 201 | # include <iterator> | |
| 202 | # include <new> | |
| 203 | # include <optional> | |
| 204 | # include <type_traits> | |
| 205 | #endif | |
| 159 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 160 | # include <__cxx03/numeric> | |
| 161 | #else | |
| 162 | # include <__config> | |
| 163 | ||
| 164 | # include <__numeric/accumulate.h> | |
| 165 | # include <__numeric/adjacent_difference.h> | |
| 166 | # include <__numeric/inner_product.h> | |
| 167 | # include <__numeric/iota.h> | |
| 168 | # include <__numeric/partial_sum.h> | |
| 169 | ||
| 170 | # if _LIBCPP_STD_VER >= 17 | |
| 171 | # include <__numeric/exclusive_scan.h> | |
| 172 | # include <__numeric/gcd_lcm.h> | |
| 173 | # include <__numeric/inclusive_scan.h> | |
| 174 | # include <__numeric/pstl.h> | |
| 175 | # include <__numeric/reduce.h> | |
| 176 | # include <__numeric/transform_exclusive_scan.h> | |
| 177 | # include <__numeric/transform_inclusive_scan.h> | |
| 178 | # include <__numeric/transform_reduce.h> | |
| 179 | # endif | |
| 180 | ||
| 181 | # if _LIBCPP_STD_VER >= 20 | |
| 182 | # include <__numeric/midpoint.h> | |
| 183 | # include <__numeric/saturation_arithmetic.h> | |
| 184 | # endif | |
| 185 | ||
| 186 | # include <version> | |
| 187 | ||
| 188 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 189 | # pragma GCC system_header | |
| 190 | # endif | |
| 191 | ||
| 192 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14 | |
| 193 | # include <initializer_list> | |
| 194 | # include <limits> | |
| 195 | # endif | |
| 196 | ||
| 197 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 198 | # include <climits> | |
| 199 | # include <cmath> | |
| 200 | # include <concepts> | |
| 201 | # include <cstdint> | |
| 202 | # include <execution> | |
| 203 | # include <functional> | |
| 204 | # include <iterator> | |
| 205 | # include <new> | |
| 206 | # include <optional> | |
| 207 | # include <type_traits> | |
| 208 | # endif | |
| 209 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 206 | 210 | |
| 207 | 211 | #endif // _LIBCPP_NUMERIC |
lib/libcxx/include/optional+119-110| ... | ... | @@ -177,64 +177,71 @@ namespace std { |
| 177 | 177 | |
| 178 | 178 | */ |
| 179 | 179 | |
| 180 | #include <__assert> | |
| 181 | #include <__compare/compare_three_way_result.h> | |
| 182 | #include <__compare/three_way_comparable.h> | |
| 183 | #include <__concepts/invocable.h> | |
| 184 | #include <__config> | |
| 185 | #include <__exception/exception.h> | |
| 186 | #include <__functional/hash.h> | |
| 187 | #include <__functional/invoke.h> | |
| 188 | #include <__functional/unary_function.h> | |
| 189 | #include <__fwd/functional.h> | |
| 190 | #include <__memory/addressof.h> | |
| 191 | #include <__memory/construct_at.h> | |
| 192 | #include <__tuple/sfinae_helpers.h> | |
| 193 | #include <__type_traits/add_pointer.h> | |
| 194 | #include <__type_traits/conditional.h> | |
| 195 | #include <__type_traits/conjunction.h> | |
| 196 | #include <__type_traits/decay.h> | |
| 197 | #include <__type_traits/disjunction.h> | |
| 198 | #include <__type_traits/is_array.h> | |
| 199 | #include <__type_traits/is_assignable.h> | |
| 200 | #include <__type_traits/is_constructible.h> | |
| 201 | #include <__type_traits/is_convertible.h> | |
| 202 | #include <__type_traits/is_destructible.h> | |
| 203 | #include <__type_traits/is_nothrow_assignable.h> | |
| 204 | #include <__type_traits/is_nothrow_constructible.h> | |
| 205 | #include <__type_traits/is_object.h> | |
| 206 | #include <__type_traits/is_reference.h> | |
| 207 | #include <__type_traits/is_scalar.h> | |
| 208 | #include <__type_traits/is_swappable.h> | |
| 209 | #include <__type_traits/is_trivially_assignable.h> | |
| 210 | #include <__type_traits/is_trivially_constructible.h> | |
| 211 | #include <__type_traits/is_trivially_destructible.h> | |
| 212 | #include <__type_traits/is_trivially_relocatable.h> | |
| 213 | #include <__type_traits/negation.h> | |
| 214 | #include <__type_traits/remove_const.h> | |
| 215 | #include <__type_traits/remove_cvref.h> | |
| 216 | #include <__type_traits/remove_reference.h> | |
| 217 | #include <__utility/declval.h> | |
| 218 | #include <__utility/forward.h> | |
| 219 | #include <__utility/in_place.h> | |
| 220 | #include <__utility/move.h> | |
| 221 | #include <__utility/swap.h> | |
| 222 | #include <__verbose_abort> | |
| 223 | #include <initializer_list> | |
| 224 | #include <new> | |
| 225 | #include <version> | |
| 180 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 181 | # include <__cxx03/optional> | |
| 182 | #else | |
| 183 | # include <__assert> | |
| 184 | # include <__compare/compare_three_way_result.h> | |
| 185 | # include <__compare/ordering.h> | |
| 186 | # include <__compare/three_way_comparable.h> | |
| 187 | # include <__concepts/invocable.h> | |
| 188 | # include <__config> | |
| 189 | # include <__exception/exception.h> | |
| 190 | # include <__functional/hash.h> | |
| 191 | # include <__functional/invoke.h> | |
| 192 | # include <__functional/unary_function.h> | |
| 193 | # include <__fwd/functional.h> | |
| 194 | # include <__memory/addressof.h> | |
| 195 | # include <__memory/construct_at.h> | |
| 196 | # include <__tuple/sfinae_helpers.h> | |
| 197 | # include <__type_traits/add_pointer.h> | |
| 198 | # include <__type_traits/conditional.h> | |
| 199 | # include <__type_traits/conjunction.h> | |
| 200 | # include <__type_traits/decay.h> | |
| 201 | # include <__type_traits/disjunction.h> | |
| 202 | # include <__type_traits/enable_if.h> | |
| 203 | # include <__type_traits/invoke.h> | |
| 204 | # include <__type_traits/is_array.h> | |
| 205 | # include <__type_traits/is_assignable.h> | |
| 206 | # include <__type_traits/is_constructible.h> | |
| 207 | # include <__type_traits/is_convertible.h> | |
| 208 | # include <__type_traits/is_destructible.h> | |
| 209 | # include <__type_traits/is_nothrow_assignable.h> | |
| 210 | # include <__type_traits/is_nothrow_constructible.h> | |
| 211 | # include <__type_traits/is_object.h> | |
| 212 | # include <__type_traits/is_reference.h> | |
| 213 | # include <__type_traits/is_same.h> | |
| 214 | # include <__type_traits/is_scalar.h> | |
| 215 | # include <__type_traits/is_swappable.h> | |
| 216 | # include <__type_traits/is_trivially_assignable.h> | |
| 217 | # include <__type_traits/is_trivially_constructible.h> | |
| 218 | # include <__type_traits/is_trivially_destructible.h> | |
| 219 | # include <__type_traits/is_trivially_relocatable.h> | |
| 220 | # include <__type_traits/negation.h> | |
| 221 | # include <__type_traits/remove_const.h> | |
| 222 | # include <__type_traits/remove_cv.h> | |
| 223 | # include <__type_traits/remove_cvref.h> | |
| 224 | # include <__type_traits/remove_reference.h> | |
| 225 | # include <__utility/declval.h> | |
| 226 | # include <__utility/forward.h> | |
| 227 | # include <__utility/in_place.h> | |
| 228 | # include <__utility/move.h> | |
| 229 | # include <__utility/swap.h> | |
| 230 | # include <__verbose_abort> | |
| 231 | # include <initializer_list> | |
| 232 | # include <version> | |
| 226 | 233 | |
| 227 | 234 | // standard-mandated includes |
| 228 | 235 | |
| 229 | 236 | // [optional.syn] |
| 230 | #include <compare> | |
| 237 | # include <compare> | |
| 231 | 238 | |
| 232 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 233 | # pragma GCC system_header | |
| 234 | #endif | |
| 239 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 240 | # pragma GCC system_header | |
| 241 | # endif | |
| 235 | 242 | |
| 236 | 243 | _LIBCPP_PUSH_MACROS |
| 237 | #include <__undef_macros> | |
| 244 | # include <__undef_macros> | |
| 238 | 245 | |
| 239 | 246 | namespace std // purposefully not using versioning namespace |
| 240 | 247 | { |
| ... | ... | @@ -251,17 +258,17 @@ public: |
| 251 | 258 | |
| 252 | 259 | } // namespace std |
| 253 | 260 | |
| 254 | #if _LIBCPP_STD_VER >= 17 | |
| 261 | # if _LIBCPP_STD_VER >= 17 | |
| 255 | 262 | |
| 256 | 263 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 257 | 264 | |
| 258 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void | |
| 265 | [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void | |
| 259 | 266 | __throw_bad_optional_access() { |
| 260 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 267 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 261 | 268 | throw bad_optional_access(); |
| 262 | # else | |
| 269 | # else | |
| 263 | 270 | _LIBCPP_VERBOSE_ABORT("bad_optional_access was thrown in -fno-exceptions mode"); |
| 264 | # endif | |
| 271 | # endif | |
| 265 | 272 | } |
| 266 | 273 | |
| 267 | 274 | struct nullopt_t { |
| ... | ... | @@ -284,7 +291,7 @@ struct __optional_destruct_base<_Tp, false> { |
| 284 | 291 | static_assert(is_object_v<value_type>, "instantiation of optional with a non-object type is undefined behavior"); |
| 285 | 292 | union { |
| 286 | 293 | char __null_state_; |
| 287 | value_type __val_; | |
| 294 | remove_cv_t<value_type> __val_; | |
| 288 | 295 | }; |
| 289 | 296 | bool __engaged_; |
| 290 | 297 | |
| ... | ... | @@ -299,12 +306,12 @@ struct __optional_destruct_base<_Tp, false> { |
| 299 | 306 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args) |
| 300 | 307 | : __val_(std::forward<_Args>(__args)...), __engaged_(true) {} |
| 301 | 308 | |
| 302 | # if _LIBCPP_STD_VER >= 23 | |
| 309 | # if _LIBCPP_STD_VER >= 23 | |
| 303 | 310 | template <class _Fp, class... _Args> |
| 304 | 311 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base( |
| 305 | 312 | __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) |
| 306 | 313 | : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {} |
| 307 | # endif | |
| 314 | # endif | |
| 308 | 315 | |
| 309 | 316 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { |
| 310 | 317 | if (__engaged_) { |
| ... | ... | @@ -320,7 +327,7 @@ struct __optional_destruct_base<_Tp, true> { |
| 320 | 327 | static_assert(is_object_v<value_type>, "instantiation of optional with a non-object type is undefined behavior"); |
| 321 | 328 | union { |
| 322 | 329 | char __null_state_; |
| 323 | value_type __val_; | |
| 330 | remove_cv_t<value_type> __val_; | |
| 324 | 331 | }; |
| 325 | 332 | bool __engaged_; |
| 326 | 333 | |
| ... | ... | @@ -330,12 +337,12 @@ struct __optional_destruct_base<_Tp, true> { |
| 330 | 337 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(in_place_t, _Args&&... __args) |
| 331 | 338 | : __val_(std::forward<_Args>(__args)...), __engaged_(true) {} |
| 332 | 339 | |
| 333 | # if _LIBCPP_STD_VER >= 23 | |
| 340 | # if _LIBCPP_STD_VER >= 23 | |
| 334 | 341 | template <class _Fp, class... _Args> |
| 335 | 342 | _LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base( |
| 336 | 343 | __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) |
| 337 | 344 | : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {} |
| 338 | # endif | |
| 345 | # endif | |
| 339 | 346 | |
| 340 | 347 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { |
| 341 | 348 | if (__engaged_) { |
| ... | ... | @@ -346,8 +353,8 @@ struct __optional_destruct_base<_Tp, true> { |
| 346 | 353 | |
| 347 | 354 | template <class _Tp, bool = is_reference<_Tp>::value> |
| 348 | 355 | struct __optional_storage_base : __optional_destruct_base<_Tp> { |
| 349 | using __base = __optional_destruct_base<_Tp>; | |
| 350 | using value_type = _Tp; | |
| 356 | using __base _LIBCPP_NODEBUG = __optional_destruct_base<_Tp>; | |
| 357 | using value_type = _Tp; | |
| 351 | 358 | using __base::__base; |
| 352 | 359 | |
| 353 | 360 | _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return this->__engaged_; } |
| ... | ... | @@ -374,7 +381,7 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> { |
| 374 | 381 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_from(_That&& __opt) { |
| 375 | 382 | if (this->__engaged_ == __opt.has_value()) { |
| 376 | 383 | if (this->__engaged_) |
| 377 | this->__val_ = std::forward<_That>(__opt).__get(); | |
| 384 | static_cast<_Tp&>(this->__val_) = std::forward<_That>(__opt).__get(); | |
| 378 | 385 | } else { |
| 379 | 386 | if (this->__engaged_) |
| 380 | 387 | this->reset(); |
| ... | ... | @@ -389,8 +396,8 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> { |
| 389 | 396 | // to ensure we can make the change in an ABI-compatible manner. |
| 390 | 397 | template <class _Tp> |
| 391 | 398 | struct __optional_storage_base<_Tp, true> { |
| 392 | using value_type = _Tp; | |
| 393 | using __raw_type = remove_reference_t<_Tp>; | |
| 399 | using value_type = _Tp; | |
| 400 | using __raw_type _LIBCPP_NODEBUG = remove_reference_t<_Tp>; | |
| 394 | 401 | __raw_type* __value_; |
| 395 | 402 | |
| 396 | 403 | template <class _Up> |
| ... | ... | @@ -548,23 +555,23 @@ struct __optional_move_assign_base<_Tp, false> : __optional_copy_assign_base<_Tp |
| 548 | 555 | }; |
| 549 | 556 | |
| 550 | 557 | template <class _Tp> |
| 551 | using __optional_sfinae_ctor_base_t = | |
| 558 | using __optional_sfinae_ctor_base_t _LIBCPP_NODEBUG = | |
| 552 | 559 | __sfinae_ctor_base< is_copy_constructible<_Tp>::value, is_move_constructible<_Tp>::value >; |
| 553 | 560 | |
| 554 | 561 | template <class _Tp> |
| 555 | using __optional_sfinae_assign_base_t = | |
| 562 | using __optional_sfinae_assign_base_t _LIBCPP_NODEBUG = | |
| 556 | 563 | __sfinae_assign_base< (is_copy_constructible<_Tp>::value && is_copy_assignable<_Tp>::value), |
| 557 | 564 | (is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value) >; |
| 558 | 565 | |
| 559 | 566 | template <class _Tp> |
| 560 | 567 | class optional; |
| 561 | 568 | |
| 562 | # if _LIBCPP_STD_VER >= 20 | |
| 569 | # if _LIBCPP_STD_VER >= 20 | |
| 563 | 570 | |
| 564 | 571 | template <class _Tp> |
| 565 | 572 | concept __is_derived_from_optional = requires(const _Tp& __t) { []<class _Up>(const optional<_Up>&) {}(__t); }; |
| 566 | 573 | |
| 567 | # endif // _LIBCPP_STD_VER >= 20 | |
| 574 | # endif // _LIBCPP_STD_VER >= 20 | |
| 568 | 575 | |
| 569 | 576 | template <class _Tp> |
| 570 | 577 | struct __is_std_optional : false_type {}; |
| ... | ... | @@ -576,12 +583,13 @@ class _LIBCPP_DECLSPEC_EMPTY_BASES optional |
| 576 | 583 | : private __optional_move_assign_base<_Tp>, |
| 577 | 584 | private __optional_sfinae_ctor_base_t<_Tp>, |
| 578 | 585 | private __optional_sfinae_assign_base_t<_Tp> { |
| 579 | using __base = __optional_move_assign_base<_Tp>; | |
| 586 | using __base _LIBCPP_NODEBUG = __optional_move_assign_base<_Tp>; | |
| 580 | 587 | |
| 581 | 588 | public: |
| 582 | 589 | using value_type = _Tp; |
| 583 | 590 | |
| 584 | using __trivially_relocatable = conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>; | |
| 591 | using __trivially_relocatable _LIBCPP_NODEBUG = | |
| 592 | conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>; | |
| 585 | 593 | |
| 586 | 594 | private: |
| 587 | 595 | // Disable the reference extension using this static assert. |
| ... | ... | @@ -606,7 +614,7 @@ private: |
| 606 | 614 | } |
| 607 | 615 | }; |
| 608 | 616 | template <class _Up> |
| 609 | using _CheckOptionalArgsCtor = | |
| 617 | using _CheckOptionalArgsCtor _LIBCPP_NODEBUG = | |
| 610 | 618 | _If< _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value && _IsNotSame<__remove_cvref_t<_Up>, optional>::value && |
| 611 | 619 | (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_optional<__remove_cvref_t<_Up>>::value), |
| 612 | 620 | _CheckOptionalArgsConstructor, |
| ... | ... | @@ -614,7 +622,7 @@ private: |
| 614 | 622 | template <class _QualUp> |
| 615 | 623 | struct _CheckOptionalLikeConstructor { |
| 616 | 624 | template <class _Up, class _Opt = optional<_Up>> |
| 617 | using __check_constructible_from_opt = | |
| 625 | using __check_constructible_from_opt _LIBCPP_NODEBUG = | |
| 618 | 626 | _Or< is_constructible<_Tp, _Opt&>, |
| 619 | 627 | is_constructible<_Tp, _Opt const&>, |
| 620 | 628 | is_constructible<_Tp, _Opt&&>, |
| ... | ... | @@ -624,7 +632,7 @@ private: |
| 624 | 632 | is_convertible<_Opt&&, _Tp>, |
| 625 | 633 | is_convertible<_Opt const&&, _Tp> >; |
| 626 | 634 | template <class _Up, class _Opt = optional<_Up>> |
| 627 | using __check_assignable_from_opt = | |
| 635 | using __check_assignable_from_opt _LIBCPP_NODEBUG = | |
| 628 | 636 | _Or< is_assignable<_Tp&, _Opt&>, |
| 629 | 637 | is_assignable<_Tp&, _Opt const&>, |
| 630 | 638 | is_assignable<_Tp&, _Opt&&>, |
| ... | ... | @@ -648,12 +656,12 @@ private: |
| 648 | 656 | }; |
| 649 | 657 | |
| 650 | 658 | template <class _Up, class _QualUp> |
| 651 | using _CheckOptionalLikeCtor = | |
| 659 | using _CheckOptionalLikeCtor _LIBCPP_NODEBUG = | |
| 652 | 660 | _If< _And< _IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp> >::value, |
| 653 | 661 | _CheckOptionalLikeConstructor<_QualUp>, |
| 654 | 662 | __check_tuple_constructor_fail >; |
| 655 | 663 | template <class _Up, class _QualUp> |
| 656 | using _CheckOptionalLikeAssign = | |
| 664 | using _CheckOptionalLikeAssign _LIBCPP_NODEBUG = | |
| 657 | 665 | _If< _And< _IsNotSame<_Up, _Tp>, is_constructible<_Tp, _QualUp>, is_assignable<_Tp&, _QualUp> >::value, |
| 658 | 666 | _CheckOptionalLikeConstructor<_QualUp>, |
| 659 | 667 | __check_tuple_constructor_fail >; |
| ... | ... | @@ -706,14 +714,14 @@ public: |
| 706 | 714 | this->__construct_from(std::move(__v)); |
| 707 | 715 | } |
| 708 | 716 | |
| 709 | # if _LIBCPP_STD_VER >= 23 | |
| 717 | # if _LIBCPP_STD_VER >= 23 | |
| 710 | 718 | template <class _Tag, |
| 711 | 719 | class _Fp, |
| 712 | 720 | class... _Args, |
| 713 | 721 | __enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0> |
| 714 | 722 | _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args) |
| 715 | 723 | : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {} |
| 716 | # endif | |
| 724 | # endif | |
| 717 | 725 | |
| 718 | 726 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(nullopt_t) noexcept { |
| 719 | 727 | reset(); |
| ... | ... | @@ -859,7 +867,7 @@ public: |
| 859 | 867 | return this->has_value() ? std::move(this->__get()) : static_cast<value_type>(std::forward<_Up>(__v)); |
| 860 | 868 | } |
| 861 | 869 | |
| 862 | # if _LIBCPP_STD_VER >= 23 | |
| 870 | # if _LIBCPP_STD_VER >= 23 | |
| 863 | 871 | template <class _Func> |
| 864 | 872 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) & { |
| 865 | 873 | using _Up = invoke_result_t<_Func, value_type&>; |
| ... | ... | @@ -969,15 +977,15 @@ public: |
| 969 | 977 | return std::move(*this); |
| 970 | 978 | return std::forward<_Func>(__f)(); |
| 971 | 979 | } |
| 972 | # endif // _LIBCPP_STD_VER >= 23 | |
| 980 | # endif // _LIBCPP_STD_VER >= 23 | |
| 973 | 981 | |
| 974 | 982 | using __base::reset; |
| 975 | 983 | }; |
| 976 | 984 | |
| 977 | # if _LIBCPP_STD_VER >= 17 | |
| 985 | # if _LIBCPP_STD_VER >= 17 | |
| 978 | 986 | template <class _Tp> |
| 979 | 987 | optional(_Tp) -> optional<_Tp>; |
| 980 | # endif | |
| 988 | # endif | |
| 981 | 989 | |
| 982 | 990 | // Comparisons between optionals |
| 983 | 991 | template <class _Tp, class _Up> |
| ... | ... | @@ -1052,7 +1060,7 @@ operator>=(const optional<_Tp>& __x, const optional<_Up>& __y) { |
| 1052 | 1060 | return *__x >= *__y; |
| 1053 | 1061 | } |
| 1054 | 1062 | |
| 1055 | # if _LIBCPP_STD_VER >= 20 | |
| 1063 | # if _LIBCPP_STD_VER >= 20 | |
| 1056 | 1064 | |
| 1057 | 1065 | template <class _Tp, three_way_comparable_with<_Tp> _Up> |
| 1058 | 1066 | _LIBCPP_HIDE_FROM_ABI constexpr compare_three_way_result_t<_Tp, _Up> |
| ... | ... | @@ -1062,7 +1070,7 @@ operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) { |
| 1062 | 1070 | return __x.has_value() <=> __y.has_value(); |
| 1063 | 1071 | } |
| 1064 | 1072 | |
| 1065 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1073 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1066 | 1074 | |
| 1067 | 1075 | // Comparisons with nullopt |
| 1068 | 1076 | template <class _Tp> |
| ... | ... | @@ -1070,7 +1078,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, nullop |
| 1070 | 1078 | return !static_cast<bool>(__x); |
| 1071 | 1079 | } |
| 1072 | 1080 | |
| 1073 | # if _LIBCPP_STD_VER <= 17 | |
| 1081 | # if _LIBCPP_STD_VER <= 17 | |
| 1074 | 1082 | |
| 1075 | 1083 | template <class _Tp> |
| 1076 | 1084 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(nullopt_t, const optional<_Tp>& __x) noexcept { |
| ... | ... | @@ -1127,14 +1135,14 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(nullopt_t, const optional<_Tp>& |
| 1127 | 1135 | return !static_cast<bool>(__x); |
| 1128 | 1136 | } |
| 1129 | 1137 | |
| 1130 | # else // _LIBCPP_STD_VER <= 17 | |
| 1138 | # else // _LIBCPP_STD_VER <= 17 | |
| 1131 | 1139 | |
| 1132 | 1140 | template <class _Tp> |
| 1133 | 1141 | _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>& __x, nullopt_t) noexcept { |
| 1134 | 1142 | return __x.has_value() <=> false; |
| 1135 | 1143 | } |
| 1136 | 1144 | |
| 1137 | # endif // _LIBCPP_STD_VER <= 17 | |
| 1145 | # endif // _LIBCPP_STD_VER <= 17 | |
| 1138 | 1146 | |
| 1139 | 1147 | // Comparisons with T |
| 1140 | 1148 | template <class _Tp, class _Up> |
| ... | ... | @@ -1233,7 +1241,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x) { |
| 1233 | 1241 | return static_cast<bool>(__x) ? __v >= *__x : true; |
| 1234 | 1242 | } |
| 1235 | 1243 | |
| 1236 | # if _LIBCPP_STD_VER >= 20 | |
| 1244 | # if _LIBCPP_STD_VER >= 20 | |
| 1237 | 1245 | |
| 1238 | 1246 | template <class _Tp, class _Up> |
| 1239 | 1247 | requires(!__is_derived_from_optional<_Up>) && three_way_comparable_with<_Tp, _Up> |
| ... | ... | @@ -1242,7 +1250,7 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) { |
| 1242 | 1250 | return __x.has_value() ? *__x <=> __v : strong_ordering::less; |
| 1243 | 1251 | } |
| 1244 | 1252 | |
| 1245 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1253 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1246 | 1254 | |
| 1247 | 1255 | template <class _Tp> |
| 1248 | 1256 | inline _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -1268,10 +1276,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(initializer_list<_Up |
| 1268 | 1276 | |
| 1269 | 1277 | template <class _Tp> |
| 1270 | 1278 | struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>> > { |
| 1271 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 1279 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 1272 | 1280 | _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type; |
| 1273 | 1281 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; |
| 1274 | # endif | |
| 1282 | # endif | |
| 1275 | 1283 | |
| 1276 | 1284 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const optional<_Tp>& __opt) const { |
| 1277 | 1285 | return static_cast<bool>(__opt) ? hash<remove_const_t<_Tp>>()(*__opt) : 0; |
| ... | ... | @@ -1280,25 +1288,26 @@ struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<optional<_Tp>, remove_con |
| 1280 | 1288 | |
| 1281 | 1289 | _LIBCPP_END_NAMESPACE_STD |
| 1282 | 1290 | |
| 1283 | #endif // _LIBCPP_STD_VER >= 17 | |
| 1291 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1284 | 1292 | |
| 1285 | 1293 | _LIBCPP_POP_MACROS |
| 1286 | 1294 | |
| 1287 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1288 | # include <atomic> | |
| 1289 | # include <climits> | |
| 1290 | # include <concepts> | |
| 1291 | # include <ctime> | |
| 1292 | # include <iterator> | |
| 1293 | # include <limits> | |
| 1294 | # include <memory> | |
| 1295 | # include <ratio> | |
| 1296 | # include <stdexcept> | |
| 1297 | # include <tuple> | |
| 1298 | # include <type_traits> | |
| 1299 | # include <typeinfo> | |
| 1300 | # include <utility> | |
| 1301 | # include <variant> | |
| 1302 | #endif | |
| 1295 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1296 | # include <atomic> | |
| 1297 | # include <climits> | |
| 1298 | # include <concepts> | |
| 1299 | # include <ctime> | |
| 1300 | # include <iterator> | |
| 1301 | # include <limits> | |
| 1302 | # include <memory> | |
| 1303 | # include <ratio> | |
| 1304 | # include <stdexcept> | |
| 1305 | # include <tuple> | |
| 1306 | # include <type_traits> | |
| 1307 | # include <typeinfo> | |
| 1308 | # include <utility> | |
| 1309 | # include <variant> | |
| 1310 | # endif | |
| 1311 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1303 | 1312 | |
| 1304 | 1313 | #endif // _LIBCPP_OPTIONAL |
lib/libcxx/include/ostream+34-26| ... | ... | @@ -172,31 +172,39 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args); |
| 172 | 172 | |
| 173 | 173 | */ |
| 174 | 174 | |
| 175 | #include <__config> | |
| 176 | ||
| 177 | #include <__ostream/basic_ostream.h> | |
| 178 | ||
| 179 | #if _LIBCPP_STD_VER >= 23 | |
| 180 | # include <__ostream/print.h> | |
| 181 | #endif | |
| 182 | ||
| 183 | #include <version> | |
| 184 | ||
| 185 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 186 | # pragma GCC system_header | |
| 187 | #endif | |
| 188 | ||
| 189 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 190 | # include <atomic> | |
| 191 | # include <concepts> | |
| 192 | # include <cstdio> | |
| 193 | # include <cstdlib> | |
| 194 | # include <format> | |
| 195 | # include <iosfwd> | |
| 196 | # include <iterator> | |
| 197 | # include <print> | |
| 198 | # include <stdexcept> | |
| 199 | # include <type_traits> | |
| 200 | #endif | |
| 175 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 176 | # include <__cxx03/ostream> | |
| 177 | #else | |
| 178 | # include <__config> | |
| 179 | ||
| 180 | # if _LIBCPP_HAS_LOCALIZATION | |
| 181 | ||
| 182 | # include <__ostream/basic_ostream.h> | |
| 183 | ||
| 184 | # if _LIBCPP_STD_VER >= 23 | |
| 185 | # include <__ostream/print.h> | |
| 186 | # endif | |
| 187 | ||
| 188 | # include <version> | |
| 189 | ||
| 190 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 191 | # pragma GCC system_header | |
| 192 | # endif | |
| 193 | ||
| 194 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 195 | ||
| 196 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 197 | # include <atomic> | |
| 198 | # include <concepts> | |
| 199 | # include <cstdio> | |
| 200 | # include <cstdlib> | |
| 201 | # include <format> | |
| 202 | # include <iosfwd> | |
| 203 | # include <iterator> | |
| 204 | # include <print> | |
| 205 | # include <stdexcept> | |
| 206 | # include <type_traits> | |
| 207 | # endif | |
| 208 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 201 | 209 | |
| 202 | 210 | #endif // _LIBCPP_OSTREAM |
lib/libcxx/include/print+68-63| ... | ... | @@ -33,28 +33,31 @@ namespace std { |
| 33 | 33 | } |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | #include <__assert> | |
| 37 | #include <__concepts/same_as.h> | |
| 38 | #include <__config> | |
| 39 | #include <__system_error/system_error.h> | |
| 40 | #include <__utility/forward.h> | |
| 41 | #include <cerrno> | |
| 42 | #include <cstdio> | |
| 43 | #include <format> | |
| 44 | #include <string> | |
| 45 | #include <string_view> | |
| 46 | #include <version> | |
| 47 | ||
| 48 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 49 | # pragma GCC system_header | |
| 50 | #endif | |
| 36 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 37 | # include <__cxx03/print> | |
| 38 | #else | |
| 39 | # include <__assert> | |
| 40 | # include <__concepts/same_as.h> | |
| 41 | # include <__config> | |
| 42 | # include <__system_error/throw_system_error.h> | |
| 43 | # include <__utility/forward.h> | |
| 44 | # include <cerrno> | |
| 45 | # include <cstdio> | |
| 46 | # include <format> | |
| 47 | # include <string> | |
| 48 | # include <string_view> | |
| 49 | # include <version> | |
| 50 | ||
| 51 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 52 | # pragma GCC system_header | |
| 53 | # endif | |
| 51 | 54 | |
| 52 | 55 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 53 | 56 | |
| 54 | #ifdef _LIBCPP_WIN32API | |
| 57 | # ifdef _LIBCPP_WIN32API | |
| 55 | 58 | _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream); |
| 56 | 59 | |
| 57 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 60 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 58 | 61 | // A wrapper for WriteConsoleW which is used to write to the Windows |
| 59 | 62 | // console. This function is in the dylib to avoid pulling in windows.h |
| 60 | 63 | // in the library headers. The function itself uses some private parts |
| ... | ... | @@ -65,14 +68,14 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream); |
| 65 | 68 | // |
| 66 | 69 | // Note the function is only implemented on the Windows platform. |
| 67 | 70 | _LIBCPP_EXPORTED_FROM_ABI void __write_to_windows_console(FILE* __stream, wstring_view __view); |
| 68 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 69 | #elif __has_include(<unistd.h>) | |
| 71 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 72 | # elif __has_include(<unistd.h>) | |
| 70 | 73 | _LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream); |
| 71 | #endif // _LIBCPP_WIN32API | |
| 74 | # endif // _LIBCPP_WIN32API | |
| 72 | 75 | |
| 73 | #if _LIBCPP_STD_VER >= 23 | |
| 76 | # if _LIBCPP_STD_VER >= 23 | |
| 74 | 77 | |
| 75 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 78 | # if _LIBCPP_HAS_UNICODE | |
| 76 | 79 | // This is the code to transcode UTF-8 to UTF-16. This is used on |
| 77 | 80 | // Windows for the native Unicode API. The code is modeled to make it |
| 78 | 81 | // easier to extend to |
| ... | ... | @@ -86,27 +89,27 @@ namespace __unicode { |
| 86 | 89 | // The names of these concepts are modelled after P2728R0, but the |
| 87 | 90 | // implementation is not. char16_t may contain 32-bits so depending on the |
| 88 | 91 | // number of bits is an issue. |
| 89 | # ifdef _LIBCPP_SHORT_WCHAR | |
| 92 | # ifdef _LIBCPP_SHORT_WCHAR | |
| 90 | 93 | template <class _Tp> |
| 91 | 94 | concept __utf16_code_unit = |
| 92 | 95 | same_as<_Tp, char16_t> |
| 93 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 96 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 94 | 97 | || same_as<_Tp, wchar_t> |
| 95 | # endif | |
| 98 | # endif | |
| 96 | 99 | ; |
| 97 | 100 | template <class _Tp> |
| 98 | 101 | concept __utf32_code_unit = same_as<_Tp, char32_t>; |
| 99 | # else // _LIBCPP_SHORT_WCHAR | |
| 102 | # else // _LIBCPP_SHORT_WCHAR | |
| 100 | 103 | template <class _Tp> |
| 101 | 104 | concept __utf16_code_unit = same_as<_Tp, char16_t>; |
| 102 | 105 | template <class _Tp> |
| 103 | 106 | concept __utf32_code_unit = |
| 104 | 107 | same_as<_Tp, char32_t> |
| 105 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 108 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 106 | 109 | || same_as<_Tp, wchar_t> |
| 107 | # endif | |
| 110 | # endif | |
| 108 | 111 | ; |
| 109 | # endif // _LIBCPP_SHORT_WCHAR | |
| 112 | # endif // _LIBCPP_SHORT_WCHAR | |
| 110 | 113 | |
| 111 | 114 | // Pass by reference since an output_iterator may not be copyable. |
| 112 | 115 | template <class _OutIt> |
| ... | ... | @@ -164,7 +167,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _OutIt __transcode(_InIt __first, _InIt __last, |
| 164 | 167 | |
| 165 | 168 | } // namespace __unicode |
| 166 | 169 | |
| 167 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 170 | # endif // _LIBCPP_HAS_UNICODE | |
| 168 | 171 | |
| 169 | 172 | namespace __print { |
| 170 | 173 | |
| ... | ... | @@ -184,30 +187,30 @@ namespace __print { |
| 184 | 187 | // (note at the time of writing Clang is hard-coded to UTF-8.) |
| 185 | 188 | // |
| 186 | 189 | |
| 187 | # ifdef _LIBCPP_HAS_NO_UNICODE | |
| 190 | # if !_LIBCPP_HAS_UNICODE | |
| 188 | 191 | inline constexpr bool __use_unicode_execution_charset = false; |
| 189 | # elif defined(_MSVC_EXECUTION_CHARACTER_SET) | |
| 192 | # elif defined(_MSVC_EXECUTION_CHARACTER_SET) | |
| 190 | 193 | // This is the same test MSVC STL uses in their implementation of <print> |
| 191 | 194 | // See: https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers |
| 192 | 195 | inline constexpr bool __use_unicode_execution_charset = _MSVC_EXECUTION_CHARACTER_SET == 65001; |
| 193 | # else | |
| 196 | # else | |
| 194 | 197 | inline constexpr bool __use_unicode_execution_charset = true; |
| 195 | # endif | |
| 198 | # endif | |
| 196 | 199 | |
| 197 | 200 | _LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream) { |
| 198 | 201 | // The macro _LIBCPP_TESTING_PRINT_IS_TERMINAL is used to change |
| 199 | 202 | // the behavior in the test. This is not part of the public API. |
| 200 | # ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL | |
| 203 | # ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL | |
| 201 | 204 | return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream); |
| 202 | # elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 | |
| 205 | # elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 || !_LIBCPP_HAS_TERMINAL | |
| 203 | 206 | return false; |
| 204 | # elif defined(_LIBCPP_WIN32API) | |
| 207 | # elif defined(_LIBCPP_WIN32API) | |
| 205 | 208 | return std::__is_windows_terminal(__stream); |
| 206 | # elif __has_include(<unistd.h>) | |
| 209 | # elif __has_include(<unistd.h>) | |
| 207 | 210 | return std::__is_posix_terminal(__stream); |
| 208 | # else | |
| 209 | # error "Provide a way to determine whether a FILE* is a terminal" | |
| 210 | # endif | |
| 211 | # else | |
| 212 | # error "Provide a way to determine whether a FILE* is a terminal" | |
| 213 | # endif | |
| 211 | 214 | } |
| 212 | 215 | |
| 213 | 216 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| ... | ... | @@ -226,7 +229,7 @@ __vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args, bool |
| 226 | 229 | } |
| 227 | 230 | } |
| 228 | 231 | |
| 229 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 232 | # if _LIBCPP_HAS_UNICODE | |
| 230 | 233 | |
| 231 | 234 | // Note these helper functions are mainly used to aid testing. |
| 232 | 235 | // On POSIX systems and Windows the output is no longer considered a |
| ... | ... | @@ -243,7 +246,7 @@ __vprint_unicode_posix(FILE* __stream, string_view __fmt, format_args __args, bo |
| 243 | 246 | __print::__vprint_nonunicode(__stream, __fmt, __args, __write_nl); |
| 244 | 247 | } |
| 245 | 248 | |
| 246 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 249 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 247 | 250 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| 248 | 251 | _LIBCPP_HIDE_FROM_ABI inline void |
| 249 | 252 | __vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl, bool __is_terminal) { |
| ... | ... | @@ -272,16 +275,16 @@ __vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args, |
| 272 | 275 | |
| 273 | 276 | // The macro _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION is used to change |
| 274 | 277 | // the behavior in the test. This is not part of the public API. |
| 275 | # ifdef _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION | |
| 278 | # ifdef _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION | |
| 276 | 279 | _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION(__stream, __view); |
| 277 | # elif defined(_LIBCPP_WIN32API) | |
| 280 | # elif defined(_LIBCPP_WIN32API) | |
| 278 | 281 | std::__write_to_windows_console(__stream, __view); |
| 279 | # else | |
| 282 | # else | |
| 280 | 283 | std::__throw_runtime_error("No defintion of _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION and " |
| 281 | 284 | "__write_to_windows_console is not available."); |
| 282 | # endif | |
| 285 | # endif | |
| 283 | 286 | } |
| 284 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 287 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 285 | 288 | |
| 286 | 289 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| 287 | 290 | _LIBCPP_HIDE_FROM_ABI inline void |
| ... | ... | @@ -312,29 +315,29 @@ __vprint_unicode([[maybe_unused]] FILE* __stream, |
| 312 | 315 | // so there the call can be forwarded to the non_unicode API. On |
| 313 | 316 | // Windows there is a different API. This API requires transcoding. |
| 314 | 317 | |
| 315 | # ifndef _LIBCPP_WIN32API | |
| 318 | # ifndef _LIBCPP_WIN32API | |
| 316 | 319 | __print::__vprint_unicode_posix(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream)); |
| 317 | # elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 320 | # elif _LIBCPP_HAS_WIDE_CHARACTERS | |
| 318 | 321 | __print::__vprint_unicode_windows(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream)); |
| 319 | # else | |
| 320 | # error "Windows builds with wchar_t disabled are not supported." | |
| 321 | # endif | |
| 322 | # else | |
| 323 | # error "Windows builds with wchar_t disabled are not supported." | |
| 324 | # endif | |
| 322 | 325 | } |
| 323 | 326 | |
| 324 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 327 | # endif // _LIBCPP_HAS_UNICODE | |
| 325 | 328 | |
| 326 | 329 | } // namespace __print |
| 327 | 330 | |
| 328 | 331 | template <class... _Args> |
| 329 | 332 | _LIBCPP_HIDE_FROM_ABI void print(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) { |
| 330 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 333 | # if _LIBCPP_HAS_UNICODE | |
| 331 | 334 | if constexpr (__print::__use_unicode_execution_charset) |
| 332 | 335 | __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), false); |
| 333 | 336 | else |
| 334 | 337 | __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false); |
| 335 | # else // _LIBCPP_HAS_NO_UNICODE | |
| 338 | # else // _LIBCPP_HAS_UNICODE | |
| 336 | 339 | __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false); |
| 337 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 340 | # endif // _LIBCPP_HAS_UNICODE | |
| 338 | 341 | } |
| 339 | 342 | |
| 340 | 343 | template <class... _Args> |
| ... | ... | @@ -344,7 +347,7 @@ _LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __arg |
| 344 | 347 | |
| 345 | 348 | template <class... _Args> |
| 346 | 349 | _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt, _Args&&... __args) { |
| 347 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 350 | # if _LIBCPP_HAS_UNICODE | |
| 348 | 351 | // Note the wording in the Standard is inefficient. The output of |
| 349 | 352 | // std::format is a std::string which is then copied. This solution |
| 350 | 353 | // just appends a newline at the end of the output. |
| ... | ... | @@ -352,9 +355,9 @@ _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt |
| 352 | 355 | __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), true); |
| 353 | 356 | else |
| 354 | 357 | __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true); |
| 355 | # else // _LIBCPP_HAS_NO_UNICODE | |
| 358 | # else // _LIBCPP_HAS_UNICODE | |
| 356 | 359 | __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true); |
| 357 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 360 | # endif // _LIBCPP_HAS_UNICODE | |
| 358 | 361 | } |
| 359 | 362 | |
| 360 | 363 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| ... | ... | @@ -372,7 +375,7 @@ _LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __a |
| 372 | 375 | std::println(stdout, __fmt, std::forward<_Args>(__args)...); |
| 373 | 376 | } |
| 374 | 377 | |
| 375 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 378 | # if _LIBCPP_HAS_UNICODE | |
| 376 | 379 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| 377 | 380 | _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(FILE* __stream, string_view __fmt, format_args __args) { |
| 378 | 381 | __print::__vprint_unicode(__stream, __fmt, __args, false); |
| ... | ... | @@ -383,7 +386,7 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(string_view __fmt, format_args |
| 383 | 386 | std::vprint_unicode(stdout, __fmt, __args); |
| 384 | 387 | } |
| 385 | 388 | |
| 386 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 389 | # endif // _LIBCPP_HAS_UNICODE | |
| 387 | 390 | |
| 388 | 391 | template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563). |
| 389 | 392 | _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args) { |
| ... | ... | @@ -395,8 +398,10 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(string_view __fmt, format_ar |
| 395 | 398 | std::vprint_nonunicode(stdout, __fmt, __args); |
| 396 | 399 | } |
| 397 | 400 | |
| 398 | #endif // _LIBCPP_STD_VER >= 23 | |
| 401 | # endif // _LIBCPP_STD_VER >= 23 | |
| 399 | 402 | |
| 400 | 403 | _LIBCPP_END_NAMESPACE_STD |
| 401 | 404 | |
| 405 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 406 | ||
| 402 | 407 | #endif // _LIBCPP_PRINT |
lib/libcxx/include/queue+92-88| ... | ... | @@ -254,38 +254,41 @@ template <class T, class Container, class Compare> |
| 254 | 254 | |
| 255 | 255 | */ |
| 256 | 256 | |
| 257 | #include <__algorithm/make_heap.h> | |
| 258 | #include <__algorithm/pop_heap.h> | |
| 259 | #include <__algorithm/push_heap.h> | |
| 260 | #include <__algorithm/ranges_copy.h> | |
| 261 | #include <__config> | |
| 262 | #include <__functional/operations.h> | |
| 263 | #include <__fwd/deque.h> | |
| 264 | #include <__fwd/queue.h> | |
| 265 | #include <__iterator/back_insert_iterator.h> | |
| 266 | #include <__iterator/iterator_traits.h> | |
| 267 | #include <__memory/uses_allocator.h> | |
| 268 | #include <__ranges/access.h> | |
| 269 | #include <__ranges/concepts.h> | |
| 270 | #include <__ranges/container_compatible_range.h> | |
| 271 | #include <__ranges/from_range.h> | |
| 272 | #include <__utility/forward.h> | |
| 273 | #include <deque> | |
| 274 | #include <vector> | |
| 275 | #include <version> | |
| 257 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 258 | # include <__cxx03/queue> | |
| 259 | #else | |
| 260 | # include <__algorithm/make_heap.h> | |
| 261 | # include <__algorithm/pop_heap.h> | |
| 262 | # include <__algorithm/push_heap.h> | |
| 263 | # include <__algorithm/ranges_copy.h> | |
| 264 | # include <__config> | |
| 265 | # include <__functional/operations.h> | |
| 266 | # include <__fwd/deque.h> | |
| 267 | # include <__fwd/queue.h> | |
| 268 | # include <__iterator/back_insert_iterator.h> | |
| 269 | # include <__iterator/iterator_traits.h> | |
| 270 | # include <__memory/uses_allocator.h> | |
| 271 | # include <__ranges/access.h> | |
| 272 | # include <__ranges/concepts.h> | |
| 273 | # include <__ranges/container_compatible_range.h> | |
| 274 | # include <__ranges/from_range.h> | |
| 275 | # include <__utility/forward.h> | |
| 276 | # include <deque> | |
| 277 | # include <vector> | |
| 278 | # include <version> | |
| 276 | 279 | |
| 277 | 280 | // standard-mandated includes |
| 278 | 281 | |
| 279 | 282 | // [queue.syn] |
| 280 | #include <compare> | |
| 281 | #include <initializer_list> | |
| 283 | # include <compare> | |
| 284 | # include <initializer_list> | |
| 282 | 285 | |
| 283 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 284 | # pragma GCC system_header | |
| 285 | #endif | |
| 286 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 287 | # pragma GCC system_header | |
| 288 | # endif | |
| 286 | 289 | |
| 287 | 290 | _LIBCPP_PUSH_MACROS |
| 288 | #include <__undef_macros> | |
| 291 | # include <__undef_macros> | |
| 289 | 292 | |
| 290 | 293 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 291 | 294 | |
| ... | ... | @@ -313,7 +316,7 @@ public: |
| 313 | 316 | |
| 314 | 317 | _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {} |
| 315 | 318 | |
| 316 | #if _LIBCPP_STD_VER >= 23 | |
| 319 | # if _LIBCPP_STD_VER >= 23 | |
| 317 | 320 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 318 | 321 | _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} |
| 319 | 322 | |
| ... | ... | @@ -333,14 +336,14 @@ public: |
| 333 | 336 | _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc) |
| 334 | 337 | : c(from_range, std::forward<_Range>(__range), __alloc) {} |
| 335 | 338 | |
| 336 | #endif | |
| 339 | # endif | |
| 337 | 340 | |
| 338 | 341 | _LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) { |
| 339 | 342 | c = __q.c; |
| 340 | 343 | return *this; |
| 341 | 344 | } |
| 342 | 345 | |
| 343 | #ifndef _LIBCPP_CXX03_LANG | |
| 346 | # ifndef _LIBCPP_CXX03_LANG | |
| 344 | 347 | _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) noexcept(is_nothrow_move_constructible<container_type>::value) |
| 345 | 348 | : c(std::move(__q.c)) {} |
| 346 | 349 | |
| ... | ... | @@ -348,12 +351,12 @@ public: |
| 348 | 351 | c = std::move(__q.c); |
| 349 | 352 | return *this; |
| 350 | 353 | } |
| 351 | #endif // _LIBCPP_CXX03_LANG | |
| 354 | # endif // _LIBCPP_CXX03_LANG | |
| 352 | 355 | |
| 353 | 356 | _LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {} |
| 354 | #ifndef _LIBCPP_CXX03_LANG | |
| 357 | # ifndef _LIBCPP_CXX03_LANG | |
| 355 | 358 | _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {} |
| 356 | #endif // _LIBCPP_CXX03_LANG | |
| 359 | # endif // _LIBCPP_CXX03_LANG | |
| 357 | 360 | |
| 358 | 361 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 359 | 362 | _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a) : c(__a) {} |
| ... | ... | @@ -364,15 +367,15 @@ public: |
| 364 | 367 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 365 | 368 | _LIBCPP_HIDE_FROM_ABI queue(const container_type& __c, const _Alloc& __a) : c(__c, __a) {} |
| 366 | 369 | |
| 367 | #ifndef _LIBCPP_CXX03_LANG | |
| 370 | # ifndef _LIBCPP_CXX03_LANG | |
| 368 | 371 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 369 | 372 | _LIBCPP_HIDE_FROM_ABI queue(container_type&& __c, const _Alloc& __a) : c(std::move(__c), __a) {} |
| 370 | 373 | |
| 371 | 374 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 372 | 375 | _LIBCPP_HIDE_FROM_ABI queue(queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a) {} |
| 373 | #endif // _LIBCPP_CXX03_LANG | |
| 376 | # endif // _LIBCPP_CXX03_LANG | |
| 374 | 377 | |
| 375 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | |
| 378 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | |
| 376 | 379 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 377 | 380 | |
| 378 | 381 | _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); } |
| ... | ... | @@ -381,10 +384,10 @@ public: |
| 381 | 384 | _LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); } |
| 382 | 385 | |
| 383 | 386 | _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } |
| 384 | #ifndef _LIBCPP_CXX03_LANG | |
| 387 | # ifndef _LIBCPP_CXX03_LANG | |
| 385 | 388 | _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); } |
| 386 | 389 | |
| 387 | # if _LIBCPP_STD_VER >= 23 | |
| 390 | # if _LIBCPP_STD_VER >= 23 | |
| 388 | 391 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 389 | 392 | _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { |
| 390 | 393 | if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { |
| ... | ... | @@ -393,22 +396,22 @@ public: |
| 393 | 396 | ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); |
| 394 | 397 | } |
| 395 | 398 | } |
| 396 | # endif | |
| 399 | # endif | |
| 397 | 400 | |
| 398 | 401 | template <class... _Args> |
| 399 | 402 | _LIBCPP_HIDE_FROM_ABI |
| 400 | # if _LIBCPP_STD_VER >= 17 | |
| 403 | # if _LIBCPP_STD_VER >= 17 | |
| 401 | 404 | decltype(auto) |
| 402 | 405 | emplace(_Args&&... __args) { |
| 403 | 406 | return c.emplace_back(std::forward<_Args>(__args)...); |
| 404 | 407 | } |
| 405 | # else | |
| 408 | # else | |
| 406 | 409 | void |
| 407 | 410 | emplace(_Args&&... __args) { |
| 408 | 411 | c.emplace_back(std::forward<_Args>(__args)...); |
| 409 | 412 | } |
| 410 | # endif | |
| 411 | #endif // _LIBCPP_CXX03_LANG | |
| 413 | # endif | |
| 414 | # endif // _LIBCPP_CXX03_LANG | |
| 412 | 415 | _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); } |
| 413 | 416 | |
| 414 | 417 | _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable_v<container_type>) { |
| ... | ... | @@ -416,7 +419,7 @@ public: |
| 416 | 419 | swap(c, __q.c); |
| 417 | 420 | } |
| 418 | 421 | |
| 419 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } | |
| 422 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } | |
| 420 | 423 | |
| 421 | 424 | template <class _T1, class _OtherContainer> |
| 422 | 425 | friend _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -427,7 +430,7 @@ public: |
| 427 | 430 | operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); |
| 428 | 431 | }; |
| 429 | 432 | |
| 430 | #if _LIBCPP_STD_VER >= 17 | |
| 433 | # if _LIBCPP_STD_VER >= 17 | |
| 431 | 434 | template <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> > |
| 432 | 435 | queue(_Container) -> queue<typename _Container::value_type, _Container>; |
| 433 | 436 | |
| ... | ... | @@ -436,9 +439,9 @@ template <class _Container, |
| 436 | 439 | class = enable_if_t<!__is_allocator<_Container>::value>, |
| 437 | 440 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > |
| 438 | 441 | queue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>; |
| 439 | #endif | |
| 442 | # endif | |
| 440 | 443 | |
| 441 | #if _LIBCPP_STD_VER >= 23 | |
| 444 | # if _LIBCPP_STD_VER >= 23 | |
| 442 | 445 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 443 | 446 | queue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>; |
| 444 | 447 | |
| ... | ... | @@ -457,7 +460,7 @@ template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator |
| 457 | 460 | queue(from_range_t, |
| 458 | 461 | _Range&&, |
| 459 | 462 | _Alloc) -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; |
| 460 | #endif | |
| 463 | # endif | |
| 461 | 464 | |
| 462 | 465 | template <class _Tp, class _Container> |
| 463 | 466 | inline _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { |
| ... | ... | @@ -489,7 +492,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x, |
| 489 | 492 | return !(__y < __x); |
| 490 | 493 | } |
| 491 | 494 | |
| 492 | #if _LIBCPP_STD_VER >= 20 | |
| 495 | # if _LIBCPP_STD_VER >= 20 | |
| 493 | 496 | |
| 494 | 497 | template <class _Tp, three_way_comparable _Container> |
| 495 | 498 | _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> |
| ... | ... | @@ -498,7 +501,7 @@ operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y |
| 498 | 501 | return __x.__get_container() <=> __y.__get_container(); |
| 499 | 502 | } |
| 500 | 503 | |
| 501 | #endif | |
| 504 | # endif | |
| 502 | 505 | |
| 503 | 506 | template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0> |
| 504 | 507 | inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) |
| ... | ... | @@ -538,7 +541,7 @@ public: |
| 538 | 541 | return *this; |
| 539 | 542 | } |
| 540 | 543 | |
| 541 | #ifndef _LIBCPP_CXX03_LANG | |
| 544 | # ifndef _LIBCPP_CXX03_LANG | |
| 542 | 545 | _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept( |
| 543 | 546 | is_nothrow_move_constructible<container_type>::value && is_nothrow_move_constructible<value_compare>::value) |
| 544 | 547 | : c(std::move(__q.c)), comp(std::move(__q.comp)) {} |
| ... | ... | @@ -549,13 +552,13 @@ public: |
| 549 | 552 | comp = std::move(__q.comp); |
| 550 | 553 | return *this; |
| 551 | 554 | } |
| 552 | #endif // _LIBCPP_CXX03_LANG | |
| 555 | # endif // _LIBCPP_CXX03_LANG | |
| 553 | 556 | |
| 554 | 557 | _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {} |
| 555 | 558 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c); |
| 556 | #ifndef _LIBCPP_CXX03_LANG | |
| 559 | # ifndef _LIBCPP_CXX03_LANG | |
| 557 | 560 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c); |
| 558 | #endif | |
| 561 | # endif | |
| 559 | 562 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 560 | 563 | _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare()); |
| 561 | 564 | |
| ... | ... | @@ -563,19 +566,19 @@ public: |
| 563 | 566 | _LIBCPP_HIDE_FROM_ABI |
| 564 | 567 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c); |
| 565 | 568 | |
| 566 | #ifndef _LIBCPP_CXX03_LANG | |
| 569 | # ifndef _LIBCPP_CXX03_LANG | |
| 567 | 570 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 568 | 571 | _LIBCPP_HIDE_FROM_ABI |
| 569 | 572 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c); |
| 570 | #endif // _LIBCPP_CXX03_LANG | |
| 573 | # endif // _LIBCPP_CXX03_LANG | |
| 571 | 574 | |
| 572 | #if _LIBCPP_STD_VER >= 23 | |
| 575 | # if _LIBCPP_STD_VER >= 23 | |
| 573 | 576 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 574 | 577 | _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare()) |
| 575 | 578 | : c(from_range, std::forward<_Range>(__range)), comp(__comp) { |
| 576 | 579 | std::make_heap(c.begin(), c.end(), comp); |
| 577 | 580 | } |
| 578 | #endif | |
| 581 | # endif | |
| 579 | 582 | |
| 580 | 583 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 581 | 584 | _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a); |
| ... | ... | @@ -589,13 +592,13 @@ public: |
| 589 | 592 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 590 | 593 | _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a); |
| 591 | 594 | |
| 592 | #ifndef _LIBCPP_CXX03_LANG | |
| 595 | # ifndef _LIBCPP_CXX03_LANG | |
| 593 | 596 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 594 | 597 | _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a); |
| 595 | 598 | |
| 596 | 599 | template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 597 | 600 | _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a); |
| 598 | #endif // _LIBCPP_CXX03_LANG | |
| 601 | # endif // _LIBCPP_CXX03_LANG | |
| 599 | 602 | |
| 600 | 603 | template < |
| 601 | 604 | class _InputIter, |
| ... | ... | @@ -619,7 +622,7 @@ public: |
| 619 | 622 | _LIBCPP_HIDE_FROM_ABI priority_queue( |
| 620 | 623 | _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a); |
| 621 | 624 | |
| 622 | #ifndef _LIBCPP_CXX03_LANG | |
| 625 | # ifndef _LIBCPP_CXX03_LANG | |
| 623 | 626 | template < |
| 624 | 627 | class _InputIter, |
| 625 | 628 | class _Alloc, |
| ... | ... | @@ -627,9 +630,9 @@ public: |
| 627 | 630 | int> = 0> |
| 628 | 631 | _LIBCPP_HIDE_FROM_ABI |
| 629 | 632 | priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a); |
| 630 | #endif // _LIBCPP_CXX03_LANG | |
| 633 | # endif // _LIBCPP_CXX03_LANG | |
| 631 | 634 | |
| 632 | #if _LIBCPP_STD_VER >= 23 | |
| 635 | # if _LIBCPP_STD_VER >= 23 | |
| 633 | 636 | |
| 634 | 637 | template <_ContainerCompatibleRange<_Tp> _Range, |
| 635 | 638 | class _Alloc, |
| ... | ... | @@ -647,17 +650,17 @@ public: |
| 647 | 650 | std::make_heap(c.begin(), c.end(), comp); |
| 648 | 651 | } |
| 649 | 652 | |
| 650 | #endif | |
| 653 | # endif | |
| 651 | 654 | |
| 652 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | |
| 655 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | |
| 653 | 656 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 654 | 657 | _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } |
| 655 | 658 | |
| 656 | 659 | _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v); |
| 657 | #ifndef _LIBCPP_CXX03_LANG | |
| 660 | # ifndef _LIBCPP_CXX03_LANG | |
| 658 | 661 | _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v); |
| 659 | 662 | |
| 660 | # if _LIBCPP_STD_VER >= 23 | |
| 663 | # if _LIBCPP_STD_VER >= 23 | |
| 661 | 664 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 662 | 665 | _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { |
| 663 | 666 | if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { |
| ... | ... | @@ -668,20 +671,20 @@ public: |
| 668 | 671 | |
| 669 | 672 | std::make_heap(c.begin(), c.end(), comp); |
| 670 | 673 | } |
| 671 | # endif | |
| 674 | # endif | |
| 672 | 675 | |
| 673 | 676 | template <class... _Args> |
| 674 | 677 | _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args); |
| 675 | #endif // _LIBCPP_CXX03_LANG | |
| 678 | # endif // _LIBCPP_CXX03_LANG | |
| 676 | 679 | _LIBCPP_HIDE_FROM_ABI void pop(); |
| 677 | 680 | |
| 678 | 681 | _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q) |
| 679 | 682 | _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>); |
| 680 | 683 | |
| 681 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } | |
| 684 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } | |
| 682 | 685 | }; |
| 683 | 686 | |
| 684 | #if _LIBCPP_STD_VER >= 17 | |
| 687 | # if _LIBCPP_STD_VER >= 17 | |
| 685 | 688 | template <class _Compare, |
| 686 | 689 | class _Container, |
| 687 | 690 | class = enable_if_t<!__is_allocator<_Compare>::value>, |
| ... | ... | @@ -735,9 +738,9 @@ template <class _InputIterator, |
| 735 | 738 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > |
| 736 | 739 | priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) |
| 737 | 740 | -> priority_queue<typename _Container::value_type, _Container, _Compare>; |
| 738 | #endif | |
| 741 | # endif | |
| 739 | 742 | |
| 740 | #if _LIBCPP_STD_VER >= 23 | |
| 743 | # if _LIBCPP_STD_VER >= 23 | |
| 741 | 744 | |
| 742 | 745 | template <ranges::input_range _Range, |
| 743 | 746 | class _Compare = less<ranges::range_value_t<_Range>>, |
| ... | ... | @@ -757,7 +760,7 @@ template <ranges::input_range _Range, class _Alloc, class = enable_if_t<__is_all |
| 757 | 760 | priority_queue(from_range_t, _Range&&, _Alloc) |
| 758 | 761 | -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>; |
| 759 | 762 | |
| 760 | #endif | |
| 763 | # endif | |
| 761 | 764 | |
| 762 | 765 | template <class _Tp, class _Container, class _Compare> |
| 763 | 766 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c) |
| ... | ... | @@ -765,7 +768,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& |
| 765 | 768 | std::make_heap(c.begin(), c.end(), comp); |
| 766 | 769 | } |
| 767 | 770 | |
| 768 | #ifndef _LIBCPP_CXX03_LANG | |
| 771 | # ifndef _LIBCPP_CXX03_LANG | |
| 769 | 772 | |
| 770 | 773 | template <class _Tp, class _Container, class _Compare> |
| 771 | 774 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c) |
| ... | ... | @@ -773,7 +776,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com |
| 773 | 776 | std::make_heap(c.begin(), c.end(), comp); |
| 774 | 777 | } |
| 775 | 778 | |
| 776 | #endif // _LIBCPP_CXX03_LANG | |
| 779 | # endif // _LIBCPP_CXX03_LANG | |
| 777 | 780 | |
| 778 | 781 | template <class _Tp, class _Container, class _Compare> |
| 779 | 782 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| ... | ... | @@ -792,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 792 | 795 | std::make_heap(c.begin(), c.end(), comp); |
| 793 | 796 | } |
| 794 | 797 | |
| 795 | #ifndef _LIBCPP_CXX03_LANG | |
| 798 | # ifndef _LIBCPP_CXX03_LANG | |
| 796 | 799 | |
| 797 | 800 | template <class _Tp, class _Container, class _Compare> |
| 798 | 801 | template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| ... | ... | @@ -803,7 +806,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 803 | 806 | std::make_heap(c.begin(), c.end(), comp); |
| 804 | 807 | } |
| 805 | 808 | |
| 806 | #endif // _LIBCPP_CXX03_LANG | |
| 809 | # endif // _LIBCPP_CXX03_LANG | |
| 807 | 810 | |
| 808 | 811 | template <class _Tp, class _Container, class _Compare> |
| 809 | 812 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| ... | ... | @@ -827,7 +830,7 @@ template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, |
| 827 | 830 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a) |
| 828 | 831 | : c(__q.c, __a), comp(__q.comp) {} |
| 829 | 832 | |
| 830 | #ifndef _LIBCPP_CXX03_LANG | |
| 833 | # ifndef _LIBCPP_CXX03_LANG | |
| 831 | 834 | |
| 832 | 835 | template <class _Tp, class _Container, class _Compare> |
| 833 | 836 | template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| ... | ... | @@ -842,7 +845,7 @@ template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, |
| 842 | 845 | inline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a) |
| 843 | 846 | : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {} |
| 844 | 847 | |
| 845 | #endif // _LIBCPP_CXX03_LANG | |
| 848 | # endif // _LIBCPP_CXX03_LANG | |
| 846 | 849 | |
| 847 | 850 | template <class _Tp, class _Container, class _Compare> |
| 848 | 851 | template < |
| ... | ... | @@ -877,7 +880,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 877 | 880 | std::make_heap(c.begin(), c.end(), comp); |
| 878 | 881 | } |
| 879 | 882 | |
| 880 | #ifndef _LIBCPP_CXX03_LANG | |
| 883 | # ifndef _LIBCPP_CXX03_LANG | |
| 881 | 884 | template <class _Tp, class _Container, class _Compare> |
| 882 | 885 | template < |
| 883 | 886 | class _InputIter, |
| ... | ... | @@ -889,7 +892,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 889 | 892 | c.insert(c.end(), __f, __l); |
| 890 | 893 | std::make_heap(c.begin(), c.end(), comp); |
| 891 | 894 | } |
| 892 | #endif // _LIBCPP_CXX03_LANG | |
| 895 | # endif // _LIBCPP_CXX03_LANG | |
| 893 | 896 | |
| 894 | 897 | template <class _Tp, class _Container, class _Compare> |
| 895 | 898 | inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) { |
| ... | ... | @@ -897,7 +900,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __ |
| 897 | 900 | std::push_heap(c.begin(), c.end(), comp); |
| 898 | 901 | } |
| 899 | 902 | |
| 900 | #ifndef _LIBCPP_CXX03_LANG | |
| 903 | # ifndef _LIBCPP_CXX03_LANG | |
| 901 | 904 | |
| 902 | 905 | template <class _Tp, class _Container, class _Compare> |
| 903 | 906 | inline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) { |
| ... | ... | @@ -912,7 +915,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args |
| 912 | 915 | std::push_heap(c.begin(), c.end(), comp); |
| 913 | 916 | } |
| 914 | 917 | |
| 915 | #endif // _LIBCPP_CXX03_LANG | |
| 918 | # endif // _LIBCPP_CXX03_LANG | |
| 916 | 919 | |
| 917 | 920 | template <class _Tp, class _Container, class _Compare> |
| 918 | 921 | inline void priority_queue<_Tp, _Container, _Compare>::pop() { |
| ... | ... | @@ -946,11 +949,12 @@ _LIBCPP_END_NAMESPACE_STD |
| 946 | 949 | |
| 947 | 950 | _LIBCPP_POP_MACROS |
| 948 | 951 | |
| 949 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 950 | # include <concepts> | |
| 951 | # include <cstdlib> | |
| 952 | # include <functional> | |
| 953 | # include <type_traits> | |
| 954 | #endif | |
| 952 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 953 | # include <concepts> | |
| 954 | # include <cstdlib> | |
| 955 | # include <functional> | |
| 956 | # include <type_traits> | |
| 957 | # endif | |
| 958 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 955 | 959 | |
| 956 | 960 | #endif // _LIBCPP_QUEUE |
lib/libcxx/include/random+61-57| ... | ... | @@ -1677,66 +1677,70 @@ class piecewise_linear_distribution |
| 1677 | 1677 | } // std |
| 1678 | 1678 | */ |
| 1679 | 1679 | |
| 1680 | #include <__config> | |
| 1681 | #include <__random/bernoulli_distribution.h> | |
| 1682 | #include <__random/binomial_distribution.h> | |
| 1683 | #include <__random/cauchy_distribution.h> | |
| 1684 | #include <__random/chi_squared_distribution.h> | |
| 1685 | #include <__random/default_random_engine.h> | |
| 1686 | #include <__random/discard_block_engine.h> | |
| 1687 | #include <__random/discrete_distribution.h> | |
| 1688 | #include <__random/exponential_distribution.h> | |
| 1689 | #include <__random/extreme_value_distribution.h> | |
| 1690 | #include <__random/fisher_f_distribution.h> | |
| 1691 | #include <__random/gamma_distribution.h> | |
| 1692 | #include <__random/generate_canonical.h> | |
| 1693 | #include <__random/geometric_distribution.h> | |
| 1694 | #include <__random/independent_bits_engine.h> | |
| 1695 | #include <__random/is_seed_sequence.h> | |
| 1696 | #include <__random/knuth_b.h> | |
| 1697 | #include <__random/linear_congruential_engine.h> | |
| 1698 | #include <__random/lognormal_distribution.h> | |
| 1699 | #include <__random/mersenne_twister_engine.h> | |
| 1700 | #include <__random/negative_binomial_distribution.h> | |
| 1701 | #include <__random/normal_distribution.h> | |
| 1702 | #include <__random/piecewise_constant_distribution.h> | |
| 1703 | #include <__random/piecewise_linear_distribution.h> | |
| 1704 | #include <__random/poisson_distribution.h> | |
| 1705 | #include <__random/random_device.h> | |
| 1706 | #include <__random/ranlux.h> | |
| 1707 | #include <__random/seed_seq.h> | |
| 1708 | #include <__random/shuffle_order_engine.h> | |
| 1709 | #include <__random/student_t_distribution.h> | |
| 1710 | #include <__random/subtract_with_carry_engine.h> | |
| 1711 | #include <__random/uniform_int_distribution.h> | |
| 1712 | #include <__random/uniform_random_bit_generator.h> | |
| 1713 | #include <__random/uniform_real_distribution.h> | |
| 1714 | #include <__random/weibull_distribution.h> | |
| 1715 | #include <version> | |
| 1680 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1681 | # include <__cxx03/random> | |
| 1682 | #else | |
| 1683 | # include <__config> | |
| 1684 | # include <__random/bernoulli_distribution.h> | |
| 1685 | # include <__random/binomial_distribution.h> | |
| 1686 | # include <__random/cauchy_distribution.h> | |
| 1687 | # include <__random/chi_squared_distribution.h> | |
| 1688 | # include <__random/default_random_engine.h> | |
| 1689 | # include <__random/discard_block_engine.h> | |
| 1690 | # include <__random/discrete_distribution.h> | |
| 1691 | # include <__random/exponential_distribution.h> | |
| 1692 | # include <__random/extreme_value_distribution.h> | |
| 1693 | # include <__random/fisher_f_distribution.h> | |
| 1694 | # include <__random/gamma_distribution.h> | |
| 1695 | # include <__random/generate_canonical.h> | |
| 1696 | # include <__random/geometric_distribution.h> | |
| 1697 | # include <__random/independent_bits_engine.h> | |
| 1698 | # include <__random/is_seed_sequence.h> | |
| 1699 | # include <__random/knuth_b.h> | |
| 1700 | # include <__random/linear_congruential_engine.h> | |
| 1701 | # include <__random/lognormal_distribution.h> | |
| 1702 | # include <__random/mersenne_twister_engine.h> | |
| 1703 | # include <__random/negative_binomial_distribution.h> | |
| 1704 | # include <__random/normal_distribution.h> | |
| 1705 | # include <__random/piecewise_constant_distribution.h> | |
| 1706 | # include <__random/piecewise_linear_distribution.h> | |
| 1707 | # include <__random/poisson_distribution.h> | |
| 1708 | # include <__random/random_device.h> | |
| 1709 | # include <__random/ranlux.h> | |
| 1710 | # include <__random/seed_seq.h> | |
| 1711 | # include <__random/shuffle_order_engine.h> | |
| 1712 | # include <__random/student_t_distribution.h> | |
| 1713 | # include <__random/subtract_with_carry_engine.h> | |
| 1714 | # include <__random/uniform_int_distribution.h> | |
| 1715 | # include <__random/uniform_random_bit_generator.h> | |
| 1716 | # include <__random/uniform_real_distribution.h> | |
| 1717 | # include <__random/weibull_distribution.h> | |
| 1718 | # include <version> | |
| 1716 | 1719 | |
| 1717 | 1720 | // standard-mandated includes |
| 1718 | 1721 | |
| 1719 | 1722 | // [rand.synopsis] |
| 1720 | #include <initializer_list> | |
| 1721 | ||
| 1722 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 1723 | # pragma GCC system_header | |
| 1724 | #endif | |
| 1725 | ||
| 1726 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1727 | # include <algorithm> | |
| 1728 | # include <climits> | |
| 1729 | # include <cmath> | |
| 1730 | # include <concepts> | |
| 1731 | # include <cstddef> | |
| 1732 | # include <cstdint> | |
| 1733 | # include <cstdlib> | |
| 1734 | # include <iosfwd> | |
| 1735 | # include <limits> | |
| 1736 | # include <numeric> | |
| 1737 | # include <string> | |
| 1738 | # include <type_traits> | |
| 1739 | # include <vector> | |
| 1740 | #endif | |
| 1723 | # include <initializer_list> | |
| 1724 | ||
| 1725 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 1726 | # pragma GCC system_header | |
| 1727 | # endif | |
| 1728 | ||
| 1729 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1730 | # include <algorithm> | |
| 1731 | # include <climits> | |
| 1732 | # include <cmath> | |
| 1733 | # include <concepts> | |
| 1734 | # include <cstddef> | |
| 1735 | # include <cstdint> | |
| 1736 | # include <cstdlib> | |
| 1737 | # include <iosfwd> | |
| 1738 | # include <limits> | |
| 1739 | # include <numeric> | |
| 1740 | # include <string> | |
| 1741 | # include <type_traits> | |
| 1742 | # include <vector> | |
| 1743 | # endif | |
| 1744 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1741 | 1745 | |
| 1742 | 1746 | #endif // _LIBCPP_RANDOM |
lib/libcxx/include/ranges+66-70| ... | ... | @@ -380,84 +380,80 @@ namespace std { |
| 380 | 380 | } |
| 381 | 381 | */ |
| 382 | 382 | |
| 383 | #include <__config> | |
| 384 | ||
| 385 | #if _LIBCPP_STD_VER >= 20 | |
| 386 | # include <__ranges/access.h> | |
| 387 | # include <__ranges/all.h> | |
| 388 | # include <__ranges/common_view.h> | |
| 389 | # include <__ranges/concepts.h> | |
| 390 | # include <__ranges/counted.h> | |
| 391 | # include <__ranges/dangling.h> | |
| 392 | # include <__ranges/data.h> | |
| 393 | # include <__ranges/drop_view.h> | |
| 394 | # include <__ranges/drop_while_view.h> | |
| 395 | # include <__ranges/elements_view.h> | |
| 396 | # include <__ranges/empty.h> | |
| 397 | # include <__ranges/empty_view.h> | |
| 398 | # include <__ranges/enable_borrowed_range.h> | |
| 399 | # include <__ranges/enable_view.h> | |
| 400 | # include <__ranges/filter_view.h> | |
| 401 | # include <__ranges/iota_view.h> | |
| 402 | # include <__ranges/join_view.h> | |
| 403 | # include <__ranges/lazy_split_view.h> | |
| 404 | # include <__ranges/rbegin.h> | |
| 405 | # include <__ranges/ref_view.h> | |
| 406 | # include <__ranges/rend.h> | |
| 407 | # include <__ranges/reverse_view.h> | |
| 408 | # include <__ranges/single_view.h> | |
| 409 | # include <__ranges/size.h> | |
| 410 | # include <__ranges/split_view.h> | |
| 411 | # include <__ranges/subrange.h> | |
| 412 | # include <__ranges/take_view.h> | |
| 413 | # include <__ranges/take_while_view.h> | |
| 414 | # include <__ranges/transform_view.h> | |
| 415 | # include <__ranges/view_interface.h> | |
| 416 | # include <__ranges/views.h> | |
| 417 | ||
| 418 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 419 | # include <__ranges/istream_view.h> | |
| 383 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 384 | # include <__cxx03/ranges> | |
| 385 | #else | |
| 386 | # include <__config> | |
| 387 | ||
| 388 | # if _LIBCPP_STD_VER >= 20 | |
| 389 | # include <__ranges/access.h> | |
| 390 | # include <__ranges/all.h> | |
| 391 | # include <__ranges/common_view.h> | |
| 392 | # include <__ranges/concepts.h> | |
| 393 | # include <__ranges/counted.h> | |
| 394 | # include <__ranges/dangling.h> | |
| 395 | # include <__ranges/data.h> | |
| 396 | # include <__ranges/drop_view.h> | |
| 397 | # include <__ranges/drop_while_view.h> | |
| 398 | # include <__ranges/elements_view.h> | |
| 399 | # include <__ranges/empty.h> | |
| 400 | # include <__ranges/empty_view.h> | |
| 401 | # include <__ranges/enable_borrowed_range.h> | |
| 402 | # include <__ranges/enable_view.h> | |
| 403 | # include <__ranges/filter_view.h> | |
| 404 | # include <__ranges/iota_view.h> | |
| 405 | # include <__ranges/join_view.h> | |
| 406 | # include <__ranges/lazy_split_view.h> | |
| 407 | # include <__ranges/rbegin.h> | |
| 408 | # include <__ranges/ref_view.h> | |
| 409 | # include <__ranges/rend.h> | |
| 410 | # include <__ranges/reverse_view.h> | |
| 411 | # include <__ranges/single_view.h> | |
| 412 | # include <__ranges/size.h> | |
| 413 | # include <__ranges/split_view.h> | |
| 414 | # include <__ranges/subrange.h> | |
| 415 | # include <__ranges/take_view.h> | |
| 416 | # include <__ranges/take_while_view.h> | |
| 417 | # include <__ranges/transform_view.h> | |
| 418 | # include <__ranges/view_interface.h> | |
| 419 | # include <__ranges/views.h> | |
| 420 | ||
| 421 | # if _LIBCPP_HAS_LOCALIZATION | |
| 422 | # include <__ranges/istream_view.h> | |
| 423 | # endif | |
| 420 | 424 | # endif |
| 421 | #endif | |
| 422 | 425 | |
| 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> | |
| 430 | #endif | |
| 426 | # if _LIBCPP_STD_VER >= 23 | |
| 427 | # include <__ranges/as_rvalue_view.h> | |
| 428 | # include <__ranges/chunk_by_view.h> | |
| 429 | # include <__ranges/from_range.h> | |
| 430 | # include <__ranges/repeat_view.h> | |
| 431 | # include <__ranges/to.h> | |
| 432 | # include <__ranges/zip_view.h> | |
| 433 | # endif | |
| 431 | 434 | |
| 432 | #include <version> | |
| 435 | # include <version> | |
| 433 | 436 | |
| 434 | 437 | // standard-mandated includes |
| 435 | 438 | |
| 436 | 439 | // [ranges.syn] |
| 437 | #include <compare> | |
| 438 | #include <initializer_list> | |
| 439 | #include <iterator> | |
| 440 | # include <compare> | |
| 441 | # include <initializer_list> | |
| 442 | # include <iterator> | |
| 440 | 443 | |
| 441 | 444 | // [tuple.helper] |
| 442 | #include <__tuple/tuple_element.h> | |
| 443 | #include <__tuple/tuple_size.h> | |
| 444 | ||
| 445 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 446 | # pragma GCC system_header | |
| 447 | #endif | |
| 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 | ||
| 457 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 458 | # include <cstdlib> | |
| 459 | # include <iosfwd> | |
| 460 | # include <type_traits> | |
| 461 | #endif | |
| 445 | # include <__tuple/tuple_element.h> | |
| 446 | # include <__tuple/tuple_size.h> | |
| 447 | ||
| 448 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 449 | # pragma GCC system_header | |
| 450 | # endif | |
| 451 | ||
| 452 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 453 | # include <cstdlib> | |
| 454 | # include <iosfwd> | |
| 455 | # include <type_traits> | |
| 456 | # endif | |
| 457 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 462 | 458 | |
| 463 | 459 | #endif // _LIBCPP_RANGES |
lib/libcxx/include/ratio+82-100| ... | ... | @@ -81,56 +81,47 @@ 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 <__config> | |
| 85 | #include <__type_traits/integral_constant.h> | |
| 86 | #include <climits> | |
| 87 | #include <cstdint> | |
| 88 | #include <version> | |
| 89 | ||
| 90 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 91 | # pragma GCC system_header | |
| 92 | #endif | |
| 84 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 85 | # include <__cxx03/ratio> | |
| 86 | #else | |
| 87 | # include <__config> | |
| 88 | # include <__type_traits/integral_constant.h> | |
| 89 | # include <climits> | |
| 90 | # include <cstdint> | |
| 91 | # include <version> | |
| 92 | ||
| 93 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 94 | # pragma GCC system_header | |
| 95 | # endif | |
| 93 | 96 | |
| 94 | 97 | _LIBCPP_PUSH_MACROS |
| 95 | #include <__undef_macros> | |
| 98 | # include <__undef_macros> | |
| 96 | 99 | |
| 97 | 100 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 98 | 101 | |
| 99 | 102 | // __static_gcd |
| 100 | 103 | |
| 101 | 104 | template <intmax_t _Xp, intmax_t _Yp> |
| 102 | struct __static_gcd { | |
| 103 | static const intmax_t value = __static_gcd<_Yp, _Xp % _Yp>::value; | |
| 104 | }; | |
| 105 | inline const intmax_t __static_gcd = __static_gcd<_Yp, _Xp % _Yp>; | |
| 105 | 106 | |
| 106 | 107 | template <intmax_t _Xp> |
| 107 | struct __static_gcd<_Xp, 0> { | |
| 108 | static const intmax_t value = _Xp; | |
| 109 | }; | |
| 108 | inline const intmax_t __static_gcd<_Xp, 0> = _Xp; | |
| 110 | 109 | |
| 111 | 110 | template <> |
| 112 | struct __static_gcd<0, 0> { | |
| 113 | static const intmax_t value = 1; | |
| 114 | }; | |
| 111 | inline const intmax_t __static_gcd<0, 0> = 1; | |
| 115 | 112 | |
| 116 | 113 | // __static_lcm |
| 117 | 114 | |
| 118 | 115 | template <intmax_t _Xp, intmax_t _Yp> |
| 119 | struct __static_lcm { | |
| 120 | static const intmax_t value = _Xp / __static_gcd<_Xp, _Yp>::value * _Yp; | |
| 121 | }; | |
| 116 | inline const intmax_t __static_lcm = _Xp / __static_gcd<_Xp, _Yp> * _Yp; | |
| 122 | 117 | |
| 123 | 118 | template <intmax_t _Xp> |
| 124 | struct __static_abs { | |
| 125 | static const intmax_t value = _Xp < 0 ? -_Xp : _Xp; | |
| 126 | }; | |
| 119 | inline const intmax_t __static_abs = _Xp < 0 ? -_Xp : _Xp; | |
| 127 | 120 | |
| 128 | 121 | template <intmax_t _Xp> |
| 129 | struct __static_sign { | |
| 130 | static const intmax_t value = _Xp == 0 ? 0 : (_Xp < 0 ? -1 : 1); | |
| 131 | }; | |
| 122 | inline const intmax_t __static_sign = _Xp == 0 ? 0 : (_Xp < 0 ? -1 : 1); | |
| 132 | 123 | |
| 133 | template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value> | |
| 124 | template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp> > | |
| 134 | 125 | class __ll_add; |
| 135 | 126 | |
| 136 | 127 | template <intmax_t _Xp, intmax_t _Yp> |
| ... | ... | @@ -161,7 +152,7 @@ public: |
| 161 | 152 | static const intmax_t value = _Xp + _Yp; |
| 162 | 153 | }; |
| 163 | 154 | |
| 164 | template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value> | |
| 155 | template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp> > | |
| 165 | 156 | class __ll_sub; |
| 166 | 157 | |
| 167 | 158 | template <intmax_t _Xp, intmax_t _Yp> |
| ... | ... | @@ -197,8 +188,8 @@ class __ll_mul { |
| 197 | 188 | static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)); |
| 198 | 189 | static const intmax_t min = nan + 1; |
| 199 | 190 | static const intmax_t max = -min; |
| 200 | static const intmax_t __a_x = __static_abs<_Xp>::value; | |
| 201 | static const intmax_t __a_y = __static_abs<_Yp>::value; | |
| 191 | static const intmax_t __a_x = __static_abs<_Xp>; | |
| 192 | static const intmax_t __a_y = __static_abs<_Yp>; | |
| 202 | 193 | |
| 203 | 194 | static_assert(_Xp != nan && _Yp != nan && __a_x <= max / __a_y, "overflow in __ll_mul"); |
| 204 | 195 | |
| ... | ... | @@ -239,31 +230,26 @@ public: |
| 239 | 230 | |
| 240 | 231 | template <intmax_t _Num, intmax_t _Den = 1> |
| 241 | 232 | class _LIBCPP_TEMPLATE_VIS ratio { |
| 242 | static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range"); | |
| 233 | static_assert(__static_abs<_Num> >= 0, "ratio numerator is out of range"); | |
| 243 | 234 | static_assert(_Den != 0, "ratio divide by 0"); |
| 244 | static_assert(__static_abs<_Den>::value > 0, "ratio denominator is out of range"); | |
| 245 | static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>::value; | |
| 246 | static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>::value; | |
| 247 | static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value; | |
| 248 | static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>::value; | |
| 235 | static_assert(__static_abs<_Den> > 0, "ratio denominator is out of range"); | |
| 236 | static _LIBCPP_CONSTEXPR const intmax_t __na = __static_abs<_Num>; | |
| 237 | static _LIBCPP_CONSTEXPR const intmax_t __da = __static_abs<_Den>; | |
| 238 | static _LIBCPP_CONSTEXPR const intmax_t __s = __static_sign<_Num> * __static_sign<_Den>; | |
| 239 | static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>; | |
| 249 | 240 | |
| 250 | 241 | public: |
| 251 | static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd; | |
| 252 | static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd; | |
| 242 | static inline _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd; | |
| 243 | static inline _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd; | |
| 253 | 244 | |
| 254 | 245 | typedef ratio<num, den> type; |
| 255 | 246 | }; |
| 256 | 247 | |
| 257 | template <intmax_t _Num, intmax_t _Den> | |
| 258 | _LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num; | |
| 259 | ||
| 260 | template <intmax_t _Num, intmax_t _Den> | |
| 261 | _LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den; | |
| 262 | ||
| 263 | 248 | template <class _Tp> |
| 264 | struct __is_ratio : false_type {}; | |
| 249 | inline const bool __is_ratio_v = false; | |
| 250 | ||
| 265 | 251 | template <intmax_t _Num, intmax_t _Den> |
| 266 | struct __is_ratio<ratio<_Num, _Den> > : true_type {}; | |
| 252 | inline const bool __is_ratio_v<ratio<_Num, _Den> > = true; | |
| 267 | 253 | |
| 268 | 254 | typedef ratio<1LL, 1000000000000000000LL> atto; |
| 269 | 255 | typedef ratio<1LL, 1000000000000000LL> femto; |
| ... | ... | @@ -285,63 +271,63 @@ typedef ratio<1000000000000000000LL, 1LL> exa; |
| 285 | 271 | template <class _R1, class _R2> |
| 286 | 272 | struct __ratio_multiply { |
| 287 | 273 | private: |
| 288 | static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>::value; | |
| 289 | static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>::value; | |
| 274 | static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>; | |
| 275 | static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>; | |
| 290 | 276 | |
| 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"); | |
| 277 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | |
| 278 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | |
| 293 | 279 | |
| 294 | 280 | public: |
| 295 | 281 | typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_d2, _R2::num / __gcd_d1_n2>::value, |
| 296 | 282 | __ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value >::type type; |
| 297 | 283 | }; |
| 298 | 284 | |
| 299 | #ifndef _LIBCPP_CXX03_LANG | |
| 285 | # ifndef _LIBCPP_CXX03_LANG | |
| 300 | 286 | |
| 301 | 287 | template <class _R1, class _R2> |
| 302 | 288 | using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type; |
| 303 | 289 | |
| 304 | #else // _LIBCPP_CXX03_LANG | |
| 290 | # else // _LIBCPP_CXX03_LANG | |
| 305 | 291 | |
| 306 | 292 | template <class _R1, class _R2> |
| 307 | 293 | struct _LIBCPP_TEMPLATE_VIS ratio_multiply : public __ratio_multiply<_R1, _R2>::type {}; |
| 308 | 294 | |
| 309 | #endif // _LIBCPP_CXX03_LANG | |
| 295 | # endif // _LIBCPP_CXX03_LANG | |
| 310 | 296 | |
| 311 | 297 | template <class _R1, class _R2> |
| 312 | 298 | struct __ratio_divide { |
| 313 | 299 | private: |
| 314 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; | |
| 315 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; | |
| 300 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>; | |
| 301 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>; | |
| 316 | 302 | |
| 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"); | |
| 303 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | |
| 304 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | |
| 319 | 305 | |
| 320 | 306 | public: |
| 321 | 307 | typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value, |
| 322 | 308 | __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value >::type type; |
| 323 | 309 | }; |
| 324 | 310 | |
| 325 | #ifndef _LIBCPP_CXX03_LANG | |
| 311 | # ifndef _LIBCPP_CXX03_LANG | |
| 326 | 312 | |
| 327 | 313 | template <class _R1, class _R2> |
| 328 | 314 | using ratio_divide = typename __ratio_divide<_R1, _R2>::type; |
| 329 | 315 | |
| 330 | #else // _LIBCPP_CXX03_LANG | |
| 316 | # else // _LIBCPP_CXX03_LANG | |
| 331 | 317 | |
| 332 | 318 | template <class _R1, class _R2> |
| 333 | 319 | struct _LIBCPP_TEMPLATE_VIS ratio_divide : public __ratio_divide<_R1, _R2>::type {}; |
| 334 | 320 | |
| 335 | #endif // _LIBCPP_CXX03_LANG | |
| 321 | # endif // _LIBCPP_CXX03_LANG | |
| 336 | 322 | |
| 337 | 323 | template <class _R1, class _R2> |
| 338 | 324 | struct __ratio_add { |
| 339 | 325 | private: |
| 340 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; | |
| 341 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; | |
| 326 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>; | |
| 327 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>; | |
| 342 | 328 | |
| 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"); | |
| 329 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | |
| 330 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | |
| 345 | 331 | |
| 346 | 332 | public: |
| 347 | 333 | typedef typename ratio_multiply< |
| ... | ... | @@ -351,26 +337,26 @@ public: |
| 351 | 337 | _R2::den > >::type type; |
| 352 | 338 | }; |
| 353 | 339 | |
| 354 | #ifndef _LIBCPP_CXX03_LANG | |
| 340 | # ifndef _LIBCPP_CXX03_LANG | |
| 355 | 341 | |
| 356 | 342 | template <class _R1, class _R2> |
| 357 | 343 | using ratio_add = typename __ratio_add<_R1, _R2>::type; |
| 358 | 344 | |
| 359 | #else // _LIBCPP_CXX03_LANG | |
| 345 | # else // _LIBCPP_CXX03_LANG | |
| 360 | 346 | |
| 361 | 347 | template <class _R1, class _R2> |
| 362 | 348 | struct _LIBCPP_TEMPLATE_VIS ratio_add : public __ratio_add<_R1, _R2>::type {}; |
| 363 | 349 | |
| 364 | #endif // _LIBCPP_CXX03_LANG | |
| 350 | # endif // _LIBCPP_CXX03_LANG | |
| 365 | 351 | |
| 366 | 352 | template <class _R1, class _R2> |
| 367 | 353 | struct __ratio_subtract { |
| 368 | 354 | private: |
| 369 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; | |
| 370 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; | |
| 355 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>; | |
| 356 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>; | |
| 371 | 357 | |
| 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"); | |
| 358 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | |
| 359 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | |
| 374 | 360 | |
| 375 | 361 | public: |
| 376 | 362 | typedef typename ratio_multiply< |
| ... | ... | @@ -380,30 +366,30 @@ public: |
| 380 | 366 | _R2::den > >::type type; |
| 381 | 367 | }; |
| 382 | 368 | |
| 383 | #ifndef _LIBCPP_CXX03_LANG | |
| 369 | # ifndef _LIBCPP_CXX03_LANG | |
| 384 | 370 | |
| 385 | 371 | template <class _R1, class _R2> |
| 386 | 372 | using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type; |
| 387 | 373 | |
| 388 | #else // _LIBCPP_CXX03_LANG | |
| 374 | # else // _LIBCPP_CXX03_LANG | |
| 389 | 375 | |
| 390 | 376 | template <class _R1, class _R2> |
| 391 | 377 | struct _LIBCPP_TEMPLATE_VIS ratio_subtract : public __ratio_subtract<_R1, _R2>::type {}; |
| 392 | 378 | |
| 393 | #endif // _LIBCPP_CXX03_LANG | |
| 379 | # endif // _LIBCPP_CXX03_LANG | |
| 394 | 380 | |
| 395 | 381 | // ratio_equal |
| 396 | 382 | |
| 397 | 383 | template <class _R1, class _R2> |
| 398 | 384 | 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"); | |
| 385 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | |
| 386 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | |
| 401 | 387 | }; |
| 402 | 388 | |
| 403 | 389 | template <class _R1, class _R2> |
| 404 | 390 | 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"); | |
| 391 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | |
| 392 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | |
| 407 | 393 | }; |
| 408 | 394 | |
| 409 | 395 | // ratio_less |
| ... | ... | @@ -439,10 +425,7 @@ struct __ratio_less1<_R1, _R2, _Odd, _Qp, _M1, _Qp, _M2> { |
| 439 | 425 | static const bool value = __ratio_less1<ratio<_R1::den, _M1>, ratio<_R2::den, _M2>, !_Odd>::value; |
| 440 | 426 | }; |
| 441 | 427 | |
| 442 | template <class _R1, | |
| 443 | class _R2, | |
| 444 | intmax_t _S1 = __static_sign<_R1::num>::value, | |
| 445 | intmax_t _S2 = __static_sign<_R2::num>::value> | |
| 428 | template <class _R1, class _R2, intmax_t _S1 = __static_sign<_R1::num>, intmax_t _S2 = __static_sign<_R2::num> > | |
| 446 | 429 | struct __ratio_less { |
| 447 | 430 | static const bool value = _S1 < _S2; |
| 448 | 431 | }; |
| ... | ... | @@ -459,34 +442,32 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> { |
| 459 | 442 | |
| 460 | 443 | template <class _R1, class _R2> |
| 461 | 444 | 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"); | |
| 445 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | |
| 446 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | |
| 464 | 447 | }; |
| 465 | 448 | |
| 466 | 449 | template <class _R1, class _R2> |
| 467 | 450 | 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"); | |
| 451 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | |
| 452 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | |
| 470 | 453 | }; |
| 471 | 454 | |
| 472 | 455 | template <class _R1, class _R2> |
| 473 | 456 | 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"); | |
| 457 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | |
| 458 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | |
| 476 | 459 | }; |
| 477 | 460 | |
| 478 | 461 | template <class _R1, class _R2> |
| 479 | 462 | 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"); | |
| 463 | static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template"); | |
| 464 | static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template"); | |
| 482 | 465 | }; |
| 483 | 466 | |
| 484 | 467 | template <class _R1, class _R2> |
| 485 | struct __ratio_gcd { | |
| 486 | typedef ratio<__static_gcd<_R1::num, _R2::num>::value, __static_lcm<_R1::den, _R2::den>::value> type; | |
| 487 | }; | |
| 468 | using __ratio_gcd _LIBCPP_NODEBUG = ratio<__static_gcd<_R1::num, _R2::num>, __static_lcm<_R1::den, _R2::den> >; | |
| 488 | 469 | |
| 489 | #if _LIBCPP_STD_VER >= 17 | |
| 470 | # if _LIBCPP_STD_VER >= 17 | |
| 490 | 471 | template <class _R1, class _R2> |
| 491 | 472 | inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value; |
| 492 | 473 | |
| ... | ... | @@ -504,14 +485,15 @@ inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value; |
| 504 | 485 | |
| 505 | 486 | template <class _R1, class _R2> |
| 506 | 487 | inline constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value; |
| 507 | #endif | |
| 488 | # endif | |
| 508 | 489 | |
| 509 | 490 | _LIBCPP_END_NAMESPACE_STD |
| 510 | 491 | |
| 511 | 492 | _LIBCPP_POP_MACROS |
| 512 | 493 | |
| 513 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 514 | # include <type_traits> | |
| 515 | #endif | |
| 494 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 495 | # include <type_traits> | |
| 496 | # endif | |
| 497 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 516 | 498 | |
| 517 | 499 | #endif // _LIBCPP_RATIO |
lib/libcxx/include/regex+164-161| ... | ... | @@ -789,48 +789,51 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; |
| 789 | 789 | } // std |
| 790 | 790 | */ |
| 791 | 791 | |
| 792 | #include <__algorithm/find.h> | |
| 793 | #include <__algorithm/search.h> | |
| 794 | #include <__assert> | |
| 795 | #include <__config> | |
| 796 | #include <__iterator/back_insert_iterator.h> | |
| 797 | #include <__iterator/default_sentinel.h> | |
| 798 | #include <__iterator/wrap_iter.h> | |
| 799 | #include <__locale> | |
| 800 | #include <__memory/shared_ptr.h> | |
| 801 | #include <__memory_resource/polymorphic_allocator.h> | |
| 802 | #include <__type_traits/is_swappable.h> | |
| 803 | #include <__utility/move.h> | |
| 804 | #include <__utility/pair.h> | |
| 805 | #include <__utility/swap.h> | |
| 806 | #include <__verbose_abort> | |
| 807 | #include <deque> | |
| 808 | #include <stdexcept> | |
| 809 | #include <string> | |
| 810 | #include <vector> | |
| 811 | #include <version> | |
| 792 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 793 | # include <__cxx03/regex> | |
| 794 | #else | |
| 795 | # include <__algorithm/find.h> | |
| 796 | # include <__algorithm/search.h> | |
| 797 | # include <__assert> | |
| 798 | # include <__config> | |
| 799 | # include <__iterator/back_insert_iterator.h> | |
| 800 | # include <__iterator/default_sentinel.h> | |
| 801 | # include <__iterator/wrap_iter.h> | |
| 802 | # include <__locale> | |
| 803 | # include <__memory/shared_ptr.h> | |
| 804 | # include <__memory_resource/polymorphic_allocator.h> | |
| 805 | # include <__type_traits/is_swappable.h> | |
| 806 | # include <__utility/move.h> | |
| 807 | # include <__utility/pair.h> | |
| 808 | # include <__utility/swap.h> | |
| 809 | # include <__verbose_abort> | |
| 810 | # include <deque> | |
| 811 | # include <stdexcept> | |
| 812 | # include <string> | |
| 813 | # include <vector> | |
| 814 | # include <version> | |
| 812 | 815 | |
| 813 | 816 | // standard-mandated includes |
| 814 | 817 | |
| 815 | 818 | // [iterator.range] |
| 816 | #include <__iterator/access.h> | |
| 817 | #include <__iterator/data.h> | |
| 818 | #include <__iterator/empty.h> | |
| 819 | #include <__iterator/reverse_access.h> | |
| 820 | #include <__iterator/size.h> | |
| 819 | # include <__iterator/access.h> | |
| 820 | # include <__iterator/data.h> | |
| 821 | # include <__iterator/empty.h> | |
| 822 | # include <__iterator/reverse_access.h> | |
| 823 | # include <__iterator/size.h> | |
| 821 | 824 | |
| 822 | 825 | // [re.syn] |
| 823 | #include <compare> | |
| 824 | #include <initializer_list> | |
| 826 | # include <compare> | |
| 827 | # include <initializer_list> | |
| 825 | 828 | |
| 826 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 827 | # pragma GCC system_header | |
| 828 | #endif | |
| 829 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 830 | # pragma GCC system_header | |
| 831 | # endif | |
| 829 | 832 | |
| 830 | 833 | _LIBCPP_PUSH_MACROS |
| 831 | #include <__undef_macros> | |
| 834 | # include <__undef_macros> | |
| 832 | 835 | |
| 833 | #define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096 | |
| 836 | # define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096 | |
| 834 | 837 | |
| 835 | 838 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 836 | 839 | |
| ... | ... | @@ -843,11 +846,11 @@ enum syntax_option_type { |
| 843 | 846 | nosubs = 1 << 1, |
| 844 | 847 | optimize = 1 << 2, |
| 845 | 848 | collate = 1 << 3, |
| 846 | #ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | |
| 849 | # ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | |
| 847 | 850 | ECMAScript = 1 << 9, |
| 848 | #else | |
| 851 | # else | |
| 849 | 852 | ECMAScript = 0, |
| 850 | #endif | |
| 853 | # endif | |
| 851 | 854 | basic = 1 << 4, |
| 852 | 855 | extended = 1 << 5, |
| 853 | 856 | awk = 1 << 6, |
| ... | ... | @@ -858,11 +861,11 @@ enum syntax_option_type { |
| 858 | 861 | }; |
| 859 | 862 | |
| 860 | 863 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR syntax_option_type __get_grammar(syntax_option_type __g) { |
| 861 | #ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | |
| 864 | # ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | |
| 862 | 865 | return static_cast<syntax_option_type>(__g & 0x3F0); |
| 863 | #else | |
| 866 | # else | |
| 864 | 867 | return static_cast<syntax_option_type>(__g & 0x1F0); |
| 865 | #endif | |
| 868 | # endif | |
| 866 | 869 | } |
| 867 | 870 | |
| 868 | 871 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type operator~(syntax_option_type __x) { |
| ... | ... | @@ -983,12 +986,12 @@ public: |
| 983 | 986 | }; |
| 984 | 987 | |
| 985 | 988 | template <regex_constants::error_type _Ev> |
| 986 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() { | |
| 987 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 989 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() { | |
| 990 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 988 | 991 | throw regex_error(_Ev); |
| 989 | #else | |
| 992 | # else | |
| 990 | 993 | _LIBCPP_VERBOSE_ABORT("regex_error was thrown in -fno-exceptions mode"); |
| 991 | #endif | |
| 994 | # endif | |
| 992 | 995 | } |
| 993 | 996 | |
| 994 | 997 | template <class _CharT> |
| ... | ... | @@ -997,7 +1000,7 @@ public: |
| 997 | 1000 | typedef _CharT char_type; |
| 998 | 1001 | typedef basic_string<char_type> string_type; |
| 999 | 1002 | typedef locale locale_type; |
| 1000 | #if defined(__BIONIC__) || defined(_NEWLIB_VERSION) | |
| 1003 | # if defined(__BIONIC__) || defined(_NEWLIB_VERSION) | |
| 1001 | 1004 | // Originally bionic's ctype_base used its own ctype masks because the |
| 1002 | 1005 | // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask |
| 1003 | 1006 | // was only 8 bits wide and already saturated, so it used a wider type here |
| ... | ... | @@ -1012,9 +1015,9 @@ public: |
| 1012 | 1015 | // often used for space constrained environments, so it makes sense not to |
| 1013 | 1016 | // duplicate the ctype table. |
| 1014 | 1017 | typedef uint16_t char_class_type; |
| 1015 | #else | |
| 1018 | # else | |
| 1016 | 1019 | typedef ctype_base::mask char_class_type; |
| 1017 | #endif | |
| 1020 | # endif | |
| 1018 | 1021 | |
| 1019 | 1022 | static const char_class_type __regex_word = ctype_base::__regex_word; |
| 1020 | 1023 | |
| ... | ... | @@ -1054,30 +1057,30 @@ private: |
| 1054 | 1057 | |
| 1055 | 1058 | template <class _ForwardIterator> |
| 1056 | 1059 | string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const; |
| 1057 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1060 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1058 | 1061 | template <class _ForwardIterator> |
| 1059 | 1062 | string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; |
| 1060 | #endif | |
| 1063 | # endif | |
| 1061 | 1064 | template <class _ForwardIterator> |
| 1062 | 1065 | string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const; |
| 1063 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1066 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1064 | 1067 | template <class _ForwardIterator> |
| 1065 | 1068 | string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; |
| 1066 | #endif | |
| 1069 | # endif | |
| 1067 | 1070 | template <class _ForwardIterator> |
| 1068 | 1071 | char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const; |
| 1069 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1072 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1070 | 1073 | template <class _ForwardIterator> |
| 1071 | 1074 | char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const; |
| 1072 | #endif | |
| 1075 | # endif | |
| 1073 | 1076 | |
| 1074 | 1077 | static int __regex_traits_value(unsigned char __ch, int __radix); |
| 1075 | 1078 | _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(char __ch, int __radix) const { |
| 1076 | 1079 | return __regex_traits_value(static_cast<unsigned char>(__ch), __radix); |
| 1077 | 1080 | } |
| 1078 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1081 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1079 | 1082 | _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(wchar_t __ch, int __radix) const; |
| 1080 | #endif | |
| 1083 | # endif | |
| 1081 | 1084 | }; |
| 1082 | 1085 | |
| 1083 | 1086 | template <class _CharT> |
| ... | ... | @@ -1136,7 +1139,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator |
| 1136 | 1139 | return __d; |
| 1137 | 1140 | } |
| 1138 | 1141 | |
| 1139 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1142 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1140 | 1143 | template <class _CharT> |
| 1141 | 1144 | template <class _ForwardIterator> |
| 1142 | 1145 | typename regex_traits<_CharT>::string_type |
| ... | ... | @@ -1155,7 +1158,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator |
| 1155 | 1158 | } |
| 1156 | 1159 | return __d; |
| 1157 | 1160 | } |
| 1158 | #endif | |
| 1161 | # endif | |
| 1159 | 1162 | |
| 1160 | 1163 | // lookup_collatename is very FreeBSD-specific |
| 1161 | 1164 | |
| ... | ... | @@ -1180,7 +1183,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato |
| 1180 | 1183 | return __r; |
| 1181 | 1184 | } |
| 1182 | 1185 | |
| 1183 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1186 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1184 | 1187 | template <class _CharT> |
| 1185 | 1188 | template <class _ForwardIterator> |
| 1186 | 1189 | typename regex_traits<_CharT>::string_type |
| ... | ... | @@ -1208,7 +1211,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato |
| 1208 | 1211 | } |
| 1209 | 1212 | return __r; |
| 1210 | 1213 | } |
| 1211 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1214 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1212 | 1215 | |
| 1213 | 1216 | // lookup_classname |
| 1214 | 1217 | |
| ... | ... | @@ -1223,7 +1226,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator |
| 1223 | 1226 | return std::__get_classname(__s.c_str(), __icase); |
| 1224 | 1227 | } |
| 1225 | 1228 | |
| 1226 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1229 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1227 | 1230 | template <class _CharT> |
| 1228 | 1231 | template <class _ForwardIterator> |
| 1229 | 1232 | typename regex_traits<_CharT>::char_class_type |
| ... | ... | @@ -1239,7 +1242,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator |
| 1239 | 1242 | } |
| 1240 | 1243 | return __get_classname(__n.c_str(), __icase); |
| 1241 | 1244 | } |
| 1242 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1245 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1243 | 1246 | |
| 1244 | 1247 | template <class _CharT> |
| 1245 | 1248 | bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const { |
| ... | ... | @@ -1250,28 +1253,28 @@ bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const { |
| 1250 | 1253 | |
| 1251 | 1254 | inline _LIBCPP_HIDE_FROM_ABI bool __is_07(unsigned char __c) { |
| 1252 | 1255 | return (__c & 0xF8u) == |
| 1253 | #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | |
| 1256 | # if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | |
| 1254 | 1257 | 0xF0; |
| 1255 | #else | |
| 1258 | # else | |
| 1256 | 1259 | 0x30; |
| 1257 | #endif | |
| 1260 | # endif | |
| 1258 | 1261 | } |
| 1259 | 1262 | |
| 1260 | 1263 | inline _LIBCPP_HIDE_FROM_ABI bool __is_89(unsigned char __c) { |
| 1261 | 1264 | return (__c & 0xFEu) == |
| 1262 | #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | |
| 1265 | # if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | |
| 1263 | 1266 | 0xF8; |
| 1264 | #else | |
| 1267 | # else | |
| 1265 | 1268 | 0x38; |
| 1266 | #endif | |
| 1269 | # endif | |
| 1267 | 1270 | } |
| 1268 | 1271 | |
| 1269 | 1272 | inline _LIBCPP_HIDE_FROM_ABI unsigned char __to_lower(unsigned char __c) { |
| 1270 | #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | |
| 1273 | # if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | |
| 1271 | 1274 | return __c & 0xBF; |
| 1272 | #else | |
| 1275 | # else | |
| 1273 | 1276 | return __c | 0x20; |
| 1274 | #endif | |
| 1277 | # endif | |
| 1275 | 1278 | } |
| 1276 | 1279 | |
| 1277 | 1280 | template <class _CharT> |
| ... | ... | @@ -1290,12 +1293,12 @@ int regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) |
| 1290 | 1293 | return -1; |
| 1291 | 1294 | } |
| 1292 | 1295 | |
| 1293 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1296 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1294 | 1297 | template <class _CharT> |
| 1295 | 1298 | inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const { |
| 1296 | 1299 | return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); |
| 1297 | 1300 | } |
| 1298 | #endif | |
| 1301 | # endif | |
| 1299 | 1302 | |
| 1300 | 1303 | template <class _CharT> |
| 1301 | 1304 | class __node; |
| ... | ... | @@ -1938,10 +1941,10 @@ public: |
| 1938 | 1941 | |
| 1939 | 1942 | template <> |
| 1940 | 1943 | _LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<char>::__exec(__state&) const; |
| 1941 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1944 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1942 | 1945 | template <> |
| 1943 | 1946 | _LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<wchar_t>::__exec(__state&) const; |
| 1944 | #endif | |
| 1947 | # endif | |
| 1945 | 1948 | |
| 1946 | 1949 | // __match_char |
| 1947 | 1950 | |
| ... | ... | @@ -2262,9 +2265,9 @@ template <class _CharT, class _Traits = regex_traits<_CharT> > |
| 2262 | 2265 | class _LIBCPP_TEMPLATE_VIS basic_regex; |
| 2263 | 2266 | |
| 2264 | 2267 | typedef basic_regex<char> regex; |
| 2265 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2268 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2266 | 2269 | typedef basic_regex<wchar_t> wregex; |
| 2267 | #endif | |
| 2270 | # endif | |
| 2268 | 2271 | |
| 2269 | 2272 | template <class _CharT, class _Traits> |
| 2270 | 2273 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(regex) |
| ... | ... | @@ -2335,21 +2338,21 @@ public: |
| 2335 | 2338 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) { |
| 2336 | 2339 | __init(__first, __last); |
| 2337 | 2340 | } |
| 2338 | #ifndef _LIBCPP_CXX03_LANG | |
| 2341 | # ifndef _LIBCPP_CXX03_LANG | |
| 2339 | 2342 | _LIBCPP_HIDE_FROM_ABI basic_regex(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) |
| 2340 | 2343 | : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) { |
| 2341 | 2344 | __init(__il.begin(), __il.end()); |
| 2342 | 2345 | } |
| 2343 | #endif // _LIBCPP_CXX03_LANG | |
| 2346 | # endif // _LIBCPP_CXX03_LANG | |
| 2344 | 2347 | |
| 2345 | 2348 | // ~basic_regex() = default; |
| 2346 | 2349 | |
| 2347 | 2350 | // basic_regex& operator=(const basic_regex&) = default; |
| 2348 | 2351 | // basic_regex& operator=(basic_regex&&) = default; |
| 2349 | 2352 | _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const value_type* __p) { return assign(__p); } |
| 2350 | #ifndef _LIBCPP_CXX03_LANG | |
| 2353 | # ifndef _LIBCPP_CXX03_LANG | |
| 2351 | 2354 | _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(initializer_list<value_type> __il) { return assign(__il); } |
| 2352 | #endif // _LIBCPP_CXX03_LANG | |
| 2355 | # endif // _LIBCPP_CXX03_LANG | |
| 2353 | 2356 | template <class _ST, class _SA> |
| 2354 | 2357 | _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p) { |
| 2355 | 2358 | return assign(__p); |
| ... | ... | @@ -2357,9 +2360,9 @@ public: |
| 2357 | 2360 | |
| 2358 | 2361 | // assign: |
| 2359 | 2362 | _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const basic_regex& __that) { return *this = __that; } |
| 2360 | #ifndef _LIBCPP_CXX03_LANG | |
| 2363 | # ifndef _LIBCPP_CXX03_LANG | |
| 2361 | 2364 | _LIBCPP_HIDE_FROM_ABI basic_regex& assign(basic_regex&& __that) _NOEXCEPT { return *this = std::move(__that); } |
| 2362 | #endif | |
| 2365 | # endif | |
| 2363 | 2366 | _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript) { |
| 2364 | 2367 | return assign(__p, __p + __traits_.length(__p), __f); |
| 2365 | 2368 | } |
| ... | ... | @@ -2396,14 +2399,14 @@ public: |
| 2396 | 2399 | return assign(basic_regex(__first, __last, __f)); |
| 2397 | 2400 | } |
| 2398 | 2401 | |
| 2399 | #ifndef _LIBCPP_CXX03_LANG | |
| 2402 | # ifndef _LIBCPP_CXX03_LANG | |
| 2400 | 2403 | |
| 2401 | 2404 | _LIBCPP_HIDE_FROM_ABI basic_regex& |
| 2402 | 2405 | assign(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) { |
| 2403 | 2406 | return assign(__il.begin(), __il.end(), __f); |
| 2404 | 2407 | } |
| 2405 | 2408 | |
| 2406 | #endif // _LIBCPP_CXX03_LANG | |
| 2409 | # endif // _LIBCPP_CXX03_LANG | |
| 2407 | 2410 | |
| 2408 | 2411 | // const operations: |
| 2409 | 2412 | _LIBCPP_HIDE_FROM_ABI unsigned mark_count() const { return __marked_count_; } |
| ... | ... | @@ -2644,11 +2647,11 @@ private: |
| 2644 | 2647 | friend class __lookahead; |
| 2645 | 2648 | }; |
| 2646 | 2649 | |
| 2647 | #if _LIBCPP_STD_VER >= 17 | |
| 2650 | # if _LIBCPP_STD_VER >= 17 | |
| 2648 | 2651 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> |
| 2649 | 2652 | basic_regex(_ForwardIterator, _ForwardIterator, regex_constants::syntax_option_type = regex_constants::ECMAScript) |
| 2650 | 2653 | -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>; |
| 2651 | #endif | |
| 2654 | # endif | |
| 2652 | 2655 | |
| 2653 | 2656 | template <class _CharT, class _Traits> |
| 2654 | 2657 | const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase; |
| ... | ... | @@ -3921,7 +3924,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape( |
| 3921 | 3924 | if (__hd == -1) |
| 3922 | 3925 | __throw_regex_error<regex_constants::error_escape>(); |
| 3923 | 3926 | __sum = 16 * __sum + static_cast<unsigned>(__hd); |
| 3924 | // fallthrough | |
| 3927 | _LIBCPP_FALLTHROUGH(); | |
| 3925 | 3928 | case 'x': |
| 3926 | 3929 | ++__first; |
| 3927 | 3930 | if (__first == __last) |
| ... | ... | @@ -4181,10 +4184,10 @@ void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, bo |
| 4181 | 4184 | |
| 4182 | 4185 | typedef sub_match<const char*> csub_match; |
| 4183 | 4186 | typedef sub_match<string::const_iterator> ssub_match; |
| 4184 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4187 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4185 | 4188 | typedef sub_match<const wchar_t*> wcsub_match; |
| 4186 | 4189 | typedef sub_match<wstring::const_iterator> wssub_match; |
| 4187 | #endif | |
| 4190 | # endif | |
| 4188 | 4191 | |
| 4189 | 4192 | template <class _BidirectionalIterator> |
| 4190 | 4193 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(csub_match) |
| ... | ... | @@ -4224,15 +4227,16 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const sub_match<_BiIter>& __x, cons |
| 4224 | 4227 | return __x.compare(__y) == 0; |
| 4225 | 4228 | } |
| 4226 | 4229 | |
| 4227 | #if _LIBCPP_STD_VER >= 20 | |
| 4230 | # if _LIBCPP_STD_VER >= 20 | |
| 4228 | 4231 | template <class _BiIter> |
| 4229 | using __sub_match_cat = compare_three_way_result_t<basic_string<typename iterator_traits<_BiIter>::value_type>>; | |
| 4232 | using __sub_match_cat _LIBCPP_NODEBUG = | |
| 4233 | compare_three_way_result_t<basic_string<typename iterator_traits<_BiIter>::value_type>>; | |
| 4230 | 4234 | |
| 4231 | 4235 | template <class _BiIter> |
| 4232 | 4236 | _LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) { |
| 4233 | 4237 | return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0); |
| 4234 | 4238 | } |
| 4235 | #else // _LIBCPP_STD_VER >= 20 | |
| 4239 | # else // _LIBCPP_STD_VER >= 20 | |
| 4236 | 4240 | template <class _BiIter> |
| 4237 | 4241 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) { |
| 4238 | 4242 | return !(__x == __y); |
| ... | ... | @@ -4299,7 +4303,7 @@ operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST |
| 4299 | 4303 | const sub_match<_BiIter>& __y) { |
| 4300 | 4304 | return !(__y < __x); |
| 4301 | 4305 | } |
| 4302 | #endif // _LIBCPP_STD_VER >= 20 | |
| 4306 | # endif // _LIBCPP_STD_VER >= 20 | |
| 4303 | 4307 | |
| 4304 | 4308 | template <class _BiIter, class _ST, class _SA> |
| 4305 | 4309 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -4308,7 +4312,7 @@ operator==(const sub_match<_BiIter>& __x, |
| 4308 | 4312 | return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0; |
| 4309 | 4313 | } |
| 4310 | 4314 | |
| 4311 | #if _LIBCPP_STD_VER >= 20 | |
| 4315 | # if _LIBCPP_STD_VER >= 20 | |
| 4312 | 4316 | template <class _BiIter, class _ST, class _SA> |
| 4313 | 4317 | _LIBCPP_HIDE_FROM_ABI auto |
| 4314 | 4318 | operator<=>(const sub_match<_BiIter>& __x, |
| ... | ... | @@ -4316,7 +4320,7 @@ operator<=>(const sub_match<_BiIter>& __x, |
| 4316 | 4320 | return static_cast<__sub_match_cat<_BiIter>>( |
| 4317 | 4321 | __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) <=> 0); |
| 4318 | 4322 | } |
| 4319 | #else // _LIBCPP_STD_VER >= 20 | |
| 4323 | # else // _LIBCPP_STD_VER >= 20 | |
| 4320 | 4324 | template <class _BiIter, class _ST, class _SA> |
| 4321 | 4325 | inline _LIBCPP_HIDE_FROM_ABI bool |
| 4322 | 4326 | operator!=(const sub_match<_BiIter>& __x, |
| ... | ... | @@ -4387,7 +4391,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool |
| 4387 | 4391 | operator<=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) { |
| 4388 | 4392 | return !(__y < __x); |
| 4389 | 4393 | } |
| 4390 | #endif // _LIBCPP_STD_VER >= 20 | |
| 4394 | # endif // _LIBCPP_STD_VER >= 20 | |
| 4391 | 4395 | |
| 4392 | 4396 | template <class _BiIter> |
| 4393 | 4397 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -4395,13 +4399,13 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val |
| 4395 | 4399 | return __x.compare(__y) == 0; |
| 4396 | 4400 | } |
| 4397 | 4401 | |
| 4398 | #if _LIBCPP_STD_VER >= 20 | |
| 4402 | # if _LIBCPP_STD_VER >= 20 | |
| 4399 | 4403 | template <class _BiIter> |
| 4400 | 4404 | _LIBCPP_HIDE_FROM_ABI auto |
| 4401 | 4405 | operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) { |
| 4402 | 4406 | return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0); |
| 4403 | 4407 | } |
| 4404 | #else // _LIBCPP_STD_VER >= 20 | |
| 4408 | # else // _LIBCPP_STD_VER >= 20 | |
| 4405 | 4409 | template <class _BiIter> |
| 4406 | 4410 | inline _LIBCPP_HIDE_FROM_ABI bool |
| 4407 | 4411 | operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) { |
| ... | ... | @@ -4469,7 +4473,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool |
| 4469 | 4473 | operator<=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) { |
| 4470 | 4474 | return !(__y < __x); |
| 4471 | 4475 | } |
| 4472 | #endif // _LIBCPP_STD_VER >= 20 | |
| 4476 | # endif // _LIBCPP_STD_VER >= 20 | |
| 4473 | 4477 | |
| 4474 | 4478 | template <class _BiIter> |
| 4475 | 4479 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -4478,14 +4482,14 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val |
| 4478 | 4482 | return __x.compare(string_type(1, __y)) == 0; |
| 4479 | 4483 | } |
| 4480 | 4484 | |
| 4481 | #if _LIBCPP_STD_VER >= 20 | |
| 4485 | # if _LIBCPP_STD_VER >= 20 | |
| 4482 | 4486 | template <class _BiIter> |
| 4483 | 4487 | _LIBCPP_HIDE_FROM_ABI auto |
| 4484 | 4488 | operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { |
| 4485 | 4489 | using string_type = basic_string<typename iterator_traits<_BiIter>::value_type>; |
| 4486 | 4490 | return static_cast<__sub_match_cat<_BiIter>>(__x.compare(string_type(1, __y)) <=> 0); |
| 4487 | 4491 | } |
| 4488 | #else // _LIBCPP_STD_VER >= 20 | |
| 4492 | # else // _LIBCPP_STD_VER >= 20 | |
| 4489 | 4493 | template <class _BiIter> |
| 4490 | 4494 | inline _LIBCPP_HIDE_FROM_ABI bool |
| 4491 | 4495 | operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { |
| ... | ... | @@ -4516,7 +4520,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool |
| 4516 | 4520 | operator<=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) { |
| 4517 | 4521 | return !(__y < __x); |
| 4518 | 4522 | } |
| 4519 | #endif // _LIBCPP_STD_VER >= 20 | |
| 4523 | # endif // _LIBCPP_STD_VER >= 20 | |
| 4520 | 4524 | |
| 4521 | 4525 | template <class _CharT, class _ST, class _BiIter> |
| 4522 | 4526 | inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _ST>& |
| ... | ... | @@ -4526,10 +4530,10 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) { |
| 4526 | 4530 | |
| 4527 | 4531 | typedef match_results<const char*> cmatch; |
| 4528 | 4532 | typedef match_results<string::const_iterator> smatch; |
| 4529 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4533 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4530 | 4534 | typedef match_results<const wchar_t*> wcmatch; |
| 4531 | 4535 | typedef match_results<wstring::const_iterator> wsmatch; |
| 4532 | #endif | |
| 4536 | # endif | |
| 4533 | 4537 | |
| 4534 | 4538 | template <class _BidirectionalIterator, class _Allocator> |
| 4535 | 4539 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cmatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch)) |
| ... | ... | @@ -4559,12 +4563,12 @@ public: |
| 4559 | 4563 | typedef basic_string<char_type> string_type; |
| 4560 | 4564 | |
| 4561 | 4565 | // construct/copy/destroy: |
| 4562 | #ifndef _LIBCPP_CXX03_LANG | |
| 4566 | # ifndef _LIBCPP_CXX03_LANG | |
| 4563 | 4567 | match_results() : match_results(allocator_type()) {} |
| 4564 | 4568 | explicit match_results(const allocator_type& __a); |
| 4565 | #else | |
| 4569 | # else | |
| 4566 | 4570 | explicit match_results(const allocator_type& __a = allocator_type()); |
| 4567 | #endif | |
| 4571 | # endif | |
| 4568 | 4572 | |
| 4569 | 4573 | // match_results(const match_results&) = default; |
| 4570 | 4574 | // match_results& operator=(const match_results&) = default; |
| ... | ... | @@ -4577,7 +4581,7 @@ public: |
| 4577 | 4581 | // size: |
| 4578 | 4582 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __matches_.size(); } |
| 4579 | 4583 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __matches_.max_size(); } |
| 4580 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } | |
| 4584 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; } | |
| 4581 | 4585 | |
| 4582 | 4586 | // element access: |
| 4583 | 4587 | _LIBCPP_HIDE_FROM_ABI difference_type length(size_type __sub = 0) const { |
| ... | ... | @@ -4814,13 +4818,13 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const match_results<_BidirectionalIterator |
| 4814 | 4818 | return __x.__matches_ == __y.__matches_ && __x.__prefix_ == __y.__prefix_ && __x.__suffix_ == __y.__suffix_; |
| 4815 | 4819 | } |
| 4816 | 4820 | |
| 4817 | #if _LIBCPP_STD_VER < 20 | |
| 4821 | # if _LIBCPP_STD_VER < 20 | |
| 4818 | 4822 | template <class _BidirectionalIterator, class _Allocator> |
| 4819 | 4823 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x, |
| 4820 | 4824 | const match_results<_BidirectionalIterator, _Allocator>& __y) { |
| 4821 | 4825 | return !(__x == __y); |
| 4822 | 4826 | } |
| 4823 | #endif | |
| 4827 | # endif | |
| 4824 | 4828 | |
| 4825 | 4829 | template <class _BidirectionalIterator, class _Allocator> |
| 4826 | 4830 | inline _LIBCPP_HIDE_FROM_ABI void |
| ... | ... | @@ -5232,13 +5236,13 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s, |
| 5232 | 5236 | return __r; |
| 5233 | 5237 | } |
| 5234 | 5238 | |
| 5235 | #if _LIBCPP_STD_VER >= 14 | |
| 5239 | # if _LIBCPP_STD_VER >= 14 | |
| 5236 | 5240 | template <class _ST, class _SA, class _Ap, class _Cp, class _Tp> |
| 5237 | 5241 | bool regex_search(const basic_string<_Cp, _ST, _SA>&& __s, |
| 5238 | 5242 | match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&, |
| 5239 | 5243 | const basic_regex<_Cp, _Tp>& __e, |
| 5240 | 5244 | regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; |
| 5241 | #endif | |
| 5245 | # endif | |
| 5242 | 5246 | |
| 5243 | 5247 | // regex_match |
| 5244 | 5248 | |
| ... | ... | @@ -5287,14 +5291,14 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s, |
| 5287 | 5291 | return std::regex_match(__s.begin(), __s.end(), __m, __e, __flags); |
| 5288 | 5292 | } |
| 5289 | 5293 | |
| 5290 | #if _LIBCPP_STD_VER >= 14 | |
| 5294 | # if _LIBCPP_STD_VER >= 14 | |
| 5291 | 5295 | template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits> |
| 5292 | 5296 | inline _LIBCPP_HIDE_FROM_ABI bool |
| 5293 | 5297 | regex_match(const basic_string<_CharT, _ST, _SA>&& __s, |
| 5294 | 5298 | match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m, |
| 5295 | 5299 | const basic_regex<_CharT, _Traits>& __e, |
| 5296 | 5300 | regex_constants::match_flag_type __flags = regex_constants::match_default) = delete; |
| 5297 | #endif | |
| 5301 | # endif | |
| 5298 | 5302 | |
| 5299 | 5303 | template <class _CharT, class _Traits> |
| 5300 | 5304 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -5321,10 +5325,10 @@ class _LIBCPP_TEMPLATE_VIS regex_iterator; |
| 5321 | 5325 | |
| 5322 | 5326 | typedef regex_iterator<const char*> cregex_iterator; |
| 5323 | 5327 | typedef regex_iterator<string::const_iterator> sregex_iterator; |
| 5324 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5328 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 5325 | 5329 | typedef regex_iterator<const wchar_t*> wcregex_iterator; |
| 5326 | 5330 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; |
| 5327 | #endif | |
| 5331 | # endif | |
| 5328 | 5332 | |
| 5329 | 5333 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5330 | 5334 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_iterator) |
| ... | ... | @@ -5337,9 +5341,9 @@ public: |
| 5337 | 5341 | typedef const value_type* pointer; |
| 5338 | 5342 | typedef const value_type& reference; |
| 5339 | 5343 | typedef forward_iterator_tag iterator_category; |
| 5340 | #if _LIBCPP_STD_VER >= 20 | |
| 5344 | # if _LIBCPP_STD_VER >= 20 | |
| 5341 | 5345 | typedef input_iterator_tag iterator_concept; |
| 5342 | #endif | |
| 5346 | # endif | |
| 5343 | 5347 | |
| 5344 | 5348 | private: |
| 5345 | 5349 | _BidirectionalIterator __begin_; |
| ... | ... | @@ -5354,20 +5358,20 @@ public: |
| 5354 | 5358 | _BidirectionalIterator __b, |
| 5355 | 5359 | const regex_type& __re, |
| 5356 | 5360 | regex_constants::match_flag_type __m = regex_constants::match_default); |
| 5357 | #if _LIBCPP_STD_VER >= 14 | |
| 5361 | # if _LIBCPP_STD_VER >= 14 | |
| 5358 | 5362 | regex_iterator(_BidirectionalIterator __a, |
| 5359 | 5363 | _BidirectionalIterator __b, |
| 5360 | 5364 | const regex_type&& __re, |
| 5361 | 5365 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; |
| 5362 | #endif | |
| 5366 | # endif | |
| 5363 | 5367 | |
| 5364 | 5368 | _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_iterator& __x) const; |
| 5365 | #if _LIBCPP_STD_VER >= 20 | |
| 5369 | # if _LIBCPP_STD_VER >= 20 | |
| 5366 | 5370 | _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_iterator(); } |
| 5367 | #endif | |
| 5368 | #if _LIBCPP_STD_VER < 20 | |
| 5371 | # endif | |
| 5372 | # if _LIBCPP_STD_VER < 20 | |
| 5369 | 5373 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_iterator& __x) const { return !(*this == __x); } |
| 5370 | #endif | |
| 5374 | # endif | |
| 5371 | 5375 | |
| 5372 | 5376 | _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __match_; } |
| 5373 | 5377 | _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return std::addressof(__match_); } |
| ... | ... | @@ -5451,10 +5455,10 @@ class _LIBCPP_TEMPLATE_VIS regex_token_iterator; |
| 5451 | 5455 | |
| 5452 | 5456 | typedef regex_token_iterator<const char*> cregex_token_iterator; |
| 5453 | 5457 | typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; |
| 5454 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5458 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 5455 | 5459 | typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; |
| 5456 | 5460 | typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; |
| 5457 | #endif | |
| 5461 | # endif | |
| 5458 | 5462 | |
| 5459 | 5463 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5460 | 5464 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_token_iterator) |
| ... | ... | @@ -5468,9 +5472,9 @@ public: |
| 5468 | 5472 | typedef const value_type* pointer; |
| 5469 | 5473 | typedef const value_type& reference; |
| 5470 | 5474 | typedef forward_iterator_tag iterator_category; |
| 5471 | #if _LIBCPP_STD_VER >= 20 | |
| 5475 | # if _LIBCPP_STD_VER >= 20 | |
| 5472 | 5476 | typedef input_iterator_tag iterator_concept; |
| 5473 | #endif | |
| 5477 | # endif | |
| 5474 | 5478 | |
| 5475 | 5479 | private: |
| 5476 | 5480 | typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position; |
| ... | ... | @@ -5488,69 +5492,67 @@ public: |
| 5488 | 5492 | const regex_type& __re, |
| 5489 | 5493 | int __submatch = 0, |
| 5490 | 5494 | regex_constants::match_flag_type __m = regex_constants::match_default); |
| 5491 | #if _LIBCPP_STD_VER >= 14 | |
| 5495 | # if _LIBCPP_STD_VER >= 14 | |
| 5492 | 5496 | regex_token_iterator(_BidirectionalIterator __a, |
| 5493 | 5497 | _BidirectionalIterator __b, |
| 5494 | 5498 | const regex_type&& __re, |
| 5495 | 5499 | int __submatch = 0, |
| 5496 | 5500 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; |
| 5497 | #endif | |
| 5501 | # endif | |
| 5498 | 5502 | |
| 5499 | 5503 | regex_token_iterator(_BidirectionalIterator __a, |
| 5500 | 5504 | _BidirectionalIterator __b, |
| 5501 | 5505 | const regex_type& __re, |
| 5502 | 5506 | const vector<int>& __submatches, |
| 5503 | 5507 | regex_constants::match_flag_type __m = regex_constants::match_default); |
| 5504 | #if _LIBCPP_STD_VER >= 14 | |
| 5508 | # if _LIBCPP_STD_VER >= 14 | |
| 5505 | 5509 | regex_token_iterator(_BidirectionalIterator __a, |
| 5506 | 5510 | _BidirectionalIterator __b, |
| 5507 | 5511 | const regex_type&& __re, |
| 5508 | 5512 | const vector<int>& __submatches, |
| 5509 | 5513 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; |
| 5510 | #endif | |
| 5514 | # endif | |
| 5511 | 5515 | |
| 5512 | #ifndef _LIBCPP_CXX03_LANG | |
| 5516 | # ifndef _LIBCPP_CXX03_LANG | |
| 5513 | 5517 | regex_token_iterator(_BidirectionalIterator __a, |
| 5514 | 5518 | _BidirectionalIterator __b, |
| 5515 | 5519 | const regex_type& __re, |
| 5516 | 5520 | initializer_list<int> __submatches, |
| 5517 | 5521 | regex_constants::match_flag_type __m = regex_constants::match_default); |
| 5518 | 5522 | |
| 5519 | # if _LIBCPP_STD_VER >= 14 | |
| 5523 | # if _LIBCPP_STD_VER >= 14 | |
| 5520 | 5524 | regex_token_iterator(_BidirectionalIterator __a, |
| 5521 | 5525 | _BidirectionalIterator __b, |
| 5522 | 5526 | const regex_type&& __re, |
| 5523 | 5527 | initializer_list<int> __submatches, |
| 5524 | 5528 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; |
| 5525 | # endif | |
| 5526 | #endif // _LIBCPP_CXX03_LANG | |
| 5529 | # endif | |
| 5530 | # endif // _LIBCPP_CXX03_LANG | |
| 5527 | 5531 | template <size_t _Np> |
| 5528 | 5532 | regex_token_iterator(_BidirectionalIterator __a, |
| 5529 | 5533 | _BidirectionalIterator __b, |
| 5530 | 5534 | const regex_type& __re, |
| 5531 | 5535 | const int (&__submatches)[_Np], |
| 5532 | 5536 | regex_constants::match_flag_type __m = regex_constants::match_default); |
| 5533 | #if _LIBCPP_STD_VER >= 14 | |
| 5537 | # if _LIBCPP_STD_VER >= 14 | |
| 5534 | 5538 | template <size_t _Np> |
| 5535 | 5539 | regex_token_iterator(_BidirectionalIterator __a, |
| 5536 | 5540 | _BidirectionalIterator __b, |
| 5537 | 5541 | const regex_type&& __re, |
| 5538 | 5542 | const int (&__submatches)[_Np], |
| 5539 | 5543 | regex_constants::match_flag_type __m = regex_constants::match_default) = delete; |
| 5540 | #endif | |
| 5544 | # endif | |
| 5541 | 5545 | |
| 5542 | 5546 | regex_token_iterator(const regex_token_iterator&); |
| 5543 | 5547 | regex_token_iterator& operator=(const regex_token_iterator&); |
| 5544 | 5548 | |
| 5545 | 5549 | _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_token_iterator& __x) const; |
| 5546 | #if _LIBCPP_STD_VER >= 20 | |
| 5547 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { | |
| 5548 | return *this == regex_token_iterator(); | |
| 5549 | } | |
| 5550 | #endif | |
| 5551 | #if _LIBCPP_STD_VER < 20 | |
| 5550 | # if _LIBCPP_STD_VER >= 20 | |
| 5551 | _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); } | |
| 5552 | # endif | |
| 5553 | # if _LIBCPP_STD_VER < 20 | |
| 5552 | 5554 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_token_iterator& __x) const { return !(*this == __x); } |
| 5553 | #endif | |
| 5555 | # endif | |
| 5554 | 5556 | |
| 5555 | 5557 | _LIBCPP_HIDE_FROM_ABI const value_type& operator*() const { return *__result_; } |
| 5556 | 5558 | _LIBCPP_HIDE_FROM_ABI const value_type* operator->() const { return __result_; } |
| ... | ... | @@ -5612,7 +5614,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera |
| 5612 | 5614 | __init(__a, __b); |
| 5613 | 5615 | } |
| 5614 | 5616 | |
| 5615 | #ifndef _LIBCPP_CXX03_LANG | |
| 5617 | # ifndef _LIBCPP_CXX03_LANG | |
| 5616 | 5618 | |
| 5617 | 5619 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5618 | 5620 | regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator( |
| ... | ... | @@ -5625,7 +5627,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera |
| 5625 | 5627 | __init(__a, __b); |
| 5626 | 5628 | } |
| 5627 | 5629 | |
| 5628 | #endif // _LIBCPP_CXX03_LANG | |
| 5630 | # endif // _LIBCPP_CXX03_LANG | |
| 5629 | 5631 | |
| 5630 | 5632 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 5631 | 5633 | template <size_t _Np> |
| ... | ... | @@ -5800,7 +5802,7 @@ regex_replace(const _CharT* __s, |
| 5800 | 5802 | |
| 5801 | 5803 | _LIBCPP_END_NAMESPACE_STD |
| 5802 | 5804 | |
| 5803 | #if _LIBCPP_STD_VER >= 17 | |
| 5805 | # if _LIBCPP_STD_VER >= 17 | |
| 5804 | 5806 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 5805 | 5807 | namespace pmr { |
| 5806 | 5808 | template <class _BidirT> |
| ... | ... | @@ -5810,27 +5812,28 @@ using match_results _LIBCPP_AVAILABILITY_PMR = |
| 5810 | 5812 | using cmatch _LIBCPP_AVAILABILITY_PMR = match_results<const char*>; |
| 5811 | 5813 | using smatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::string::const_iterator>; |
| 5812 | 5814 | |
| 5813 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5815 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 5814 | 5816 | using wcmatch _LIBCPP_AVAILABILITY_PMR = match_results<const wchar_t*>; |
| 5815 | 5817 | using wsmatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::wstring::const_iterator>; |
| 5816 | # endif | |
| 5818 | # endif | |
| 5817 | 5819 | } // namespace pmr |
| 5818 | 5820 | _LIBCPP_END_NAMESPACE_STD |
| 5819 | #endif | |
| 5821 | # endif | |
| 5820 | 5822 | |
| 5821 | 5823 | _LIBCPP_POP_MACROS |
| 5822 | 5824 | |
| 5823 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 5824 | # include <atomic> | |
| 5825 | # include <concepts> | |
| 5826 | # include <cstdlib> | |
| 5827 | # include <iosfwd> | |
| 5828 | # include <iterator> | |
| 5829 | # include <mutex> | |
| 5830 | # include <new> | |
| 5831 | # include <type_traits> | |
| 5832 | # include <typeinfo> | |
| 5833 | # include <utility> | |
| 5834 | #endif | |
| 5825 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 5826 | # include <atomic> | |
| 5827 | # include <concepts> | |
| 5828 | # include <cstdlib> | |
| 5829 | # include <iosfwd> | |
| 5830 | # include <iterator> | |
| 5831 | # include <mutex> | |
| 5832 | # include <new> | |
| 5833 | # include <type_traits> | |
| 5834 | # include <typeinfo> | |
| 5835 | # include <utility> | |
| 5836 | # endif | |
| 5837 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 5835 | 5838 | |
| 5836 | 5839 | #endif // _LIBCPP_REGEX |
lib/libcxx/include/scoped_allocator+48-44| ... | ... | @@ -109,32 +109,35 @@ template <class OuterA1, class OuterA2, class... InnerAllocs> |
| 109 | 109 | |
| 110 | 110 | */ |
| 111 | 111 | |
| 112 | #include <__config> | |
| 113 | #include <__memory/allocator_traits.h> | |
| 114 | #include <__memory/uses_allocator_construction.h> | |
| 115 | #include <__type_traits/common_type.h> | |
| 116 | #include <__type_traits/enable_if.h> | |
| 117 | #include <__type_traits/integral_constant.h> | |
| 118 | #include <__type_traits/is_constructible.h> | |
| 119 | #include <__type_traits/remove_reference.h> | |
| 120 | #include <__utility/declval.h> | |
| 121 | #include <__utility/forward.h> | |
| 122 | #include <__utility/move.h> | |
| 123 | #include <__utility/pair.h> | |
| 124 | #include <__utility/piecewise_construct.h> | |
| 125 | #include <tuple> | |
| 126 | #include <version> | |
| 127 | ||
| 128 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 129 | # pragma GCC system_header | |
| 130 | #endif | |
| 112 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 113 | # include <__cxx03/scoped_allocator> | |
| 114 | #else | |
| 115 | # include <__config> | |
| 116 | # include <__memory/allocator_traits.h> | |
| 117 | # include <__memory/uses_allocator_construction.h> | |
| 118 | # include <__type_traits/common_type.h> | |
| 119 | # include <__type_traits/enable_if.h> | |
| 120 | # include <__type_traits/integral_constant.h> | |
| 121 | # include <__type_traits/is_constructible.h> | |
| 122 | # include <__type_traits/remove_reference.h> | |
| 123 | # include <__utility/declval.h> | |
| 124 | # include <__utility/forward.h> | |
| 125 | # include <__utility/move.h> | |
| 126 | # include <__utility/pair.h> | |
| 127 | # include <__utility/piecewise_construct.h> | |
| 128 | # include <tuple> | |
| 129 | # include <version> | |
| 130 | ||
| 131 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 132 | # pragma GCC system_header | |
| 133 | # endif | |
| 131 | 134 | |
| 132 | 135 | _LIBCPP_PUSH_MACROS |
| 133 | #include <__undef_macros> | |
| 136 | # include <__undef_macros> | |
| 134 | 137 | |
| 135 | 138 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 136 | 139 | |
| 137 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 140 | # if !defined(_LIBCPP_CXX03_LANG) | |
| 138 | 141 | |
| 139 | 142 | // scoped_allocator_adaptor |
| 140 | 143 | |
| ... | ... | @@ -389,10 +392,10 @@ public: |
| 389 | 392 | return _Base::outer_allocator(); |
| 390 | 393 | } |
| 391 | 394 | |
| 392 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) { | |
| 395 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) { | |
| 393 | 396 | return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n); |
| 394 | 397 | } |
| 395 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) { | |
| 398 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) { | |
| 396 | 399 | return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n, __hint); |
| 397 | 400 | } |
| 398 | 401 | |
| ... | ... | @@ -404,7 +407,7 @@ public: |
| 404 | 407 | return allocator_traits<outer_allocator_type>::max_size(outer_allocator()); |
| 405 | 408 | } |
| 406 | 409 | |
| 407 | # if _LIBCPP_STD_VER >= 20 | |
| 410 | # if _LIBCPP_STD_VER >= 20 | |
| 408 | 411 | template <class _Type, class... _Args> |
| 409 | 412 | _LIBCPP_HIDE_FROM_ABI void construct(_Type* __ptr, _Args&&... __args) { |
| 410 | 413 | using _OM = __outermost<outer_allocator_type>; |
| ... | ... | @@ -415,7 +418,7 @@ public: |
| 415 | 418 | }, |
| 416 | 419 | std::uses_allocator_construction_args<_Type>(inner_allocator(), std::forward<_Args>(__args)...)); |
| 417 | 420 | } |
| 418 | # else | |
| 421 | # else | |
| 419 | 422 | template <class _Tp, class... _Args> |
| 420 | 423 | _LIBCPP_HIDE_FROM_ABI void construct(_Tp* __p, _Args&&... __args) { |
| 421 | 424 | __construct(__uses_alloc_ctor<_Tp, inner_allocator_type&, _Args...>(), __p, std::forward<_Args>(__args)...); |
| ... | ... | @@ -462,7 +465,7 @@ public: |
| 462 | 465 | std::forward_as_tuple(std::forward<_Up>(__x.first)), |
| 463 | 466 | std::forward_as_tuple(std::forward<_Vp>(__x.second))); |
| 464 | 467 | } |
| 465 | # endif | |
| 468 | # endif | |
| 466 | 469 | |
| 467 | 470 | template <class _Tp> |
| 468 | 471 | _LIBCPP_HIDE_FROM_ABI void destroy(_Tp* __p) { |
| ... | ... | @@ -522,10 +525,10 @@ private: |
| 522 | 525 | friend class __scoped_allocator_storage; |
| 523 | 526 | }; |
| 524 | 527 | |
| 525 | # if _LIBCPP_STD_VER >= 17 | |
| 528 | # if _LIBCPP_STD_VER >= 17 | |
| 526 | 529 | template <class _OuterAlloc, class... _InnerAllocs> |
| 527 | 530 | scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>; |
| 528 | # endif | |
| 531 | # endif | |
| 529 | 532 | |
| 530 | 533 | template <class _OuterA1, class _OuterA2> |
| 531 | 534 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -540,7 +543,7 @@ operator==(const scoped_allocator_adaptor<_OuterA1, _InnerA0, _InnerAllocs...>& |
| 540 | 543 | return __a.outer_allocator() == __b.outer_allocator() && __a.inner_allocator() == __b.inner_allocator(); |
| 541 | 544 | } |
| 542 | 545 | |
| 543 | # if _LIBCPP_STD_VER <= 17 | |
| 546 | # if _LIBCPP_STD_VER <= 17 | |
| 544 | 547 | |
| 545 | 548 | template <class _OuterA1, class _OuterA2, class... _InnerAllocs> |
| 546 | 549 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_OuterA1, _InnerAllocs...>& __a, |
| ... | ... | @@ -548,26 +551,27 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_Out |
| 548 | 551 | return !(__a == __b); |
| 549 | 552 | } |
| 550 | 553 | |
| 551 | # endif // _LIBCPP_STD_VER <= 17 | |
| 554 | # endif // _LIBCPP_STD_VER <= 17 | |
| 552 | 555 | |
| 553 | #endif // !defined(_LIBCPP_CXX03_LANG) | |
| 556 | # endif // !defined(_LIBCPP_CXX03_LANG) | |
| 554 | 557 | |
| 555 | 558 | _LIBCPP_END_NAMESPACE_STD |
| 556 | 559 | |
| 557 | 560 | _LIBCPP_POP_MACROS |
| 558 | 561 | |
| 559 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 560 | # include <atomic> | |
| 561 | # include <climits> | |
| 562 | # include <concepts> | |
| 563 | # include <cstring> | |
| 564 | # include <ctime> | |
| 565 | # include <iterator> | |
| 566 | # include <memory> | |
| 567 | # include <ratio> | |
| 568 | # include <stdexcept> | |
| 569 | # include <type_traits> | |
| 570 | # include <variant> | |
| 571 | #endif | |
| 562 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 563 | # include <atomic> | |
| 564 | # include <climits> | |
| 565 | # include <concepts> | |
| 566 | # include <cstring> | |
| 567 | # include <ctime> | |
| 568 | # include <iterator> | |
| 569 | # include <memory> | |
| 570 | # include <ratio> | |
| 571 | # include <stdexcept> | |
| 572 | # include <type_traits> | |
| 573 | # include <variant> | |
| 574 | # endif | |
| 575 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 572 | 576 | |
| 573 | 577 | #endif // _LIBCPP_SCOPED_ALLOCATOR |
lib/libcxx/include/semaphore+41-37| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | namespace std { |
| 17 | 17 | |
| 18 | 18 | template<ptrdiff_t least_max_value = implementation-defined> |
| 19 | class counting_semaphore | |
| 19 | class counting_semaphore // since C++20 | |
| 20 | 20 | { |
| 21 | 21 | public: |
| 22 | 22 | static constexpr ptrdiff_t max() noexcept; |
| ... | ... | @@ -39,36 +39,39 @@ private: |
| 39 | 39 | ptrdiff_t counter; // exposition only |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | using binary_semaphore = counting_semaphore<1>; | |
| 42 | using binary_semaphore = counting_semaphore<1>; // since C++20 | |
| 43 | 43 | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | #include <__config> | |
| 49 | ||
| 50 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 51 | ||
| 52 | # include <__assert> | |
| 53 | # include <__atomic/atomic_base.h> | |
| 54 | # include <__atomic/atomic_sync.h> | |
| 55 | # include <__atomic/memory_order.h> | |
| 56 | # include <__chrono/time_point.h> | |
| 57 | # include <__thread/poll_with_backoff.h> | |
| 58 | # include <__thread/support.h> | |
| 59 | # include <__thread/timed_backoff_policy.h> | |
| 60 | # include <cstddef> | |
| 61 | # include <limits> | |
| 62 | # include <version> | |
| 63 | ||
| 64 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 65 | # pragma GCC system_header | |
| 66 | # endif | |
| 48 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 49 | # include <__cxx03/semaphore> | |
| 50 | #else | |
| 51 | # include <__config> | |
| 52 | ||
| 53 | # if _LIBCPP_HAS_THREADS | |
| 54 | ||
| 55 | # include <__assert> | |
| 56 | # include <__atomic/atomic.h> | |
| 57 | # include <__atomic/atomic_sync.h> | |
| 58 | # include <__atomic/memory_order.h> | |
| 59 | # include <__chrono/time_point.h> | |
| 60 | # include <__cstddef/ptrdiff_t.h> | |
| 61 | # include <__thread/poll_with_backoff.h> | |
| 62 | # include <__thread/support.h> | |
| 63 | # include <__thread/timed_backoff_policy.h> | |
| 64 | # include <limits> | |
| 65 | # include <version> | |
| 66 | ||
| 67 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 68 | # pragma GCC system_header | |
| 69 | # endif | |
| 67 | 70 | |
| 68 | 71 | _LIBCPP_PUSH_MACROS |
| 69 | # include <__undef_macros> | |
| 72 | # include <__undef_macros> | |
| 70 | 73 | |
| 71 | # if _LIBCPP_STD_VER >= 14 | |
| 74 | # if _LIBCPP_STD_VER >= 20 | |
| 72 | 75 | |
| 73 | 76 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 74 | 77 | |
| ... | ... | @@ -80,10 +83,10 @@ functions. It avoids contention against users' own use of those facilities. |
| 80 | 83 | |
| 81 | 84 | */ |
| 82 | 85 | |
| 83 | # define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max()) | |
| 86 | # define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max()) | |
| 84 | 87 | |
| 85 | 88 | class __atomic_semaphore_base { |
| 86 | __atomic_base<ptrdiff_t> __a_; | |
| 89 | atomic<ptrdiff_t> __a_; | |
| 87 | 90 | |
| 88 | 91 | public: |
| 89 | 92 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a_(__count) {} |
| ... | ... | @@ -96,8 +99,9 @@ public: |
| 96 | 99 | } |
| 97 | 100 | } |
| 98 | 101 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void acquire() { |
| 99 | std::__atomic_wait_unless( | |
| 100 | __a_, [this](ptrdiff_t& __old) { return __try_acquire_impl(__old); }, memory_order_relaxed); | |
| 102 | std::__atomic_wait_unless(__a_, memory_order_relaxed, [this](ptrdiff_t& __old) { | |
| 103 | return __try_acquire_impl(__old); | |
| 104 | }); | |
| 101 | 105 | } |
| 102 | 106 | template <class _Rep, class _Period> |
| 103 | 107 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -124,7 +128,7 @@ private: |
| 124 | 128 | }; |
| 125 | 129 | |
| 126 | 130 | template <ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX> |
| 127 | class _LIBCPP_DEPRECATED_ATOMIC_SYNC counting_semaphore { | |
| 131 | class counting_semaphore { | |
| 128 | 132 | __atomic_semaphore_base __semaphore_; |
| 129 | 133 | |
| 130 | 134 | public: |
| ... | ... | @@ -169,20 +173,20 @@ public: |
| 169 | 173 | } |
| 170 | 174 | }; |
| 171 | 175 | |
| 172 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 173 | using binary_semaphore _LIBCPP_DEPRECATED_ATOMIC_SYNC = counting_semaphore<1>; | |
| 174 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 176 | using binary_semaphore = counting_semaphore<1>; | |
| 175 | 177 | |
| 176 | 178 | _LIBCPP_END_NAMESPACE_STD |
| 177 | 179 | |
| 178 | # endif // _LIBCPP_STD_VER >= 14 | |
| 180 | # endif // _LIBCPP_STD_VER >= 20 | |
| 179 | 181 | |
| 180 | 182 | _LIBCPP_POP_MACROS |
| 181 | 183 | |
| 182 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 184 | # endif // _LIBCPP_HAS_THREADS | |
| 183 | 185 | |
| 184 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 185 | # include <atomic> | |
| 186 | #endif | |
| 186 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 187 | # include <atomic> | |
| 188 | # include <cstddef> | |
| 189 | # endif | |
| 190 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 187 | 191 | |
| 188 | #endif //_LIBCPP_SEMAPHORE | |
| 192 | #endif // _LIBCPP_SEMAPHORE |
lib/libcxx/include/set+167-138| ... | ... | @@ -512,47 +512,60 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
| 512 | 512 | |
| 513 | 513 | */ |
| 514 | 514 | |
| 515 | #include <__algorithm/equal.h> | |
| 516 | #include <__algorithm/lexicographical_compare.h> | |
| 517 | #include <__algorithm/lexicographical_compare_three_way.h> | |
| 518 | #include <__assert> | |
| 519 | #include <__config> | |
| 520 | #include <__functional/is_transparent.h> | |
| 521 | #include <__functional/operations.h> | |
| 522 | #include <__iterator/erase_if_container.h> | |
| 523 | #include <__iterator/iterator_traits.h> | |
| 524 | #include <__iterator/ranges_iterator_traits.h> | |
| 525 | #include <__iterator/reverse_iterator.h> | |
| 526 | #include <__memory/allocator.h> | |
| 527 | #include <__memory_resource/polymorphic_allocator.h> | |
| 528 | #include <__node_handle> | |
| 529 | #include <__ranges/concepts.h> | |
| 530 | #include <__ranges/container_compatible_range.h> | |
| 531 | #include <__ranges/from_range.h> | |
| 532 | #include <__tree> | |
| 533 | #include <__type_traits/is_allocator.h> | |
| 534 | #include <__utility/forward.h> | |
| 535 | #include <version> | |
| 515 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 516 | # include <__cxx03/set> | |
| 517 | #else | |
| 518 | # include <__algorithm/equal.h> | |
| 519 | # include <__algorithm/lexicographical_compare.h> | |
| 520 | # include <__algorithm/lexicographical_compare_three_way.h> | |
| 521 | # include <__assert> | |
| 522 | # include <__config> | |
| 523 | # include <__functional/is_transparent.h> | |
| 524 | # include <__functional/operations.h> | |
| 525 | # include <__iterator/erase_if_container.h> | |
| 526 | # include <__iterator/iterator_traits.h> | |
| 527 | # include <__iterator/ranges_iterator_traits.h> | |
| 528 | # include <__iterator/reverse_iterator.h> | |
| 529 | # include <__memory/allocator.h> | |
| 530 | # include <__memory/allocator_traits.h> | |
| 531 | # include <__memory_resource/polymorphic_allocator.h> | |
| 532 | # include <__node_handle> | |
| 533 | # include <__ranges/concepts.h> | |
| 534 | # include <__ranges/container_compatible_range.h> | |
| 535 | # include <__ranges/from_range.h> | |
| 536 | # include <__tree> | |
| 537 | # include <__type_traits/container_traits.h> | |
| 538 | # include <__type_traits/enable_if.h> | |
| 539 | # include <__type_traits/is_allocator.h> | |
| 540 | # include <__type_traits/is_nothrow_assignable.h> | |
| 541 | # include <__type_traits/is_nothrow_constructible.h> | |
| 542 | # include <__type_traits/is_same.h> | |
| 543 | # include <__type_traits/is_swappable.h> | |
| 544 | # include <__type_traits/type_identity.h> | |
| 545 | # include <__utility/forward.h> | |
| 546 | # include <__utility/move.h> | |
| 547 | # include <__utility/pair.h> | |
| 548 | # include <version> | |
| 536 | 549 | |
| 537 | 550 | // standard-mandated includes |
| 538 | 551 | |
| 539 | 552 | // [iterator.range] |
| 540 | #include <__iterator/access.h> | |
| 541 | #include <__iterator/data.h> | |
| 542 | #include <__iterator/empty.h> | |
| 543 | #include <__iterator/reverse_access.h> | |
| 544 | #include <__iterator/size.h> | |
| 553 | # include <__iterator/access.h> | |
| 554 | # include <__iterator/data.h> | |
| 555 | # include <__iterator/empty.h> | |
| 556 | # include <__iterator/reverse_access.h> | |
| 557 | # include <__iterator/size.h> | |
| 545 | 558 | |
| 546 | 559 | // [associative.set.syn] |
| 547 | #include <compare> | |
| 548 | #include <initializer_list> | |
| 560 | # include <compare> | |
| 561 | # include <initializer_list> | |
| 549 | 562 | |
| 550 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 551 | # pragma GCC system_header | |
| 552 | #endif | |
| 563 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 564 | # pragma GCC system_header | |
| 565 | # endif | |
| 553 | 566 | |
| 554 | 567 | _LIBCPP_PUSH_MACROS |
| 555 | #include <__undef_macros> | |
| 568 | # include <__undef_macros> | |
| 556 | 569 | |
| 557 | 570 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 558 | 571 | |
| ... | ... | @@ -592,10 +605,10 @@ public: |
| 592 | 605 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 593 | 606 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 594 | 607 | |
| 595 | #if _LIBCPP_STD_VER >= 17 | |
| 608 | # if _LIBCPP_STD_VER >= 17 | |
| 596 | 609 | typedef __set_node_handle<typename __base::__node, allocator_type> node_type; |
| 597 | 610 | typedef __insert_return_type<iterator, node_type> insert_return_type; |
| 598 | #endif | |
| 611 | # endif | |
| 599 | 612 | |
| 600 | 613 | template <class _Key2, class _Compare2, class _Alloc2> |
| 601 | 614 | friend class _LIBCPP_TEMPLATE_VIS set; |
| ... | ... | @@ -625,7 +638,7 @@ public: |
| 625 | 638 | insert(__f, __l); |
| 626 | 639 | } |
| 627 | 640 | |
| 628 | #if _LIBCPP_STD_VER >= 23 | |
| 641 | # if _LIBCPP_STD_VER >= 23 | |
| 629 | 642 | template <_ContainerCompatibleRange<value_type> _Range> |
| 630 | 643 | _LIBCPP_HIDE_FROM_ABI |
| 631 | 644 | set(from_range_t, |
| ... | ... | @@ -635,19 +648,19 @@ public: |
| 635 | 648 | : __tree_(__comp, __a) { |
| 636 | 649 | insert_range(std::forward<_Range>(__range)); |
| 637 | 650 | } |
| 638 | #endif | |
| 651 | # endif | |
| 639 | 652 | |
| 640 | #if _LIBCPP_STD_VER >= 14 | |
| 653 | # if _LIBCPP_STD_VER >= 14 | |
| 641 | 654 | template <class _InputIterator> |
| 642 | 655 | _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 643 | 656 | : set(__f, __l, key_compare(), __a) {} |
| 644 | #endif | |
| 657 | # endif | |
| 645 | 658 | |
| 646 | #if _LIBCPP_STD_VER >= 23 | |
| 659 | # if _LIBCPP_STD_VER >= 23 | |
| 647 | 660 | template <_ContainerCompatibleRange<value_type> _Range> |
| 648 | 661 | _LIBCPP_HIDE_FROM_ABI set(from_range_t, _Range&& __range, const allocator_type& __a) |
| 649 | 662 | : set(from_range, std::forward<_Range>(__range), key_compare(), __a) {} |
| 650 | #endif | |
| 663 | # endif | |
| 651 | 664 | |
| 652 | 665 | _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); } |
| 653 | 666 | |
| ... | ... | @@ -656,10 +669,10 @@ public: |
| 656 | 669 | return *this; |
| 657 | 670 | } |
| 658 | 671 | |
| 659 | #ifndef _LIBCPP_CXX03_LANG | |
| 672 | # ifndef _LIBCPP_CXX03_LANG | |
| 660 | 673 | _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value) |
| 661 | 674 | : __tree_(std::move(__s.__tree_)) {} |
| 662 | #endif // _LIBCPP_CXX03_LANG | |
| 675 | # endif // _LIBCPP_CXX03_LANG | |
| 663 | 676 | |
| 664 | 677 | _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {} |
| 665 | 678 | |
| ... | ... | @@ -667,7 +680,7 @@ public: |
| 667 | 680 | insert(__s.begin(), __s.end()); |
| 668 | 681 | } |
| 669 | 682 | |
| 670 | #ifndef _LIBCPP_CXX03_LANG | |
| 683 | # ifndef _LIBCPP_CXX03_LANG | |
| 671 | 684 | _LIBCPP_HIDE_FROM_ABI set(set&& __s, const allocator_type& __a); |
| 672 | 685 | |
| 673 | 686 | _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| ... | ... | @@ -680,10 +693,10 @@ public: |
| 680 | 693 | insert(__il.begin(), __il.end()); |
| 681 | 694 | } |
| 682 | 695 | |
| 683 | # if _LIBCPP_STD_VER >= 14 | |
| 696 | # if _LIBCPP_STD_VER >= 14 | |
| 684 | 697 | _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const allocator_type& __a) |
| 685 | 698 | : set(__il, key_compare(), __a) {} |
| 686 | # endif | |
| 699 | # endif | |
| 687 | 700 | |
| 688 | 701 | _LIBCPP_HIDE_FROM_ABI set& operator=(initializer_list<value_type> __il) { |
| 689 | 702 | __tree_.__assign_unique(__il.begin(), __il.end()); |
| ... | ... | @@ -694,7 +707,7 @@ public: |
| 694 | 707 | __tree_ = std::move(__s.__tree_); |
| 695 | 708 | return *this; |
| 696 | 709 | } |
| 697 | #endif // _LIBCPP_CXX03_LANG | |
| 710 | # endif // _LIBCPP_CXX03_LANG | |
| 698 | 711 | |
| 699 | 712 | _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); } |
| 700 | 713 | |
| ... | ... | @@ -713,12 +726,12 @@ public: |
| 713 | 726 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 714 | 727 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 715 | 728 | |
| 716 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | |
| 729 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | |
| 717 | 730 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 718 | 731 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 719 | 732 | |
| 720 | 733 | // modifiers: |
| 721 | #ifndef _LIBCPP_CXX03_LANG | |
| 734 | # ifndef _LIBCPP_CXX03_LANG | |
| 722 | 735 | template <class... _Args> |
| 723 | 736 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) { |
| 724 | 737 | return __tree_.__emplace_unique(std::forward<_Args>(__args)...); |
| ... | ... | @@ -727,7 +740,7 @@ public: |
| 727 | 740 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) { |
| 728 | 741 | return __tree_.__emplace_hint_unique(__p, std::forward<_Args>(__args)...); |
| 729 | 742 | } |
| 730 | #endif // _LIBCPP_CXX03_LANG | |
| 743 | # endif // _LIBCPP_CXX03_LANG | |
| 731 | 744 | |
| 732 | 745 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); } |
| 733 | 746 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { |
| ... | ... | @@ -740,7 +753,7 @@ public: |
| 740 | 753 | __tree_.__insert_unique(__e, *__f); |
| 741 | 754 | } |
| 742 | 755 | |
| 743 | #if _LIBCPP_STD_VER >= 23 | |
| 756 | # if _LIBCPP_STD_VER >= 23 | |
| 744 | 757 | template <_ContainerCompatibleRange<value_type> _Range> |
| 745 | 758 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 746 | 759 | const_iterator __end = cend(); |
| ... | ... | @@ -748,9 +761,9 @@ public: |
| 748 | 761 | __tree_.__insert_unique(__end, std::forward<decltype(__element)>(__element)); |
| 749 | 762 | } |
| 750 | 763 | } |
| 751 | #endif | |
| 764 | # endif | |
| 752 | 765 | |
| 753 | #ifndef _LIBCPP_CXX03_LANG | |
| 766 | # ifndef _LIBCPP_CXX03_LANG | |
| 754 | 767 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) { |
| 755 | 768 | return __tree_.__insert_unique(std::move(__v)); |
| 756 | 769 | } |
| ... | ... | @@ -760,14 +773,14 @@ public: |
| 760 | 773 | } |
| 761 | 774 | |
| 762 | 775 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 763 | #endif // _LIBCPP_CXX03_LANG | |
| 776 | # endif // _LIBCPP_CXX03_LANG | |
| 764 | 777 | |
| 765 | 778 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); } |
| 766 | 779 | _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); } |
| 767 | 780 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); } |
| 768 | 781 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } |
| 769 | 782 | |
| 770 | #if _LIBCPP_STD_VER >= 17 | |
| 783 | # if _LIBCPP_STD_VER >= 17 | |
| 771 | 784 | _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) { |
| 772 | 785 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 773 | 786 | "node_type with incompatible allocator passed to set::insert()"); |
| ... | ... | @@ -808,7 +821,7 @@ public: |
| 808 | 821 | __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); |
| 809 | 822 | __tree_.__node_handle_merge_unique(__source.__tree_); |
| 810 | 823 | } |
| 811 | #endif | |
| 824 | # endif | |
| 812 | 825 | |
| 813 | 826 | _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); } |
| 814 | 827 | |
| ... | ... | @@ -819,7 +832,7 @@ public: |
| 819 | 832 | // set operations: |
| 820 | 833 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 821 | 834 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 822 | #if _LIBCPP_STD_VER >= 14 | |
| 835 | # if _LIBCPP_STD_VER >= 14 | |
| 823 | 836 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 824 | 837 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 825 | 838 | return __tree_.find(__k); |
| ... | ... | @@ -828,27 +841,27 @@ public: |
| 828 | 841 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 829 | 842 | return __tree_.find(__k); |
| 830 | 843 | } |
| 831 | #endif | |
| 844 | # endif | |
| 832 | 845 | |
| 833 | 846 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); } |
| 834 | #if _LIBCPP_STD_VER >= 14 | |
| 847 | # if _LIBCPP_STD_VER >= 14 | |
| 835 | 848 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 836 | 849 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 837 | 850 | return __tree_.__count_multi(__k); |
| 838 | 851 | } |
| 839 | #endif | |
| 852 | # endif | |
| 840 | 853 | |
| 841 | #if _LIBCPP_STD_VER >= 20 | |
| 854 | # if _LIBCPP_STD_VER >= 20 | |
| 842 | 855 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 843 | 856 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 844 | 857 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 845 | 858 | return find(__k) != end(); |
| 846 | 859 | } |
| 847 | #endif // _LIBCPP_STD_VER >= 20 | |
| 860 | # endif // _LIBCPP_STD_VER >= 20 | |
| 848 | 861 | |
| 849 | 862 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } |
| 850 | 863 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } |
| 851 | #if _LIBCPP_STD_VER >= 14 | |
| 864 | # if _LIBCPP_STD_VER >= 14 | |
| 852 | 865 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 853 | 866 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 854 | 867 | return __tree_.lower_bound(__k); |
| ... | ... | @@ -858,11 +871,11 @@ public: |
| 858 | 871 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 859 | 872 | return __tree_.lower_bound(__k); |
| 860 | 873 | } |
| 861 | #endif | |
| 874 | # endif | |
| 862 | 875 | |
| 863 | 876 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } |
| 864 | 877 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } |
| 865 | #if _LIBCPP_STD_VER >= 14 | |
| 878 | # if _LIBCPP_STD_VER >= 14 | |
| 866 | 879 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 867 | 880 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 868 | 881 | return __tree_.upper_bound(__k); |
| ... | ... | @@ -871,7 +884,7 @@ public: |
| 871 | 884 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 872 | 885 | return __tree_.upper_bound(__k); |
| 873 | 886 | } |
| 874 | #endif | |
| 887 | # endif | |
| 875 | 888 | |
| 876 | 889 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 877 | 890 | return __tree_.__equal_range_unique(__k); |
| ... | ... | @@ -879,7 +892,7 @@ public: |
| 879 | 892 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 880 | 893 | return __tree_.__equal_range_unique(__k); |
| 881 | 894 | } |
| 882 | #if _LIBCPP_STD_VER >= 14 | |
| 895 | # if _LIBCPP_STD_VER >= 14 | |
| 883 | 896 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 884 | 897 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 885 | 898 | return __tree_.__equal_range_multi(__k); |
| ... | ... | @@ -888,10 +901,10 @@ public: |
| 888 | 901 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 889 | 902 | return __tree_.__equal_range_multi(__k); |
| 890 | 903 | } |
| 891 | #endif | |
| 904 | # endif | |
| 892 | 905 | }; |
| 893 | 906 | |
| 894 | #if _LIBCPP_STD_VER >= 17 | |
| 907 | # if _LIBCPP_STD_VER >= 17 | |
| 895 | 908 | template <class _InputIterator, |
| 896 | 909 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 897 | 910 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
| ... | ... | @@ -901,7 +914,7 @@ template <class _InputIterator, |
| 901 | 914 | set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 902 | 915 | -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>; |
| 903 | 916 | |
| 904 | # if _LIBCPP_STD_VER >= 23 | |
| 917 | # if _LIBCPP_STD_VER >= 23 | |
| 905 | 918 | template <ranges::input_range _Range, |
| 906 | 919 | class _Compare = less<ranges::range_value_t<_Range>>, |
| 907 | 920 | class _Allocator = allocator<ranges::range_value_t<_Range>>, |
| ... | ... | @@ -909,7 +922,7 @@ template <ranges::input_range _Range, |
| 909 | 922 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> |
| 910 | 923 | set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) |
| 911 | 924 | -> set<ranges::range_value_t<_Range>, _Compare, _Allocator>; |
| 912 | # endif | |
| 925 | # endif | |
| 913 | 926 | |
| 914 | 927 | template <class _Key, |
| 915 | 928 | class _Compare = less<_Key>, |
| ... | ... | @@ -926,18 +939,18 @@ set(_InputIterator, |
| 926 | 939 | _InputIterator, |
| 927 | 940 | _Allocator) -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>; |
| 928 | 941 | |
| 929 | # if _LIBCPP_STD_VER >= 23 | |
| 942 | # if _LIBCPP_STD_VER >= 23 | |
| 930 | 943 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 931 | 944 | set(from_range_t, |
| 932 | 945 | _Range&&, |
| 933 | 946 | _Allocator) -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; |
| 934 | # endif | |
| 947 | # endif | |
| 935 | 948 | |
| 936 | 949 | template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 937 | 950 | set(initializer_list<_Key>, _Allocator) -> set<_Key, less<_Key>, _Allocator>; |
| 938 | #endif | |
| 951 | # endif | |
| 939 | 952 | |
| 940 | #ifndef _LIBCPP_CXX03_LANG | |
| 953 | # ifndef _LIBCPP_CXX03_LANG | |
| 941 | 954 | |
| 942 | 955 | template <class _Key, class _Compare, class _Allocator> |
| 943 | 956 | set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __tree_(std::move(__s.__tree_), __a) { |
| ... | ... | @@ -948,7 +961,7 @@ set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __t |
| 948 | 961 | } |
| 949 | 962 | } |
| 950 | 963 | |
| 951 | #endif // _LIBCPP_CXX03_LANG | |
| 964 | # endif // _LIBCPP_CXX03_LANG | |
| 952 | 965 | |
| 953 | 966 | template <class _Key, class _Compare, class _Allocator> |
| 954 | 967 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -956,7 +969,7 @@ operator==(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, |
| 956 | 969 | return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); |
| 957 | 970 | } |
| 958 | 971 | |
| 959 | #if _LIBCPP_STD_VER <= 17 | |
| 972 | # if _LIBCPP_STD_VER <= 17 | |
| 960 | 973 | |
| 961 | 974 | template <class _Key, class _Compare, class _Allocator> |
| 962 | 975 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -988,7 +1001,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, |
| 988 | 1001 | return !(__y < __x); |
| 989 | 1002 | } |
| 990 | 1003 | |
| 991 | #else // _LIBCPP_STD_VER <= 17 | |
| 1004 | # else // _LIBCPP_STD_VER <= 17 | |
| 992 | 1005 | |
| 993 | 1006 | template <class _Key, class _Allocator> |
| 994 | 1007 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> |
| ... | ... | @@ -996,7 +1009,7 @@ operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) |
| 996 | 1009 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); |
| 997 | 1010 | } |
| 998 | 1011 | |
| 999 | #endif // _LIBCPP_STD_VER <= 17 | |
| 1012 | # endif // _LIBCPP_STD_VER <= 17 | |
| 1000 | 1013 | |
| 1001 | 1014 | // specialized algorithms: |
| 1002 | 1015 | template <class _Key, class _Compare, class _Allocator> |
| ... | ... | @@ -1005,13 +1018,21 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(set<_Key, _Compare, _Allocator>& __x, set |
| 1005 | 1018 | __x.swap(__y); |
| 1006 | 1019 | } |
| 1007 | 1020 | |
| 1008 | #if _LIBCPP_STD_VER >= 20 | |
| 1021 | # if _LIBCPP_STD_VER >= 20 | |
| 1009 | 1022 | template <class _Key, class _Compare, class _Allocator, class _Predicate> |
| 1010 | 1023 | inline _LIBCPP_HIDE_FROM_ABI typename set<_Key, _Compare, _Allocator>::size_type |
| 1011 | 1024 | erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { |
| 1012 | 1025 | return std::__libcpp_erase_if_container(__c, __pred); |
| 1013 | 1026 | } |
| 1014 | #endif | |
| 1027 | # endif | |
| 1028 | ||
| 1029 | template <class _Key, class _Compare, class _Allocator> | |
| 1030 | struct __container_traits<set<_Key, _Compare, _Allocator> > { | |
| 1031 | // http://eel.is/c++draft/associative.reqmts.except#2 | |
| 1032 | // For associative containers, if an exception is thrown by any operation from within | |
| 1033 | // an insert or emplace function inserting a single element, the insertion has no effect. | |
| 1034 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | |
| 1035 | }; | |
| 1015 | 1036 | |
| 1016 | 1037 | template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> > |
| 1017 | 1038 | class _LIBCPP_TEMPLATE_VIS multiset { |
| ... | ... | @@ -1046,9 +1067,9 @@ public: |
| 1046 | 1067 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 1047 | 1068 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 1048 | 1069 | |
| 1049 | #if _LIBCPP_STD_VER >= 17 | |
| 1070 | # if _LIBCPP_STD_VER >= 17 | |
| 1050 | 1071 | typedef __set_node_handle<typename __base::__node, allocator_type> node_type; |
| 1051 | #endif | |
| 1072 | # endif | |
| 1052 | 1073 | |
| 1053 | 1074 | template <class _Key2, class _Compare2, class _Alloc2> |
| 1054 | 1075 | friend class _LIBCPP_TEMPLATE_VIS set; |
| ... | ... | @@ -1073,11 +1094,11 @@ public: |
| 1073 | 1094 | insert(__f, __l); |
| 1074 | 1095 | } |
| 1075 | 1096 | |
| 1076 | #if _LIBCPP_STD_VER >= 14 | |
| 1097 | # if _LIBCPP_STD_VER >= 14 | |
| 1077 | 1098 | template <class _InputIterator> |
| 1078 | 1099 | _LIBCPP_HIDE_FROM_ABI multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) |
| 1079 | 1100 | : multiset(__f, __l, key_compare(), __a) {} |
| 1080 | #endif | |
| 1101 | # endif | |
| 1081 | 1102 | |
| 1082 | 1103 | template <class _InputIterator> |
| 1083 | 1104 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -1086,7 +1107,7 @@ public: |
| 1086 | 1107 | insert(__f, __l); |
| 1087 | 1108 | } |
| 1088 | 1109 | |
| 1089 | #if _LIBCPP_STD_VER >= 23 | |
| 1110 | # if _LIBCPP_STD_VER >= 23 | |
| 1090 | 1111 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1091 | 1112 | _LIBCPP_HIDE_FROM_ABI |
| 1092 | 1113 | multiset(from_range_t, |
| ... | ... | @@ -1100,7 +1121,7 @@ public: |
| 1100 | 1121 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1101 | 1122 | _LIBCPP_HIDE_FROM_ABI multiset(from_range_t, _Range&& __range, const allocator_type& __a) |
| 1102 | 1123 | : multiset(from_range, std::forward<_Range>(__range), key_compare(), __a) {} |
| 1103 | #endif | |
| 1124 | # endif | |
| 1104 | 1125 | |
| 1105 | 1126 | _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s) |
| 1106 | 1127 | : __tree_(__s.__tree_.value_comp(), |
| ... | ... | @@ -1113,19 +1134,19 @@ public: |
| 1113 | 1134 | return *this; |
| 1114 | 1135 | } |
| 1115 | 1136 | |
| 1116 | #ifndef _LIBCPP_CXX03_LANG | |
| 1137 | # ifndef _LIBCPP_CXX03_LANG | |
| 1117 | 1138 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value) |
| 1118 | 1139 | : __tree_(std::move(__s.__tree_)) {} |
| 1119 | 1140 | |
| 1120 | 1141 | _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a); |
| 1121 | #endif // _LIBCPP_CXX03_LANG | |
| 1142 | # endif // _LIBCPP_CXX03_LANG | |
| 1122 | 1143 | _LIBCPP_HIDE_FROM_ABI explicit multiset(const allocator_type& __a) : __tree_(__a) {} |
| 1123 | 1144 | _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s, const allocator_type& __a) |
| 1124 | 1145 | : __tree_(__s.__tree_.value_comp(), __a) { |
| 1125 | 1146 | insert(__s.begin(), __s.end()); |
| 1126 | 1147 | } |
| 1127 | 1148 | |
| 1128 | #ifndef _LIBCPP_CXX03_LANG | |
| 1149 | # ifndef _LIBCPP_CXX03_LANG | |
| 1129 | 1150 | _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare()) |
| 1130 | 1151 | : __tree_(__comp) { |
| 1131 | 1152 | insert(__il.begin(), __il.end()); |
| ... | ... | @@ -1137,10 +1158,10 @@ public: |
| 1137 | 1158 | insert(__il.begin(), __il.end()); |
| 1138 | 1159 | } |
| 1139 | 1160 | |
| 1140 | # if _LIBCPP_STD_VER >= 14 | |
| 1161 | # if _LIBCPP_STD_VER >= 14 | |
| 1141 | 1162 | _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const allocator_type& __a) |
| 1142 | 1163 | : multiset(__il, key_compare(), __a) {} |
| 1143 | # endif | |
| 1164 | # endif | |
| 1144 | 1165 | |
| 1145 | 1166 | _LIBCPP_HIDE_FROM_ABI multiset& operator=(initializer_list<value_type> __il) { |
| 1146 | 1167 | __tree_.__assign_multi(__il.begin(), __il.end()); |
| ... | ... | @@ -1151,7 +1172,7 @@ public: |
| 1151 | 1172 | __tree_ = std::move(__s.__tree_); |
| 1152 | 1173 | return *this; |
| 1153 | 1174 | } |
| 1154 | #endif // _LIBCPP_CXX03_LANG | |
| 1175 | # endif // _LIBCPP_CXX03_LANG | |
| 1155 | 1176 | |
| 1156 | 1177 | _LIBCPP_HIDE_FROM_ABI ~multiset() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); } |
| 1157 | 1178 | |
| ... | ... | @@ -1170,12 +1191,12 @@ public: |
| 1170 | 1191 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } |
| 1171 | 1192 | _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } |
| 1172 | 1193 | |
| 1173 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | |
| 1194 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; } | |
| 1174 | 1195 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); } |
| 1175 | 1196 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); } |
| 1176 | 1197 | |
| 1177 | 1198 | // modifiers: |
| 1178 | #ifndef _LIBCPP_CXX03_LANG | |
| 1199 | # ifndef _LIBCPP_CXX03_LANG | |
| 1179 | 1200 | template <class... _Args> |
| 1180 | 1201 | _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { |
| 1181 | 1202 | return __tree_.__emplace_multi(std::forward<_Args>(__args)...); |
| ... | ... | @@ -1184,7 +1205,7 @@ public: |
| 1184 | 1205 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) { |
| 1185 | 1206 | return __tree_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...); |
| 1186 | 1207 | } |
| 1187 | #endif // _LIBCPP_CXX03_LANG | |
| 1208 | # endif // _LIBCPP_CXX03_LANG | |
| 1188 | 1209 | |
| 1189 | 1210 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); } |
| 1190 | 1211 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { |
| ... | ... | @@ -1197,7 +1218,7 @@ public: |
| 1197 | 1218 | __tree_.__insert_multi(__e, *__f); |
| 1198 | 1219 | } |
| 1199 | 1220 | |
| 1200 | #if _LIBCPP_STD_VER >= 23 | |
| 1221 | # if _LIBCPP_STD_VER >= 23 | |
| 1201 | 1222 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1202 | 1223 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1203 | 1224 | const_iterator __end = cend(); |
| ... | ... | @@ -1205,9 +1226,9 @@ public: |
| 1205 | 1226 | __tree_.__insert_multi(__end, std::forward<decltype(__element)>(__element)); |
| 1206 | 1227 | } |
| 1207 | 1228 | } |
| 1208 | #endif | |
| 1229 | # endif | |
| 1209 | 1230 | |
| 1210 | #ifndef _LIBCPP_CXX03_LANG | |
| 1231 | # ifndef _LIBCPP_CXX03_LANG | |
| 1211 | 1232 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); } |
| 1212 | 1233 | |
| 1213 | 1234 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) { |
| ... | ... | @@ -1215,14 +1236,14 @@ public: |
| 1215 | 1236 | } |
| 1216 | 1237 | |
| 1217 | 1238 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 1218 | #endif // _LIBCPP_CXX03_LANG | |
| 1239 | # endif // _LIBCPP_CXX03_LANG | |
| 1219 | 1240 | |
| 1220 | 1241 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); } |
| 1221 | 1242 | _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); } |
| 1222 | 1243 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); } |
| 1223 | 1244 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } |
| 1224 | 1245 | |
| 1225 | #if _LIBCPP_STD_VER >= 17 | |
| 1246 | # if _LIBCPP_STD_VER >= 17 | |
| 1226 | 1247 | _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) { |
| 1227 | 1248 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1228 | 1249 | "node_type with incompatible allocator passed to multiset::insert()"); |
| ... | ... | @@ -1263,7 +1284,7 @@ public: |
| 1263 | 1284 | __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); |
| 1264 | 1285 | __tree_.__node_handle_merge_multi(__source.__tree_); |
| 1265 | 1286 | } |
| 1266 | #endif | |
| 1287 | # endif | |
| 1267 | 1288 | |
| 1268 | 1289 | _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { |
| 1269 | 1290 | __tree_.swap(__s.__tree_); |
| ... | ... | @@ -1276,7 +1297,7 @@ public: |
| 1276 | 1297 | // set operations: |
| 1277 | 1298 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); } |
| 1278 | 1299 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); } |
| 1279 | #if _LIBCPP_STD_VER >= 14 | |
| 1300 | # if _LIBCPP_STD_VER >= 14 | |
| 1280 | 1301 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1281 | 1302 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1282 | 1303 | return __tree_.find(__k); |
| ... | ... | @@ -1285,27 +1306,27 @@ public: |
| 1285 | 1306 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1286 | 1307 | return __tree_.find(__k); |
| 1287 | 1308 | } |
| 1288 | #endif | |
| 1309 | # endif | |
| 1289 | 1310 | |
| 1290 | 1311 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); } |
| 1291 | #if _LIBCPP_STD_VER >= 14 | |
| 1312 | # if _LIBCPP_STD_VER >= 14 | |
| 1292 | 1313 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1293 | 1314 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1294 | 1315 | return __tree_.__count_multi(__k); |
| 1295 | 1316 | } |
| 1296 | #endif | |
| 1317 | # endif | |
| 1297 | 1318 | |
| 1298 | #if _LIBCPP_STD_VER >= 20 | |
| 1319 | # if _LIBCPP_STD_VER >= 20 | |
| 1299 | 1320 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1300 | 1321 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1301 | 1322 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1302 | 1323 | return find(__k) != end(); |
| 1303 | 1324 | } |
| 1304 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1325 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1305 | 1326 | |
| 1306 | 1327 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); } |
| 1307 | 1328 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } |
| 1308 | #if _LIBCPP_STD_VER >= 14 | |
| 1329 | # if _LIBCPP_STD_VER >= 14 | |
| 1309 | 1330 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1310 | 1331 | _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) { |
| 1311 | 1332 | return __tree_.lower_bound(__k); |
| ... | ... | @@ -1315,11 +1336,11 @@ public: |
| 1315 | 1336 | _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const { |
| 1316 | 1337 | return __tree_.lower_bound(__k); |
| 1317 | 1338 | } |
| 1318 | #endif | |
| 1339 | # endif | |
| 1319 | 1340 | |
| 1320 | 1341 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } |
| 1321 | 1342 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } |
| 1322 | #if _LIBCPP_STD_VER >= 14 | |
| 1343 | # if _LIBCPP_STD_VER >= 14 | |
| 1323 | 1344 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1324 | 1345 | _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) { |
| 1325 | 1346 | return __tree_.upper_bound(__k); |
| ... | ... | @@ -1328,7 +1349,7 @@ public: |
| 1328 | 1349 | _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const { |
| 1329 | 1350 | return __tree_.upper_bound(__k); |
| 1330 | 1351 | } |
| 1331 | #endif | |
| 1352 | # endif | |
| 1332 | 1353 | |
| 1333 | 1354 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 1334 | 1355 | return __tree_.__equal_range_multi(__k); |
| ... | ... | @@ -1336,7 +1357,7 @@ public: |
| 1336 | 1357 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 1337 | 1358 | return __tree_.__equal_range_multi(__k); |
| 1338 | 1359 | } |
| 1339 | #if _LIBCPP_STD_VER >= 14 | |
| 1360 | # if _LIBCPP_STD_VER >= 14 | |
| 1340 | 1361 | template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0> |
| 1341 | 1362 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1342 | 1363 | return __tree_.__equal_range_multi(__k); |
| ... | ... | @@ -1345,10 +1366,10 @@ public: |
| 1345 | 1366 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1346 | 1367 | return __tree_.__equal_range_multi(__k); |
| 1347 | 1368 | } |
| 1348 | #endif | |
| 1369 | # endif | |
| 1349 | 1370 | }; |
| 1350 | 1371 | |
| 1351 | #if _LIBCPP_STD_VER >= 17 | |
| 1372 | # if _LIBCPP_STD_VER >= 17 | |
| 1352 | 1373 | template <class _InputIterator, |
| 1353 | 1374 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 1354 | 1375 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
| ... | ... | @@ -1358,7 +1379,7 @@ template <class _InputIterator, |
| 1358 | 1379 | multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1359 | 1380 | -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>; |
| 1360 | 1381 | |
| 1361 | # if _LIBCPP_STD_VER >= 23 | |
| 1382 | # if _LIBCPP_STD_VER >= 23 | |
| 1362 | 1383 | template <ranges::input_range _Range, |
| 1363 | 1384 | class _Compare = less<ranges::range_value_t<_Range>>, |
| 1364 | 1385 | class _Allocator = allocator<ranges::range_value_t<_Range>>, |
| ... | ... | @@ -1366,7 +1387,7 @@ template <ranges::input_range _Range, |
| 1366 | 1387 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> |
| 1367 | 1388 | multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1368 | 1389 | -> multiset<ranges::range_value_t<_Range>, _Compare, _Allocator>; |
| 1369 | # endif | |
| 1390 | # endif | |
| 1370 | 1391 | |
| 1371 | 1392 | template <class _Key, |
| 1372 | 1393 | class _Compare = less<_Key>, |
| ... | ... | @@ -1384,18 +1405,18 @@ template <class _InputIterator, |
| 1384 | 1405 | multiset(_InputIterator, _InputIterator, _Allocator) |
| 1385 | 1406 | -> multiset<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>; |
| 1386 | 1407 | |
| 1387 | # if _LIBCPP_STD_VER >= 23 | |
| 1408 | # if _LIBCPP_STD_VER >= 23 | |
| 1388 | 1409 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 1389 | 1410 | multiset(from_range_t, |
| 1390 | 1411 | _Range&&, |
| 1391 | 1412 | _Allocator) -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>; |
| 1392 | # endif | |
| 1413 | # endif | |
| 1393 | 1414 | |
| 1394 | 1415 | template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>> |
| 1395 | 1416 | multiset(initializer_list<_Key>, _Allocator) -> multiset<_Key, less<_Key>, _Allocator>; |
| 1396 | #endif | |
| 1417 | # endif | |
| 1397 | 1418 | |
| 1398 | #ifndef _LIBCPP_CXX03_LANG | |
| 1419 | # ifndef _LIBCPP_CXX03_LANG | |
| 1399 | 1420 | |
| 1400 | 1421 | template <class _Key, class _Compare, class _Allocator> |
| 1401 | 1422 | multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a) |
| ... | ... | @@ -1407,7 +1428,7 @@ multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_t |
| 1407 | 1428 | } |
| 1408 | 1429 | } |
| 1409 | 1430 | |
| 1410 | #endif // _LIBCPP_CXX03_LANG | |
| 1431 | # endif // _LIBCPP_CXX03_LANG | |
| 1411 | 1432 | |
| 1412 | 1433 | template <class _Key, class _Compare, class _Allocator> |
| 1413 | 1434 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -1415,7 +1436,7 @@ operator==(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, |
| 1415 | 1436 | return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); |
| 1416 | 1437 | } |
| 1417 | 1438 | |
| 1418 | #if _LIBCPP_STD_VER <= 17 | |
| 1439 | # if _LIBCPP_STD_VER <= 17 | |
| 1419 | 1440 | |
| 1420 | 1441 | template <class _Key, class _Compare, class _Allocator> |
| 1421 | 1442 | inline _LIBCPP_HIDE_FROM_ABI bool |
| ... | ... | @@ -1447,16 +1468,15 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, |
| 1447 | 1468 | return !(__y < __x); |
| 1448 | 1469 | } |
| 1449 | 1470 | |
| 1450 | #else // _LIBCPP_STD_VER <= 17 | |
| 1471 | # else // _LIBCPP_STD_VER <= 17 | |
| 1451 | 1472 | |
| 1452 | 1473 | template <class _Key, class _Allocator> |
| 1453 | 1474 | _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key> |
| 1454 | 1475 | operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) { |
| 1455 | return std::lexicographical_compare_three_way( | |
| 1456 | __x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); | |
| 1476 | return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way); | |
| 1457 | 1477 | } |
| 1458 | 1478 | |
| 1459 | #endif // _LIBCPP_STD_VER <= 17 | |
| 1479 | # endif // _LIBCPP_STD_VER <= 17 | |
| 1460 | 1480 | |
| 1461 | 1481 | template <class _Key, class _Compare, class _Allocator> |
| 1462 | 1482 | inline _LIBCPP_HIDE_FROM_ABI void |
| ... | ... | @@ -1465,17 +1485,25 @@ swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Alloca |
| 1465 | 1485 | __x.swap(__y); |
| 1466 | 1486 | } |
| 1467 | 1487 | |
| 1468 | #if _LIBCPP_STD_VER >= 20 | |
| 1488 | # if _LIBCPP_STD_VER >= 20 | |
| 1469 | 1489 | template <class _Key, class _Compare, class _Allocator, class _Predicate> |
| 1470 | 1490 | inline _LIBCPP_HIDE_FROM_ABI typename multiset<_Key, _Compare, _Allocator>::size_type |
| 1471 | 1491 | erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) { |
| 1472 | 1492 | return std::__libcpp_erase_if_container(__c, __pred); |
| 1473 | 1493 | } |
| 1474 | #endif | |
| 1494 | # endif | |
| 1495 | ||
| 1496 | template <class _Key, class _Compare, class _Allocator> | |
| 1497 | struct __container_traits<multiset<_Key, _Compare, _Allocator> > { | |
| 1498 | // http://eel.is/c++draft/associative.reqmts.except#2 | |
| 1499 | // For associative containers, if an exception is thrown by any operation from within | |
| 1500 | // an insert or emplace function inserting a single element, the insertion has no effect. | |
| 1501 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true; | |
| 1502 | }; | |
| 1475 | 1503 | |
| 1476 | 1504 | _LIBCPP_END_NAMESPACE_STD |
| 1477 | 1505 | |
| 1478 | #if _LIBCPP_STD_VER >= 17 | |
| 1506 | # if _LIBCPP_STD_VER >= 17 | |
| 1479 | 1507 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 1480 | 1508 | namespace pmr { |
| 1481 | 1509 | template <class _KeyT, class _CompareT = std::less<_KeyT>> |
| ... | ... | @@ -1485,17 +1513,18 @@ template <class _KeyT, class _CompareT = std::less<_KeyT>> |
| 1485 | 1513 | using multiset _LIBCPP_AVAILABILITY_PMR = std::multiset<_KeyT, _CompareT, polymorphic_allocator<_KeyT>>; |
| 1486 | 1514 | } // namespace pmr |
| 1487 | 1515 | _LIBCPP_END_NAMESPACE_STD |
| 1488 | #endif | |
| 1516 | # endif | |
| 1489 | 1517 | |
| 1490 | 1518 | _LIBCPP_POP_MACROS |
| 1491 | 1519 | |
| 1492 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1493 | # include <concepts> | |
| 1494 | # include <cstdlib> | |
| 1495 | # include <functional> | |
| 1496 | # include <iterator> | |
| 1497 | # include <stdexcept> | |
| 1498 | # include <type_traits> | |
| 1499 | #endif | |
| 1520 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1521 | # include <concepts> | |
| 1522 | # include <cstdlib> | |
| 1523 | # include <functional> | |
| 1524 | # include <iterator> | |
| 1525 | # include <stdexcept> | |
| 1526 | # include <type_traits> | |
| 1527 | # endif | |
| 1528 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1500 | 1529 | |
| 1501 | 1530 | #endif // _LIBCPP_SET |
lib/libcxx/include/shared_mutex+32-28| ... | ... | @@ -122,31 +122,34 @@ template <class Mutex> |
| 122 | 122 | |
| 123 | 123 | */ |
| 124 | 124 | |
| 125 | #include <__config> | |
| 126 | ||
| 127 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 128 | ||
| 129 | # include <__chrono/duration.h> | |
| 130 | # include <__chrono/steady_clock.h> | |
| 131 | # include <__chrono/time_point.h> | |
| 132 | # include <__condition_variable/condition_variable.h> | |
| 133 | # include <__memory/addressof.h> | |
| 134 | # include <__mutex/mutex.h> | |
| 135 | # include <__mutex/tag_types.h> | |
| 136 | # include <__mutex/unique_lock.h> | |
| 137 | # include <__system_error/system_error.h> | |
| 138 | # include <__utility/swap.h> | |
| 139 | # include <cerrno> | |
| 140 | # include <version> | |
| 125 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 126 | # include <__cxx03/shared_mutex> | |
| 127 | #else | |
| 128 | # include <__config> | |
| 129 | ||
| 130 | # if _LIBCPP_HAS_THREADS | |
| 131 | ||
| 132 | # include <__chrono/duration.h> | |
| 133 | # include <__chrono/steady_clock.h> | |
| 134 | # include <__chrono/time_point.h> | |
| 135 | # include <__condition_variable/condition_variable.h> | |
| 136 | # include <__memory/addressof.h> | |
| 137 | # include <__mutex/mutex.h> | |
| 138 | # include <__mutex/tag_types.h> | |
| 139 | # include <__mutex/unique_lock.h> | |
| 140 | # include <__system_error/throw_system_error.h> | |
| 141 | # include <__utility/swap.h> | |
| 142 | # include <cerrno> | |
| 143 | # include <version> | |
| 141 | 144 | |
| 142 | 145 | _LIBCPP_PUSH_MACROS |
| 143 | # include <__undef_macros> | |
| 146 | # include <__undef_macros> | |
| 144 | 147 | |
| 145 | # if _LIBCPP_STD_VER >= 14 | |
| 148 | # if _LIBCPP_STD_VER >= 14 | |
| 146 | 149 | |
| 147 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 148 | # pragma GCC system_header | |
| 149 | # endif | |
| 150 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 151 | # pragma GCC system_header | |
| 152 | # endif | |
| 150 | 153 | |
| 151 | 154 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 152 | 155 | |
| ... | ... | @@ -179,7 +182,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base { |
| 179 | 182 | // native_handle_type native_handle(); // See 30.2.3 |
| 180 | 183 | }; |
| 181 | 184 | |
| 182 | # if _LIBCPP_STD_VER >= 17 | |
| 185 | # if _LIBCPP_STD_VER >= 17 | |
| 183 | 186 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_mutex")) shared_mutex { |
| 184 | 187 | __shared_mutex_base __base_; |
| 185 | 188 | |
| ... | ... | @@ -216,7 +219,7 @@ public: |
| 216 | 219 | // typedef __shared_mutex_base::native_handle_type native_handle_type; |
| 217 | 220 | // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); } |
| 218 | 221 | }; |
| 219 | # endif | |
| 222 | # endif | |
| 220 | 223 | |
| 221 | 224 | class _LIBCPP_EXPORTED_FROM_ABI |
| 222 | 225 | _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex")) shared_timed_mutex { |
| ... | ... | @@ -451,14 +454,15 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_lock<_Mutex>& __x, shared_lock<_Mu |
| 451 | 454 | |
| 452 | 455 | _LIBCPP_END_NAMESPACE_STD |
| 453 | 456 | |
| 454 | # endif // _LIBCPP_STD_VER >= 14 | |
| 457 | # endif // _LIBCPP_STD_VER >= 14 | |
| 455 | 458 | |
| 456 | 459 | _LIBCPP_POP_MACROS |
| 457 | 460 | |
| 458 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 461 | # endif // _LIBCPP_HAS_THREADS | |
| 459 | 462 | |
| 460 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 461 | # include <system_error> | |
| 462 | #endif | |
| 463 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 464 | # include <system_error> | |
| 465 | # endif | |
| 466 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 463 | 467 | |
| 464 | 468 | #endif // _LIBCPP_SHARED_MUTEX |
lib/libcxx/include/source_location+14-9| ... | ... | @@ -25,17 +25,20 @@ namespace std { |
| 25 | 25 | } |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | #include <__config> | |
| 29 | #include <cstdint> | |
| 30 | #include <version> | |
| 28 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 29 | # include <__cxx03/source_location> | |
| 30 | #else | |
| 31 | # include <__config> | |
| 32 | # include <cstdint> | |
| 33 | # include <version> | |
| 31 | 34 | |
| 32 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 33 | # pragma GCC system_header | |
| 34 | #endif | |
| 35 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 36 | # pragma GCC system_header | |
| 37 | # endif | |
| 35 | 38 | |
| 36 | 39 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 37 | 40 | |
| 38 | #if _LIBCPP_STD_VER >= 20 | |
| 41 | # if _LIBCPP_STD_VER >= 20 | |
| 39 | 42 | |
| 40 | 43 | class source_location { |
| 41 | 44 | // The names source_location::__impl, _M_file_name, _M_function_name, _M_line, and _M_column |
| ... | ... | @@ -52,7 +55,7 @@ class source_location { |
| 52 | 55 | // in constant evaluation, so we don't want to use `void*` as the argument |
| 53 | 56 | // type unless the builtin returned that, anyhow, and the invalid cast is |
| 54 | 57 | // unavoidable. |
| 55 | using __bsl_ty = decltype(__builtin_source_location()); | |
| 58 | using __bsl_ty _LIBCPP_NODEBUG = decltype(__builtin_source_location()); | |
| 56 | 59 | |
| 57 | 60 | public: |
| 58 | 61 | // The defaulted __ptr argument is necessary so that the builtin is evaluated |
| ... | ... | @@ -78,8 +81,10 @@ public: |
| 78 | 81 | } |
| 79 | 82 | }; |
| 80 | 83 | |
| 81 | #endif // _LIBCPP_STD_VER >= 20 | |
| 84 | # endif // _LIBCPP_STD_VER >= 20 | |
| 82 | 85 | |
| 83 | 86 | _LIBCPP_END_NAMESPACE_STD |
| 84 | 87 | |
| 88 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 89 | ||
| 85 | 90 | #endif // _LIBCPP_SOURCE_LOCATION |
lib/libcxx/include/span+93-83| ... | ... | @@ -144,59 +144,63 @@ template<class R> |
| 144 | 144 | |
| 145 | 145 | */ |
| 146 | 146 | |
| 147 | #include <__assert> | |
| 148 | #include <__concepts/convertible_to.h> | |
| 149 | #include <__concepts/equality_comparable.h> | |
| 150 | #include <__config> | |
| 151 | #include <__fwd/array.h> | |
| 152 | #include <__fwd/span.h> | |
| 153 | #include <__iterator/bounded_iter.h> | |
| 154 | #include <__iterator/concepts.h> | |
| 155 | #include <__iterator/iterator_traits.h> | |
| 156 | #include <__iterator/reverse_iterator.h> | |
| 157 | #include <__iterator/wrap_iter.h> | |
| 158 | #include <__memory/pointer_traits.h> | |
| 159 | #include <__ranges/concepts.h> | |
| 160 | #include <__ranges/data.h> | |
| 161 | #include <__ranges/enable_borrowed_range.h> | |
| 162 | #include <__ranges/enable_view.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> | |
| 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> | |
| 172 | #include <__type_traits/remove_cvref.h> | |
| 173 | #include <__type_traits/remove_reference.h> | |
| 174 | #include <__type_traits/type_identity.h> | |
| 175 | #include <__utility/forward.h> | |
| 176 | #include <cstddef> // for byte | |
| 177 | #include <initializer_list> | |
| 178 | #include <stdexcept> | |
| 179 | #include <version> | |
| 147 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 148 | # include <__cxx03/span> | |
| 149 | #else | |
| 150 | # include <__assert> | |
| 151 | # include <__concepts/convertible_to.h> | |
| 152 | # include <__concepts/equality_comparable.h> | |
| 153 | # include <__config> | |
| 154 | # include <__cstddef/byte.h> | |
| 155 | # include <__cstddef/ptrdiff_t.h> | |
| 156 | # include <__fwd/array.h> | |
| 157 | # include <__fwd/span.h> | |
| 158 | # include <__iterator/bounded_iter.h> | |
| 159 | # include <__iterator/concepts.h> | |
| 160 | # include <__iterator/iterator_traits.h> | |
| 161 | # include <__iterator/reverse_iterator.h> | |
| 162 | # include <__iterator/wrap_iter.h> | |
| 163 | # include <__memory/pointer_traits.h> | |
| 164 | # include <__ranges/concepts.h> | |
| 165 | # include <__ranges/data.h> | |
| 166 | # include <__ranges/enable_borrowed_range.h> | |
| 167 | # include <__ranges/enable_view.h> | |
| 168 | # include <__ranges/size.h> | |
| 169 | # include <__type_traits/integral_constant.h> | |
| 170 | # include <__type_traits/is_array.h> | |
| 171 | # include <__type_traits/is_const.h> | |
| 172 | # include <__type_traits/is_convertible.h> | |
| 173 | # include <__type_traits/is_integral.h> | |
| 174 | # include <__type_traits/is_same.h> | |
| 175 | # include <__type_traits/remove_const.h> | |
| 176 | # include <__type_traits/remove_cv.h> | |
| 177 | # include <__type_traits/remove_cvref.h> | |
| 178 | # include <__type_traits/remove_reference.h> | |
| 179 | # include <__type_traits/type_identity.h> | |
| 180 | # include <__utility/forward.h> | |
| 181 | # include <initializer_list> | |
| 182 | # include <stdexcept> | |
| 183 | # include <version> | |
| 180 | 184 | |
| 181 | 185 | // standard-mandated includes |
| 182 | 186 | |
| 183 | 187 | // [iterator.range] |
| 184 | #include <__iterator/access.h> | |
| 185 | #include <__iterator/data.h> | |
| 186 | #include <__iterator/empty.h> | |
| 187 | #include <__iterator/reverse_access.h> | |
| 188 | #include <__iterator/size.h> | |
| 189 | ||
| 190 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 191 | # pragma GCC system_header | |
| 192 | #endif | |
| 188 | # include <__iterator/access.h> | |
| 189 | # include <__iterator/data.h> | |
| 190 | # include <__iterator/empty.h> | |
| 191 | # include <__iterator/reverse_access.h> | |
| 192 | # include <__iterator/size.h> | |
| 193 | ||
| 194 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 195 | # pragma GCC system_header | |
| 196 | # endif | |
| 193 | 197 | |
| 194 | 198 | _LIBCPP_PUSH_MACROS |
| 195 | #include <__undef_macros> | |
| 199 | # include <__undef_macros> | |
| 196 | 200 | |
| 197 | 201 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 198 | 202 | |
| 199 | #if _LIBCPP_STD_VER >= 20 | |
| 203 | # if _LIBCPP_STD_VER >= 20 | |
| 200 | 204 | |
| 201 | 205 | template <class _Tp> |
| 202 | 206 | struct __is_std_span : false_type {}; |
| ... | ... | @@ -210,7 +214,7 @@ concept __span_compatible_range = |
| 210 | 214 | ranges::contiguous_range<_Range> && // |
| 211 | 215 | ranges::sized_range<_Range> && // |
| 212 | 216 | (ranges::borrowed_range<_Range> || is_const_v<_ElementType>) && // |
| 213 | !__is_std_array<remove_cvref_t<_Range>>::value && // | |
| 217 | !__is_std_array_v<remove_cvref_t<_Range>> && // | |
| 214 | 218 | !is_array_v<remove_cvref_t<_Range>> && // |
| 215 | 219 | is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>> (*)[], _ElementType (*)[]>; |
| 216 | 220 | |
| ... | ... | @@ -236,11 +240,11 @@ public: |
| 236 | 240 | using const_pointer = const _Tp*; |
| 237 | 241 | using reference = _Tp&; |
| 238 | 242 | using const_reference = const _Tp&; |
| 239 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 243 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 240 | 244 | using iterator = __bounded_iter<pointer>; |
| 241 | # else | |
| 245 | # else | |
| 242 | 246 | using iterator = __wrap_iter<pointer>; |
| 243 | # endif | |
| 247 | # endif | |
| 244 | 248 | using reverse_iterator = std::reverse_iterator<iterator>; |
| 245 | 249 | |
| 246 | 250 | static constexpr size_type extent = _Extent; |
| ... | ... | @@ -250,14 +254,14 @@ public: |
| 250 | 254 | requires(_Sz == 0) |
| 251 | 255 | _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr} {} |
| 252 | 256 | |
| 253 | # if _LIBCPP_STD_VER >= 26 | |
| 257 | # if _LIBCPP_STD_VER >= 26 | |
| 254 | 258 | _LIBCPP_HIDE_FROM_ABI constexpr explicit span(std::initializer_list<value_type> __il) |
| 255 | 259 | requires is_const_v<element_type> |
| 256 | 260 | : __data_{__il.begin()} { |
| 257 | 261 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( |
| 258 | 262 | _Extent == __il.size(), "Size mismatch in span's constructor _Extent != __il.size()."); |
| 259 | 263 | } |
| 260 | # endif | |
| 264 | # endif | |
| 261 | 265 | |
| 262 | 266 | constexpr span(const span&) noexcept = default; |
| 263 | 267 | constexpr span& operator=(const span&) noexcept = default; |
| ... | ... | @@ -266,6 +270,8 @@ public: |
| 266 | 270 | _LIBCPP_HIDE_FROM_ABI constexpr explicit span(_It __first, size_type __count) : __data_{std::to_address(__first)} { |
| 267 | 271 | (void)__count; |
| 268 | 272 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(_Extent == __count, "size mismatch in span's constructor (iterator, len)"); |
| 273 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__count == 0 || std::to_address(__first) != nullptr, | |
| 274 | "passed nullptr with non-zero length in span's constructor (iterator, len)"); | |
| 269 | 275 | } |
| 270 | 276 | |
| 271 | 277 | template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End> |
| ... | ... | @@ -355,13 +361,13 @@ public: |
| 355 | 361 | return __data_[__idx]; |
| 356 | 362 | } |
| 357 | 363 | |
| 358 | # if _LIBCPP_STD_VER >= 26 | |
| 364 | # if _LIBCPP_STD_VER >= 26 | |
| 359 | 365 | _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const { |
| 360 | 366 | if (__index >= size()) |
| 361 | 367 | std::__throw_out_of_range("span"); |
| 362 | 368 | return __data_[__index]; |
| 363 | 369 | } |
| 364 | # endif | |
| 370 | # endif | |
| 365 | 371 | |
| 366 | 372 | _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept { |
| 367 | 373 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T, N>::front() on empty span"); |
| ... | ... | @@ -377,18 +383,18 @@ public: |
| 377 | 383 | |
| 378 | 384 | // [span.iter], span iterator support |
| 379 | 385 | _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept { |
| 380 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 386 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 381 | 387 | return std::__make_bounded_iter(data(), data(), data() + size()); |
| 382 | # else | |
| 388 | # else | |
| 383 | 389 | return iterator(data()); |
| 384 | # endif | |
| 390 | # endif | |
| 385 | 391 | } |
| 386 | 392 | _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept { |
| 387 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 393 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 388 | 394 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); |
| 389 | # else | |
| 395 | # else | |
| 390 | 396 | return iterator(data() + size()); |
| 391 | # endif | |
| 397 | # endif | |
| 392 | 398 | } |
| 393 | 399 | _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } |
| 394 | 400 | _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } |
| ... | ... | @@ -417,11 +423,11 @@ public: |
| 417 | 423 | using const_pointer = const _Tp*; |
| 418 | 424 | using reference = _Tp&; |
| 419 | 425 | using const_reference = const _Tp&; |
| 420 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 426 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 421 | 427 | using iterator = __bounded_iter<pointer>; |
| 422 | # else | |
| 428 | # else | |
| 423 | 429 | using iterator = __wrap_iter<pointer>; |
| 424 | # endif | |
| 430 | # endif | |
| 425 | 431 | using reverse_iterator = std::reverse_iterator<iterator>; |
| 426 | 432 | |
| 427 | 433 | static constexpr size_type extent = dynamic_extent; |
| ... | ... | @@ -429,18 +435,21 @@ public: |
| 429 | 435 | // [span.cons], span constructors, copy, assignment, and destructor |
| 430 | 436 | _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr}, __size_{0} {} |
| 431 | 437 | |
| 432 | # if _LIBCPP_STD_VER >= 26 | |
| 438 | # if _LIBCPP_STD_VER >= 26 | |
| 433 | 439 | _LIBCPP_HIDE_FROM_ABI constexpr span(std::initializer_list<value_type> __il) |
| 434 | 440 | requires is_const_v<element_type> |
| 435 | 441 | : __data_{__il.begin()}, __size_{__il.size()} {} |
| 436 | # endif | |
| 442 | # endif | |
| 437 | 443 | |
| 438 | 444 | constexpr span(const span&) noexcept = default; |
| 439 | 445 | constexpr span& operator=(const span&) noexcept = default; |
| 440 | 446 | |
| 441 | 447 | template <__span_compatible_iterator<element_type> _It> |
| 442 | 448 | _LIBCPP_HIDE_FROM_ABI constexpr span(_It __first, size_type __count) |
| 443 | : __data_{std::to_address(__first)}, __size_{__count} {} | |
| 449 | : __data_{std::to_address(__first)}, __size_{__count} { | |
| 450 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__count == 0 || std::to_address(__first) != nullptr, | |
| 451 | "passed nullptr with non-zero length in span's constructor (iterator, len)"); | |
| 452 | } | |
| 444 | 453 | |
| 445 | 454 | template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End> |
| 446 | 455 | _LIBCPP_HIDE_FROM_ABI constexpr span(_It __first, _End __last) |
| ... | ... | @@ -517,13 +526,13 @@ public: |
| 517 | 526 | return __data_[__idx]; |
| 518 | 527 | } |
| 519 | 528 | |
| 520 | # if _LIBCPP_STD_VER >= 26 | |
| 529 | # if _LIBCPP_STD_VER >= 26 | |
| 521 | 530 | _LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __index) const { |
| 522 | 531 | if (__index >= size()) |
| 523 | 532 | std::__throw_out_of_range("span"); |
| 524 | 533 | return __data_[__index]; |
| 525 | 534 | } |
| 526 | # endif | |
| 535 | # endif | |
| 527 | 536 | |
| 528 | 537 | _LIBCPP_HIDE_FROM_ABI constexpr reference front() const noexcept { |
| 529 | 538 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span<T>::front() on empty span"); |
| ... | ... | @@ -539,18 +548,18 @@ public: |
| 539 | 548 | |
| 540 | 549 | // [span.iter], span iterator support |
| 541 | 550 | _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() const noexcept { |
| 542 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 551 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 543 | 552 | return std::__make_bounded_iter(data(), data(), data() + size()); |
| 544 | # else | |
| 553 | # else | |
| 545 | 554 | return iterator(data()); |
| 546 | # endif | |
| 555 | # endif | |
| 547 | 556 | } |
| 548 | 557 | _LIBCPP_HIDE_FROM_ABI constexpr iterator end() const noexcept { |
| 549 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 558 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 550 | 559 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); |
| 551 | # else | |
| 560 | # else | |
| 552 | 561 | return iterator(data() + size()); |
| 553 | # endif | |
| 562 | # endif | |
| 554 | 563 | } |
| 555 | 564 | _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } |
| 556 | 565 | _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } |
| ... | ... | @@ -586,7 +595,7 @@ _LIBCPP_HIDE_FROM_ABI auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept { |
| 586 | 595 | return __s.__as_writable_bytes(); |
| 587 | 596 | } |
| 588 | 597 | |
| 589 | # if _LIBCPP_STD_VER >= 26 | |
| 598 | # if _LIBCPP_STD_VER >= 26 | |
| 590 | 599 | template <class _Tp> |
| 591 | 600 | concept __integral_constant_like = |
| 592 | 601 | is_integral_v<decltype(_Tp::value)> && !is_same_v<bool, remove_const_t<decltype(_Tp::value)>> && |
| ... | ... | @@ -602,10 +611,10 @@ inline constexpr size_t __maybe_static_ext<_Tp> = {_Tp::value}; |
| 602 | 611 | |
| 603 | 612 | template <contiguous_iterator _It, class _EndOrSize> |
| 604 | 613 | span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>, __maybe_static_ext<_EndOrSize>>; |
| 605 | # else | |
| 614 | # else | |
| 606 | 615 | template <contiguous_iterator _It, class _EndOrSize> |
| 607 | 616 | span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>; |
| 608 | # endif | |
| 617 | # endif | |
| 609 | 618 | |
| 610 | 619 | template <class _Tp, size_t _Sz> |
| 611 | 620 | span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>; |
| ... | ... | @@ -619,18 +628,19 @@ span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>; |
| 619 | 628 | template <ranges::contiguous_range _Range> |
| 620 | 629 | span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>; |
| 621 | 630 | |
| 622 | #endif // _LIBCPP_STD_VER >= 20 | |
| 631 | # endif // _LIBCPP_STD_VER >= 20 | |
| 623 | 632 | |
| 624 | 633 | _LIBCPP_END_NAMESPACE_STD |
| 625 | 634 | |
| 626 | 635 | _LIBCPP_POP_MACROS |
| 627 | 636 | |
| 628 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 629 | # include <array> | |
| 630 | # include <concepts> | |
| 631 | # include <functional> | |
| 632 | # include <iterator> | |
| 633 | # include <type_traits> | |
| 634 | #endif | |
| 637 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 638 | # include <array> | |
| 639 | # include <concepts> | |
| 640 | # include <functional> | |
| 641 | # include <iterator> | |
| 642 | # include <type_traits> | |
| 643 | # endif | |
| 644 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 635 | 645 | |
| 636 | 646 | #endif // _LIBCPP_SPAN |
lib/libcxx/include/sstream+129-108| ... | ... | @@ -312,22 +312,30 @@ typedef basic_stringstream<wchar_t> wstringstream; |
| 312 | 312 | |
| 313 | 313 | // clang-format on |
| 314 | 314 | |
| 315 | #include <__config> | |
| 316 | #include <__fwd/sstream.h> | |
| 317 | #include <__ostream/basic_ostream.h> | |
| 318 | #include <__type_traits/is_convertible.h> | |
| 319 | #include <__utility/swap.h> | |
| 320 | #include <istream> | |
| 321 | #include <string> | |
| 322 | #include <string_view> | |
| 323 | #include <version> | |
| 324 | ||
| 325 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 326 | # pragma GCC system_header | |
| 327 | #endif | |
| 315 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 316 | # include <__cxx03/sstream> | |
| 317 | #else | |
| 318 | # include <__config> | |
| 319 | ||
| 320 | # if _LIBCPP_HAS_LOCALIZATION | |
| 321 | ||
| 322 | # include <__fwd/sstream.h> | |
| 323 | # include <__ostream/basic_ostream.h> | |
| 324 | # include <__type_traits/is_convertible.h> | |
| 325 | # include <__utility/swap.h> | |
| 326 | # include <ios> | |
| 327 | # include <istream> | |
| 328 | # include <locale> | |
| 329 | # include <string> | |
| 330 | # include <string_view> | |
| 331 | # include <version> | |
| 332 | ||
| 333 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 334 | # pragma GCC system_header | |
| 335 | # endif | |
| 328 | 336 | |
| 329 | 337 | _LIBCPP_PUSH_MACROS |
| 330 | #include <__undef_macros> | |
| 338 | # include <__undef_macros> | |
| 331 | 339 | |
| 332 | 340 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 333 | 341 | |
| ... | ... | @@ -354,9 +362,15 @@ private: |
| 354 | 362 | |
| 355 | 363 | public: |
| 356 | 364 | // [stringbuf.cons] constructors: |
| 357 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf() : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) {} | |
| 365 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf() : __hm_(nullptr), __mode_(ios_base::in | ios_base::out) { | |
| 366 | // it is implementation-defined whether we initialize eback() & friends to nullptr, and libc++ doesn't | |
| 367 | __init_buf_ptrs(); | |
| 368 | } | |
| 358 | 369 | |
| 359 | _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(ios_base::openmode __wch) : __hm_(nullptr), __mode_(__wch) {} | |
| 370 | _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(ios_base::openmode __wch) : __hm_(nullptr), __mode_(__wch) { | |
| 371 | // it is implementation-defined whether we initialize eback() & friends to nullptr, and libc++ doesn't | |
| 372 | __init_buf_ptrs(); | |
| 373 | } | |
| 360 | 374 | |
| 361 | 375 | _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const string_type& __s, |
| 362 | 376 | ios_base::openmode __wch = ios_base::in | ios_base::out) |
| ... | ... | @@ -364,12 +378,14 @@ public: |
| 364 | 378 | str(__s); |
| 365 | 379 | } |
| 366 | 380 | |
| 367 | #if _LIBCPP_STD_VER >= 20 | |
| 381 | # if _LIBCPP_STD_VER >= 20 | |
| 368 | 382 | _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const allocator_type& __a) |
| 369 | 383 | : basic_stringbuf(ios_base::in | ios_base::out, __a) {} |
| 370 | 384 | |
| 371 | 385 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf(ios_base::openmode __wch, const allocator_type& __a) |
| 372 | : __str_(__a), __hm_(nullptr), __mode_(__wch) {} | |
| 386 | : __str_(__a), __hm_(nullptr), __mode_(__wch) { | |
| 387 | __init_buf_ptrs(); | |
| 388 | } | |
| 373 | 389 | |
| 374 | 390 | _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(string_type&& __s, |
| 375 | 391 | ios_base::openmode __wch = ios_base::in | ios_base::out) |
| ... | ... | @@ -396,9 +412,9 @@ public: |
| 396 | 412 | : __str_(__s), __hm_(nullptr), __mode_(__wch) { |
| 397 | 413 | __init_buf_ptrs(); |
| 398 | 414 | } |
| 399 | #endif // _LIBCPP_STD_VER >= 20 | |
| 415 | # endif // _LIBCPP_STD_VER >= 20 | |
| 400 | 416 | |
| 401 | #if _LIBCPP_STD_VER >= 26 | |
| 417 | # if _LIBCPP_STD_VER >= 26 | |
| 402 | 418 | |
| 403 | 419 | template <class _Tp> |
| 404 | 420 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> |
| ... | ... | @@ -420,37 +436,37 @@ public: |
| 420 | 436 | __init_buf_ptrs(); |
| 421 | 437 | } |
| 422 | 438 | |
| 423 | #endif // _LIBCPP_STD_VER >= 26 | |
| 439 | # endif // _LIBCPP_STD_VER >= 26 | |
| 424 | 440 | |
| 425 | 441 | basic_stringbuf(const basic_stringbuf&) = delete; |
| 426 | 442 | basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); } |
| 427 | 443 | |
| 428 | #if _LIBCPP_STD_VER >= 20 | |
| 444 | # if _LIBCPP_STD_VER >= 20 | |
| 429 | 445 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a) |
| 430 | 446 | : basic_stringbuf(__rhs.__mode_, __a) { |
| 431 | 447 | __move_init(std::move(__rhs)); |
| 432 | 448 | } |
| 433 | #endif | |
| 449 | # endif | |
| 434 | 450 | |
| 435 | 451 | // [stringbuf.assign] Assign and swap: |
| 436 | 452 | basic_stringbuf& operator=(const basic_stringbuf&) = delete; |
| 437 | 453 | basic_stringbuf& operator=(basic_stringbuf&& __rhs); |
| 438 | 454 | void swap(basic_stringbuf& __rhs) |
| 439 | #if _LIBCPP_STD_VER >= 20 | |
| 455 | # if _LIBCPP_STD_VER >= 20 | |
| 440 | 456 | noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || |
| 441 | 457 | allocator_traits<allocator_type>::is_always_equal::value) |
| 442 | #endif | |
| 458 | # endif | |
| 443 | 459 | ; |
| 444 | 460 | |
| 445 | 461 | // [stringbuf.members] Member functions: |
| 446 | 462 | |
| 447 | #if _LIBCPP_STD_VER >= 20 | |
| 463 | # if _LIBCPP_STD_VER >= 20 | |
| 448 | 464 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); } |
| 449 | #endif | |
| 465 | # endif | |
| 450 | 466 | |
| 451 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 467 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 452 | 468 | string_type str() const; |
| 453 | #else | |
| 469 | # else | |
| 454 | 470 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); } |
| 455 | 471 | |
| 456 | 472 | _LIBCPP_HIDE_FROM_ABI string_type str() && { |
| ... | ... | @@ -464,9 +480,9 @@ public: |
| 464 | 480 | __init_buf_ptrs(); |
| 465 | 481 | return __result; |
| 466 | 482 | } |
| 467 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 483 | # endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 468 | 484 | |
| 469 | #if _LIBCPP_STD_VER >= 20 | |
| 485 | # if _LIBCPP_STD_VER >= 20 | |
| 470 | 486 | template <class _SAlloc> |
| 471 | 487 | requires __is_allocator<_SAlloc>::value |
| 472 | 488 | _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { |
| ... | ... | @@ -474,14 +490,14 @@ public: |
| 474 | 490 | } |
| 475 | 491 | |
| 476 | 492 | _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept; |
| 477 | #endif // _LIBCPP_STD_VER >= 20 | |
| 493 | # endif // _LIBCPP_STD_VER >= 20 | |
| 478 | 494 | |
| 479 | 495 | void str(const string_type& __s) { |
| 480 | 496 | __str_ = __s; |
| 481 | 497 | __init_buf_ptrs(); |
| 482 | 498 | } |
| 483 | 499 | |
| 484 | #if _LIBCPP_STD_VER >= 20 | |
| 500 | # if _LIBCPP_STD_VER >= 20 | |
| 485 | 501 | template <class _SAlloc> |
| 486 | 502 | requires(!is_same_v<_SAlloc, allocator_type>) |
| 487 | 503 | _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) { |
| ... | ... | @@ -493,9 +509,9 @@ public: |
| 493 | 509 | __str_ = std::move(__s); |
| 494 | 510 | __init_buf_ptrs(); |
| 495 | 511 | } |
| 496 | #endif // _LIBCPP_STD_VER >= 20 | |
| 512 | # endif // _LIBCPP_STD_VER >= 20 | |
| 497 | 513 | |
| 498 | #if _LIBCPP_STD_VER >= 26 | |
| 514 | # if _LIBCPP_STD_VER >= 26 | |
| 499 | 515 | |
| 500 | 516 | template <class _Tp> |
| 501 | 517 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> |
| ... | ... | @@ -505,7 +521,7 @@ public: |
| 505 | 521 | __init_buf_ptrs(); |
| 506 | 522 | } |
| 507 | 523 | |
| 508 | #endif // _LIBCPP_STD_VER >= 26 | |
| 524 | # endif // _LIBCPP_STD_VER >= 26 | |
| 509 | 525 | |
| 510 | 526 | protected: |
| 511 | 527 | // [stringbuf.virtuals] Overridden virtual functions: |
| ... | ... | @@ -601,10 +617,10 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs) |
| 601 | 617 | |
| 602 | 618 | template <class _CharT, class _Traits, class _Allocator> |
| 603 | 619 | void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs) |
| 604 | #if _LIBCPP_STD_VER >= 20 | |
| 620 | # if _LIBCPP_STD_VER >= 20 | |
| 605 | 621 | noexcept(allocator_traits<_Allocator>::propagate_on_container_swap::value || |
| 606 | 622 | allocator_traits<_Allocator>::is_always_equal::value) |
| 607 | #endif | |
| 623 | # endif | |
| 608 | 624 | { |
| 609 | 625 | char_type* __p = const_cast<char_type*>(__rhs.__str_.data()); |
| 610 | 626 | ptrdiff_t __rbinp = -1; |
| ... | ... | @@ -674,14 +690,14 @@ void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs) |
| 674 | 690 | template <class _CharT, class _Traits, class _Allocator> |
| 675 | 691 | inline _LIBCPP_HIDE_FROM_ABI void |
| 676 | 692 | swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y) |
| 677 | #if _LIBCPP_STD_VER >= 20 | |
| 693 | # if _LIBCPP_STD_VER >= 20 | |
| 678 | 694 | noexcept(noexcept(__x.swap(__y))) |
| 679 | #endif | |
| 695 | # endif | |
| 680 | 696 | { |
| 681 | 697 | __x.swap(__y); |
| 682 | 698 | } |
| 683 | 699 | |
| 684 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 700 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 685 | 701 | template <class _CharT, class _Traits, class _Allocator> |
| 686 | 702 | basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allocator>::str() const { |
| 687 | 703 | if (__mode_ & ios_base::out) { |
| ... | ... | @@ -692,7 +708,7 @@ basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allo |
| 692 | 708 | return string_type(this->eback(), this->egptr(), __str_.get_allocator()); |
| 693 | 709 | return string_type(__str_.get_allocator()); |
| 694 | 710 | } |
| 695 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 711 | # endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 696 | 712 | |
| 697 | 713 | template <class _CharT, class _Traits, class _Allocator> |
| 698 | 714 | _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_buf_ptrs() { |
| ... | ... | @@ -718,7 +734,7 @@ _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_ |
| 718 | 734 | } |
| 719 | 735 | } |
| 720 | 736 | |
| 721 | #if _LIBCPP_STD_VER >= 20 | |
| 737 | # if _LIBCPP_STD_VER >= 20 | |
| 722 | 738 | template <class _CharT, class _Traits, class _Allocator> |
| 723 | 739 | _LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT, _Traits> |
| 724 | 740 | basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept { |
| ... | ... | @@ -730,7 +746,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept { |
| 730 | 746 | return basic_string_view<_CharT, _Traits>(this->eback(), this->egptr()); |
| 731 | 747 | return basic_string_view<_CharT, _Traits>(); |
| 732 | 748 | } |
| 733 | #endif // _LIBCPP_STD_VER >= 20 | |
| 749 | # endif // _LIBCPP_STD_VER >= 20 | |
| 734 | 750 | |
| 735 | 751 | template <class _CharT, class _Traits, class _Allocator> |
| 736 | 752 | typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type |
| ... | ... | @@ -773,9 +789,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) { |
| 773 | 789 | if (this->pptr() == this->epptr()) { |
| 774 | 790 | if (!(__mode_ & ios_base::out)) |
| 775 | 791 | return traits_type::eof(); |
| 776 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 792 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 777 | 793 | try { |
| 778 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 794 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 779 | 795 | ptrdiff_t __nout = this->pptr() - this->pbase(); |
| 780 | 796 | ptrdiff_t __hm = __hm_ - this->pbase(); |
| 781 | 797 | __str_.push_back(char_type()); |
| ... | ... | @@ -784,11 +800,11 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) { |
| 784 | 800 | this->setp(__p, __p + __str_.size()); |
| 785 | 801 | this->__pbump(__nout); |
| 786 | 802 | __hm_ = this->pbase() + __hm; |
| 787 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 803 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 788 | 804 | } catch (...) { |
| 789 | 805 | return traits_type::eof(); |
| 790 | 806 | } |
| 791 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 807 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 792 | 808 | } |
| 793 | 809 | __hm_ = std::max(this->pptr() + 1, __hm_); |
| 794 | 810 | if (__mode_ & ios_base::in) { |
| ... | ... | @@ -864,15 +880,16 @@ private: |
| 864 | 880 | |
| 865 | 881 | public: |
| 866 | 882 | // [istringstream.cons] Constructors: |
| 867 | _LIBCPP_HIDE_FROM_ABI basic_istringstream() : basic_istream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in) {} | |
| 883 | _LIBCPP_HIDE_FROM_ABI basic_istringstream() | |
| 884 | : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(ios_base::in) {} | |
| 868 | 885 | |
| 869 | 886 | _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(ios_base::openmode __wch) |
| 870 | : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {} | |
| 887 | : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::in) {} | |
| 871 | 888 | |
| 872 | 889 | _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in) |
| 873 | : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch | ios_base::in) {} | |
| 890 | : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {} | |
| 874 | 891 | |
| 875 | #if _LIBCPP_STD_VER >= 20 | |
| 892 | # if _LIBCPP_STD_VER >= 20 | |
| 876 | 893 | _LIBCPP_HIDE_FROM_ABI basic_istringstream(ios_base::openmode __wch, const _Allocator& __a) |
| 877 | 894 | : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::in, __a) {} |
| 878 | 895 | |
| ... | ... | @@ -892,9 +909,9 @@ public: |
| 892 | 909 | _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, |
| 893 | 910 | ios_base::openmode __wch = ios_base::in) |
| 894 | 911 | : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {} |
| 895 | #endif // _LIBCPP_STD_VER >= 20 | |
| 912 | # endif // _LIBCPP_STD_VER >= 20 | |
| 896 | 913 | |
| 897 | #if _LIBCPP_STD_VER >= 26 | |
| 914 | # if _LIBCPP_STD_VER >= 26 | |
| 898 | 915 | |
| 899 | 916 | template <class _Tp> |
| 900 | 917 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> |
| ... | ... | @@ -911,12 +928,12 @@ public: |
| 911 | 928 | _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) |
| 912 | 929 | : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {} |
| 913 | 930 | |
| 914 | #endif // _LIBCPP_STD_VER >= 26 | |
| 931 | # endif // _LIBCPP_STD_VER >= 26 | |
| 915 | 932 | |
| 916 | 933 | basic_istringstream(const basic_istringstream&) = delete; |
| 917 | 934 | _LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs) |
| 918 | 935 | : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { |
| 919 | basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); | |
| 936 | basic_istream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); | |
| 920 | 937 | } |
| 921 | 938 | |
| 922 | 939 | // [istringstream.assign] Assign and swap: |
| ... | ... | @@ -933,18 +950,18 @@ public: |
| 933 | 950 | |
| 934 | 951 | // [istringstream.members] Member functions: |
| 935 | 952 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { |
| 936 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_); | |
| 953 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); | |
| 937 | 954 | } |
| 938 | 955 | |
| 939 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 956 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 940 | 957 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } |
| 941 | #else | |
| 958 | # else | |
| 942 | 959 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } |
| 943 | 960 | |
| 944 | 961 | _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } |
| 945 | #endif | |
| 962 | # endif | |
| 946 | 963 | |
| 947 | #if _LIBCPP_STD_VER >= 20 | |
| 964 | # if _LIBCPP_STD_VER >= 20 | |
| 948 | 965 | template <class _SAlloc> |
| 949 | 966 | requires __is_allocator<_SAlloc>::value |
| 950 | 967 | _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { |
| ... | ... | @@ -952,26 +969,26 @@ public: |
| 952 | 969 | } |
| 953 | 970 | |
| 954 | 971 | _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); } |
| 955 | #endif // _LIBCPP_STD_VER >= 20 | |
| 972 | # endif // _LIBCPP_STD_VER >= 20 | |
| 956 | 973 | |
| 957 | 974 | _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } |
| 958 | 975 | |
| 959 | #if _LIBCPP_STD_VER >= 20 | |
| 976 | # if _LIBCPP_STD_VER >= 20 | |
| 960 | 977 | template <class _SAlloc> |
| 961 | 978 | _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) { |
| 962 | 979 | __sb_.str(__s); |
| 963 | 980 | } |
| 964 | 981 | |
| 965 | 982 | _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } |
| 966 | #endif // _LIBCPP_STD_VER >= 20 | |
| 983 | # endif // _LIBCPP_STD_VER >= 20 | |
| 967 | 984 | |
| 968 | #if _LIBCPP_STD_VER >= 26 | |
| 985 | # if _LIBCPP_STD_VER >= 26 | |
| 969 | 986 | template <class _Tp> |
| 970 | 987 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> |
| 971 | 988 | _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { |
| 972 | 989 | rdbuf()->str(__t); |
| 973 | 990 | } |
| 974 | #endif // _LIBCPP_STD_VER >= 26 | |
| 991 | # endif // _LIBCPP_STD_VER >= 26 | |
| 975 | 992 | }; |
| 976 | 993 | |
| 977 | 994 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -999,15 +1016,16 @@ private: |
| 999 | 1016 | |
| 1000 | 1017 | public: |
| 1001 | 1018 | // [ostringstream.cons] Constructors: |
| 1002 | _LIBCPP_HIDE_FROM_ABI basic_ostringstream() : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::out) {} | |
| 1019 | _LIBCPP_HIDE_FROM_ABI basic_ostringstream() | |
| 1020 | : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(ios_base::out) {} | |
| 1003 | 1021 | |
| 1004 | 1022 | _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(ios_base::openmode __wch) |
| 1005 | : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::out) {} | |
| 1023 | : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::out) {} | |
| 1006 | 1024 | |
| 1007 | 1025 | _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const string_type& __s, ios_base::openmode __wch = ios_base::out) |
| 1008 | : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch | ios_base::out) {} | |
| 1026 | : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {} | |
| 1009 | 1027 | |
| 1010 | #if _LIBCPP_STD_VER >= 20 | |
| 1028 | # if _LIBCPP_STD_VER >= 20 | |
| 1011 | 1029 | _LIBCPP_HIDE_FROM_ABI basic_ostringstream(ios_base::openmode __wch, const _Allocator& __a) |
| 1012 | 1030 | : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::out, __a) {} |
| 1013 | 1031 | |
| ... | ... | @@ -1028,9 +1046,9 @@ public: |
| 1028 | 1046 | _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, |
| 1029 | 1047 | ios_base::openmode __wch = ios_base::out) |
| 1030 | 1048 | : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {} |
| 1031 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1049 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1032 | 1050 | |
| 1033 | #if _LIBCPP_STD_VER >= 26 | |
| 1051 | # if _LIBCPP_STD_VER >= 26 | |
| 1034 | 1052 | |
| 1035 | 1053 | template <class _Tp> |
| 1036 | 1054 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> |
| ... | ... | @@ -1047,12 +1065,12 @@ public: |
| 1047 | 1065 | _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) |
| 1048 | 1066 | : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {} |
| 1049 | 1067 | |
| 1050 | #endif // _LIBCPP_STD_VER >= 26 | |
| 1068 | # endif // _LIBCPP_STD_VER >= 26 | |
| 1051 | 1069 | |
| 1052 | 1070 | basic_ostringstream(const basic_ostringstream&) = delete; |
| 1053 | 1071 | _LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs) |
| 1054 | 1072 | : basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { |
| 1055 | basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_); | |
| 1073 | basic_ostream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); | |
| 1056 | 1074 | } |
| 1057 | 1075 | |
| 1058 | 1076 | // [ostringstream.assign] Assign and swap: |
| ... | ... | @@ -1070,18 +1088,18 @@ public: |
| 1070 | 1088 | |
| 1071 | 1089 | // [ostringstream.members] Member functions: |
| 1072 | 1090 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { |
| 1073 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_); | |
| 1091 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); | |
| 1074 | 1092 | } |
| 1075 | 1093 | |
| 1076 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 1094 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 1077 | 1095 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } |
| 1078 | #else | |
| 1096 | # else | |
| 1079 | 1097 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } |
| 1080 | 1098 | |
| 1081 | 1099 | _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } |
| 1082 | #endif | |
| 1100 | # endif | |
| 1083 | 1101 | |
| 1084 | #if _LIBCPP_STD_VER >= 20 | |
| 1102 | # if _LIBCPP_STD_VER >= 20 | |
| 1085 | 1103 | template <class _SAlloc> |
| 1086 | 1104 | requires __is_allocator<_SAlloc>::value |
| 1087 | 1105 | _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { |
| ... | ... | @@ -1089,26 +1107,26 @@ public: |
| 1089 | 1107 | } |
| 1090 | 1108 | |
| 1091 | 1109 | _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); } |
| 1092 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1110 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1093 | 1111 | |
| 1094 | 1112 | _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } |
| 1095 | 1113 | |
| 1096 | #if _LIBCPP_STD_VER >= 20 | |
| 1114 | # if _LIBCPP_STD_VER >= 20 | |
| 1097 | 1115 | template <class _SAlloc> |
| 1098 | 1116 | _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) { |
| 1099 | 1117 | __sb_.str(__s); |
| 1100 | 1118 | } |
| 1101 | 1119 | |
| 1102 | 1120 | _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } |
| 1103 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1121 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1104 | 1122 | |
| 1105 | #if _LIBCPP_STD_VER >= 26 | |
| 1123 | # if _LIBCPP_STD_VER >= 26 | |
| 1106 | 1124 | template <class _Tp> |
| 1107 | 1125 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> |
| 1108 | 1126 | _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { |
| 1109 | 1127 | rdbuf()->str(__t); |
| 1110 | 1128 | } |
| 1111 | #endif // _LIBCPP_STD_VER >= 26 | |
| 1129 | # endif // _LIBCPP_STD_VER >= 26 | |
| 1112 | 1130 | }; |
| 1113 | 1131 | |
| 1114 | 1132 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -1137,16 +1155,16 @@ private: |
| 1137 | 1155 | public: |
| 1138 | 1156 | // [stringstream.cons] constructors |
| 1139 | 1157 | _LIBCPP_HIDE_FROM_ABI basic_stringstream() |
| 1140 | : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(ios_base::in | ios_base::out) {} | |
| 1158 | : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(ios_base::in | ios_base::out) {} | |
| 1141 | 1159 | |
| 1142 | 1160 | _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(ios_base::openmode __wch) |
| 1143 | : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {} | |
| 1161 | : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch) {} | |
| 1144 | 1162 | |
| 1145 | 1163 | _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const string_type& __s, |
| 1146 | 1164 | ios_base::openmode __wch = ios_base::in | ios_base::out) |
| 1147 | : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__s, __wch) {} | |
| 1165 | : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {} | |
| 1148 | 1166 | |
| 1149 | #if _LIBCPP_STD_VER >= 20 | |
| 1167 | # if _LIBCPP_STD_VER >= 20 | |
| 1150 | 1168 | _LIBCPP_HIDE_FROM_ABI basic_stringstream(ios_base::openmode __wch, const _Allocator& __a) |
| 1151 | 1169 | : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch, __a) {} |
| 1152 | 1170 | |
| ... | ... | @@ -1168,9 +1186,9 @@ public: |
| 1168 | 1186 | _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s, |
| 1169 | 1187 | ios_base::openmode __wch = ios_base::out | ios_base::in) |
| 1170 | 1188 | : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {} |
| 1171 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1189 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1172 | 1190 | |
| 1173 | #if _LIBCPP_STD_VER >= 26 | |
| 1191 | # if _LIBCPP_STD_VER >= 26 | |
| 1174 | 1192 | |
| 1175 | 1193 | template <class _Tp> |
| 1176 | 1194 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> |
| ... | ... | @@ -1188,12 +1206,12 @@ public: |
| 1188 | 1206 | _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a) |
| 1189 | 1207 | : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which, __a) {} |
| 1190 | 1208 | |
| 1191 | #endif // _LIBCPP_STD_VER >= 26 | |
| 1209 | # endif // _LIBCPP_STD_VER >= 26 | |
| 1192 | 1210 | |
| 1193 | 1211 | basic_stringstream(const basic_stringstream&) = delete; |
| 1194 | 1212 | _LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs) |
| 1195 | 1213 | : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) { |
| 1196 | basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); | |
| 1214 | basic_istream<_CharT, _Traits>::set_rdbuf(std::addressof(__sb_)); | |
| 1197 | 1215 | } |
| 1198 | 1216 | |
| 1199 | 1217 | // [stringstream.assign] Assign and swap: |
| ... | ... | @@ -1210,18 +1228,18 @@ public: |
| 1210 | 1228 | |
| 1211 | 1229 | // [stringstream.members] Member functions: |
| 1212 | 1230 | _LIBCPP_HIDE_FROM_ABI basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const { |
| 1213 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_); | |
| 1231 | return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_)); | |
| 1214 | 1232 | } |
| 1215 | 1233 | |
| 1216 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 1234 | # if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 1217 | 1235 | _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); } |
| 1218 | #else | |
| 1236 | # else | |
| 1219 | 1237 | _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); } |
| 1220 | 1238 | |
| 1221 | 1239 | _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); } |
| 1222 | #endif | |
| 1240 | # endif | |
| 1223 | 1241 | |
| 1224 | #if _LIBCPP_STD_VER >= 20 | |
| 1242 | # if _LIBCPP_STD_VER >= 20 | |
| 1225 | 1243 | template <class _SAlloc> |
| 1226 | 1244 | requires __is_allocator<_SAlloc>::value |
| 1227 | 1245 | _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { |
| ... | ... | @@ -1229,26 +1247,26 @@ public: |
| 1229 | 1247 | } |
| 1230 | 1248 | |
| 1231 | 1249 | _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); } |
| 1232 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1250 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1233 | 1251 | |
| 1234 | 1252 | _LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); } |
| 1235 | 1253 | |
| 1236 | #if _LIBCPP_STD_VER >= 20 | |
| 1254 | # if _LIBCPP_STD_VER >= 20 | |
| 1237 | 1255 | template <class _SAlloc> |
| 1238 | 1256 | _LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) { |
| 1239 | 1257 | __sb_.str(__s); |
| 1240 | 1258 | } |
| 1241 | 1259 | |
| 1242 | 1260 | _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); } |
| 1243 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1261 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1244 | 1262 | |
| 1245 | #if _LIBCPP_STD_VER >= 26 | |
| 1263 | # if _LIBCPP_STD_VER >= 26 | |
| 1246 | 1264 | template <class _Tp> |
| 1247 | 1265 | requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>> |
| 1248 | 1266 | _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) { |
| 1249 | 1267 | rdbuf()->str(__t); |
| 1250 | 1268 | } |
| 1251 | #endif // _LIBCPP_STD_VER >= 26 | |
| 1269 | # endif // _LIBCPP_STD_VER >= 26 | |
| 1252 | 1270 | }; |
| 1253 | 1271 | |
| 1254 | 1272 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -1257,20 +1275,23 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_C |
| 1257 | 1275 | __x.swap(__y); |
| 1258 | 1276 | } |
| 1259 | 1277 | |
| 1260 | #if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 | |
| 1278 | # if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 | |
| 1261 | 1279 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>; |
| 1262 | 1280 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>; |
| 1263 | 1281 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>; |
| 1264 | 1282 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>; |
| 1265 | #endif | |
| 1283 | # endif | |
| 1266 | 1284 | |
| 1267 | 1285 | _LIBCPP_END_NAMESPACE_STD |
| 1268 | 1286 | |
| 1269 | 1287 | _LIBCPP_POP_MACROS |
| 1270 | 1288 | |
| 1271 | #if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) | |
| 1272 | # include <ostream> | |
| 1273 | # include <type_traits> | |
| 1274 | #endif | |
| 1289 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 1290 | ||
| 1291 | # if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) | |
| 1292 | # include <ostream> | |
| 1293 | # include <type_traits> | |
| 1294 | # endif | |
| 1295 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1275 | 1296 | |
| 1276 | 1297 | #endif // _LIBCPP_SSTREAM |
lib/libcxx/include/stack+50-46| ... | ... | @@ -113,33 +113,36 @@ template <class T, class Container> |
| 113 | 113 | |
| 114 | 114 | */ |
| 115 | 115 | |
| 116 | #include <__algorithm/ranges_copy.h> | |
| 117 | #include <__config> | |
| 118 | #include <__fwd/stack.h> | |
| 119 | #include <__iterator/back_insert_iterator.h> | |
| 120 | #include <__iterator/iterator_traits.h> | |
| 121 | #include <__memory/uses_allocator.h> | |
| 122 | #include <__ranges/access.h> | |
| 123 | #include <__ranges/concepts.h> | |
| 124 | #include <__ranges/container_compatible_range.h> | |
| 125 | #include <__ranges/from_range.h> | |
| 126 | #include <__type_traits/is_same.h> | |
| 127 | #include <__utility/forward.h> | |
| 128 | #include <deque> | |
| 129 | #include <version> | |
| 116 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 117 | # include <__cxx03/stack> | |
| 118 | #else | |
| 119 | # include <__algorithm/ranges_copy.h> | |
| 120 | # include <__config> | |
| 121 | # include <__fwd/stack.h> | |
| 122 | # include <__iterator/back_insert_iterator.h> | |
| 123 | # include <__iterator/iterator_traits.h> | |
| 124 | # include <__memory/uses_allocator.h> | |
| 125 | # include <__ranges/access.h> | |
| 126 | # include <__ranges/concepts.h> | |
| 127 | # include <__ranges/container_compatible_range.h> | |
| 128 | # include <__ranges/from_range.h> | |
| 129 | # include <__type_traits/is_same.h> | |
| 130 | # include <__utility/forward.h> | |
| 131 | # include <deque> | |
| 132 | # include <version> | |
| 130 | 133 | |
| 131 | 134 | // standard-mandated includes |
| 132 | 135 | |
| 133 | 136 | // [stack.syn] |
| 134 | #include <compare> | |
| 135 | #include <initializer_list> | |
| 137 | # include <compare> | |
| 138 | # include <initializer_list> | |
| 136 | 139 | |
| 137 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 138 | # pragma GCC system_header | |
| 139 | #endif | |
| 140 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 141 | # pragma GCC system_header | |
| 142 | # endif | |
| 140 | 143 | |
| 141 | 144 | _LIBCPP_PUSH_MACROS |
| 142 | #include <__undef_macros> | |
| 145 | # include <__undef_macros> | |
| 143 | 146 | |
| 144 | 147 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 145 | 148 | |
| ... | ... | @@ -172,7 +175,7 @@ public: |
| 172 | 175 | return *this; |
| 173 | 176 | } |
| 174 | 177 | |
| 175 | #ifndef _LIBCPP_CXX03_LANG | |
| 178 | # ifndef _LIBCPP_CXX03_LANG | |
| 176 | 179 | _LIBCPP_HIDE_FROM_ABI stack(stack&& __q) noexcept(is_nothrow_move_constructible<container_type>::value) |
| 177 | 180 | : c(std::move(__q.c)) {} |
| 178 | 181 | |
| ... | ... | @@ -182,7 +185,7 @@ public: |
| 182 | 185 | } |
| 183 | 186 | |
| 184 | 187 | _LIBCPP_HIDE_FROM_ABI explicit stack(container_type&& __c) : c(std::move(__c)) {} |
| 185 | #endif // _LIBCPP_CXX03_LANG | |
| 188 | # endif // _LIBCPP_CXX03_LANG | |
| 186 | 189 | |
| 187 | 190 | _LIBCPP_HIDE_FROM_ABI explicit stack(const container_type& __c) : c(__c) {} |
| 188 | 191 | |
| ... | ... | @@ -198,7 +201,7 @@ public: |
| 198 | 201 | _LIBCPP_HIDE_FROM_ABI |
| 199 | 202 | stack(const stack& __s, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) |
| 200 | 203 | : c(__s.c, __a) {} |
| 201 | #ifndef _LIBCPP_CXX03_LANG | |
| 204 | # ifndef _LIBCPP_CXX03_LANG | |
| 202 | 205 | template <class _Alloc> |
| 203 | 206 | _LIBCPP_HIDE_FROM_ABI |
| 204 | 207 | stack(container_type&& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) |
| ... | ... | @@ -207,9 +210,9 @@ public: |
| 207 | 210 | _LIBCPP_HIDE_FROM_ABI |
| 208 | 211 | stack(stack&& __s, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) |
| 209 | 212 | : c(std::move(__s.c), __a) {} |
| 210 | #endif // _LIBCPP_CXX03_LANG | |
| 213 | # endif // _LIBCPP_CXX03_LANG | |
| 211 | 214 | |
| 212 | #if _LIBCPP_STD_VER >= 23 | |
| 215 | # if _LIBCPP_STD_VER >= 23 | |
| 213 | 216 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 214 | 217 | _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} |
| 215 | 218 | |
| ... | ... | @@ -229,18 +232,18 @@ public: |
| 229 | 232 | _LIBCPP_HIDE_FROM_ABI stack(from_range_t, _Range&& __range, const _Alloc& __alloc) |
| 230 | 233 | : c(from_range, std::forward<_Range>(__range), __alloc) {} |
| 231 | 234 | |
| 232 | #endif | |
| 235 | # endif | |
| 233 | 236 | |
| 234 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | |
| 237 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } | |
| 235 | 238 | _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 236 | 239 | _LIBCPP_HIDE_FROM_ABI reference top() { return c.back(); } |
| 237 | 240 | _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); } |
| 238 | 241 | |
| 239 | 242 | _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } |
| 240 | #ifndef _LIBCPP_CXX03_LANG | |
| 243 | # ifndef _LIBCPP_CXX03_LANG | |
| 241 | 244 | _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v) { c.push_back(std::move(__v)); } |
| 242 | 245 | |
| 243 | # if _LIBCPP_STD_VER >= 23 | |
| 246 | # if _LIBCPP_STD_VER >= 23 | |
| 244 | 247 | template <_ContainerCompatibleRange<_Tp> _Range> |
| 245 | 248 | _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) { |
| 246 | 249 | if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) { |
| ... | ... | @@ -249,22 +252,22 @@ public: |
| 249 | 252 | ranges::copy(std::forward<_Range>(__range), std::back_inserter(c)); |
| 250 | 253 | } |
| 251 | 254 | } |
| 252 | # endif | |
| 255 | # endif | |
| 253 | 256 | |
| 254 | 257 | template <class... _Args> |
| 255 | 258 | _LIBCPP_HIDE_FROM_ABI |
| 256 | # if _LIBCPP_STD_VER >= 17 | |
| 259 | # if _LIBCPP_STD_VER >= 17 | |
| 257 | 260 | decltype(auto) |
| 258 | 261 | emplace(_Args&&... __args) { |
| 259 | 262 | return c.emplace_back(std::forward<_Args>(__args)...); |
| 260 | 263 | } |
| 261 | # else | |
| 264 | # else | |
| 262 | 265 | void |
| 263 | 266 | emplace(_Args&&... __args) { |
| 264 | 267 | c.emplace_back(std::forward<_Args>(__args)...); |
| 265 | 268 | } |
| 266 | # endif | |
| 267 | #endif // _LIBCPP_CXX03_LANG | |
| 269 | # endif | |
| 270 | # endif // _LIBCPP_CXX03_LANG | |
| 268 | 271 | |
| 269 | 272 | _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_back(); } |
| 270 | 273 | |
| ... | ... | @@ -273,7 +276,7 @@ public: |
| 273 | 276 | swap(c, __s.c); |
| 274 | 277 | } |
| 275 | 278 | |
| 276 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } | |
| 279 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } | |
| 277 | 280 | |
| 278 | 281 | template <class _T1, class _OtherContainer> |
| 279 | 282 | friend bool operator==(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); |
| ... | ... | @@ -282,7 +285,7 @@ public: |
| 282 | 285 | friend bool operator<(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y); |
| 283 | 286 | }; |
| 284 | 287 | |
| 285 | #if _LIBCPP_STD_VER >= 17 | |
| 288 | # if _LIBCPP_STD_VER >= 17 | |
| 286 | 289 | template <class _Container, class = enable_if_t<!__is_allocator<_Container>::value> > |
| 287 | 290 | stack(_Container) -> stack<typename _Container::value_type, _Container>; |
| 288 | 291 | |
| ... | ... | @@ -291,9 +294,9 @@ template <class _Container, |
| 291 | 294 | class = enable_if_t<!__is_allocator<_Container>::value>, |
| 292 | 295 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> > |
| 293 | 296 | stack(_Container, _Alloc) -> stack<typename _Container::value_type, _Container>; |
| 294 | #endif | |
| 297 | # endif | |
| 295 | 298 | |
| 296 | #if _LIBCPP_STD_VER >= 23 | |
| 299 | # if _LIBCPP_STD_VER >= 23 | |
| 297 | 300 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 298 | 301 | stack(_InputIterator, _InputIterator) -> stack<__iter_value_type<_InputIterator>>; |
| 299 | 302 | |
| ... | ... | @@ -313,7 +316,7 @@ stack(from_range_t, |
| 313 | 316 | _Range&&, |
| 314 | 317 | _Alloc) -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>; |
| 315 | 318 | |
| 316 | #endif | |
| 319 | # endif | |
| 317 | 320 | |
| 318 | 321 | template <class _Tp, class _Container> |
| 319 | 322 | inline _LIBCPP_HIDE_FROM_ABI bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) { |
| ... | ... | @@ -345,7 +348,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const stack<_Tp, _Container>& __x, |
| 345 | 348 | return !(__y < __x); |
| 346 | 349 | } |
| 347 | 350 | |
| 348 | #if _LIBCPP_STD_VER >= 20 | |
| 351 | # if _LIBCPP_STD_VER >= 20 | |
| 349 | 352 | |
| 350 | 353 | template <class _Tp, three_way_comparable _Container> |
| 351 | 354 | _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container> |
| ... | ... | @@ -354,7 +357,7 @@ operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y |
| 354 | 357 | return __x.__get_container() <=> __y.__get_container(); |
| 355 | 358 | } |
| 356 | 359 | |
| 357 | #endif | |
| 360 | # endif | |
| 358 | 361 | |
| 359 | 362 | template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0> |
| 360 | 363 | inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) |
| ... | ... | @@ -370,10 +373,11 @@ _LIBCPP_END_NAMESPACE_STD |
| 370 | 373 | |
| 371 | 374 | _LIBCPP_POP_MACROS |
| 372 | 375 | |
| 373 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 374 | # include <concepts> | |
| 375 | # include <functional> | |
| 376 | # include <type_traits> | |
| 377 | #endif | |
| 376 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 377 | # include <concepts> | |
| 378 | # include <functional> | |
| 379 | # include <type_traits> | |
| 380 | # endif | |
| 381 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 378 | 382 | |
| 379 | 383 | #endif // _LIBCPP_STACK |
lib/libcxx/include/stdatomic.h+28-16| ... | ... | @@ -103,6 +103,8 @@ using std::atomic_fetch_sub // see below |
| 103 | 103 | using std::atomic_fetch_sub_explicit // see below |
| 104 | 104 | using std::atomic_fetch_or // see below |
| 105 | 105 | using std::atomic_fetch_or_explicit // see below |
| 106 | using std::atomic_fetch_xor // see below | |
| 107 | using std::atomic_fetch_xor_explicit // see below | |
| 106 | 108 | using std::atomic_fetch_and // see below |
| 107 | 109 | using std::atomic_fetch_and_explicit // see below |
| 108 | 110 | using std::atomic_flag_test_and_set // see below |
| ... | ... | @@ -115,22 +117,25 @@ using std::atomic_signal_fence // see below |
| 115 | 117 | |
| 116 | 118 | */ |
| 117 | 119 | |
| 118 | #include <__config> | |
| 120 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 121 | # include <__cxx03/stdatomic.h> | |
| 122 | #else | |
| 123 | # include <__config> | |
| 119 | 124 | |
| 120 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 121 | # pragma GCC system_header | |
| 122 | #endif | |
| 125 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 126 | # pragma GCC system_header | |
| 127 | # endif | |
| 123 | 128 | |
| 124 | #if defined(__cplusplus) && _LIBCPP_STD_VER >= 23 | |
| 129 | # if defined(__cplusplus) && _LIBCPP_STD_VER >= 23 | |
| 125 | 130 | |
| 126 | # include <atomic> | |
| 127 | # include <version> | |
| 131 | # include <atomic> | |
| 132 | # include <version> | |
| 128 | 133 | |
| 129 | # ifdef _Atomic | |
| 130 | # undef _Atomic | |
| 131 | # endif | |
| 134 | # ifdef _Atomic | |
| 135 | # undef _Atomic | |
| 136 | # endif | |
| 132 | 137 | |
| 133 | # define _Atomic(_Tp) ::std::atomic<_Tp> | |
| 138 | # define _Atomic(_Tp) ::std::atomic<_Tp> | |
| 134 | 139 | |
| 135 | 140 | using std::memory_order _LIBCPP_USING_IF_EXISTS; |
| 136 | 141 | using std::memory_order_relaxed _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -154,10 +159,14 @@ using std::atomic_long _LIBCPP_USING_IF_EXISTS; |
| 154 | 159 | using std::atomic_ulong _LIBCPP_USING_IF_EXISTS; |
| 155 | 160 | using std::atomic_llong _LIBCPP_USING_IF_EXISTS; |
| 156 | 161 | using std::atomic_ullong _LIBCPP_USING_IF_EXISTS; |
| 162 | # if _LIBCPP_HAS_CHAR8_T | |
| 157 | 163 | using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS; |
| 164 | # endif | |
| 158 | 165 | using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS; |
| 159 | 166 | using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS; |
| 167 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 160 | 168 | using std::atomic_wchar_t _LIBCPP_USING_IF_EXISTS; |
| 169 | # endif | |
| 161 | 170 | |
| 162 | 171 | using std::atomic_int8_t _LIBCPP_USING_IF_EXISTS; |
| 163 | 172 | using std::atomic_uint8_t _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -204,6 +213,8 @@ using std::atomic_fetch_add_explicit _LIBCPP_USING_IF_EXISTS; |
| 204 | 213 | using std::atomic_fetch_and _LIBCPP_USING_IF_EXISTS; |
| 205 | 214 | using std::atomic_fetch_and_explicit _LIBCPP_USING_IF_EXISTS; |
| 206 | 215 | using std::atomic_fetch_or _LIBCPP_USING_IF_EXISTS; |
| 216 | using std::atomic_fetch_xor_explicit _LIBCPP_USING_IF_EXISTS; | |
| 217 | using std::atomic_fetch_xor _LIBCPP_USING_IF_EXISTS; | |
| 207 | 218 | using std::atomic_fetch_or_explicit _LIBCPP_USING_IF_EXISTS; |
| 208 | 219 | using std::atomic_fetch_sub _LIBCPP_USING_IF_EXISTS; |
| 209 | 220 | using std::atomic_fetch_sub_explicit _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -220,16 +231,17 @@ using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS; |
| 220 | 231 | using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS; |
| 221 | 232 | using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS; |
| 222 | 233 | |
| 223 | #elif defined(_LIBCPP_COMPILER_CLANG_BASED) | |
| 234 | # elif defined(_LIBCPP_COMPILER_CLANG_BASED) | |
| 224 | 235 | |
| 225 | 236 | // Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking |
| 226 | 237 | // the header. We do this because Clang has historically shipped a <stdatomic.h> |
| 227 | 238 | // header that would be available in all Standard modes, and we don't want to |
| 228 | 239 | // break that use case. |
| 229 | # if __has_include_next(<stdatomic.h>) | |
| 230 | # include_next <stdatomic.h> | |
| 231 | # endif | |
| 240 | # if __has_include_next(<stdatomic.h>) | |
| 241 | # include_next <stdatomic.h> | |
| 242 | # endif | |
| 232 | 243 | |
| 233 | #endif // defined(__cplusplus) && _LIBCPP_STD_VER >= 23 | |
| 244 | # endif // defined(__cplusplus) && _LIBCPP_STD_VER >= 23 | |
| 245 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 234 | 246 | |
| 235 | 247 | #endif // _LIBCPP_STDATOMIC_H |
lib/libcxx/include/stdbool.h+21-17| ... | ... | @@ -19,22 +19,26 @@ Macros: |
| 19 | 19 | |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | #include <__config> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | #if __has_include_next(<stdbool.h>) | |
| 29 | # include_next <stdbool.h> | |
| 30 | #endif | |
| 31 | ||
| 32 | #ifdef __cplusplus | |
| 33 | # undef bool | |
| 34 | # undef true | |
| 35 | # undef false | |
| 36 | # undef __bool_true_false_are_defined | |
| 37 | # define __bool_true_false_are_defined 1 | |
| 38 | #endif | |
| 22 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 23 | # include <__cxx03/stdbool.h> | |
| 24 | #else | |
| 25 | # include <__config> | |
| 26 | ||
| 27 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 28 | # pragma GCC system_header | |
| 29 | # endif | |
| 30 | ||
| 31 | # if __has_include_next(<stdbool.h>) | |
| 32 | # include_next <stdbool.h> | |
| 33 | # endif | |
| 34 | ||
| 35 | # ifdef __cplusplus | |
| 36 | # undef bool | |
| 37 | # undef true | |
| 38 | # undef false | |
| 39 | # undef __bool_true_false_are_defined | |
| 40 | # define __bool_true_false_are_defined 1 | |
| 41 | # endif | |
| 42 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 39 | 43 | |
| 40 | 44 | #endif // _LIBCPP_STDBOOL_H |
lib/libcxx/include/stddef.h+13-9| ... | ... | @@ -24,21 +24,25 @@ Types: |
| 24 | 24 | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | #include <__config> | |
| 27 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 28 | # include <__cxx03/stddef.h> | |
| 29 | #else | |
| 30 | # include <__config> | |
| 28 | 31 | |
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 30 | # pragma GCC system_header | |
| 31 | #endif | |
| 32 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 33 | # pragma GCC system_header | |
| 34 | # endif | |
| 32 | 35 | |
| 33 | 36 | // Note: This include is outside of header guards because we sometimes get included multiple times |
| 34 | 37 | // with different defines and the underlying <stddef.h> will know how to deal with that. |
| 35 | #include_next <stddef.h> | |
| 38 | # include_next <stddef.h> | |
| 36 | 39 | |
| 37 | #ifndef _LIBCPP_STDDEF_H | |
| 38 | # define _LIBCPP_STDDEF_H | |
| 40 | # ifndef _LIBCPP_STDDEF_H | |
| 41 | # define _LIBCPP_STDDEF_H | |
| 39 | 42 | |
| 40 | # ifdef __cplusplus | |
| 43 | # ifdef __cplusplus | |
| 41 | 44 | typedef decltype(nullptr) nullptr_t; |
| 42 | # endif | |
| 45 | # endif | |
| 46 | # endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 43 | 47 | |
| 44 | 48 | #endif // _LIBCPP_STDDEF_H |
lib/libcxx/include/stdexcept+73-67| ... | ... | @@ -41,18 +41,21 @@ public: |
| 41 | 41 | |
| 42 | 42 | */ |
| 43 | 43 | |
| 44 | #include <__config> | |
| 45 | #include <__exception/exception.h> | |
| 46 | #include <__fwd/string.h> | |
| 47 | #include <__verbose_abort> | |
| 44 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 45 | # include <__cxx03/stdexcept> | |
| 46 | #else | |
| 47 | # include <__config> | |
| 48 | # include <__exception/exception.h> | |
| 49 | # include <__fwd/string.h> | |
| 50 | # include <__verbose_abort> | |
| 48 | 51 | |
| 49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 50 | # pragma GCC system_header | |
| 51 | #endif | |
| 52 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 53 | # pragma GCC system_header | |
| 54 | # endif | |
| 52 | 55 | |
| 53 | 56 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 54 | 57 | |
| 55 | #ifndef _LIBCPP_ABI_VCRUNTIME | |
| 58 | # ifndef _LIBCPP_ABI_VCRUNTIME | |
| 56 | 59 | class _LIBCPP_HIDDEN __libcpp_refstring { |
| 57 | 60 | const char* __imp_; |
| 58 | 61 | |
| ... | ... | @@ -66,7 +69,7 @@ public: |
| 66 | 69 | |
| 67 | 70 | _LIBCPP_HIDE_FROM_ABI const char* c_str() const _NOEXCEPT { return __imp_; } |
| 68 | 71 | }; |
| 69 | #endif // !_LIBCPP_ABI_VCRUNTIME | |
| 72 | # endif // !_LIBCPP_ABI_VCRUNTIME | |
| 70 | 73 | |
| 71 | 74 | _LIBCPP_END_NAMESPACE_STD |
| 72 | 75 | |
| ... | ... | @@ -74,7 +77,7 @@ namespace std // purposefully not using versioning namespace |
| 74 | 77 | { |
| 75 | 78 | |
| 76 | 79 | class _LIBCPP_EXPORTED_FROM_ABI logic_error : public exception { |
| 77 | #ifndef _LIBCPP_ABI_VCRUNTIME | |
| 80 | # ifndef _LIBCPP_ABI_VCRUNTIME | |
| 78 | 81 | |
| 79 | 82 | private: |
| 80 | 83 | std::__libcpp_refstring __imp_; |
| ... | ... | @@ -89,16 +92,16 @@ public: |
| 89 | 92 | ~logic_error() _NOEXCEPT override; |
| 90 | 93 | |
| 91 | 94 | const char* what() const _NOEXCEPT override; |
| 92 | #else | |
| 95 | # else | |
| 93 | 96 | |
| 94 | 97 | public: |
| 95 | 98 | explicit logic_error(const std::string&); // Symbol uses versioned std::string |
| 96 | 99 | _LIBCPP_HIDE_FROM_ABI explicit logic_error(const char* __s) : exception(__s) {} |
| 97 | #endif | |
| 100 | # endif | |
| 98 | 101 | }; |
| 99 | 102 | |
| 100 | 103 | class _LIBCPP_EXPORTED_FROM_ABI runtime_error : public exception { |
| 101 | #ifndef _LIBCPP_ABI_VCRUNTIME | |
| 104 | # ifndef _LIBCPP_ABI_VCRUNTIME | |
| 102 | 105 | |
| 103 | 106 | private: |
| 104 | 107 | std::__libcpp_refstring __imp_; |
| ... | ... | @@ -113,12 +116,12 @@ public: |
| 113 | 116 | ~runtime_error() _NOEXCEPT override; |
| 114 | 117 | |
| 115 | 118 | const char* what() const _NOEXCEPT override; |
| 116 | #else | |
| 119 | # else | |
| 117 | 120 | |
| 118 | 121 | public: |
| 119 | 122 | explicit runtime_error(const std::string&); // Symbol uses versioned std::string |
| 120 | 123 | _LIBCPP_HIDE_FROM_ABI explicit runtime_error(const char* __s) : exception(__s) {} |
| 121 | #endif // _LIBCPP_ABI_VCRUNTIME | |
| 124 | # endif // _LIBCPP_ABI_VCRUNTIME | |
| 122 | 125 | }; |
| 123 | 126 | |
| 124 | 127 | class _LIBCPP_EXPORTED_FROM_ABI domain_error : public logic_error { |
| ... | ... | @@ -126,11 +129,11 @@ public: |
| 126 | 129 | _LIBCPP_HIDE_FROM_ABI explicit domain_error(const string& __s) : logic_error(__s) {} |
| 127 | 130 | _LIBCPP_HIDE_FROM_ABI explicit domain_error(const char* __s) : logic_error(__s) {} |
| 128 | 131 | |
| 129 | #ifndef _LIBCPP_ABI_VCRUNTIME | |
| 132 | # ifndef _LIBCPP_ABI_VCRUNTIME | |
| 130 | 133 | _LIBCPP_HIDE_FROM_ABI domain_error(const domain_error&) _NOEXCEPT = default; |
| 131 | 134 | _LIBCPP_HIDE_FROM_ABI domain_error& operator=(const domain_error&) _NOEXCEPT = default; |
| 132 | 135 | ~domain_error() _NOEXCEPT override; |
| 133 | #endif | |
| 136 | # endif | |
| 134 | 137 | }; |
| 135 | 138 | |
| 136 | 139 | class _LIBCPP_EXPORTED_FROM_ABI invalid_argument : public logic_error { |
| ... | ... | @@ -138,22 +141,22 @@ public: |
| 138 | 141 | _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const string& __s) : logic_error(__s) {} |
| 139 | 142 | _LIBCPP_HIDE_FROM_ABI explicit invalid_argument(const char* __s) : logic_error(__s) {} |
| 140 | 143 | |
| 141 | #ifndef _LIBCPP_ABI_VCRUNTIME | |
| 144 | # ifndef _LIBCPP_ABI_VCRUNTIME | |
| 142 | 145 | _LIBCPP_HIDE_FROM_ABI invalid_argument(const invalid_argument&) _NOEXCEPT = default; |
| 143 | 146 | _LIBCPP_HIDE_FROM_ABI invalid_argument& operator=(const invalid_argument&) _NOEXCEPT = default; |
| 144 | 147 | ~invalid_argument() _NOEXCEPT override; |
| 145 | #endif | |
| 148 | # endif | |
| 146 | 149 | }; |
| 147 | 150 | |
| 148 | 151 | class _LIBCPP_EXPORTED_FROM_ABI length_error : public logic_error { |
| 149 | 152 | public: |
| 150 | 153 | _LIBCPP_HIDE_FROM_ABI explicit length_error(const string& __s) : logic_error(__s) {} |
| 151 | 154 | _LIBCPP_HIDE_FROM_ABI explicit length_error(const char* __s) : logic_error(__s) {} |
| 152 | #ifndef _LIBCPP_ABI_VCRUNTIME | |
| 155 | # ifndef _LIBCPP_ABI_VCRUNTIME | |
| 153 | 156 | _LIBCPP_HIDE_FROM_ABI length_error(const length_error&) _NOEXCEPT = default; |
| 154 | 157 | _LIBCPP_HIDE_FROM_ABI length_error& operator=(const length_error&) _NOEXCEPT = default; |
| 155 | 158 | ~length_error() _NOEXCEPT override; |
| 156 | #endif | |
| 159 | # endif | |
| 157 | 160 | }; |
| 158 | 161 | |
| 159 | 162 | class _LIBCPP_EXPORTED_FROM_ABI out_of_range : public logic_error { |
| ... | ... | @@ -161,11 +164,11 @@ public: |
| 161 | 164 | _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const string& __s) : logic_error(__s) {} |
| 162 | 165 | _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const char* __s) : logic_error(__s) {} |
| 163 | 166 | |
| 164 | #ifndef _LIBCPP_ABI_VCRUNTIME | |
| 167 | # ifndef _LIBCPP_ABI_VCRUNTIME | |
| 165 | 168 | _LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default; |
| 166 | 169 | _LIBCPP_HIDE_FROM_ABI out_of_range& operator=(const out_of_range&) _NOEXCEPT = default; |
| 167 | 170 | ~out_of_range() _NOEXCEPT override; |
| 168 | #endif | |
| 171 | # endif | |
| 169 | 172 | }; |
| 170 | 173 | |
| 171 | 174 | class _LIBCPP_EXPORTED_FROM_ABI range_error : public runtime_error { |
| ... | ... | @@ -173,11 +176,11 @@ public: |
| 173 | 176 | _LIBCPP_HIDE_FROM_ABI explicit range_error(const string& __s) : runtime_error(__s) {} |
| 174 | 177 | _LIBCPP_HIDE_FROM_ABI explicit range_error(const char* __s) : runtime_error(__s) {} |
| 175 | 178 | |
| 176 | #ifndef _LIBCPP_ABI_VCRUNTIME | |
| 179 | # ifndef _LIBCPP_ABI_VCRUNTIME | |
| 177 | 180 | _LIBCPP_HIDE_FROM_ABI range_error(const range_error&) _NOEXCEPT = default; |
| 178 | 181 | _LIBCPP_HIDE_FROM_ABI range_error& operator=(const range_error&) _NOEXCEPT = default; |
| 179 | 182 | ~range_error() _NOEXCEPT override; |
| 180 | #endif | |
| 183 | # endif | |
| 181 | 184 | }; |
| 182 | 185 | |
| 183 | 186 | class _LIBCPP_EXPORTED_FROM_ABI overflow_error : public runtime_error { |
| ... | ... | @@ -185,11 +188,11 @@ public: |
| 185 | 188 | _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const string& __s) : runtime_error(__s) {} |
| 186 | 189 | _LIBCPP_HIDE_FROM_ABI explicit overflow_error(const char* __s) : runtime_error(__s) {} |
| 187 | 190 | |
| 188 | #ifndef _LIBCPP_ABI_VCRUNTIME | |
| 191 | # ifndef _LIBCPP_ABI_VCRUNTIME | |
| 189 | 192 | _LIBCPP_HIDE_FROM_ABI overflow_error(const overflow_error&) _NOEXCEPT = default; |
| 190 | 193 | _LIBCPP_HIDE_FROM_ABI overflow_error& operator=(const overflow_error&) _NOEXCEPT = default; |
| 191 | 194 | ~overflow_error() _NOEXCEPT override; |
| 192 | #endif | |
| 195 | # endif | |
| 193 | 196 | }; |
| 194 | 197 | |
| 195 | 198 | class _LIBCPP_EXPORTED_FROM_ABI underflow_error : public runtime_error { |
| ... | ... | @@ -197,11 +200,11 @@ public: |
| 197 | 200 | _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const string& __s) : runtime_error(__s) {} |
| 198 | 201 | _LIBCPP_HIDE_FROM_ABI explicit underflow_error(const char* __s) : runtime_error(__s) {} |
| 199 | 202 | |
| 200 | #ifndef _LIBCPP_ABI_VCRUNTIME | |
| 203 | # ifndef _LIBCPP_ABI_VCRUNTIME | |
| 201 | 204 | _LIBCPP_HIDE_FROM_ABI underflow_error(const underflow_error&) _NOEXCEPT = default; |
| 202 | 205 | _LIBCPP_HIDE_FROM_ABI underflow_error& operator=(const underflow_error&) _NOEXCEPT = default; |
| 203 | 206 | ~underflow_error() _NOEXCEPT override; |
| 204 | #endif | |
| 207 | # endif | |
| 205 | 208 | }; |
| 206 | 209 | |
| 207 | 210 | } // namespace std |
| ... | ... | @@ -209,78 +212,81 @@ public: |
| 209 | 212 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 210 | 213 | |
| 211 | 214 | // in the dylib |
| 212 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*); | |
| 215 | [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*); | |
| 213 | 216 | |
| 214 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) { | |
| 215 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 217 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) { | |
| 218 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 216 | 219 | throw logic_error(__msg); |
| 217 | #else | |
| 220 | # else | |
| 218 | 221 | _LIBCPP_VERBOSE_ABORT("logic_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); |
| 219 | #endif | |
| 222 | # endif | |
| 220 | 223 | } |
| 221 | 224 | |
| 222 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) { | |
| 223 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 225 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) { | |
| 226 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 224 | 227 | throw domain_error(__msg); |
| 225 | #else | |
| 228 | # else | |
| 226 | 229 | _LIBCPP_VERBOSE_ABORT("domain_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); |
| 227 | #endif | |
| 230 | # endif | |
| 228 | 231 | } |
| 229 | 232 | |
| 230 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) { | |
| 231 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 233 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) { | |
| 234 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 232 | 235 | throw invalid_argument(__msg); |
| 233 | #else | |
| 236 | # else | |
| 234 | 237 | _LIBCPP_VERBOSE_ABORT("invalid_argument was thrown in -fno-exceptions mode with message \"%s\"", __msg); |
| 235 | #endif | |
| 238 | # endif | |
| 236 | 239 | } |
| 237 | 240 | |
| 238 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) { | |
| 239 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 241 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) { | |
| 242 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 240 | 243 | throw length_error(__msg); |
| 241 | #else | |
| 244 | # else | |
| 242 | 245 | _LIBCPP_VERBOSE_ABORT("length_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); |
| 243 | #endif | |
| 246 | # endif | |
| 244 | 247 | } |
| 245 | 248 | |
| 246 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) { | |
| 247 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 249 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) { | |
| 250 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 248 | 251 | throw out_of_range(__msg); |
| 249 | #else | |
| 252 | # else | |
| 250 | 253 | _LIBCPP_VERBOSE_ABORT("out_of_range was thrown in -fno-exceptions mode with message \"%s\"", __msg); |
| 251 | #endif | |
| 254 | # endif | |
| 252 | 255 | } |
| 253 | 256 | |
| 254 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) { | |
| 255 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 257 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) { | |
| 258 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 256 | 259 | throw range_error(__msg); |
| 257 | #else | |
| 260 | # else | |
| 258 | 261 | _LIBCPP_VERBOSE_ABORT("range_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); |
| 259 | #endif | |
| 262 | # endif | |
| 260 | 263 | } |
| 261 | 264 | |
| 262 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) { | |
| 263 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 265 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) { | |
| 266 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 264 | 267 | throw overflow_error(__msg); |
| 265 | #else | |
| 268 | # else | |
| 266 | 269 | _LIBCPP_VERBOSE_ABORT("overflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); |
| 267 | #endif | |
| 270 | # endif | |
| 268 | 271 | } |
| 269 | 272 | |
| 270 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) { | |
| 271 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 273 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) { | |
| 274 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 272 | 275 | throw underflow_error(__msg); |
| 273 | #else | |
| 276 | # else | |
| 274 | 277 | _LIBCPP_VERBOSE_ABORT("underflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); |
| 275 | #endif | |
| 278 | # endif | |
| 276 | 279 | } |
| 277 | 280 | |
| 278 | 281 | _LIBCPP_END_NAMESPACE_STD |
| 279 | 282 | |
| 280 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 281 | # include <cstdlib> | |
| 282 | # include <exception> | |
| 283 | # include <iosfwd> | |
| 284 | #endif | |
| 283 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 284 | # include <cstddef> | |
| 285 | # include <cstdlib> | |
| 286 | # include <exception> | |
| 287 | # include <iosfwd> | |
| 288 | # include <new> | |
| 289 | # endif | |
| 290 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 285 | 291 | |
| 286 | 292 | #endif // _LIBCPP_STDEXCEPT |
lib/libcxx/include/stdint.h deleted-127| ... | ... | @@ -1,127 +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_STDINT_H | |
| 11 | // AIX system headers need stdint.h to be re-enterable while _STD_TYPES_T | |
| 12 | // is defined until an inclusion of it without _STD_TYPES_T occurs, in which | |
| 13 | // case the header guard macro is defined. | |
| 14 | #if !defined(_AIX) || !defined(_STD_TYPES_T) | |
| 15 | # define _LIBCPP_STDINT_H | |
| 16 | #endif // _STD_TYPES_T | |
| 17 | ||
| 18 | /* | |
| 19 | stdint.h synopsis | |
| 20 | ||
| 21 | Macros: | |
| 22 | ||
| 23 | INT8_MIN | |
| 24 | INT16_MIN | |
| 25 | INT32_MIN | |
| 26 | INT64_MIN | |
| 27 | ||
| 28 | INT8_MAX | |
| 29 | INT16_MAX | |
| 30 | INT32_MAX | |
| 31 | INT64_MAX | |
| 32 | ||
| 33 | UINT8_MAX | |
| 34 | UINT16_MAX | |
| 35 | UINT32_MAX | |
| 36 | UINT64_MAX | |
| 37 | ||
| 38 | INT_LEAST8_MIN | |
| 39 | INT_LEAST16_MIN | |
| 40 | INT_LEAST32_MIN | |
| 41 | INT_LEAST64_MIN | |
| 42 | ||
| 43 | INT_LEAST8_MAX | |
| 44 | INT_LEAST16_MAX | |
| 45 | INT_LEAST32_MAX | |
| 46 | INT_LEAST64_MAX | |
| 47 | ||
| 48 | UINT_LEAST8_MAX | |
| 49 | UINT_LEAST16_MAX | |
| 50 | UINT_LEAST32_MAX | |
| 51 | UINT_LEAST64_MAX | |
| 52 | ||
| 53 | INT_FAST8_MIN | |
| 54 | INT_FAST16_MIN | |
| 55 | INT_FAST32_MIN | |
| 56 | INT_FAST64_MIN | |
| 57 | ||
| 58 | INT_FAST8_MAX | |
| 59 | INT_FAST16_MAX | |
| 60 | INT_FAST32_MAX | |
| 61 | INT_FAST64_MAX | |
| 62 | ||
| 63 | UINT_FAST8_MAX | |
| 64 | UINT_FAST16_MAX | |
| 65 | UINT_FAST32_MAX | |
| 66 | UINT_FAST64_MAX | |
| 67 | ||
| 68 | INTPTR_MIN | |
| 69 | INTPTR_MAX | |
| 70 | UINTPTR_MAX | |
| 71 | ||
| 72 | INTMAX_MIN | |
| 73 | INTMAX_MAX | |
| 74 | ||
| 75 | UINTMAX_MAX | |
| 76 | ||
| 77 | PTRDIFF_MIN | |
| 78 | PTRDIFF_MAX | |
| 79 | ||
| 80 | SIG_ATOMIC_MIN | |
| 81 | SIG_ATOMIC_MAX | |
| 82 | ||
| 83 | SIZE_MAX | |
| 84 | ||
| 85 | WCHAR_MIN | |
| 86 | WCHAR_MAX | |
| 87 | ||
| 88 | WINT_MIN | |
| 89 | WINT_MAX | |
| 90 | ||
| 91 | INT8_C(value) | |
| 92 | INT16_C(value) | |
| 93 | INT32_C(value) | |
| 94 | INT64_C(value) | |
| 95 | ||
| 96 | UINT8_C(value) | |
| 97 | UINT16_C(value) | |
| 98 | UINT32_C(value) | |
| 99 | UINT64_C(value) | |
| 100 | ||
| 101 | INTMAX_C(value) | |
| 102 | UINTMAX_C(value) | |
| 103 | ||
| 104 | */ | |
| 105 | ||
| 106 | #include <__config> | |
| 107 | ||
| 108 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 109 | # pragma GCC system_header | |
| 110 | #endif | |
| 111 | ||
| 112 | /* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed | |
| 113 | for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS | |
| 114 | are defined | |
| 115 | */ | |
| 116 | #if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS) | |
| 117 | # define __STDC_LIMIT_MACROS | |
| 118 | #endif | |
| 119 | #if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS) | |
| 120 | # define __STDC_CONSTANT_MACROS | |
| 121 | #endif | |
| 122 | ||
| 123 | #if __has_include_next(<stdint.h>) | |
| 124 | # include_next <stdint.h> | |
| 125 | #endif | |
| 126 | ||
| 127 | #endif // _LIBCPP_STDINT_H |
lib/libcxx/include/stdio.h+20-21| ... | ... | @@ -7,17 +7,6 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #if defined(__need_FILE) || defined(__need___FILE) | |
| 11 | ||
| 12 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 13 | # pragma GCC system_header | |
| 14 | # endif | |
| 15 | ||
| 16 | # include_next <stdio.h> | |
| 17 | ||
| 18 | #elif !defined(_LIBCPP_STDIO_H) | |
| 19 | # define _LIBCPP_STDIO_H | |
| 20 | ||
| 21 | 10 | /* |
| 22 | 11 | stdio.h synopsis |
| 23 | 12 | |
| ... | ... | @@ -98,26 +87,36 @@ int ferror(FILE* stream); |
| 98 | 87 | void perror(const char* s); |
| 99 | 88 | */ |
| 100 | 89 | |
| 90 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 91 | # include <__cxx03/stdio.h> | |
| 92 | #else | |
| 101 | 93 | # include <__config> |
| 102 | 94 | |
| 103 | 95 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 104 | 96 | # pragma GCC system_header |
| 105 | 97 | # endif |
| 106 | 98 | |
| 99 | // The inclusion of the system's <stdio.h> is intentionally done once outside of any include | |
| 100 | // guards because some code expects to be able to include the underlying system header multiple | |
| 101 | // times to get different definitions based on the macros that are set before inclusion. | |
| 107 | 102 | # if __has_include_next(<stdio.h>) |
| 108 | 103 | # include_next <stdio.h> |
| 109 | 104 | # endif |
| 110 | 105 | |
| 111 | # ifdef __cplusplus | |
| 106 | # ifndef _LIBCPP_STDIO_H | |
| 107 | # define _LIBCPP_STDIO_H | |
| 112 | 108 | |
| 113 | # undef getc | |
| 114 | # undef putc | |
| 115 | # undef clearerr | |
| 116 | # undef feof | |
| 117 | # undef ferror | |
| 118 | # undef putchar | |
| 119 | # undef getchar | |
| 109 | # ifdef __cplusplus | |
| 120 | 110 | |
| 121 | # endif | |
| 111 | # undef getc | |
| 112 | # undef putc | |
| 113 | # undef clearerr | |
| 114 | # undef feof | |
| 115 | # undef ferror | |
| 116 | # undef putchar | |
| 117 | # undef getchar | |
| 118 | ||
| 119 | # endif // __cplusplus | |
| 120 | # endif // _LIBCPP_STDIO_H | |
| 122 | 121 | |
| 123 | #endif // _LIBCPP_STDIO_H | |
| 122 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
lib/libcxx/include/stdlib.h+42-43| ... | ... | @@ -7,17 +7,6 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #if defined(__need_malloc_and_calloc) | |
| 11 | ||
| 12 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 13 | # pragma GCC system_header | |
| 14 | # endif | |
| 15 | ||
| 16 | # include_next <stdlib.h> | |
| 17 | ||
| 18 | #elif !defined(_LIBCPP_STDLIB_H) | |
| 19 | # define _LIBCPP_STDLIB_H | |
| 20 | ||
| 21 | 10 | /* |
| 22 | 11 | stdlib.h synopsis |
| 23 | 12 | |
| ... | ... | @@ -84,68 +73,78 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 |
| 84 | 73 | |
| 85 | 74 | */ |
| 86 | 75 | |
| 76 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 77 | # include <__cxx03/stdlib.h> | |
| 78 | #else | |
| 87 | 79 | # include <__config> |
| 88 | 80 | |
| 89 | 81 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 90 | 82 | # pragma GCC system_header |
| 91 | 83 | # endif |
| 92 | 84 | |
| 85 | // The inclusion of the system's <stdlib.h> is intentionally done once outside of any include | |
| 86 | // guards because some code expects to be able to include the underlying system header multiple | |
| 87 | // times to get different definitions based on the macros that are set before inclusion. | |
| 93 | 88 | # if __has_include_next(<stdlib.h>) |
| 94 | 89 | # include_next <stdlib.h> |
| 95 | 90 | # endif |
| 96 | 91 | |
| 97 | # ifdef __cplusplus | |
| 92 | # if !defined(_LIBCPP_STDLIB_H) | |
| 93 | # define _LIBCPP_STDLIB_H | |
| 94 | ||
| 95 | # ifdef __cplusplus | |
| 98 | 96 | extern "C++" { |
| 99 | 97 | // abs |
| 100 | 98 | |
| 101 | # ifdef abs | |
| 102 | # undef abs | |
| 103 | # endif | |
| 104 | # ifdef labs | |
| 105 | # undef labs | |
| 106 | # endif | |
| 107 | # ifdef llabs | |
| 108 | # undef llabs | |
| 109 | # endif | |
| 99 | # ifdef abs | |
| 100 | # undef abs | |
| 101 | # endif | |
| 102 | # ifdef labs | |
| 103 | # undef labs | |
| 104 | # endif | |
| 105 | # ifdef llabs | |
| 106 | # undef llabs | |
| 107 | # endif | |
| 110 | 108 | |
| 111 | 109 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined |
| 112 | # if !defined(_LIBCPP_MSVCRT) | |
| 113 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } | |
| 114 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } | |
| 115 | # endif // !defined(_LIBCPP_MSVCRT) | |
| 110 | # if !defined(_LIBCPP_MSVCRT) | |
| 111 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); } | |
| 112 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); } | |
| 113 | # endif // !defined(_LIBCPP_MSVCRT) | |
| 116 | 114 | |
| 117 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { | |
| 115 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT { | |
| 118 | 116 | return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h |
| 119 | 117 | } |
| 120 | 118 | |
| 121 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT { | |
| 119 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT { | |
| 122 | 120 | return __builtin_fabs(__lcpp_x); |
| 123 | 121 | } |
| 124 | 122 | |
| 125 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT { | |
| 123 | [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT { | |
| 126 | 124 | return __builtin_fabsl(__lcpp_x); |
| 127 | 125 | } |
| 128 | 126 | |
| 129 | 127 | // div |
| 130 | 128 | |
| 131 | # ifdef div | |
| 132 | # undef div | |
| 133 | # endif | |
| 134 | # ifdef ldiv | |
| 135 | # undef ldiv | |
| 136 | # endif | |
| 137 | # ifdef lldiv | |
| 138 | # undef lldiv | |
| 139 | # endif | |
| 129 | # ifdef div | |
| 130 | # undef div | |
| 131 | # endif | |
| 132 | # ifdef ldiv | |
| 133 | # undef ldiv | |
| 134 | # endif | |
| 135 | # ifdef lldiv | |
| 136 | # undef lldiv | |
| 137 | # endif | |
| 140 | 138 | |
| 141 | 139 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined |
| 142 | # if !defined(_LIBCPP_MSVCRT) | |
| 140 | # if !defined(_LIBCPP_MSVCRT) | |
| 143 | 141 | inline _LIBCPP_HIDE_FROM_ABI ldiv_t div(long __x, long __y) _NOEXCEPT { return ::ldiv(__x, __y); } |
| 144 | # if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED)) | |
| 142 | # if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED)) | |
| 145 | 143 | inline _LIBCPP_HIDE_FROM_ABI lldiv_t div(long long __x, long long __y) _NOEXCEPT { return ::lldiv(__x, __y); } |
| 146 | # endif | |
| 147 | # endif // _LIBCPP_MSVCRT | |
| 144 | # endif | |
| 145 | # endif // _LIBCPP_MSVCRT | |
| 148 | 146 | } // extern "C++" |
| 149 | # endif // __cplusplus | |
| 147 | # endif // __cplusplus | |
| 148 | # endif // _LIBCPP_STDLIB_H | |
| 150 | 149 | |
| 151 | #endif // _LIBCPP_STDLIB_H | |
| 150 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
lib/libcxx/include/stop_token+20-15| ... | ... | @@ -31,26 +31,31 @@ namespace std { |
| 31 | 31 | |
| 32 | 32 | */ |
| 33 | 33 | |
| 34 | #include <__config> | |
| 34 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 35 | # include <__cxx03/stop_token> | |
| 36 | #else | |
| 37 | # include <__config> | |
| 35 | 38 | |
| 36 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 39 | # if _LIBCPP_HAS_THREADS | |
| 37 | 40 | |
| 38 | # if _LIBCPP_STD_VER >= 20 | |
| 39 | # include <__stop_token/stop_callback.h> | |
| 40 | # include <__stop_token/stop_source.h> | |
| 41 | # include <__stop_token/stop_token.h> | |
| 42 | # endif | |
| 41 | # if _LIBCPP_STD_VER >= 20 | |
| 42 | # include <__stop_token/stop_callback.h> | |
| 43 | # include <__stop_token/stop_source.h> | |
| 44 | # include <__stop_token/stop_token.h> | |
| 45 | # endif | |
| 43 | 46 | |
| 44 | # include <version> | |
| 47 | # include <version> | |
| 45 | 48 | |
| 46 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 47 | # pragma GCC system_header | |
| 48 | # endif | |
| 49 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 50 | # pragma GCC system_header | |
| 51 | # endif | |
| 49 | 52 | |
| 50 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 53 | # endif // _LIBCPP_HAS_THREADS | |
| 51 | 54 | |
| 52 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 53 | # include <iosfwd> | |
| 54 | #endif | |
| 55 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 56 | # include <cstddef> | |
| 57 | # include <iosfwd> | |
| 58 | # endif | |
| 59 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 55 | 60 | |
| 56 | 61 | #endif // _LIBCPP_STOP_TOKEN |
lib/libcxx/include/streambuf+126-179| ... | ... | @@ -107,23 +107,29 @@ protected: |
| 107 | 107 | |
| 108 | 108 | */ |
| 109 | 109 | |
| 110 | #include <__assert> | |
| 111 | #include <__config> | |
| 112 | #include <__fwd/streambuf.h> | |
| 113 | #include <__locale> | |
| 114 | #include <__type_traits/is_same.h> | |
| 115 | #include <__utility/is_valid_range.h> | |
| 116 | #include <climits> | |
| 117 | #include <ios> | |
| 118 | #include <iosfwd> | |
| 119 | #include <version> | |
| 120 | ||
| 121 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 122 | # pragma GCC system_header | |
| 123 | #endif | |
| 110 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 111 | # include <__cxx03/streambuf> | |
| 112 | #else | |
| 113 | # include <__config> | |
| 114 | ||
| 115 | # if _LIBCPP_HAS_LOCALIZATION | |
| 116 | ||
| 117 | # include <__assert> | |
| 118 | # include <__fwd/streambuf.h> | |
| 119 | # include <__locale> | |
| 120 | # include <__type_traits/is_same.h> | |
| 121 | # include <__utility/is_valid_range.h> | |
| 122 | # include <climits> | |
| 123 | # include <ios> | |
| 124 | # include <iosfwd> | |
| 125 | # include <version> | |
| 126 | ||
| 127 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 128 | # pragma GCC system_header | |
| 129 | # endif | |
| 124 | 130 | |
| 125 | 131 | _LIBCPP_PUSH_MACROS |
| 126 | #include <__undef_macros> | |
| 132 | # include <__undef_macros> | |
| 127 | 133 | |
| 128 | 134 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 129 | 135 | |
| ... | ... | @@ -140,7 +146,7 @@ public: |
| 140 | 146 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, |
| 141 | 147 | "traits_type::char_type must be the same type as CharT"); |
| 142 | 148 | |
| 143 | virtual ~basic_streambuf(); | |
| 149 | virtual ~basic_streambuf() {} | |
| 144 | 150 | |
| 145 | 151 | // 27.6.2.2.1 locales: |
| 146 | 152 | inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 locale pubimbue(const locale& __loc) { |
| ... | ... | @@ -223,10 +229,36 @@ public: |
| 223 | 229 | } |
| 224 | 230 | |
| 225 | 231 | protected: |
| 226 | basic_streambuf(); | |
| 227 | basic_streambuf(const basic_streambuf& __rhs); | |
| 228 | basic_streambuf& operator=(const basic_streambuf& __rhs); | |
| 229 | void swap(basic_streambuf& __rhs); | |
| 232 | basic_streambuf() {} | |
| 233 | basic_streambuf(const basic_streambuf& __sb) | |
| 234 | : __loc_(__sb.__loc_), | |
| 235 | __binp_(__sb.__binp_), | |
| 236 | __ninp_(__sb.__ninp_), | |
| 237 | __einp_(__sb.__einp_), | |
| 238 | __bout_(__sb.__bout_), | |
| 239 | __nout_(__sb.__nout_), | |
| 240 | __eout_(__sb.__eout_) {} | |
| 241 | ||
| 242 | basic_streambuf& operator=(const basic_streambuf& __sb) { | |
| 243 | __loc_ = __sb.__loc_; | |
| 244 | __binp_ = __sb.__binp_; | |
| 245 | __ninp_ = __sb.__ninp_; | |
| 246 | __einp_ = __sb.__einp_; | |
| 247 | __bout_ = __sb.__bout_; | |
| 248 | __nout_ = __sb.__nout_; | |
| 249 | __eout_ = __sb.__eout_; | |
| 250 | return *this; | |
| 251 | } | |
| 252 | ||
| 253 | void swap(basic_streambuf& __sb) { | |
| 254 | std::swap(__loc_, __sb.__loc_); | |
| 255 | std::swap(__binp_, __sb.__binp_); | |
| 256 | std::swap(__ninp_, __sb.__ninp_); | |
| 257 | std::swap(__einp_, __sb.__einp_); | |
| 258 | std::swap(__bout_, __sb.__bout_); | |
| 259 | std::swap(__nout_, __sb.__nout_); | |
| 260 | std::swap(__eout_, __sb.__eout_); | |
| 261 | } | |
| 230 | 262 | |
| 231 | 263 | // 27.6.2.3.2 Get area: |
| 232 | 264 | _LIBCPP_HIDE_FROM_ABI char_type* eback() const { return __binp_; } |
| ... | ... | @@ -261,185 +293,100 @@ protected: |
| 261 | 293 | |
| 262 | 294 | // 27.6.2.4 virtual functions: |
| 263 | 295 | // 27.6.2.4.1 Locales: |
| 264 | virtual void imbue(const locale& __loc); | |
| 296 | virtual void imbue(const locale&) {} | |
| 265 | 297 | |
| 266 | 298 | // 27.6.2.4.2 Buffer management and positioning: |
| 267 | virtual basic_streambuf* setbuf(char_type* __s, streamsize __n); | |
| 268 | virtual pos_type | |
| 269 | seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out); | |
| 270 | virtual pos_type seekpos(pos_type __sp, ios_base::openmode __which = ios_base::in | ios_base::out); | |
| 271 | virtual int sync(); | |
| 299 | virtual basic_streambuf* setbuf(char_type*, streamsize) { return this; } | |
| 300 | virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode = ios_base::in | ios_base::out) { | |
| 301 | return pos_type(off_type(-1)); | |
| 302 | } | |
| 303 | virtual pos_type seekpos(pos_type, ios_base::openmode = ios_base::in | ios_base::out) { | |
| 304 | return pos_type(off_type(-1)); | |
| 305 | } | |
| 306 | virtual int sync() { return 0; } | |
| 272 | 307 | |
| 273 | 308 | // 27.6.2.4.3 Get area: |
| 274 | virtual streamsize showmanyc(); | |
| 275 | virtual streamsize xsgetn(char_type* __s, streamsize __n); | |
| 276 | virtual int_type underflow(); | |
| 277 | virtual int_type uflow(); | |
| 309 | virtual streamsize showmanyc() { return 0; } | |
| 310 | ||
| 311 | virtual streamsize xsgetn(char_type* __s, streamsize __n) { | |
| 312 | const int_type __eof = traits_type::eof(); | |
| 313 | int_type __c; | |
| 314 | streamsize __i = 0; | |
| 315 | while (__i < __n) { | |
| 316 | if (__ninp_ < __einp_) { | |
| 317 | const streamsize __len = std::min(static_cast<streamsize>(INT_MAX), std::min(__einp_ - __ninp_, __n - __i)); | |
| 318 | traits_type::copy(__s, __ninp_, __len); | |
| 319 | __s += __len; | |
| 320 | __i += __len; | |
| 321 | this->gbump(__len); | |
| 322 | } else if ((__c = uflow()) != __eof) { | |
| 323 | *__s = traits_type::to_char_type(__c); | |
| 324 | ++__s; | |
| 325 | ++__i; | |
| 326 | } else | |
| 327 | break; | |
| 328 | } | |
| 329 | return __i; | |
| 330 | } | |
| 331 | ||
| 332 | virtual int_type underflow() { return traits_type::eof(); } | |
| 333 | virtual int_type uflow() { | |
| 334 | if (underflow() == traits_type::eof()) | |
| 335 | return traits_type::eof(); | |
| 336 | return traits_type::to_int_type(*__ninp_++); | |
| 337 | } | |
| 278 | 338 | |
| 279 | 339 | // 27.6.2.4.4 Putback: |
| 280 | virtual int_type pbackfail(int_type __c = traits_type::eof()); | |
| 340 | virtual int_type pbackfail(int_type = traits_type::eof()) { return traits_type::eof(); } | |
| 281 | 341 | |
| 282 | 342 | // 27.6.2.4.5 Put area: |
| 283 | virtual streamsize xsputn(const char_type* __s, streamsize __n); | |
| 284 | virtual int_type overflow(int_type __c = traits_type::eof()); | |
| 343 | virtual streamsize xsputn(const char_type* __s, streamsize __n) { | |
| 344 | streamsize __i = 0; | |
| 345 | int_type __eof = traits_type::eof(); | |
| 346 | while (__i < __n) { | |
| 347 | if (__nout_ >= __eout_) { | |
| 348 | if (overflow(traits_type::to_int_type(*__s)) == __eof) | |
| 349 | break; | |
| 350 | ++__s; | |
| 351 | ++__i; | |
| 352 | } else { | |
| 353 | streamsize __chunk_size = std::min(__eout_ - __nout_, __n - __i); | |
| 354 | traits_type::copy(__nout_, __s, __chunk_size); | |
| 355 | __nout_ += __chunk_size; | |
| 356 | __s += __chunk_size; | |
| 357 | __i += __chunk_size; | |
| 358 | } | |
| 359 | } | |
| 360 | return __i; | |
| 361 | } | |
| 362 | ||
| 363 | virtual int_type overflow(int_type = traits_type::eof()) { return traits_type::eof(); } | |
| 285 | 364 | |
| 286 | 365 | private: |
| 287 | 366 | locale __loc_; |
| 288 | char_type* __binp_; | |
| 289 | char_type* __ninp_; | |
| 290 | char_type* __einp_; | |
| 291 | char_type* __bout_; | |
| 292 | char_type* __nout_; | |
| 293 | char_type* __eout_; | |
| 367 | char_type* __binp_ = nullptr; | |
| 368 | char_type* __ninp_ = nullptr; | |
| 369 | char_type* __einp_ = nullptr; | |
| 370 | char_type* __bout_ = nullptr; | |
| 371 | char_type* __nout_ = nullptr; | |
| 372 | char_type* __eout_ = nullptr; | |
| 294 | 373 | }; |
| 295 | 374 | |
| 296 | template <class _CharT, class _Traits> | |
| 297 | basic_streambuf<_CharT, _Traits>::~basic_streambuf() {} | |
| 298 | ||
| 299 | template <class _CharT, class _Traits> | |
| 300 | basic_streambuf<_CharT, _Traits>::basic_streambuf() | |
| 301 | : __binp_(nullptr), __ninp_(nullptr), __einp_(nullptr), __bout_(nullptr), __nout_(nullptr), __eout_(nullptr) {} | |
| 302 | ||
| 303 | template <class _CharT, class _Traits> | |
| 304 | basic_streambuf<_CharT, _Traits>::basic_streambuf(const basic_streambuf& __sb) | |
| 305 | : __loc_(__sb.__loc_), | |
| 306 | __binp_(__sb.__binp_), | |
| 307 | __ninp_(__sb.__ninp_), | |
| 308 | __einp_(__sb.__einp_), | |
| 309 | __bout_(__sb.__bout_), | |
| 310 | __nout_(__sb.__nout_), | |
| 311 | __eout_(__sb.__eout_) {} | |
| 312 | ||
| 313 | template <class _CharT, class _Traits> | |
| 314 | basic_streambuf<_CharT, _Traits>& basic_streambuf<_CharT, _Traits>::operator=(const basic_streambuf& __sb) { | |
| 315 | __loc_ = __sb.__loc_; | |
| 316 | __binp_ = __sb.__binp_; | |
| 317 | __ninp_ = __sb.__ninp_; | |
| 318 | __einp_ = __sb.__einp_; | |
| 319 | __bout_ = __sb.__bout_; | |
| 320 | __nout_ = __sb.__nout_; | |
| 321 | __eout_ = __sb.__eout_; | |
| 322 | return *this; | |
| 323 | } | |
| 324 | ||
| 325 | template <class _CharT, class _Traits> | |
| 326 | void basic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb) { | |
| 327 | std::swap(__loc_, __sb.__loc_); | |
| 328 | std::swap(__binp_, __sb.__binp_); | |
| 329 | std::swap(__ninp_, __sb.__ninp_); | |
| 330 | std::swap(__einp_, __sb.__einp_); | |
| 331 | std::swap(__bout_, __sb.__bout_); | |
| 332 | std::swap(__nout_, __sb.__nout_); | |
| 333 | std::swap(__eout_, __sb.__eout_); | |
| 334 | } | |
| 335 | ||
| 336 | template <class _CharT, class _Traits> | |
| 337 | void basic_streambuf<_CharT, _Traits>::imbue(const locale&) {} | |
| 338 | ||
| 339 | template <class _CharT, class _Traits> | |
| 340 | basic_streambuf<_CharT, _Traits>* basic_streambuf<_CharT, _Traits>::setbuf(char_type*, streamsize) { | |
| 341 | return this; | |
| 342 | } | |
| 343 | ||
| 344 | template <class _CharT, class _Traits> | |
| 345 | typename basic_streambuf<_CharT, _Traits>::pos_type | |
| 346 | basic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir, ios_base::openmode) { | |
| 347 | return pos_type(off_type(-1)); | |
| 348 | } | |
| 349 | ||
| 350 | template <class _CharT, class _Traits> | |
| 351 | typename basic_streambuf<_CharT, _Traits>::pos_type | |
| 352 | basic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode) { | |
| 353 | return pos_type(off_type(-1)); | |
| 354 | } | |
| 355 | ||
| 356 | template <class _CharT, class _Traits> | |
| 357 | int basic_streambuf<_CharT, _Traits>::sync() { | |
| 358 | return 0; | |
| 359 | } | |
| 360 | ||
| 361 | template <class _CharT, class _Traits> | |
| 362 | streamsize basic_streambuf<_CharT, _Traits>::showmanyc() { | |
| 363 | return 0; | |
| 364 | } | |
| 365 | ||
| 366 | template <class _CharT, class _Traits> | |
| 367 | streamsize basic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n) { | |
| 368 | const int_type __eof = traits_type::eof(); | |
| 369 | int_type __c; | |
| 370 | streamsize __i = 0; | |
| 371 | while (__i < __n) { | |
| 372 | if (__ninp_ < __einp_) { | |
| 373 | const streamsize __len = std::min(static_cast<streamsize>(INT_MAX), std::min(__einp_ - __ninp_, __n - __i)); | |
| 374 | traits_type::copy(__s, __ninp_, __len); | |
| 375 | __s += __len; | |
| 376 | __i += __len; | |
| 377 | this->gbump(__len); | |
| 378 | } else if ((__c = uflow()) != __eof) { | |
| 379 | *__s = traits_type::to_char_type(__c); | |
| 380 | ++__s; | |
| 381 | ++__i; | |
| 382 | } else | |
| 383 | break; | |
| 384 | } | |
| 385 | return __i; | |
| 386 | } | |
| 387 | ||
| 388 | template <class _CharT, class _Traits> | |
| 389 | typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::underflow() { | |
| 390 | return traits_type::eof(); | |
| 391 | } | |
| 392 | ||
| 393 | template <class _CharT, class _Traits> | |
| 394 | typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::uflow() { | |
| 395 | if (underflow() == traits_type::eof()) | |
| 396 | return traits_type::eof(); | |
| 397 | return traits_type::to_int_type(*__ninp_++); | |
| 398 | } | |
| 399 | ||
| 400 | template <class _CharT, class _Traits> | |
| 401 | typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::pbackfail(int_type) { | |
| 402 | return traits_type::eof(); | |
| 403 | } | |
| 404 | ||
| 405 | template <class _CharT, class _Traits> | |
| 406 | streamsize basic_streambuf<_CharT, _Traits>::xsputn(const char_type* __s, streamsize __n) { | |
| 407 | streamsize __i = 0; | |
| 408 | int_type __eof = traits_type::eof(); | |
| 409 | while (__i < __n) { | |
| 410 | if (__nout_ >= __eout_) { | |
| 411 | if (overflow(traits_type::to_int_type(*__s)) == __eof) | |
| 412 | break; | |
| 413 | ++__s; | |
| 414 | ++__i; | |
| 415 | } else { | |
| 416 | streamsize __chunk_size = std::min(__eout_ - __nout_, __n - __i); | |
| 417 | traits_type::copy(__nout_, __s, __chunk_size); | |
| 418 | __nout_ += __chunk_size; | |
| 419 | __s += __chunk_size; | |
| 420 | __i += __chunk_size; | |
| 421 | } | |
| 422 | } | |
| 423 | return __i; | |
| 424 | } | |
| 425 | ||
| 426 | template <class _CharT, class _Traits> | |
| 427 | typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::overflow(int_type) { | |
| 428 | return traits_type::eof(); | |
| 429 | } | |
| 430 | ||
| 431 | 375 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>; |
| 432 | 376 | |
| 433 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 377 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 434 | 378 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>; |
| 435 | #endif | |
| 379 | # endif | |
| 436 | 380 | |
| 437 | 381 | _LIBCPP_END_NAMESPACE_STD |
| 438 | 382 | |
| 439 | 383 | _LIBCPP_POP_MACROS |
| 440 | 384 | |
| 441 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 442 | # include <cstdint> | |
| 443 | #endif | |
| 385 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 386 | ||
| 387 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 388 | # include <cstdint> | |
| 389 | # endif | |
| 390 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 444 | 391 | |
| 445 | 392 | #endif // _LIBCPP_STREAMBUF |
lib/libcxx/include/string+463-461| ... | ... | @@ -586,101 +586,106 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len ); |
| 586 | 586 | |
| 587 | 587 | // clang-format on |
| 588 | 588 | |
| 589 | #include <__algorithm/max.h> | |
| 590 | #include <__algorithm/min.h> | |
| 591 | #include <__algorithm/remove.h> | |
| 592 | #include <__algorithm/remove_if.h> | |
| 593 | #include <__assert> | |
| 594 | #include <__config> | |
| 595 | #include <__debug_utils/sanitizers.h> | |
| 596 | #include <__format/enable_insertable.h> | |
| 597 | #include <__functional/hash.h> | |
| 598 | #include <__functional/unary_function.h> | |
| 599 | #include <__fwd/string.h> | |
| 600 | #include <__ios/fpos.h> | |
| 601 | #include <__iterator/bounded_iter.h> | |
| 602 | #include <__iterator/distance.h> | |
| 603 | #include <__iterator/iterator_traits.h> | |
| 604 | #include <__iterator/reverse_iterator.h> | |
| 605 | #include <__iterator/wrap_iter.h> | |
| 606 | #include <__memory/addressof.h> | |
| 607 | #include <__memory/allocate_at_least.h> | |
| 608 | #include <__memory/allocator.h> | |
| 609 | #include <__memory/allocator_traits.h> | |
| 610 | #include <__memory/compressed_pair.h> | |
| 611 | #include <__memory/construct_at.h> | |
| 612 | #include <__memory/pointer_traits.h> | |
| 613 | #include <__memory/swap_allocator.h> | |
| 614 | #include <__memory_resource/polymorphic_allocator.h> | |
| 615 | #include <__ranges/access.h> | |
| 616 | #include <__ranges/concepts.h> | |
| 617 | #include <__ranges/container_compatible_range.h> | |
| 618 | #include <__ranges/from_range.h> | |
| 619 | #include <__ranges/size.h> | |
| 620 | #include <__string/char_traits.h> | |
| 621 | #include <__string/extern_template_lists.h> | |
| 622 | #include <__type_traits/conditional.h> | |
| 623 | #include <__type_traits/is_allocator.h> | |
| 624 | #include <__type_traits/is_array.h> | |
| 625 | #include <__type_traits/is_convertible.h> | |
| 626 | #include <__type_traits/is_nothrow_assignable.h> | |
| 627 | #include <__type_traits/is_nothrow_constructible.h> | |
| 628 | #include <__type_traits/is_same.h> | |
| 629 | #include <__type_traits/is_standard_layout.h> | |
| 630 | #include <__type_traits/is_trivial.h> | |
| 631 | #include <__type_traits/is_trivially_relocatable.h> | |
| 632 | #include <__type_traits/noexcept_move_assign_container.h> | |
| 633 | #include <__type_traits/remove_cvref.h> | |
| 634 | #include <__type_traits/void_t.h> | |
| 635 | #include <__utility/auto_cast.h> | |
| 636 | #include <__utility/declval.h> | |
| 637 | #include <__utility/forward.h> | |
| 638 | #include <__utility/is_pointer_in_range.h> | |
| 639 | #include <__utility/move.h> | |
| 640 | #include <__utility/swap.h> | |
| 641 | #include <__utility/unreachable.h> | |
| 642 | #include <climits> | |
| 643 | #include <cstdio> // EOF | |
| 644 | #include <cstring> | |
| 645 | #include <limits> | |
| 646 | #include <stdexcept> | |
| 647 | #include <string_view> | |
| 648 | #include <version> | |
| 649 | ||
| 650 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 651 | # include <cwchar> | |
| 652 | #endif | |
| 589 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 590 | # include <__cxx03/string> | |
| 591 | #else | |
| 592 | # include <__algorithm/max.h> | |
| 593 | # include <__algorithm/min.h> | |
| 594 | # include <__algorithm/remove.h> | |
| 595 | # include <__algorithm/remove_if.h> | |
| 596 | # include <__assert> | |
| 597 | # include <__config> | |
| 598 | # include <__debug_utils/sanitizers.h> | |
| 599 | # include <__format/enable_insertable.h> | |
| 600 | # include <__functional/hash.h> | |
| 601 | # include <__functional/unary_function.h> | |
| 602 | # include <__fwd/string.h> | |
| 603 | # include <__ios/fpos.h> | |
| 604 | # include <__iterator/bounded_iter.h> | |
| 605 | # include <__iterator/distance.h> | |
| 606 | # include <__iterator/iterator_traits.h> | |
| 607 | # include <__iterator/reverse_iterator.h> | |
| 608 | # include <__iterator/wrap_iter.h> | |
| 609 | # include <__memory/addressof.h> | |
| 610 | # include <__memory/allocate_at_least.h> | |
| 611 | # include <__memory/allocator.h> | |
| 612 | # include <__memory/allocator_traits.h> | |
| 613 | # include <__memory/compressed_pair.h> | |
| 614 | # include <__memory/construct_at.h> | |
| 615 | # include <__memory/noexcept_move_assign_container.h> | |
| 616 | # include <__memory/pointer_traits.h> | |
| 617 | # include <__memory/swap_allocator.h> | |
| 618 | # include <__memory_resource/polymorphic_allocator.h> | |
| 619 | # include <__ranges/access.h> | |
| 620 | # include <__ranges/concepts.h> | |
| 621 | # include <__ranges/container_compatible_range.h> | |
| 622 | # include <__ranges/from_range.h> | |
| 623 | # include <__ranges/size.h> | |
| 624 | # include <__string/char_traits.h> | |
| 625 | # include <__string/extern_template_lists.h> | |
| 626 | # include <__type_traits/conditional.h> | |
| 627 | # include <__type_traits/enable_if.h> | |
| 628 | # include <__type_traits/is_allocator.h> | |
| 629 | # include <__type_traits/is_array.h> | |
| 630 | # include <__type_traits/is_convertible.h> | |
| 631 | # include <__type_traits/is_nothrow_assignable.h> | |
| 632 | # include <__type_traits/is_nothrow_constructible.h> | |
| 633 | # include <__type_traits/is_same.h> | |
| 634 | # include <__type_traits/is_standard_layout.h> | |
| 635 | # include <__type_traits/is_trivial.h> | |
| 636 | # include <__type_traits/is_trivially_relocatable.h> | |
| 637 | # include <__type_traits/remove_cvref.h> | |
| 638 | # include <__type_traits/void_t.h> | |
| 639 | # include <__utility/auto_cast.h> | |
| 640 | # include <__utility/declval.h> | |
| 641 | # include <__utility/forward.h> | |
| 642 | # include <__utility/is_pointer_in_range.h> | |
| 643 | # include <__utility/move.h> | |
| 644 | # include <__utility/scope_guard.h> | |
| 645 | # include <__utility/swap.h> | |
| 646 | # include <__utility/unreachable.h> | |
| 647 | # include <climits> | |
| 648 | # include <cstdio> // EOF | |
| 649 | # include <cstring> | |
| 650 | # include <limits> | |
| 651 | # include <stdexcept> | |
| 652 | # include <string_view> | |
| 653 | # include <version> | |
| 654 | ||
| 655 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 656 | # include <cwchar> | |
| 657 | # endif | |
| 653 | 658 | |
| 654 | 659 | // standard-mandated includes |
| 655 | 660 | |
| 656 | 661 | // [iterator.range] |
| 657 | #include <__iterator/access.h> | |
| 658 | #include <__iterator/data.h> | |
| 659 | #include <__iterator/empty.h> | |
| 660 | #include <__iterator/reverse_access.h> | |
| 661 | #include <__iterator/size.h> | |
| 662 | # include <__iterator/access.h> | |
| 663 | # include <__iterator/data.h> | |
| 664 | # include <__iterator/empty.h> | |
| 665 | # include <__iterator/reverse_access.h> | |
| 666 | # include <__iterator/size.h> | |
| 662 | 667 | |
| 663 | 668 | // [string.syn] |
| 664 | #include <compare> | |
| 665 | #include <initializer_list> | |
| 669 | # include <compare> | |
| 670 | # include <initializer_list> | |
| 666 | 671 | |
| 667 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 668 | # pragma GCC system_header | |
| 669 | #endif | |
| 672 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 673 | # pragma GCC system_header | |
| 674 | # endif | |
| 670 | 675 | |
| 671 | 676 | _LIBCPP_PUSH_MACROS |
| 672 | #include <__undef_macros> | |
| 677 | # include <__undef_macros> | |
| 673 | 678 | |
| 674 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | |
| 675 | # define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address"))) | |
| 679 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | |
| 680 | # define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address"))) | |
| 676 | 681 | // This macro disables AddressSanitizer (ASan) instrumentation for a specific function, |
| 677 | 682 | // allowing memory accesses that would normally trigger ASan errors to proceed without crashing. |
| 678 | 683 | // This is useful for accessing parts of objects memory, which should not be accessed, |
| 679 | 684 | // such as unused bytes in short strings, that should never be accessed |
| 680 | 685 | // by other parts of the program. |
| 681 | #else | |
| 682 | # define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS | |
| 683 | #endif | |
| 686 | # else | |
| 687 | # define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS | |
| 688 | # endif | |
| 684 | 689 | |
| 685 | 690 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 686 | 691 | |
| ... | ... | @@ -706,7 +711,7 @@ template <class _CharT, class _Traits, class _Allocator> |
| 706 | 711 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> |
| 707 | 712 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); |
| 708 | 713 | |
| 709 | #if _LIBCPP_STD_VER >= 26 | |
| 714 | # if _LIBCPP_STD_VER >= 26 | |
| 710 | 715 | |
| 711 | 716 | template <class _CharT, class _Traits, class _Allocator> |
| 712 | 717 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> |
| ... | ... | @@ -726,7 +731,7 @@ template <class _CharT, class _Traits, class _Allocator> |
| 726 | 731 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> |
| 727 | 732 | operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs); |
| 728 | 733 | |
| 729 | #endif | |
| 734 | # endif | |
| 730 | 735 | |
| 731 | 736 | extern template _LIBCPP_EXPORTED_FROM_ABI string operator+ |
| 732 | 737 | <char, char_traits<char>, allocator<char> >(char const*, string const&); |
| ... | ... | @@ -748,10 +753,18 @@ struct __can_be_converted_to_string_view |
| 748 | 753 | struct __uninitialized_size_tag {}; |
| 749 | 754 | struct __init_with_sentinel_tag {}; |
| 750 | 755 | |
| 756 | template <size_t _PaddingSize> | |
| 757 | struct __padding { | |
| 758 | char __padding_[_PaddingSize]; | |
| 759 | }; | |
| 760 | ||
| 761 | template <> | |
| 762 | struct __padding<0> {}; | |
| 763 | ||
| 751 | 764 | template <class _CharT, class _Traits, class _Allocator> |
| 752 | 765 | class basic_string { |
| 753 | 766 | private: |
| 754 | using __default_allocator_type = allocator<_CharT>; | |
| 767 | using __default_allocator_type _LIBCPP_NODEBUG = allocator<_CharT>; | |
| 755 | 768 | |
| 756 | 769 | public: |
| 757 | 770 | typedef basic_string __self; |
| ... | ... | @@ -776,7 +789,7 @@ public: |
| 776 | 789 | // |
| 777 | 790 | // This string implementation doesn't contain any references into itself. It only contains a bit that says whether |
| 778 | 791 | // 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) | |
| 792 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | |
| 780 | 793 | // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially |
| 781 | 794 | // relocatable. Because the object's memory might be poisoned when its content |
| 782 | 795 | // is kept inside objects memory (short string optimization), instead of in allocated |
| ... | ... | @@ -784,13 +797,14 @@ public: |
| 784 | 797 | // the memory to avoid triggering false positives. |
| 785 | 798 | // Therefore it's crucial to ensure the destructor is called. |
| 786 | 799 | using __trivially_relocatable = void; |
| 787 | #else | |
| 788 | using __trivially_relocatable = __conditional_t< | |
| 800 | # else | |
| 801 | using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t< | |
| 789 | 802 | __libcpp_is_trivially_relocatable<allocator_type>::value && __libcpp_is_trivially_relocatable<pointer>::value, |
| 790 | 803 | basic_string, |
| 791 | 804 | void>; |
| 792 | #endif | |
| 793 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | |
| 805 | # endif | |
| 806 | ||
| 807 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | |
| 794 | 808 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const { |
| 795 | 809 | if (__libcpp_is_constant_evaluated()) |
| 796 | 810 | return __ptr; |
| ... | ... | @@ -809,10 +823,10 @@ public: |
| 809 | 823 | |
| 810 | 824 | return const_cast<const_pointer&>(__copy_ptr); |
| 811 | 825 | } |
| 812 | # define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR) | |
| 813 | #else | |
| 814 | # define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR | |
| 815 | #endif | |
| 826 | # define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR) | |
| 827 | # else | |
| 828 | # define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR | |
| 829 | # endif | |
| 816 | 830 | |
| 817 | 831 | static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array"); |
| 818 | 832 | static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout"); |
| ... | ... | @@ -823,23 +837,23 @@ public: |
| 823 | 837 | "Allocator::value_type must be same type as value_type"); |
| 824 | 838 | static_assert(__check_valid_allocator<allocator_type>::value, ""); |
| 825 | 839 | |
| 826 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | |
| 840 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | |
| 827 | 841 | // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's |
| 828 | 842 | // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is |
| 829 | 843 | // considered contiguous. |
| 830 | typedef __bounded_iter<__wrap_iter<pointer>> iterator; | |
| 831 | typedef __bounded_iter<__wrap_iter<const_pointer>> const_iterator; | |
| 832 | #else | |
| 844 | typedef __bounded_iter<__wrap_iter<pointer> > iterator; | |
| 845 | typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator; | |
| 846 | # else | |
| 833 | 847 | typedef __wrap_iter<pointer> iterator; |
| 834 | 848 | typedef __wrap_iter<const_pointer> const_iterator; |
| 835 | #endif | |
| 849 | # endif | |
| 836 | 850 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 837 | 851 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 838 | 852 | |
| 839 | 853 | private: |
| 840 | 854 | static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits"); |
| 841 | 855 | |
| 842 | #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 856 | # ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 843 | 857 | |
| 844 | 858 | struct __long { |
| 845 | 859 | pointer __data_; |
| ... | ... | @@ -852,7 +866,7 @@ private: |
| 852 | 866 | |
| 853 | 867 | struct __short { |
| 854 | 868 | value_type __data_[__min_cap]; |
| 855 | unsigned char __padding_[sizeof(value_type) - 1]; | |
| 869 | _LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_; | |
| 856 | 870 | unsigned char __size_ : 7; |
| 857 | 871 | unsigned char __is_long_ : 1; |
| 858 | 872 | }; |
| ... | ... | @@ -870,19 +884,19 @@ private: |
| 870 | 884 | // This does not impact the short string representation, since we never need the MSB |
| 871 | 885 | // for representing the size of a short string anyway. |
| 872 | 886 | |
| 873 | # ifdef _LIBCPP_BIG_ENDIAN | |
| 887 | # ifdef _LIBCPP_BIG_ENDIAN | |
| 874 | 888 | static const size_type __endian_factor = 2; |
| 875 | # else | |
| 889 | # else | |
| 876 | 890 | static const size_type __endian_factor = 1; |
| 877 | # endif | |
| 891 | # endif | |
| 878 | 892 | |
| 879 | #else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 893 | # else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 880 | 894 | |
| 881 | # ifdef _LIBCPP_BIG_ENDIAN | |
| 895 | # ifdef _LIBCPP_BIG_ENDIAN | |
| 882 | 896 | static const size_type __endian_factor = 1; |
| 883 | # else | |
| 897 | # else | |
| 884 | 898 | static const size_type __endian_factor = 2; |
| 885 | # endif | |
| 899 | # endif | |
| 886 | 900 | |
| 887 | 901 | // Attribute 'packed' is used to keep the layout compatible with the |
| 888 | 902 | // previous definition that did not use bit fields. This is because on |
| ... | ... | @@ -904,11 +918,11 @@ private: |
| 904 | 918 | unsigned char __is_long_ : 1; |
| 905 | 919 | unsigned char __size_ : 7; |
| 906 | 920 | }; |
| 907 | char __padding_[sizeof(value_type) - 1]; | |
| 921 | _LIBCPP_NO_UNIQUE_ADDRESS __padding<sizeof(value_type) - 1> __padding_; | |
| 908 | 922 | value_type __data_[__min_cap]; |
| 909 | 923 | }; |
| 910 | 924 | |
| 911 | #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 925 | # endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 912 | 926 | |
| 913 | 927 | static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size."); |
| 914 | 928 | |
| ... | ... | @@ -917,22 +931,31 @@ private: |
| 917 | 931 | __long __l; |
| 918 | 932 | }; |
| 919 | 933 | |
| 920 | __compressed_pair<__rep, allocator_type> __r_; | |
| 934 | _LIBCPP_COMPRESSED_PAIR(__rep, __rep_, allocator_type, __alloc_); | |
| 935 | ||
| 936 | // annotate the string with its size() at scope exit. The string has to be in a valid state at that point. | |
| 937 | struct __annotate_new_size { | |
| 938 | basic_string& __str_; | |
| 939 | ||
| 940 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __annotate_new_size(basic_string& __str) : __str_(__str) {} | |
| 941 | ||
| 942 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()() { __str_.__annotate_new(__str_.size()); } | |
| 943 | }; | |
| 921 | 944 | |
| 922 | 945 | // Construct a string with the given allocator and enough storage to hold `__size` characters, but |
| 923 | 946 | // don't initialize the characters. The contents of the string, including the null terminator, must be |
| 924 | 947 | // initialized separately. |
| 925 | 948 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string( |
| 926 | 949 | __uninitialized_size_tag, size_type __size, const allocator_type& __a) |
| 927 | : __r_(__default_init_tag(), __a) { | |
| 950 | : __alloc_(__a) { | |
| 928 | 951 | if (__size > max_size()) |
| 929 | 952 | __throw_length_error(); |
| 930 | 953 | if (__fits_in_sso(__size)) { |
| 931 | __r_.first() = __rep(); | |
| 954 | __rep_ = __rep(); | |
| 932 | 955 | __set_short_size(__size); |
| 933 | 956 | } else { |
| 934 | 957 | auto __capacity = __recommend(__size) + 1; |
| 935 | auto __allocation = __alloc_traits::allocate(__alloc(), __capacity); | |
| 958 | auto __allocation = __alloc_traits::allocate(__alloc_, __capacity); | |
| 936 | 959 | __begin_lifetime(__allocation, __capacity); |
| 937 | 960 | __set_long_cap(__capacity); |
| 938 | 961 | __set_long_pointer(__allocation); |
| ... | ... | @@ -944,12 +967,12 @@ private: |
| 944 | 967 | template <class _Iter, class _Sent> |
| 945 | 968 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 946 | 969 | basic_string(__init_with_sentinel_tag, _Iter __first, _Sent __last, const allocator_type& __a) |
| 947 | : __r_(__default_init_tag(), __a) { | |
| 970 | : __alloc_(__a) { | |
| 948 | 971 | __init_with_sentinel(std::move(__first), std::move(__last)); |
| 949 | 972 | } |
| 950 | 973 | |
| 951 | 974 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) { |
| 952 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | |
| 975 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | |
| 953 | 976 | // Bound the iterator according to the size (and not the capacity, unlike vector). |
| 954 | 977 | // |
| 955 | 978 | // By the Standard, string iterators are generally not guaranteed to stay valid when the container is modified, |
| ... | ... | @@ -960,21 +983,21 @@ private: |
| 960 | 983 | std::__wrap_iter<pointer>(__p), |
| 961 | 984 | std::__wrap_iter<pointer>(__get_pointer()), |
| 962 | 985 | std::__wrap_iter<pointer>(__get_pointer() + size())); |
| 963 | #else | |
| 986 | # else | |
| 964 | 987 | return iterator(__p); |
| 965 | #endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | |
| 988 | # endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | |
| 966 | 989 | } |
| 967 | 990 | |
| 968 | 991 | _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 | |
| 992 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | |
| 970 | 993 | // Bound the iterator according to the size (and not the capacity, unlike vector). |
| 971 | 994 | return std::__make_bounded_iter( |
| 972 | 995 | std::__wrap_iter<const_pointer>(__p), |
| 973 | 996 | std::__wrap_iter<const_pointer>(__get_pointer()), |
| 974 | 997 | std::__wrap_iter<const_pointer>(__get_pointer() + size())); |
| 975 | #else | |
| 998 | # else | |
| 976 | 999 | return const_iterator(__p); |
| 977 | #endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | |
| 1000 | # endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING | |
| 978 | 1001 | } |
| 979 | 1002 | |
| 980 | 1003 | public: |
| ... | ... | @@ -982,24 +1005,24 @@ public: |
| 982 | 1005 | |
| 983 | 1006 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string() |
| 984 | 1007 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| 985 | : __r_(__value_init_tag(), __default_init_tag()) { | |
| 1008 | : __rep_() { | |
| 986 | 1009 | __annotate_new(0); |
| 987 | 1010 | } |
| 988 | 1011 | |
| 989 | 1012 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const allocator_type& __a) |
| 990 | #if _LIBCPP_STD_VER <= 14 | |
| 1013 | # if _LIBCPP_STD_VER <= 14 | |
| 991 | 1014 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) |
| 992 | #else | |
| 1015 | # else | |
| 993 | 1016 | _NOEXCEPT |
| 994 | #endif | |
| 995 | : __r_(__value_init_tag(), __a) { | |
| 1017 | # endif | |
| 1018 | : __rep_(), __alloc_(__a) { | |
| 996 | 1019 | __annotate_new(0); |
| 997 | 1020 | } |
| 998 | 1021 | |
| 999 | 1022 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& __str) |
| 1000 | : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) { | |
| 1023 | : __alloc_(__alloc_traits::select_on_container_copy_construction(__str.__alloc_)) { | |
| 1001 | 1024 | if (!__str.__is_long()) { |
| 1002 | __r_.first() = __str.__r_.first(); | |
| 1025 | __rep_ = __str.__rep_; | |
| 1003 | 1026 | __annotate_new(__get_short_size()); |
| 1004 | 1027 | } else |
| 1005 | 1028 | __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); |
| ... | ... | @@ -1007,119 +1030,115 @@ public: |
| 1007 | 1030 | |
| 1008 | 1031 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS |
| 1009 | 1032 | basic_string(const basic_string& __str, const allocator_type& __a) |
| 1010 | : __r_(__default_init_tag(), __a) { | |
| 1033 | : __alloc_(__a) { | |
| 1011 | 1034 | if (!__str.__is_long()) { |
| 1012 | __r_.first() = __str.__r_.first(); | |
| 1035 | __rep_ = __str.__rep_; | |
| 1013 | 1036 | __annotate_new(__get_short_size()); |
| 1014 | 1037 | } else |
| 1015 | 1038 | __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); |
| 1016 | 1039 | } |
| 1017 | 1040 | |
| 1018 | #ifndef _LIBCPP_CXX03_LANG | |
| 1041 | # ifndef _LIBCPP_CXX03_LANG | |
| 1019 | 1042 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str) |
| 1020 | # if _LIBCPP_STD_VER <= 14 | |
| 1043 | # if _LIBCPP_STD_VER <= 14 | |
| 1021 | 1044 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) |
| 1022 | # else | |
| 1045 | # else | |
| 1023 | 1046 | _NOEXCEPT |
| 1024 | # endif | |
| 1047 | # endif | |
| 1025 | 1048 | // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS |
| 1026 | 1049 | // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first. |
| 1027 | 1050 | // __str's memory needs to be unpoisoned only in the case where it's a short string. |
| 1028 | : __r_([](basic_string& __s) -> decltype(__s.__r_)&& { | |
| 1051 | : __rep_([](basic_string& __s) -> decltype(__s.__rep_)&& { | |
| 1029 | 1052 | if (!__s.__is_long()) |
| 1030 | 1053 | __s.__annotate_delete(); |
| 1031 | return std::move(__s.__r_); | |
| 1032 | }(__str)) { | |
| 1033 | __str.__r_.first() = __rep(); | |
| 1054 | return std::move(__s.__rep_); | |
| 1055 | }(__str)), | |
| 1056 | __alloc_(std::move(__str.__alloc_)) { | |
| 1057 | __str.__rep_ = __rep(); | |
| 1034 | 1058 | __str.__annotate_new(0); |
| 1035 | 1059 | if (!__is_long()) |
| 1036 | 1060 | __annotate_new(size()); |
| 1037 | 1061 | } |
| 1038 | 1062 | |
| 1039 | 1063 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str, const allocator_type& __a) |
| 1040 | : __r_(__default_init_tag(), __a) { | |
| 1041 | if (__str.__is_long() && __a != __str.__alloc()) // copy, not move | |
| 1064 | : __alloc_(__a) { | |
| 1065 | if (__str.__is_long() && __a != __str.__alloc_) // copy, not move | |
| 1042 | 1066 | __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); |
| 1043 | 1067 | else { |
| 1044 | 1068 | if (__libcpp_is_constant_evaluated()) |
| 1045 | __r_.first() = __rep(); | |
| 1069 | __rep_ = __rep(); | |
| 1046 | 1070 | if (!__str.__is_long()) |
| 1047 | 1071 | __str.__annotate_delete(); |
| 1048 | __r_.first() = __str.__r_.first(); | |
| 1049 | __str.__r_.first() = __rep(); | |
| 1072 | __rep_ = __str.__rep_; | |
| 1073 | __str.__rep_ = __rep(); | |
| 1050 | 1074 | __str.__annotate_new(0); |
| 1051 | if (!__is_long() && this != &__str) | |
| 1075 | if (!__is_long() && this != std::addressof(__str)) | |
| 1052 | 1076 | __annotate_new(size()); |
| 1053 | 1077 | } |
| 1054 | 1078 | } |
| 1055 | #endif // _LIBCPP_CXX03_LANG | |
| 1079 | # endif // _LIBCPP_CXX03_LANG | |
| 1056 | 1080 | |
| 1057 | 1081 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> |
| 1058 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) | |
| 1059 | : __r_(__default_init_tag(), __default_init_tag()) { | |
| 1082 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) { | |
| 1060 | 1083 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr"); |
| 1061 | 1084 | __init(__s, traits_type::length(__s)); |
| 1062 | 1085 | } |
| 1063 | 1086 | |
| 1064 | 1087 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> |
| 1065 | 1088 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a) |
| 1066 | : __r_(__default_init_tag(), __a) { | |
| 1089 | : __alloc_(__a) { | |
| 1067 | 1090 | _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); |
| 1068 | 1091 | __init(__s, traits_type::length(__s)); |
| 1069 | 1092 | } |
| 1070 | 1093 | |
| 1071 | #if _LIBCPP_STD_VER >= 23 | |
| 1094 | # if _LIBCPP_STD_VER >= 23 | |
| 1072 | 1095 | basic_string(nullptr_t) = delete; |
| 1073 | #endif | |
| 1096 | # endif | |
| 1074 | 1097 | |
| 1075 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) | |
| 1076 | : __r_(__default_init_tag(), __default_init_tag()) { | |
| 1098 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) { | |
| 1077 | 1099 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); |
| 1078 | 1100 | __init(__s, __n); |
| 1079 | 1101 | } |
| 1080 | 1102 | |
| 1081 | 1103 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1082 | 1104 | basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) |
| 1083 | : __r_(__default_init_tag(), __a) { | |
| 1105 | : __alloc_(__a) { | |
| 1084 | 1106 | _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); |
| 1085 | 1107 | __init(__s, __n); |
| 1086 | 1108 | } |
| 1087 | 1109 | |
| 1088 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c) | |
| 1089 | : __r_(__default_init_tag(), __default_init_tag()) { | |
| 1090 | __init(__n, __c); | |
| 1091 | } | |
| 1110 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c) { __init(__n, __c); } | |
| 1092 | 1111 | |
| 1093 | #if _LIBCPP_STD_VER >= 23 | |
| 1112 | # if _LIBCPP_STD_VER >= 23 | |
| 1094 | 1113 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string( |
| 1095 | 1114 | basic_string&& __str, size_type __pos, const _Allocator& __alloc = _Allocator()) |
| 1096 | 1115 | : basic_string(std::move(__str), __pos, npos, __alloc) {} |
| 1097 | 1116 | |
| 1098 | 1117 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string( |
| 1099 | 1118 | basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator()) |
| 1100 | : __r_(__default_init_tag(), __alloc) { | |
| 1119 | : __alloc_(__alloc) { | |
| 1101 | 1120 | if (__pos > __str.size()) |
| 1102 | 1121 | __throw_out_of_range(); |
| 1103 | 1122 | |
| 1104 | 1123 | auto __len = std::min<size_type>(__n, __str.size() - __pos); |
| 1105 | if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc()) { | |
| 1124 | if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc_) { | |
| 1106 | 1125 | __move_assign(std::move(__str), __pos, __len); |
| 1107 | 1126 | } else { |
| 1108 | 1127 | // Perform a copy because the allocators are not compatible. |
| 1109 | 1128 | __init(__str.data() + __pos, __len); |
| 1110 | 1129 | } |
| 1111 | 1130 | } |
| 1112 | #endif | |
| 1131 | # endif | |
| 1113 | 1132 | |
| 1114 | 1133 | template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0> |
| 1115 | 1134 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a) |
| 1116 | : __r_(__default_init_tag(), __a) { | |
| 1135 | : __alloc_(__a) { | |
| 1117 | 1136 | __init(__n, __c); |
| 1118 | 1137 | } |
| 1119 | 1138 | |
| 1120 | 1139 | _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1121 | 1140 | basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a = _Allocator()) |
| 1122 | : __r_(__default_init_tag(), __a) { | |
| 1141 | : __alloc_(__a) { | |
| 1123 | 1142 | size_type __str_sz = __str.size(); |
| 1124 | 1143 | if (__pos > __str_sz) |
| 1125 | 1144 | __throw_out_of_range(); |
| ... | ... | @@ -1128,7 +1147,7 @@ public: |
| 1128 | 1147 | |
| 1129 | 1148 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1130 | 1149 | basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a = _Allocator()) |
| 1131 | : __r_(__default_init_tag(), __a) { | |
| 1150 | : __alloc_(__a) { | |
| 1132 | 1151 | size_type __str_sz = __str.size(); |
| 1133 | 1152 | if (__pos > __str_sz) |
| 1134 | 1153 | __throw_out_of_range(); |
| ... | ... | @@ -1141,7 +1160,7 @@ public: |
| 1141 | 1160 | int> = 0> |
| 1142 | 1161 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1143 | 1162 | basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type()) |
| 1144 | : __r_(__default_init_tag(), __a) { | |
| 1163 | : __alloc_(__a) { | |
| 1145 | 1164 | __self_view __sv0 = __t; |
| 1146 | 1165 | __self_view __sv = __sv0.substr(__pos, __n); |
| 1147 | 1166 | __init(__sv.data(), __sv.size()); |
| ... | ... | @@ -1151,8 +1170,8 @@ public: |
| 1151 | 1170 | __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 1152 | 1171 | !__is_same_uncvref<_Tp, basic_string>::value, |
| 1153 | 1172 | int> = 0> |
| 1154 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) | |
| 1155 | : __r_(__default_init_tag(), __default_init_tag()) { | |
| 1173 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1174 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) { | |
| 1156 | 1175 | __self_view __sv = __t; |
| 1157 | 1176 | __init(__sv.data(), __sv.size()); |
| 1158 | 1177 | } |
| ... | ... | @@ -1163,57 +1182,55 @@ public: |
| 1163 | 1182 | int> = 0> |
| 1164 | 1183 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1165 | 1184 | _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a) |
| 1166 | : __r_(__default_init_tag(), __a) { | |
| 1185 | : __alloc_(__a) { | |
| 1167 | 1186 | __self_view __sv = __t; |
| 1168 | 1187 | __init(__sv.data(), __sv.size()); |
| 1169 | 1188 | } |
| 1170 | 1189 | |
| 1171 | 1190 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 1172 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last) | |
| 1173 | : __r_(__default_init_tag(), __default_init_tag()) { | |
| 1191 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last) { | |
| 1174 | 1192 | __init(__first, __last); |
| 1175 | 1193 | } |
| 1176 | 1194 | |
| 1177 | 1195 | template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> |
| 1178 | 1196 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 1179 | 1197 | basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a) |
| 1180 | : __r_(__default_init_tag(), __a) { | |
| 1198 | : __alloc_(__a) { | |
| 1181 | 1199 | __init(__first, __last); |
| 1182 | 1200 | } |
| 1183 | 1201 | |
| 1184 | #if _LIBCPP_STD_VER >= 23 | |
| 1202 | # if _LIBCPP_STD_VER >= 23 | |
| 1185 | 1203 | template <_ContainerCompatibleRange<_CharT> _Range> |
| 1186 | 1204 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string( |
| 1187 | 1205 | from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) |
| 1188 | : __r_(__default_init_tag(), __a) { | |
| 1206 | : __alloc_(__a) { | |
| 1189 | 1207 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { |
| 1190 | 1208 | __init_with_size(ranges::begin(__range), ranges::end(__range), ranges::distance(__range)); |
| 1191 | 1209 | } else { |
| 1192 | 1210 | __init_with_sentinel(ranges::begin(__range), ranges::end(__range)); |
| 1193 | 1211 | } |
| 1194 | 1212 | } |
| 1195 | #endif | |
| 1213 | # endif | |
| 1196 | 1214 | |
| 1197 | #ifndef _LIBCPP_CXX03_LANG | |
| 1198 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il) | |
| 1199 | : __r_(__default_init_tag(), __default_init_tag()) { | |
| 1215 | # ifndef _LIBCPP_CXX03_LANG | |
| 1216 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il) { | |
| 1200 | 1217 | __init(__il.begin(), __il.end()); |
| 1201 | 1218 | } |
| 1202 | 1219 | |
| 1203 | 1220 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il, const _Allocator& __a) |
| 1204 | : __r_(__default_init_tag(), __a) { | |
| 1221 | : __alloc_(__a) { | |
| 1205 | 1222 | __init(__il.begin(), __il.end()); |
| 1206 | 1223 | } |
| 1207 | #endif // _LIBCPP_CXX03_LANG | |
| 1224 | # endif // _LIBCPP_CXX03_LANG | |
| 1208 | 1225 | |
| 1209 | 1226 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 ~basic_string() { |
| 1210 | 1227 | __annotate_delete(); |
| 1211 | 1228 | if (__is_long()) |
| 1212 | __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); | |
| 1229 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | |
| 1213 | 1230 | } |
| 1214 | 1231 | |
| 1215 | 1232 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator __self_view() const _NOEXCEPT { |
| 1216 | return __self_view(data(), size()); | |
| 1233 | return __self_view(typename __self_view::__assume_valid(), data(), size()); | |
| 1217 | 1234 | } |
| 1218 | 1235 | |
| 1219 | 1236 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string& |
| ... | ... | @@ -1228,7 +1245,7 @@ public: |
| 1228 | 1245 | return assign(__sv); |
| 1229 | 1246 | } |
| 1230 | 1247 | |
| 1231 | #ifndef _LIBCPP_CXX03_LANG | |
| 1248 | # ifndef _LIBCPP_CXX03_LANG | |
| 1232 | 1249 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1233 | 1250 | operator=(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { |
| 1234 | 1251 | __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); |
| ... | ... | @@ -1238,13 +1255,13 @@ public: |
| 1238 | 1255 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(initializer_list<value_type> __il) { |
| 1239 | 1256 | return assign(__il.begin(), __il.size()); |
| 1240 | 1257 | } |
| 1241 | #endif | |
| 1258 | # endif | |
| 1242 | 1259 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const value_type* __s) { |
| 1243 | 1260 | return assign(__s); |
| 1244 | 1261 | } |
| 1245 | #if _LIBCPP_STD_VER >= 23 | |
| 1262 | # if _LIBCPP_STD_VER >= 23 | |
| 1246 | 1263 | basic_string& operator=(nullptr_t) = delete; |
| 1247 | #endif | |
| 1264 | # endif | |
| 1248 | 1265 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c); |
| 1249 | 1266 | |
| 1250 | 1267 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { |
| ... | ... | @@ -1286,7 +1303,7 @@ public: |
| 1286 | 1303 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT { return size(); } |
| 1287 | 1304 | |
| 1288 | 1305 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT { |
| 1289 | size_type __m = __alloc_traits::max_size(__alloc()); | |
| 1306 | size_type __m = __alloc_traits::max_size(__alloc_); | |
| 1290 | 1307 | if (__m <= std::numeric_limits<size_type>::max() / 2) { |
| 1291 | 1308 | return __m - __alignment; |
| 1292 | 1309 | } else { |
| ... | ... | @@ -1304,23 +1321,23 @@ public: |
| 1304 | 1321 | |
| 1305 | 1322 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __requested_capacity); |
| 1306 | 1323 | |
| 1307 | #if _LIBCPP_STD_VER >= 23 | |
| 1324 | # if _LIBCPP_STD_VER >= 23 | |
| 1308 | 1325 | template <class _Op> |
| 1309 | 1326 | _LIBCPP_HIDE_FROM_ABI constexpr void resize_and_overwrite(size_type __n, _Op __op) { |
| 1310 | 1327 | __resize_default_init(__n); |
| 1311 | 1328 | __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n))); |
| 1312 | 1329 | } |
| 1313 | #endif | |
| 1330 | # endif | |
| 1314 | 1331 | |
| 1315 | 1332 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __resize_default_init(size_type __n); |
| 1316 | 1333 | |
| 1317 | #if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE) | |
| 1334 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRING_RESERVE) | |
| 1318 | 1335 | _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); } |
| 1319 | #endif | |
| 1336 | # endif | |
| 1320 | 1337 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT; |
| 1321 | 1338 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT; |
| 1322 | 1339 | |
| 1323 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { | |
| 1340 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { | |
| 1324 | 1341 | return size() == 0; |
| 1325 | 1342 | } |
| 1326 | 1343 | |
| ... | ... | @@ -1366,11 +1383,11 @@ public: |
| 1366 | 1383 | return *this; |
| 1367 | 1384 | } |
| 1368 | 1385 | |
| 1369 | #ifndef _LIBCPP_CXX03_LANG | |
| 1386 | # ifndef _LIBCPP_CXX03_LANG | |
| 1370 | 1387 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(initializer_list<value_type> __il) { |
| 1371 | 1388 | return append(__il); |
| 1372 | 1389 | } |
| 1373 | #endif // _LIBCPP_CXX03_LANG | |
| 1390 | # endif // _LIBCPP_CXX03_LANG | |
| 1374 | 1391 | |
| 1375 | 1392 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const basic_string& __str) { |
| 1376 | 1393 | return append(__str.data(), __str.size()); |
| ... | ... | @@ -1406,7 +1423,7 @@ public: |
| 1406 | 1423 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> |
| 1407 | 1424 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1408 | 1425 | append(_InputIterator __first, _InputIterator __last) { |
| 1409 | const basic_string __temp(__first, __last, __alloc()); | |
| 1426 | const basic_string __temp(__first, __last, __alloc_); | |
| 1410 | 1427 | append(__temp.data(), __temp.size()); |
| 1411 | 1428 | return *this; |
| 1412 | 1429 | } |
| ... | ... | @@ -1415,19 +1432,19 @@ public: |
| 1415 | 1432 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1416 | 1433 | append(_ForwardIterator __first, _ForwardIterator __last); |
| 1417 | 1434 | |
| 1418 | #if _LIBCPP_STD_VER >= 23 | |
| 1435 | # if _LIBCPP_STD_VER >= 23 | |
| 1419 | 1436 | template <_ContainerCompatibleRange<_CharT> _Range> |
| 1420 | 1437 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string& append_range(_Range&& __range) { |
| 1421 | 1438 | insert_range(end(), std::forward<_Range>(__range)); |
| 1422 | 1439 | return *this; |
| 1423 | 1440 | } |
| 1424 | #endif | |
| 1441 | # endif | |
| 1425 | 1442 | |
| 1426 | #ifndef _LIBCPP_CXX03_LANG | |
| 1443 | # ifndef _LIBCPP_CXX03_LANG | |
| 1427 | 1444 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(initializer_list<value_type> __il) { |
| 1428 | 1445 | return append(__il.begin(), __il.size()); |
| 1429 | 1446 | } |
| 1430 | #endif // _LIBCPP_CXX03_LANG | |
| 1447 | # endif // _LIBCPP_CXX03_LANG | |
| 1431 | 1448 | |
| 1432 | 1449 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(value_type __c); |
| 1433 | 1450 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back(); |
| ... | ... | @@ -1459,15 +1476,15 @@ public: |
| 1459 | 1476 | return assign(__sv.data(), __sv.size()); |
| 1460 | 1477 | } |
| 1461 | 1478 | |
| 1462 | #if _LIBCPP_STD_VER >= 20 | |
| 1479 | # if _LIBCPP_STD_VER >= 20 | |
| 1463 | 1480 | _LIBCPP_HIDE_FROM_ABI constexpr void __move_assign(basic_string&& __str, size_type __pos, size_type __len) { |
| 1464 | 1481 | // Pilfer the allocation from __str. |
| 1465 | _LIBCPP_ASSERT_INTERNAL(__alloc() == __str.__alloc(), "__move_assign called with wrong allocator"); | |
| 1482 | _LIBCPP_ASSERT_INTERNAL(__alloc_ == __str.__alloc_, "__move_assign called with wrong allocator"); | |
| 1466 | 1483 | size_type __old_sz = __str.size(); |
| 1467 | 1484 | if (!__str.__is_long()) |
| 1468 | 1485 | __str.__annotate_delete(); |
| 1469 | __r_.first() = __str.__r_.first(); | |
| 1470 | __str.__r_.first() = __rep(); | |
| 1486 | __rep_ = __str.__rep_; | |
| 1487 | __str.__rep_ = __rep(); | |
| 1471 | 1488 | __str.__annotate_new(0); |
| 1472 | 1489 | |
| 1473 | 1490 | _Traits::move(data(), data() + __pos, __len); |
| ... | ... | @@ -1480,18 +1497,18 @@ public: |
| 1480 | 1497 | __annotate_shrink(__old_sz); |
| 1481 | 1498 | } |
| 1482 | 1499 | } |
| 1483 | #endif | |
| 1500 | # endif | |
| 1484 | 1501 | |
| 1485 | 1502 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str) { |
| 1486 | 1503 | return *this = __str; |
| 1487 | 1504 | } |
| 1488 | #ifndef _LIBCPP_CXX03_LANG | |
| 1505 | # ifndef _LIBCPP_CXX03_LANG | |
| 1489 | 1506 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1490 | 1507 | assign(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { |
| 1491 | 1508 | *this = std::move(__str); |
| 1492 | 1509 | return *this; |
| 1493 | 1510 | } |
| 1494 | #endif | |
| 1511 | # endif | |
| 1495 | 1512 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n = npos); |
| 1496 | 1513 | |
| 1497 | 1514 | template <class _Tp, |
| ... | ... | @@ -1512,7 +1529,7 @@ public: |
| 1512 | 1529 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1513 | 1530 | assign(_ForwardIterator __first, _ForwardIterator __last); |
| 1514 | 1531 | |
| 1515 | #if _LIBCPP_STD_VER >= 23 | |
| 1532 | # if _LIBCPP_STD_VER >= 23 | |
| 1516 | 1533 | template <_ContainerCompatibleRange<_CharT> _Range> |
| 1517 | 1534 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string& assign_range(_Range&& __range) { |
| 1518 | 1535 | if constexpr (__string_is_trivial_iterator<ranges::iterator_t<_Range>>::value && |
| ... | ... | @@ -1526,13 +1543,13 @@ public: |
| 1526 | 1543 | |
| 1527 | 1544 | return *this; |
| 1528 | 1545 | } |
| 1529 | #endif | |
| 1546 | # endif | |
| 1530 | 1547 | |
| 1531 | #ifndef _LIBCPP_CXX03_LANG | |
| 1548 | # ifndef _LIBCPP_CXX03_LANG | |
| 1532 | 1549 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(initializer_list<value_type> __il) { |
| 1533 | 1550 | return assign(__il.begin(), __il.size()); |
| 1534 | 1551 | } |
| 1535 | #endif // _LIBCPP_CXX03_LANG | |
| 1552 | # endif // _LIBCPP_CXX03_LANG | |
| 1536 | 1553 | |
| 1537 | 1554 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1538 | 1555 | insert(size_type __pos1, const basic_string& __str) { |
| ... | ... | @@ -1560,7 +1577,7 @@ public: |
| 1560 | 1577 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c); |
| 1561 | 1578 | _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c); |
| 1562 | 1579 | |
| 1563 | #if _LIBCPP_STD_VER >= 23 | |
| 1580 | # if _LIBCPP_STD_VER >= 23 | |
| 1564 | 1581 | template <_ContainerCompatibleRange<_CharT> _Range> |
| 1565 | 1582 | _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) { |
| 1566 | 1583 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { |
| ... | ... | @@ -1568,11 +1585,11 @@ public: |
| 1568 | 1585 | return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n); |
| 1569 | 1586 | |
| 1570 | 1587 | } else { |
| 1571 | basic_string __temp(from_range, std::forward<_Range>(__range), __alloc()); | |
| 1588 | basic_string __temp(from_range, std::forward<_Range>(__range), __alloc_); | |
| 1572 | 1589 | return insert(__position, __temp.data(), __temp.data() + __temp.size()); |
| 1573 | 1590 | } |
| 1574 | 1591 | } |
| 1575 | #endif | |
| 1592 | # endif | |
| 1576 | 1593 | |
| 1577 | 1594 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator |
| 1578 | 1595 | insert(const_iterator __pos, size_type __n, value_type __c) { |
| ... | ... | @@ -1589,12 +1606,12 @@ public: |
| 1589 | 1606 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator |
| 1590 | 1607 | insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); |
| 1591 | 1608 | |
| 1592 | #ifndef _LIBCPP_CXX03_LANG | |
| 1609 | # ifndef _LIBCPP_CXX03_LANG | |
| 1593 | 1610 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator |
| 1594 | 1611 | insert(const_iterator __pos, initializer_list<value_type> __il) { |
| 1595 | 1612 | return insert(__pos, __il.begin(), __il.end()); |
| 1596 | 1613 | } |
| 1597 | #endif // _LIBCPP_CXX03_LANG | |
| 1614 | # endif // _LIBCPP_CXX03_LANG | |
| 1598 | 1615 | |
| 1599 | 1616 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& erase(size_type __pos = 0, size_type __n = npos); |
| 1600 | 1617 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __pos); |
| ... | ... | @@ -1659,30 +1676,30 @@ public: |
| 1659 | 1676 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1660 | 1677 | replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); |
| 1661 | 1678 | |
| 1662 | #if _LIBCPP_STD_VER >= 23 | |
| 1679 | # if _LIBCPP_STD_VER >= 23 | |
| 1663 | 1680 | template <_ContainerCompatibleRange<_CharT> _Range> |
| 1664 | 1681 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string& |
| 1665 | 1682 | replace_with_range(const_iterator __i1, const_iterator __i2, _Range&& __range) { |
| 1666 | basic_string __temp(from_range, std::forward<_Range>(__range), __alloc()); | |
| 1683 | basic_string __temp(from_range, std::forward<_Range>(__range), __alloc_); | |
| 1667 | 1684 | return replace(__i1, __i2, __temp); |
| 1668 | 1685 | } |
| 1669 | #endif | |
| 1686 | # endif | |
| 1670 | 1687 | |
| 1671 | #ifndef _LIBCPP_CXX03_LANG | |
| 1688 | # ifndef _LIBCPP_CXX03_LANG | |
| 1672 | 1689 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& |
| 1673 | 1690 | replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il) { |
| 1674 | 1691 | return replace(__i1, __i2, __il.begin(), __il.end()); |
| 1675 | 1692 | } |
| 1676 | #endif // _LIBCPP_CXX03_LANG | |
| 1693 | # endif // _LIBCPP_CXX03_LANG | |
| 1677 | 1694 | |
| 1678 | 1695 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; |
| 1679 | 1696 | |
| 1680 | #if _LIBCPP_STD_VER <= 20 | |
| 1697 | # if _LIBCPP_STD_VER <= 20 | |
| 1681 | 1698 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string |
| 1682 | 1699 | substr(size_type __pos = 0, size_type __n = npos) const { |
| 1683 | 1700 | return basic_string(*this, __pos, __n); |
| 1684 | 1701 | } |
| 1685 | #else | |
| 1702 | # else | |
| 1686 | 1703 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) const& { |
| 1687 | 1704 | return basic_string(*this, __pos, __n); |
| 1688 | 1705 | } |
| ... | ... | @@ -1690,27 +1707,27 @@ public: |
| 1690 | 1707 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) && { |
| 1691 | 1708 | return basic_string(std::move(*this), __pos, __n); |
| 1692 | 1709 | } |
| 1693 | #endif | |
| 1710 | # endif | |
| 1694 | 1711 | |
| 1695 | 1712 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(basic_string& __str) |
| 1696 | #if _LIBCPP_STD_VER >= 14 | |
| 1713 | # if _LIBCPP_STD_VER >= 14 | |
| 1697 | 1714 | _NOEXCEPT; |
| 1698 | #else | |
| 1715 | # else | |
| 1699 | 1716 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); |
| 1700 | #endif | |
| 1717 | # endif | |
| 1701 | 1718 | |
| 1702 | 1719 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); } |
| 1703 | 1720 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT { |
| 1704 | 1721 | return std::__to_address(__get_pointer()); |
| 1705 | 1722 | } |
| 1706 | #if _LIBCPP_STD_VER >= 17 | |
| 1723 | # if _LIBCPP_STD_VER >= 17 | |
| 1707 | 1724 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 value_type* data() _NOEXCEPT { |
| 1708 | 1725 | return std::__to_address(__get_pointer()); |
| 1709 | 1726 | } |
| 1710 | #endif | |
| 1727 | # endif | |
| 1711 | 1728 | |
| 1712 | 1729 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT { |
| 1713 | return __alloc(); | |
| 1730 | return __alloc_; | |
| 1714 | 1731 | } |
| 1715 | 1732 | |
| 1716 | 1733 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type |
| ... | ... | @@ -1820,9 +1837,9 @@ public: |
| 1820 | 1837 | _LIBCPP_CONSTEXPR_SINCE_CXX20 int |
| 1821 | 1838 | compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; |
| 1822 | 1839 | |
| 1823 | #if _LIBCPP_STD_VER >= 20 | |
| 1840 | # if _LIBCPP_STD_VER >= 20 | |
| 1824 | 1841 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept { |
| 1825 | return __self_view(data(), size()).starts_with(__sv); | |
| 1842 | return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv); | |
| 1826 | 1843 | } |
| 1827 | 1844 | |
| 1828 | 1845 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(value_type __c) const noexcept { |
| ... | ... | @@ -1834,7 +1851,7 @@ public: |
| 1834 | 1851 | } |
| 1835 | 1852 | |
| 1836 | 1853 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept { |
| 1837 | return __self_view(data(), size()).ends_with(__sv); | |
| 1854 | return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv); | |
| 1838 | 1855 | } |
| 1839 | 1856 | |
| 1840 | 1857 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(value_type __c) const noexcept { |
| ... | ... | @@ -1844,52 +1861,47 @@ public: |
| 1844 | 1861 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept { |
| 1845 | 1862 | return ends_with(__self_view(__s)); |
| 1846 | 1863 | } |
| 1847 | #endif | |
| 1864 | # endif | |
| 1848 | 1865 | |
| 1849 | #if _LIBCPP_STD_VER >= 23 | |
| 1866 | # if _LIBCPP_STD_VER >= 23 | |
| 1850 | 1867 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept { |
| 1851 | return __self_view(data(), size()).contains(__sv); | |
| 1868 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv); | |
| 1852 | 1869 | } |
| 1853 | 1870 | |
| 1854 | 1871 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { |
| 1855 | return __self_view(data(), size()).contains(__c); | |
| 1872 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__c); | |
| 1856 | 1873 | } |
| 1857 | 1874 | |
| 1858 | 1875 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { |
| 1859 | return __self_view(data(), size()).contains(__s); | |
| 1876 | return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s); | |
| 1860 | 1877 | } |
| 1861 | #endif | |
| 1878 | # endif | |
| 1862 | 1879 | |
| 1863 | 1880 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const; |
| 1864 | 1881 | |
| 1865 | 1882 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __clear_and_shrink() _NOEXCEPT; |
| 1866 | 1883 | |
| 1867 | 1884 | private: |
| 1868 | template <class _Alloc> | |
| 1869 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool friend | |
| 1870 | operator==(const basic_string<char, char_traits<char>, _Alloc>& __lhs, | |
| 1871 | const basic_string<char, char_traits<char>, _Alloc>& __rhs) _NOEXCEPT; | |
| 1872 | ||
| 1873 | 1885 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __shrink_or_extend(size_type __target_capacity); |
| 1874 | 1886 | |
| 1875 | 1887 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS bool |
| 1876 | 1888 | __is_long() const _NOEXCEPT { |
| 1877 | if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__r_.first().__l.__is_long_)) { | |
| 1878 | return __r_.first().__l.__is_long_; | |
| 1889 | if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__rep_.__l.__is_long_)) { | |
| 1890 | return __rep_.__l.__is_long_; | |
| 1879 | 1891 | } |
| 1880 | return __r_.first().__s.__is_long_; | |
| 1892 | return __rep_.__s.__is_long_; | |
| 1881 | 1893 | } |
| 1882 | 1894 | |
| 1883 | 1895 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __begin_lifetime(pointer __begin, size_type __n) { |
| 1884 | #if _LIBCPP_STD_VER >= 20 | |
| 1896 | # if _LIBCPP_STD_VER >= 20 | |
| 1885 | 1897 | if (__libcpp_is_constant_evaluated()) { |
| 1886 | 1898 | for (size_type __i = 0; __i != __n; ++__i) |
| 1887 | 1899 | std::construct_at(std::addressof(__begin[__i])); |
| 1888 | 1900 | } |
| 1889 | #else | |
| 1901 | # else | |
| 1890 | 1902 | (void)__begin; |
| 1891 | 1903 | (void)__n; |
| 1892 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1904 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1893 | 1905 | } |
| 1894 | 1906 | |
| 1895 | 1907 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { return __sz < __min_cap; } |
| ... | ... | @@ -1905,13 +1917,17 @@ private: |
| 1905 | 1917 | template <class _ForwardIter, class _Sent> |
| 1906 | 1918 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static value_type* |
| 1907 | 1919 | __copy_non_overlapping_range(_ForwardIter __first, _Sent __last, value_type* __dest) { |
| 1908 | #ifndef _LIBCPP_CXX03_LANG | |
| 1920 | # ifndef _LIBCPP_CXX03_LANG | |
| 1909 | 1921 | if constexpr (__libcpp_is_contiguous_iterator<_ForwardIter>::value && |
| 1910 | is_same<value_type, __iter_value_type<_ForwardIter>>::value && is_same<_ForwardIter, _Sent>::value) { | |
| 1922 | is_same<value_type, __remove_cvref_t<decltype(*__first)>>::value && | |
| 1923 | is_same<_ForwardIter, _Sent>::value) { | |
| 1924 | _LIBCPP_ASSERT_INTERNAL( | |
| 1925 | !std::__is_overlapping_range(std::__to_address(__first), std::__to_address(__last), __dest), | |
| 1926 | "__copy_non_overlapping_range called with an overlapping range!"); | |
| 1911 | 1927 | traits_type::copy(__dest, std::__to_address(__first), __last - __first); |
| 1912 | 1928 | return __dest + (__last - __first); |
| 1913 | 1929 | } |
| 1914 | #endif | |
| 1930 | # endif | |
| 1915 | 1931 | |
| 1916 | 1932 | for (; __first != __last; ++__first) |
| 1917 | 1933 | traits_type::assign(*__dest++, *__first); |
| ... | ... | @@ -1937,7 +1953,7 @@ private: |
| 1937 | 1953 | __sz += __n; |
| 1938 | 1954 | __set_size(__sz); |
| 1939 | 1955 | traits_type::assign(__p[__sz], value_type()); |
| 1940 | __copy_non_overlapping_range(__first, __last, __p + __ip); | |
| 1956 | __copy_non_overlapping_range(std::move(__first), std::move(__last), __p + __ip); | |
| 1941 | 1957 | |
| 1942 | 1958 | return begin() + __ip; |
| 1943 | 1959 | } |
| ... | ... | @@ -1946,28 +1962,28 @@ private: |
| 1946 | 1962 | _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator |
| 1947 | 1963 | __insert_with_size(const_iterator __pos, _Iterator __first, _Sentinel __last, size_type __n); |
| 1948 | 1964 | |
| 1949 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); } | |
| 1950 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); } | |
| 1951 | ||
| 1952 | 1965 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void |
| 1953 | 1966 | __set_short_size(size_type __s) _NOEXCEPT { |
| 1954 | 1967 | _LIBCPP_ASSERT_INTERNAL(__s < __min_cap, "__s should never be greater than or equal to the short string capacity"); |
| 1955 | __r_.first().__s.__size_ = __s; | |
| 1956 | __r_.first().__s.__is_long_ = false; | |
| 1968 | __rep_.__s.__size_ = __s; | |
| 1969 | __rep_.__s.__is_long_ = false; | |
| 1957 | 1970 | } |
| 1958 | 1971 | |
| 1959 | 1972 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS size_type |
| 1960 | 1973 | __get_short_size() const _NOEXCEPT { |
| 1961 | _LIBCPP_ASSERT_INTERNAL(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size"); | |
| 1962 | return __r_.first().__s.__size_; | |
| 1974 | _LIBCPP_ASSERT_INTERNAL(!__rep_.__s.__is_long_, "String has to be short when trying to get the short size"); | |
| 1975 | return __rep_.__s.__size_; | |
| 1963 | 1976 | } |
| 1964 | 1977 | |
| 1965 | 1978 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_size(size_type __s) _NOEXCEPT { |
| 1966 | __r_.first().__l.__size_ = __s; | |
| 1979 | __rep_.__l.__size_ = __s; | |
| 1967 | 1980 | } |
| 1981 | ||
| 1968 | 1982 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_size() const _NOEXCEPT { |
| 1969 | return __r_.first().__l.__size_; | |
| 1983 | _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long size"); | |
| 1984 | return __rep_.__l.__size_; | |
| 1970 | 1985 | } |
| 1986 | ||
| 1971 | 1987 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_size(size_type __s) _NOEXCEPT { |
| 1972 | 1988 | if (__is_long()) |
| 1973 | 1989 | __set_long_size(__s); |
| ... | ... | @@ -1976,31 +1992,40 @@ private: |
| 1976 | 1992 | } |
| 1977 | 1993 | |
| 1978 | 1994 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_cap(size_type __s) _NOEXCEPT { |
| 1979 | __r_.first().__l.__cap_ = __s / __endian_factor; | |
| 1980 | __r_.first().__l.__is_long_ = true; | |
| 1995 | _LIBCPP_ASSERT_INTERNAL(!__fits_in_sso(__s), "Long capacity should always be larger than the SSO"); | |
| 1996 | __rep_.__l.__cap_ = __s / __endian_factor; | |
| 1997 | __rep_.__l.__is_long_ = true; | |
| 1981 | 1998 | } |
| 1982 | 1999 | |
| 1983 | 2000 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_long_cap() const _NOEXCEPT { |
| 1984 | return __r_.first().__l.__cap_ * __endian_factor; | |
| 2001 | _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long capacity"); | |
| 2002 | return __rep_.__l.__cap_ * __endian_factor; | |
| 1985 | 2003 | } |
| 1986 | 2004 | |
| 1987 | 2005 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_long_pointer(pointer __p) _NOEXCEPT { |
| 1988 | __r_.first().__l.__data_ = __p; | |
| 2006 | __rep_.__l.__data_ = __p; | |
| 1989 | 2007 | } |
| 2008 | ||
| 1990 | 2009 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT { |
| 1991 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_); | |
| 2010 | _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long pointer"); | |
| 2011 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_); | |
| 1992 | 2012 | } |
| 2013 | ||
| 1993 | 2014 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_long_pointer() const _NOEXCEPT { |
| 1994 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_); | |
| 2015 | _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long pointer"); | |
| 2016 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_); | |
| 1995 | 2017 | } |
| 2018 | ||
| 1996 | 2019 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS pointer |
| 1997 | 2020 | __get_short_pointer() _NOEXCEPT { |
| 1998 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0])); | |
| 2021 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__rep_.__s.__data_[0])); | |
| 1999 | 2022 | } |
| 2023 | ||
| 2000 | 2024 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS const_pointer |
| 2001 | 2025 | __get_short_pointer() const _NOEXCEPT { |
| 2002 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0])); | |
| 2026 | return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__rep_.__s.__data_[0])); | |
| 2003 | 2027 | } |
| 2028 | ||
| 2004 | 2029 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_pointer() _NOEXCEPT { |
| 2005 | 2030 | return __is_long() ? __get_long_pointer() : __get_short_pointer(); |
| 2006 | 2031 | } |
| ... | ... | @@ -2013,45 +2038,45 @@ private: |
| 2013 | 2038 | __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const { |
| 2014 | 2039 | (void)__old_mid; |
| 2015 | 2040 | (void)__new_mid; |
| 2016 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | |
| 2017 | #if defined(__APPLE__) | |
| 2041 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | |
| 2042 | # if defined(__APPLE__) | |
| 2018 | 2043 | // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099) |
| 2019 | if(!__is_long()) | |
| 2044 | if (!__is_long()) | |
| 2020 | 2045 | return; |
| 2021 | #endif | |
| 2046 | # endif | |
| 2022 | 2047 | std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid); |
| 2023 | #endif | |
| 2048 | # endif | |
| 2024 | 2049 | } |
| 2025 | 2050 | |
| 2026 | 2051 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT { |
| 2027 | 2052 | (void)__current_size; |
| 2028 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | |
| 2053 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | |
| 2029 | 2054 | if (!__libcpp_is_constant_evaluated()) |
| 2030 | 2055 | __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1); |
| 2031 | #endif | |
| 2056 | # endif | |
| 2032 | 2057 | } |
| 2033 | 2058 | |
| 2034 | 2059 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT { |
| 2035 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | |
| 2060 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | |
| 2036 | 2061 | if (!__libcpp_is_constant_evaluated()) |
| 2037 | 2062 | __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1); |
| 2038 | #endif | |
| 2063 | # endif | |
| 2039 | 2064 | } |
| 2040 | 2065 | |
| 2041 | 2066 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT { |
| 2042 | 2067 | (void)__n; |
| 2043 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | |
| 2068 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | |
| 2044 | 2069 | if (!__libcpp_is_constant_evaluated()) |
| 2045 | 2070 | __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n); |
| 2046 | #endif | |
| 2071 | # endif | |
| 2047 | 2072 | } |
| 2048 | 2073 | |
| 2049 | 2074 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT { |
| 2050 | 2075 | (void)__old_size; |
| 2051 | #if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) | |
| 2076 | # if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN | |
| 2052 | 2077 | if (!__libcpp_is_constant_evaluated()) |
| 2053 | 2078 | __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1); |
| 2054 | #endif | |
| 2079 | # endif | |
| 2055 | 2080 | } |
| 2056 | 2081 | |
| 2057 | 2082 | template <size_type __a> |
| ... | ... | @@ -2067,6 +2092,8 @@ private: |
| 2067 | 2092 | size_type __guess = __align_it<__boundary>(__s + 1) - 1; |
| 2068 | 2093 | if (__guess == __min_cap) |
| 2069 | 2094 | __guess += __endian_factor; |
| 2095 | ||
| 2096 | _LIBCPP_ASSERT_INTERNAL(__guess >= __s, "recommendation is below the requested size"); | |
| 2070 | 2097 | return __guess; |
| 2071 | 2098 | } |
| 2072 | 2099 | |
| ... | ... | @@ -2098,9 +2125,9 @@ private: |
| 2098 | 2125 | __init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz); |
| 2099 | 2126 | |
| 2100 | 2127 | _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 2101 | #if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 | |
| 2128 | # if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 | |
| 2102 | 2129 | _LIBCPP_HIDE_FROM_ABI |
| 2103 | #endif | |
| 2130 | # endif | |
| 2104 | 2131 | _LIBCPP_DEPRECATED_("use __grow_by_without_replace") void __grow_by( |
| 2105 | 2132 | size_type __old_cap, |
| 2106 | 2133 | size_type __delta_cap, |
| ... | ... | @@ -2131,6 +2158,7 @@ private: |
| 2131 | 2158 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string& __assign_no_alias(const value_type* __s, size_type __n); |
| 2132 | 2159 | |
| 2133 | 2160 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_to_end(size_type __pos) { |
| 2161 | _LIBCPP_ASSERT_INTERNAL(__pos <= capacity(), "Trying to erase at position outside the strings capacity!"); | |
| 2134 | 2162 | __null_terminate_at(std::__to_address(__get_pointer()), __pos); |
| 2135 | 2163 | } |
| 2136 | 2164 | |
| ... | ... | @@ -2144,24 +2172,24 @@ private: |
| 2144 | 2172 | } |
| 2145 | 2173 | |
| 2146 | 2174 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const basic_string& __str, true_type) { |
| 2147 | if (__alloc() == __str.__alloc()) | |
| 2148 | __alloc() = __str.__alloc(); | |
| 2175 | if (__alloc_ == __str.__alloc_) | |
| 2176 | __alloc_ = __str.__alloc_; | |
| 2149 | 2177 | else { |
| 2150 | 2178 | if (!__str.__is_long()) { |
| 2151 | 2179 | __clear_and_shrink(); |
| 2152 | __alloc() = __str.__alloc(); | |
| 2180 | __alloc_ = __str.__alloc_; | |
| 2153 | 2181 | } else { |
| 2154 | 2182 | __annotate_delete(); |
| 2155 | allocator_type __a = __str.__alloc(); | |
| 2183 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); | |
| 2184 | allocator_type __a = __str.__alloc_; | |
| 2156 | 2185 | auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap()); |
| 2157 | 2186 | __begin_lifetime(__allocation.ptr, __allocation.count); |
| 2158 | 2187 | if (__is_long()) |
| 2159 | __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); | |
| 2160 | __alloc() = std::move(__a); | |
| 2188 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | |
| 2189 | __alloc_ = std::move(__a); | |
| 2161 | 2190 | __set_long_pointer(__allocation.ptr); |
| 2162 | 2191 | __set_long_cap(__allocation.count); |
| 2163 | 2192 | __set_long_size(__str.size()); |
| 2164 | __annotate_new(__get_long_size()); | |
| 2165 | 2193 | } |
| 2166 | 2194 | } |
| 2167 | 2195 | } |
| ... | ... | @@ -2169,17 +2197,17 @@ private: |
| 2169 | 2197 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2170 | 2198 | __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {} |
| 2171 | 2199 | |
| 2172 | #ifndef _LIBCPP_CXX03_LANG | |
| 2200 | # ifndef _LIBCPP_CXX03_LANG | |
| 2173 | 2201 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2174 | 2202 | __move_assign(basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value); |
| 2175 | 2203 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void |
| 2176 | 2204 | __move_assign(basic_string& __str, true_type) |
| 2177 | # if _LIBCPP_STD_VER >= 17 | |
| 2205 | # if _LIBCPP_STD_VER >= 17 | |
| 2178 | 2206 | noexcept; |
| 2179 | # else | |
| 2207 | # else | |
| 2180 | 2208 | noexcept(is_nothrow_move_assignable<allocator_type>::value); |
| 2209 | # endif | |
| 2181 | 2210 | # endif |
| 2182 | #endif | |
| 2183 | 2211 | |
| 2184 | 2212 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string& __str) |
| 2185 | 2213 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value || |
| ... | ... | @@ -2190,7 +2218,7 @@ private: |
| 2190 | 2218 | |
| 2191 | 2219 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string& __c, true_type) |
| 2192 | 2220 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { |
| 2193 | __alloc() = std::move(__c.__alloc()); | |
| 2221 | __alloc_ = std::move(__c.__alloc_); | |
| 2194 | 2222 | } |
| 2195 | 2223 | |
| 2196 | 2224 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(basic_string&, false_type) _NOEXCEPT {} |
| ... | ... | @@ -2229,11 +2257,11 @@ private: |
| 2229 | 2257 | return std::__is_pointer_in_range(data(), data() + size() + 1, std::addressof(__v)); |
| 2230 | 2258 | } |
| 2231 | 2259 | |
| 2232 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { | |
| 2260 | [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_length_error() { | |
| 2233 | 2261 | std::__throw_length_error("basic_string"); |
| 2234 | 2262 | } |
| 2235 | 2263 | |
| 2236 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { | |
| 2264 | [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_out_of_range() { | |
| 2237 | 2265 | std::__throw_out_of_range("basic_string"); |
| 2238 | 2266 | } |
| 2239 | 2267 | |
| ... | ... | @@ -2242,29 +2270,33 @@ private: |
| 2242 | 2270 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&); |
| 2243 | 2271 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*); |
| 2244 | 2272 | friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type); |
| 2245 | #if _LIBCPP_STD_VER >= 26 | |
| 2273 | # if _LIBCPP_STD_VER >= 26 | |
| 2246 | 2274 | friend constexpr basic_string operator+ <>(const basic_string&, type_identity_t<__self_view>); |
| 2247 | 2275 | friend constexpr basic_string operator+ <>(type_identity_t<__self_view>, const basic_string&); |
| 2248 | #endif | |
| 2276 | # endif | |
| 2277 | ||
| 2278 | template <class _CharT2, class _Traits2, class _Allocator2> | |
| 2279 | friend inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool | |
| 2280 | operator==(const basic_string<_CharT2, _Traits2, _Allocator2>&, const _CharT2*) _NOEXCEPT; | |
| 2249 | 2281 | }; |
| 2250 | 2282 | |
| 2251 | 2283 | // These declarations must appear before any functions are implicitly used |
| 2252 | 2284 | // so that they have the correct visibility specifier. |
| 2253 | #define _LIBCPP_DECLARE(...) extern template __VA_ARGS__; | |
| 2254 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | |
| 2285 | # define _LIBCPP_DECLARE(...) extern template __VA_ARGS__; | |
| 2286 | # ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | |
| 2255 | 2287 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char) |
| 2256 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2288 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2257 | 2289 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t) |
| 2258 | # endif | |
| 2259 | #else | |
| 2290 | # endif | |
| 2291 | # else | |
| 2260 | 2292 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char) |
| 2261 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2293 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 2262 | 2294 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t) |
| 2295 | # endif | |
| 2263 | 2296 | # endif |
| 2264 | #endif | |
| 2265 | #undef _LIBCPP_DECLARE | |
| 2297 | # undef _LIBCPP_DECLARE | |
| 2266 | 2298 | |
| 2267 | #if _LIBCPP_STD_VER >= 17 | |
| 2299 | # if _LIBCPP_STD_VER >= 17 | |
| 2268 | 2300 | template <class _InputIterator, |
| 2269 | 2301 | class _CharT = __iter_value_type<_InputIterator>, |
| 2270 | 2302 | class _Allocator = allocator<_CharT>, |
| ... | ... | @@ -2287,21 +2319,21 @@ template <class _CharT, |
| 2287 | 2319 | class _Sz = typename allocator_traits<_Allocator>::size_type > |
| 2288 | 2320 | basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) |
| 2289 | 2321 | -> basic_string<_CharT, _Traits, _Allocator>; |
| 2290 | #endif | |
| 2322 | # endif | |
| 2291 | 2323 | |
| 2292 | #if _LIBCPP_STD_VER >= 23 | |
| 2324 | # if _LIBCPP_STD_VER >= 23 | |
| 2293 | 2325 | template <ranges::input_range _Range, |
| 2294 | 2326 | class _Allocator = allocator<ranges::range_value_t<_Range>>, |
| 2295 | 2327 | class = enable_if_t<__is_allocator<_Allocator>::value> > |
| 2296 | 2328 | basic_string(from_range_t, _Range&&, _Allocator = _Allocator()) |
| 2297 | 2329 | -> basic_string<ranges::range_value_t<_Range>, char_traits<ranges::range_value_t<_Range>>, _Allocator>; |
| 2298 | #endif | |
| 2330 | # endif | |
| 2299 | 2331 | |
| 2300 | 2332 | template <class _CharT, class _Traits, class _Allocator> |
| 2301 | 2333 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2302 | 2334 | basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) { |
| 2303 | 2335 | if (__libcpp_is_constant_evaluated()) |
| 2304 | __r_.first() = __rep(); | |
| 2336 | __rep_ = __rep(); | |
| 2305 | 2337 | if (__reserve > max_size()) |
| 2306 | 2338 | __throw_length_error(); |
| 2307 | 2339 | pointer __p; |
| ... | ... | @@ -2309,7 +2341,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty |
| 2309 | 2341 | __set_short_size(__sz); |
| 2310 | 2342 | __p = __get_short_pointer(); |
| 2311 | 2343 | } else { |
| 2312 | auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__reserve) + 1); | |
| 2344 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__reserve) + 1); | |
| 2313 | 2345 | __p = __allocation.ptr; |
| 2314 | 2346 | __begin_lifetime(__p, __allocation.count); |
| 2315 | 2347 | __set_long_pointer(__p); |
| ... | ... | @@ -2325,7 +2357,7 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2325 | 2357 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2326 | 2358 | basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) { |
| 2327 | 2359 | if (__libcpp_is_constant_evaluated()) |
| 2328 | __r_.first() = __rep(); | |
| 2360 | __rep_ = __rep(); | |
| 2329 | 2361 | if (__sz > max_size()) |
| 2330 | 2362 | __throw_length_error(); |
| 2331 | 2363 | pointer __p; |
| ... | ... | @@ -2333,7 +2365,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty |
| 2333 | 2365 | __set_short_size(__sz); |
| 2334 | 2366 | __p = __get_short_pointer(); |
| 2335 | 2367 | } else { |
| 2336 | auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); | |
| 2368 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1); | |
| 2337 | 2369 | __p = __allocation.ptr; |
| 2338 | 2370 | __begin_lifetime(__p, __allocation.count); |
| 2339 | 2371 | __set_long_pointer(__p); |
| ... | ... | @@ -2349,7 +2381,7 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2349 | 2381 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE void |
| 2350 | 2382 | basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value_type* __s, size_type __sz) { |
| 2351 | 2383 | if (__libcpp_is_constant_evaluated()) |
| 2352 | __r_.first() = __rep(); | |
| 2384 | __rep_ = __rep(); | |
| 2353 | 2385 | |
| 2354 | 2386 | pointer __p; |
| 2355 | 2387 | if (__fits_in_sso(__sz)) { |
| ... | ... | @@ -2358,7 +2390,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value |
| 2358 | 2390 | } else { |
| 2359 | 2391 | if (__sz > max_size()) |
| 2360 | 2392 | __throw_length_error(); |
| 2361 | auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); | |
| 2393 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1); | |
| 2362 | 2394 | __p = __allocation.ptr; |
| 2363 | 2395 | __begin_lifetime(__p, __allocation.count); |
| 2364 | 2396 | __set_long_pointer(__p); |
| ... | ... | @@ -2372,7 +2404,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value |
| 2372 | 2404 | template <class _CharT, class _Traits, class _Allocator> |
| 2373 | 2405 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) { |
| 2374 | 2406 | if (__libcpp_is_constant_evaluated()) |
| 2375 | __r_.first() = __rep(); | |
| 2407 | __rep_ = __rep(); | |
| 2376 | 2408 | |
| 2377 | 2409 | if (__n > max_size()) |
| 2378 | 2410 | __throw_length_error(); |
| ... | ... | @@ -2381,7 +2413,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ |
| 2381 | 2413 | __set_short_size(__n); |
| 2382 | 2414 | __p = __get_short_pointer(); |
| 2383 | 2415 | } else { |
| 2384 | auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__n) + 1); | |
| 2416 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__n) + 1); | |
| 2385 | 2417 | __p = __allocation.ptr; |
| 2386 | 2418 | __begin_lifetime(__p, __allocation.count); |
| 2387 | 2419 | __set_long_pointer(__p); |
| ... | ... | @@ -2404,22 +2436,22 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2404 | 2436 | template <class _InputIterator, class _Sentinel> |
| 2405 | 2437 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2406 | 2438 | basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator __first, _Sentinel __last) { |
| 2407 | __r_.first() = __rep(); | |
| 2439 | __rep_ = __rep(); | |
| 2408 | 2440 | __annotate_new(0); |
| 2409 | 2441 | |
| 2410 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2442 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2411 | 2443 | try { |
| 2412 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2444 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2413 | 2445 | for (; __first != __last; ++__first) |
| 2414 | 2446 | push_back(*__first); |
| 2415 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2447 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2416 | 2448 | } catch (...) { |
| 2417 | 2449 | __annotate_delete(); |
| 2418 | 2450 | if (__is_long()) |
| 2419 | __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); | |
| 2451 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | |
| 2420 | 2452 | throw; |
| 2421 | 2453 | } |
| 2422 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2454 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2423 | 2455 | } |
| 2424 | 2456 | |
| 2425 | 2457 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2435,7 +2467,7 @@ template <class _InputIterator, class _Sentinel> |
| 2435 | 2467 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2436 | 2468 | basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __first, _Sentinel __last, size_type __sz) { |
| 2437 | 2469 | if (__libcpp_is_constant_evaluated()) |
| 2438 | __r_.first() = __rep(); | |
| 2470 | __rep_ = __rep(); | |
| 2439 | 2471 | |
| 2440 | 2472 | if (__sz > max_size()) |
| 2441 | 2473 | __throw_length_error(); |
| ... | ... | @@ -2446,7 +2478,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir |
| 2446 | 2478 | __p = __get_short_pointer(); |
| 2447 | 2479 | |
| 2448 | 2480 | } else { |
| 2449 | auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); | |
| 2481 | auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1); | |
| 2450 | 2482 | __p = __allocation.ptr; |
| 2451 | 2483 | __begin_lifetime(__p, __allocation.count); |
| 2452 | 2484 | __set_long_pointer(__p); |
| ... | ... | @@ -2454,18 +2486,18 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir |
| 2454 | 2486 | __set_long_size(__sz); |
| 2455 | 2487 | } |
| 2456 | 2488 | |
| 2457 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2489 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2458 | 2490 | try { |
| 2459 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2460 | auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__p)); | |
| 2491 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2492 | auto __end = __copy_non_overlapping_range(std::move(__first), std::move(__last), std::__to_address(__p)); | |
| 2461 | 2493 | traits_type::assign(*__end, value_type()); |
| 2462 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2494 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2463 | 2495 | } catch (...) { |
| 2464 | 2496 | if (__is_long()) |
| 2465 | __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); | |
| 2497 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | |
| 2466 | 2498 | throw; |
| 2467 | 2499 | } |
| 2468 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2500 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2469 | 2501 | __annotate_new(__sz); |
| 2470 | 2502 | } |
| 2471 | 2503 | |
| ... | ... | @@ -2485,7 +2517,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ |
| 2485 | 2517 | size_type __cap = |
| 2486 | 2518 | __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1; |
| 2487 | 2519 | __annotate_delete(); |
| 2488 | auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1); | |
| 2520 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); | |
| 2521 | auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1); | |
| 2489 | 2522 | pointer __p = __allocation.ptr; |
| 2490 | 2523 | __begin_lifetime(__p, __allocation.count); |
| 2491 | 2524 | if (__n_copy != 0) |
| ... | ... | @@ -2497,13 +2530,12 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ |
| 2497 | 2530 | traits_type::copy( |
| 2498 | 2531 | std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); |
| 2499 | 2532 | if (__old_cap + 1 != __min_cap) |
| 2500 | __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1); | |
| 2533 | __alloc_traits::deallocate(__alloc_, __old_p, __old_cap + 1); | |
| 2501 | 2534 | __set_long_pointer(__p); |
| 2502 | 2535 | __set_long_cap(__allocation.count); |
| 2503 | 2536 | __old_sz = __n_copy + __n_add + __sec_cp_sz; |
| 2504 | 2537 | __set_long_size(__old_sz); |
| 2505 | 2538 | traits_type::assign(__p[__old_sz], value_type()); |
| 2506 | __annotate_new(__old_sz); | |
| 2507 | 2539 | } |
| 2508 | 2540 | |
| 2509 | 2541 | // __grow_by is deprecated because it does not set the size. It may not update the size when the size is changed, and it |
| ... | ... | @@ -2511,9 +2543,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__ |
| 2511 | 2543 | // not removed or changed to avoid breaking the ABI. |
| 2512 | 2544 | template <class _CharT, class _Traits, class _Allocator> |
| 2513 | 2545 | void _LIBCPP_CONSTEXPR_SINCE_CXX20 |
| 2514 | #if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 | |
| 2546 | # if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1 | |
| 2515 | 2547 | _LIBCPP_HIDE_FROM_ABI |
| 2516 | #endif | |
| 2548 | # endif | |
| 2517 | 2549 | _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Traits, _Allocator>::__grow_by( |
| 2518 | 2550 | size_type __old_cap, |
| 2519 | 2551 | size_type __delta_cap, |
| ... | ... | @@ -2527,8 +2559,7 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait |
| 2527 | 2559 | pointer __old_p = __get_pointer(); |
| 2528 | 2560 | size_type __cap = |
| 2529 | 2561 | __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1; |
| 2530 | __annotate_delete(); | |
| 2531 | auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1); | |
| 2562 | auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1); | |
| 2532 | 2563 | pointer __p = __allocation.ptr; |
| 2533 | 2564 | __begin_lifetime(__p, __allocation.count); |
| 2534 | 2565 | if (__n_copy != 0) |
| ... | ... | @@ -2538,7 +2569,7 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait |
| 2538 | 2569 | traits_type::copy( |
| 2539 | 2570 | std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); |
| 2540 | 2571 | if (__old_cap + 1 != __min_cap) |
| 2541 | __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1); | |
| 2572 | __alloc_traits::deallocate(__alloc_, __old_p, __old_cap + 1); | |
| 2542 | 2573 | __set_long_pointer(__p); |
| 2543 | 2574 | __set_long_cap(__allocation.count); |
| 2544 | 2575 | } |
| ... | ... | @@ -2552,11 +2583,12 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_without_replace( |
| 2552 | 2583 | size_type __n_copy, |
| 2553 | 2584 | size_type __n_del, |
| 2554 | 2585 | size_type __n_add) { |
| 2586 | __annotate_delete(); | |
| 2587 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); | |
| 2555 | 2588 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 2556 | 2589 | __grow_by(__old_cap, __delta_cap, __old_sz, __n_copy, __n_del, __n_add); |
| 2557 | 2590 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 2558 | 2591 | __set_long_size(__old_sz - __n_del + __n_add); |
| 2559 | __annotate_new(__old_sz - __n_del + __n_add); | |
| 2560 | 2592 | } |
| 2561 | 2593 | |
| 2562 | 2594 | // assign |
| ... | ... | @@ -2655,7 +2687,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) |
| 2655 | 2687 | size_type __old_size = __get_short_size(); |
| 2656 | 2688 | if (__get_short_size() < __str.__get_short_size()) |
| 2657 | 2689 | __annotate_increase(__str.__get_short_size() - __get_short_size()); |
| 2658 | __r_.first() = __str.__r_.first(); | |
| 2690 | __rep_ = __str.__rep_; | |
| 2659 | 2691 | if (__old_size > __get_short_size()) |
| 2660 | 2692 | __annotate_shrink(__old_size); |
| 2661 | 2693 | } else { |
| ... | ... | @@ -2668,12 +2700,12 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) |
| 2668 | 2700 | return *this; |
| 2669 | 2701 | } |
| 2670 | 2702 | |
| 2671 | #ifndef _LIBCPP_CXX03_LANG | |
| 2703 | # ifndef _LIBCPP_CXX03_LANG | |
| 2672 | 2704 | |
| 2673 | 2705 | template <class _CharT, class _Traits, class _Allocator> |
| 2674 | 2706 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__move_assign( |
| 2675 | 2707 | basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value) { |
| 2676 | if (__alloc() != __str.__alloc()) | |
| 2708 | if (__alloc_ != __str.__alloc_) | |
| 2677 | 2709 | assign(__str); |
| 2678 | 2710 | else |
| 2679 | 2711 | __move_assign(__str, true_type()); |
| ... | ... | @@ -2682,32 +2714,32 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat |
| 2682 | 2714 | template <class _CharT, class _Traits, class _Allocator> |
| 2683 | 2715 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void |
| 2684 | 2716 | basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) |
| 2685 | # if _LIBCPP_STD_VER >= 17 | |
| 2717 | # if _LIBCPP_STD_VER >= 17 | |
| 2686 | 2718 | noexcept |
| 2687 | # else | |
| 2719 | # else | |
| 2688 | 2720 | noexcept(is_nothrow_move_assignable<allocator_type>::value) |
| 2689 | # endif | |
| 2721 | # endif | |
| 2690 | 2722 | { |
| 2691 | 2723 | __annotate_delete(); |
| 2692 | 2724 | if (__is_long()) { |
| 2693 | __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); | |
| 2694 | # if _LIBCPP_STD_VER <= 14 | |
| 2725 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); | |
| 2726 | # if _LIBCPP_STD_VER <= 14 | |
| 2695 | 2727 | if (!is_nothrow_move_assignable<allocator_type>::value) { |
| 2696 | 2728 | __set_short_size(0); |
| 2697 | 2729 | traits_type::assign(__get_short_pointer()[0], value_type()); |
| 2698 | 2730 | __annotate_new(0); |
| 2699 | 2731 | } |
| 2700 | # endif | |
| 2732 | # endif | |
| 2701 | 2733 | } |
| 2702 | 2734 | size_type __str_old_size = __str.size(); |
| 2703 | 2735 | bool __str_was_short = !__str.__is_long(); |
| 2704 | 2736 | |
| 2705 | 2737 | __move_assign_alloc(__str); |
| 2706 | __r_.first() = __str.__r_.first(); | |
| 2738 | __rep_ = __str.__rep_; | |
| 2707 | 2739 | __str.__set_short_size(0); |
| 2708 | 2740 | traits_type::assign(__str.__get_short_pointer()[0], value_type()); |
| 2709 | 2741 | |
| 2710 | if (__str_was_short && this != &__str) | |
| 2742 | if (__str_was_short && this != std::addressof(__str)) | |
| 2711 | 2743 | __str.__annotate_shrink(__str_old_size); |
| 2712 | 2744 | else |
| 2713 | 2745 | // ASan annotations: was long, so object memory is unpoisoned as new. |
| ... | ... | @@ -2721,12 +2753,12 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr |
| 2721 | 2753 | // invariants hold (so functions without preconditions, such as the assignment operator, |
| 2722 | 2754 | // can be safely used on the object after it was moved from):" |
| 2723 | 2755 | // Quote: "v = std::move(v); // the value of v is unspecified" |
| 2724 | if (!__is_long() && &__str != this) | |
| 2756 | if (!__is_long() && std::addressof(__str) != this) | |
| 2725 | 2757 | // If it is long string, delete was never called on original __str's buffer. |
| 2726 | 2758 | __annotate_new(__get_short_size()); |
| 2727 | 2759 | } |
| 2728 | 2760 | |
| 2729 | #endif | |
| 2761 | # endif | |
| 2730 | 2762 | |
| 2731 | 2763 | template <class _CharT, class _Traits, class _Allocator> |
| 2732 | 2764 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > |
| ... | ... | @@ -2740,7 +2772,7 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2740 | 2772 | template <class _InputIterator, class _Sentinel> |
| 2741 | 2773 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 2742 | 2774 | basic_string<_CharT, _Traits, _Allocator>::__assign_with_sentinel(_InputIterator __first, _Sentinel __last) { |
| 2743 | const basic_string __temp(__init_with_sentinel_tag(), std::move(__first), std::move(__last), __alloc()); | |
| 2775 | const basic_string __temp(__init_with_sentinel_tag(), std::move(__first), std::move(__last), __alloc_); | |
| 2744 | 2776 | assign(__temp.data(), __temp.size()); |
| 2745 | 2777 | } |
| 2746 | 2778 | |
| ... | ... | @@ -2928,7 +2960,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _For |
| 2928 | 2960 | traits_type::assign(*__end, value_type()); |
| 2929 | 2961 | __set_size(__sz + __n); |
| 2930 | 2962 | } else { |
| 2931 | const basic_string __temp(__first, __last, __alloc()); | |
| 2963 | const basic_string __temp(__first, __last, __alloc_); | |
| 2932 | 2964 | append(__temp.data(), __temp.size()); |
| 2933 | 2965 | } |
| 2934 | 2966 | } |
| ... | ... | @@ -3026,7 +3058,7 @@ template <class _CharT, class _Traits, class _Allocator> |
| 3026 | 3058 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > |
| 3027 | 3059 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 3028 | 3060 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) { |
| 3029 | const basic_string __temp(__first, __last, __alloc()); | |
| 3061 | const basic_string __temp(__first, __last, __alloc_); | |
| 3030 | 3062 | return insert(__pos, __temp.data(), __temp.data() + __temp.size()); |
| 3031 | 3063 | } |
| 3032 | 3064 | |
| ... | ... | @@ -3049,9 +3081,9 @@ basic_string<_CharT, _Traits, _Allocator>::__insert_with_size( |
| 3049 | 3081 | return begin() + __ip; |
| 3050 | 3082 | |
| 3051 | 3083 | if (__string_is_trivial_iterator<_Iterator>::value && !__addr_in_range(*__first)) { |
| 3052 | return __insert_from_safe_copy(__n, __ip, __first, __last); | |
| 3084 | return __insert_from_safe_copy(__n, __ip, std::move(__first), std::move(__last)); | |
| 3053 | 3085 | } else { |
| 3054 | const basic_string __temp(__init_with_sentinel_tag(), __first, __last, __alloc()); | |
| 3086 | const basic_string __temp(__init_with_sentinel_tag(), std::move(__first), std::move(__last), __alloc_); | |
| 3055 | 3087 | return __insert_from_safe_copy(__n, __ip, __temp.begin(), __temp.end()); |
| 3056 | 3088 | } |
| 3057 | 3089 | } |
| ... | ... | @@ -3188,7 +3220,7 @@ template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_Inp |
| 3188 | 3220 | _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>& |
| 3189 | 3221 | basic_string<_CharT, _Traits, _Allocator>::replace( |
| 3190 | 3222 | const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) { |
| 3191 | const basic_string __temp(__j1, __j2, __alloc()); | |
| 3223 | const basic_string __temp(__j1, __j2, __alloc_); | |
| 3192 | 3224 | return replace(__i1, __i2, __temp); |
| 3193 | 3225 | } |
| 3194 | 3226 | |
| ... | ... | @@ -3325,12 +3357,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re |
| 3325 | 3357 | if (__requested_capacity <= capacity()) |
| 3326 | 3358 | return; |
| 3327 | 3359 | |
| 3328 | size_type __target_capacity = std::max(__requested_capacity, size()); | |
| 3329 | __target_capacity = __recommend(__target_capacity); | |
| 3330 | if (__target_capacity == capacity()) | |
| 3331 | return; | |
| 3332 | ||
| 3333 | __shrink_or_extend(__target_capacity); | |
| 3360 | __shrink_or_extend(__recommend(__requested_capacity)); | |
| 3334 | 3361 | } |
| 3335 | 3362 | |
| 3336 | 3363 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -3346,6 +3373,7 @@ template <class _CharT, class _Traits, class _Allocator> |
| 3346 | 3373 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void |
| 3347 | 3374 | basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) { |
| 3348 | 3375 | __annotate_delete(); |
| 3376 | auto __guard = std::__make_scope_guard(__annotate_new_size(*this)); | |
| 3349 | 3377 | size_type __cap = capacity(); |
| 3350 | 3378 | size_type __sz = size(); |
| 3351 | 3379 | |
| ... | ... | @@ -3360,33 +3388,32 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target |
| 3360 | 3388 | if (__target_capacity > __cap) { |
| 3361 | 3389 | // Extend |
| 3362 | 3390 | // - called from reserve should propagate the exception thrown. |
| 3363 | auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); | |
| 3391 | auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1); | |
| 3364 | 3392 | __new_data = __allocation.ptr; |
| 3365 | 3393 | __target_capacity = __allocation.count - 1; |
| 3366 | 3394 | } else { |
| 3367 | 3395 | // Shrink |
| 3368 | 3396 | // - called from shrink_to_fit should not throw. |
| 3369 | 3397 | // - called from reserve may throw but is not required to. |
| 3370 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 3398 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 3371 | 3399 | try { |
| 3372 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 3373 | auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); | |
| 3400 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 3401 | auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1); | |
| 3374 | 3402 | |
| 3375 | 3403 | // The Standard mandates shrink_to_fit() does not increase the capacity. |
| 3376 | 3404 | // With equal capacity keep the existing buffer. This avoids extra work |
| 3377 | 3405 | // 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() | |
| 3406 | if (__allocation.count - 1 > capacity()) { | |
| 3407 | __alloc_traits::deallocate(__alloc_, __allocation.ptr, __allocation.count); | |
| 3381 | 3408 | return; |
| 3382 | 3409 | } |
| 3383 | 3410 | __new_data = __allocation.ptr; |
| 3384 | 3411 | __target_capacity = __allocation.count - 1; |
| 3385 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 3412 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 3386 | 3413 | } catch (...) { |
| 3387 | 3414 | return; |
| 3388 | 3415 | } |
| 3389 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 3416 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 3390 | 3417 | } |
| 3391 | 3418 | __begin_lifetime(__new_data, __target_capacity + 1); |
| 3392 | 3419 | __now_long = true; |
| ... | ... | @@ -3395,14 +3422,13 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target |
| 3395 | 3422 | } |
| 3396 | 3423 | traits_type::copy(std::__to_address(__new_data), std::__to_address(__p), size() + 1); |
| 3397 | 3424 | if (__was_long) |
| 3398 | __alloc_traits::deallocate(__alloc(), __p, __cap + 1); | |
| 3425 | __alloc_traits::deallocate(__alloc_, __p, __cap + 1); | |
| 3399 | 3426 | if (__now_long) { |
| 3400 | 3427 | __set_long_cap(__target_capacity + 1); |
| 3401 | 3428 | __set_long_size(__sz); |
| 3402 | 3429 | __set_long_pointer(__new_data); |
| 3403 | 3430 | } else |
| 3404 | 3431 | __set_short_size(__sz); |
| 3405 | __annotate_new(__sz); | |
| 3406 | 3432 | } |
| 3407 | 3433 | |
| 3408 | 3434 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -3434,38 +3460,30 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, |
| 3434 | 3460 | |
| 3435 | 3461 | template <class _CharT, class _Traits, class _Allocator> |
| 3436 | 3462 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) |
| 3437 | #if _LIBCPP_STD_VER >= 14 | |
| 3463 | # if _LIBCPP_STD_VER >= 14 | |
| 3438 | 3464 | _NOEXCEPT |
| 3439 | #else | |
| 3465 | # else | |
| 3440 | 3466 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) |
| 3441 | #endif | |
| 3467 | # endif | |
| 3442 | 3468 | { |
| 3443 | 3469 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( |
| 3444 | 3470 | __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value || |
| 3445 | __alloc() == __str.__alloc(), | |
| 3471 | __alloc_ == __str.__alloc_, | |
| 3446 | 3472 | "swapping non-equal allocators"); |
| 3447 | 3473 | if (!__is_long()) |
| 3448 | 3474 | __annotate_delete(); |
| 3449 | if (this != &__str && !__str.__is_long()) | |
| 3475 | if (this != std::addressof(__str) && !__str.__is_long()) | |
| 3450 | 3476 | __str.__annotate_delete(); |
| 3451 | std::swap(__r_.first(), __str.__r_.first()); | |
| 3452 | std::__swap_allocator(__alloc(), __str.__alloc()); | |
| 3477 | std::swap(__rep_, __str.__rep_); | |
| 3478 | std::__swap_allocator(__alloc_, __str.__alloc_); | |
| 3453 | 3479 | if (!__is_long()) |
| 3454 | 3480 | __annotate_new(__get_short_size()); |
| 3455 | if (this != &__str && !__str.__is_long()) | |
| 3481 | if (this != std::addressof(__str) && !__str.__is_long()) | |
| 3456 | 3482 | __str.__annotate_new(__str.__get_short_size()); |
| 3457 | 3483 | } |
| 3458 | 3484 | |
| 3459 | 3485 | // find |
| 3460 | 3486 | |
| 3461 | template <class _Traits> | |
| 3462 | struct _LIBCPP_HIDDEN __traits_eq { | |
| 3463 | typedef typename _Traits::char_type char_type; | |
| 3464 | _LIBCPP_HIDE_FROM_ABI bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT { | |
| 3465 | return _Traits::eq(__x, __y); | |
| 3466 | } | |
| 3467 | }; | |
| 3468 | ||
| 3469 | 3487 | template <class _CharT, class _Traits, class _Allocator> |
| 3470 | 3488 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3471 | 3489 | basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { |
| ... | ... | @@ -3810,8 +3828,8 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat |
| 3810 | 3828 | clear(); |
| 3811 | 3829 | if (__is_long()) { |
| 3812 | 3830 | __annotate_delete(); |
| 3813 | __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1); | |
| 3814 | __r_.first() = __rep(); | |
| 3831 | __alloc_traits::deallocate(__alloc_, __get_long_pointer(), capacity() + 1); | |
| 3832 | __rep_ = __rep(); | |
| 3815 | 3833 | } |
| 3816 | 3834 | } |
| 3817 | 3835 | |
| ... | ... | @@ -3821,53 +3839,36 @@ template <class _CharT, class _Traits, class _Allocator> |
| 3821 | 3839 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool |
| 3822 | 3840 | operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 3823 | 3841 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { |
| 3824 | #if _LIBCPP_STD_VER >= 20 | |
| 3825 | return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs); | |
| 3826 | #else | |
| 3827 | 3842 | size_t __lhs_sz = __lhs.size(); |
| 3828 | 3843 | return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(), __rhs.data(), __lhs_sz) == 0; |
| 3829 | #endif | |
| 3830 | 3844 | } |
| 3831 | 3845 | |
| 3832 | template <class _Allocator> | |
| 3833 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool | |
| 3834 | operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, | |
| 3835 | const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT { | |
| 3836 | size_t __sz = __lhs.size(); | |
| 3837 | if (__sz != __rhs.size()) | |
| 3838 | return false; | |
| 3839 | return char_traits<char>::compare(__lhs.data(), __rhs.data(), __sz) == 0; | |
| 3840 | } | |
| 3841 | ||
| 3842 | #if _LIBCPP_STD_VER <= 17 | |
| 3843 | template <class _CharT, class _Traits, class _Allocator> | |
| 3844 | inline _LIBCPP_HIDE_FROM_ABI bool | |
| 3845 | operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { | |
| 3846 | typedef basic_string<_CharT, _Traits, _Allocator> _String; | |
| 3847 | _LIBCPP_ASSERT_NON_NULL(__lhs != nullptr, "operator==(char*, basic_string): received nullptr"); | |
| 3848 | size_t __lhs_len = _Traits::length(__lhs); | |
| 3849 | if (__lhs_len != __rhs.size()) | |
| 3850 | return false; | |
| 3851 | return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0; | |
| 3852 | } | |
| 3853 | #endif // _LIBCPP_STD_VER <= 17 | |
| 3854 | ||
| 3855 | 3846 | template <class _CharT, class _Traits, class _Allocator> |
| 3856 | 3847 | inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool |
| 3857 | 3848 | operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { |
| 3858 | #if _LIBCPP_STD_VER >= 20 | |
| 3859 | return basic_string_view<_CharT, _Traits>(__lhs) == basic_string_view<_CharT, _Traits>(__rhs); | |
| 3860 | #else | |
| 3861 | typedef basic_string<_CharT, _Traits, _Allocator> _String; | |
| 3862 | 3849 | _LIBCPP_ASSERT_NON_NULL(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); |
| 3850 | ||
| 3851 | using _String = basic_string<_CharT, _Traits, _Allocator>; | |
| 3852 | ||
| 3863 | 3853 | size_t __rhs_len = _Traits::length(__rhs); |
| 3854 | if (__builtin_constant_p(__rhs_len) && !_String::__fits_in_sso(__rhs_len)) { | |
| 3855 | if (!__lhs.__is_long()) | |
| 3856 | return false; | |
| 3857 | } | |
| 3864 | 3858 | if (__rhs_len != __lhs.size()) |
| 3865 | 3859 | return false; |
| 3866 | 3860 | return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; |
| 3867 | #endif | |
| 3868 | 3861 | } |
| 3869 | 3862 | |
| 3870 | #if _LIBCPP_STD_VER >= 20 | |
| 3863 | # if _LIBCPP_STD_VER <= 17 | |
| 3864 | template <class _CharT, class _Traits, class _Allocator> | |
| 3865 | inline _LIBCPP_HIDE_FROM_ABI bool | |
| 3866 | operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { | |
| 3867 | return __rhs == __lhs; | |
| 3868 | } | |
| 3869 | # endif // _LIBCPP_STD_VER <= 17 | |
| 3870 | ||
| 3871 | # if _LIBCPP_STD_VER >= 20 | |
| 3871 | 3872 | |
| 3872 | 3873 | template <class _CharT, class _Traits, class _Allocator> |
| 3873 | 3874 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| ... | ... | @@ -3881,7 +3882,7 @@ operator<=>(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT |
| 3881 | 3882 | return basic_string_view<_CharT, _Traits>(__lhs) <=> basic_string_view<_CharT, _Traits>(__rhs); |
| 3882 | 3883 | } |
| 3883 | 3884 | |
| 3884 | #else // _LIBCPP_STD_VER >= 20 | |
| 3885 | # else // _LIBCPP_STD_VER >= 20 | |
| 3885 | 3886 | |
| 3886 | 3887 | template <class _CharT, class _Traits, class _Allocator> |
| 3887 | 3888 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| ... | ... | @@ -3980,7 +3981,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool |
| 3980 | 3981 | operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { |
| 3981 | 3982 | return !(__lhs < __rhs); |
| 3982 | 3983 | } |
| 3983 | #endif // _LIBCPP_STD_VER >= 20 | |
| 3984 | # endif // _LIBCPP_STD_VER >= 20 | |
| 3984 | 3985 | |
| 3985 | 3986 | // operator + |
| 3986 | 3987 | |
| ... | ... | @@ -4063,7 +4064,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) |
| 4063 | 4064 | return __r; |
| 4064 | 4065 | } |
| 4065 | 4066 | |
| 4066 | #ifndef _LIBCPP_CXX03_LANG | |
| 4067 | # ifndef _LIBCPP_CXX03_LANG | |
| 4067 | 4068 | |
| 4068 | 4069 | template <class _CharT, class _Traits, class _Allocator> |
| 4069 | 4070 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator> |
| ... | ... | @@ -4109,9 +4110,9 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { |
| 4109 | 4110 | return std::move(__lhs); |
| 4110 | 4111 | } |
| 4111 | 4112 | |
| 4112 | #endif // _LIBCPP_CXX03_LANG | |
| 4113 | # endif // _LIBCPP_CXX03_LANG | |
| 4113 | 4114 | |
| 4114 | #if _LIBCPP_STD_VER >= 26 | |
| 4115 | # if _LIBCPP_STD_VER >= 26 | |
| 4115 | 4116 | |
| 4116 | 4117 | template <class _CharT, class _Traits, class _Allocator> |
| 4117 | 4118 | _LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator> |
| ... | ... | @@ -4163,7 +4164,7 @@ operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, |
| 4163 | 4164 | return std::move(__rhs); |
| 4164 | 4165 | } |
| 4165 | 4166 | |
| 4166 | #endif // _LIBCPP_STD_VER >= 26 | |
| 4167 | # endif // _LIBCPP_STD_VER >= 26 | |
| 4167 | 4168 | |
| 4168 | 4169 | // swap |
| 4169 | 4170 | |
| ... | ... | @@ -4194,7 +4195,7 @@ _LIBCPP_EXPORTED_FROM_ABI string to_string(float __val); |
| 4194 | 4195 | _LIBCPP_EXPORTED_FROM_ABI string to_string(double __val); |
| 4195 | 4196 | _LIBCPP_EXPORTED_FROM_ABI string to_string(long double __val); |
| 4196 | 4197 | |
| 4197 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4198 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4198 | 4199 | _LIBCPP_EXPORTED_FROM_ABI int stoi(const wstring& __str, size_t* __idx = nullptr, int __base = 10); |
| 4199 | 4200 | _LIBCPP_EXPORTED_FROM_ABI long stol(const wstring& __str, size_t* __idx = nullptr, int __base = 10); |
| 4200 | 4201 | _LIBCPP_EXPORTED_FROM_ABI unsigned long stoul(const wstring& __str, size_t* __idx = nullptr, int __base = 10); |
| ... | ... | @@ -4214,7 +4215,7 @@ _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(unsigned long long __val); |
| 4214 | 4215 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(float __val); |
| 4215 | 4216 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(double __val); |
| 4216 | 4217 | _LIBCPP_EXPORTED_FROM_ABI wstring to_wstring(long double __val); |
| 4217 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4218 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4218 | 4219 | |
| 4219 | 4220 | template <class _CharT, class _Traits, class _Allocator> |
| 4220 | 4221 | _LIBCPP_TEMPLATE_DATA_VIS const typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| ... | ... | @@ -4231,10 +4232,10 @@ struct __string_hash : public __unary_function<basic_string<_CharT, char_traits< |
| 4231 | 4232 | template <class _Allocator> |
| 4232 | 4233 | struct hash<basic_string<char, char_traits<char>, _Allocator> > : __string_hash<char, _Allocator> {}; |
| 4233 | 4234 | |
| 4234 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 4235 | # if _LIBCPP_HAS_CHAR8_T | |
| 4235 | 4236 | template <class _Allocator> |
| 4236 | 4237 | struct hash<basic_string<char8_t, char_traits<char8_t>, _Allocator> > : __string_hash<char8_t, _Allocator> {}; |
| 4237 | #endif | |
| 4238 | # endif | |
| 4238 | 4239 | |
| 4239 | 4240 | template <class _Allocator> |
| 4240 | 4241 | struct hash<basic_string<char16_t, char_traits<char16_t>, _Allocator> > : __string_hash<char16_t, _Allocator> {}; |
| ... | ... | @@ -4242,10 +4243,10 @@ struct hash<basic_string<char16_t, char_traits<char16_t>, _Allocator> > : __stri |
| 4242 | 4243 | template <class _Allocator> |
| 4243 | 4244 | struct hash<basic_string<char32_t, char_traits<char32_t>, _Allocator> > : __string_hash<char32_t, _Allocator> {}; |
| 4244 | 4245 | |
| 4245 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4246 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4246 | 4247 | template <class _Allocator> |
| 4247 | 4248 | struct hash<basic_string<wchar_t, char_traits<wchar_t>, _Allocator> > : __string_hash<wchar_t, _Allocator> {}; |
| 4248 | #endif | |
| 4249 | # endif | |
| 4249 | 4250 | |
| 4250 | 4251 | template <class _CharT, class _Traits, class _Allocator> |
| 4251 | 4252 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| ... | ... | @@ -4271,7 +4272,7 @@ template <class _CharT, class _Traits, class _Allocator> |
| 4271 | 4272 | inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& |
| 4272 | 4273 | getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str); |
| 4273 | 4274 | |
| 4274 | #if _LIBCPP_STD_VER >= 20 | |
| 4275 | # if _LIBCPP_STD_VER >= 20 | |
| 4275 | 4276 | template <class _CharT, class _Traits, class _Allocator, class _Up> |
| 4276 | 4277 | inline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 4277 | 4278 | erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { |
| ... | ... | @@ -4287,9 +4288,9 @@ erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) { |
| 4287 | 4288 | __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), __str.end()); |
| 4288 | 4289 | return __old_size - __str.size(); |
| 4289 | 4290 | } |
| 4290 | #endif | |
| 4291 | # endif | |
| 4291 | 4292 | |
| 4292 | #if _LIBCPP_STD_VER >= 14 | |
| 4293 | # if _LIBCPP_STD_VER >= 14 | |
| 4293 | 4294 | // Literal suffixes for basic_string [basic.string.literals] |
| 4294 | 4295 | inline namespace literals { |
| 4295 | 4296 | inline namespace string_literals { |
| ... | ... | @@ -4298,18 +4299,18 @@ operator""s(const char* __str, size_t __len) { |
| 4298 | 4299 | return basic_string<char>(__str, __len); |
| 4299 | 4300 | } |
| 4300 | 4301 | |
| 4301 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4302 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4302 | 4303 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<wchar_t> |
| 4303 | 4304 | operator""s(const wchar_t* __str, size_t __len) { |
| 4304 | 4305 | return basic_string<wchar_t>(__str, __len); |
| 4305 | 4306 | } |
| 4306 | # endif | |
| 4307 | # endif | |
| 4307 | 4308 | |
| 4308 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 4309 | # if _LIBCPP_HAS_CHAR8_T | |
| 4309 | 4310 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string<char8_t> operator""s(const char8_t* __str, size_t __len) { |
| 4310 | 4311 | return basic_string<char8_t>(__str, __len); |
| 4311 | 4312 | } |
| 4312 | # endif | |
| 4313 | # endif | |
| 4313 | 4314 | |
| 4314 | 4315 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<char16_t> |
| 4315 | 4316 | operator""s(const char16_t* __str, size_t __len) { |
| ... | ... | @@ -4323,30 +4324,31 @@ operator""s(const char32_t* __str, size_t __len) { |
| 4323 | 4324 | } // namespace string_literals |
| 4324 | 4325 | } // namespace literals |
| 4325 | 4326 | |
| 4326 | # if _LIBCPP_STD_VER >= 20 | |
| 4327 | # if _LIBCPP_STD_VER >= 20 | |
| 4327 | 4328 | template <> |
| 4328 | 4329 | inline constexpr bool __format::__enable_insertable<std::basic_string<char>> = true; |
| 4329 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4330 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4330 | 4331 | template <> |
| 4331 | 4332 | inline constexpr bool __format::__enable_insertable<std::basic_string<wchar_t>> = true; |
| 4333 | # endif | |
| 4332 | 4334 | # endif |
| 4333 | # endif | |
| 4334 | 4335 | |
| 4335 | #endif | |
| 4336 | # endif | |
| 4336 | 4337 | |
| 4337 | 4338 | _LIBCPP_END_NAMESPACE_STD |
| 4338 | 4339 | |
| 4339 | 4340 | _LIBCPP_POP_MACROS |
| 4340 | 4341 | |
| 4341 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 4342 | # include <algorithm> | |
| 4343 | # include <concepts> | |
| 4344 | # include <cstdlib> | |
| 4345 | # include <iterator> | |
| 4346 | # include <new> | |
| 4347 | # include <type_traits> | |
| 4348 | # include <typeinfo> | |
| 4349 | # include <utility> | |
| 4350 | #endif | |
| 4342 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 4343 | # include <algorithm> | |
| 4344 | # include <concepts> | |
| 4345 | # include <cstdlib> | |
| 4346 | # include <iterator> | |
| 4347 | # include <new> | |
| 4348 | # include <type_traits> | |
| 4349 | # include <typeinfo> | |
| 4350 | # include <utility> | |
| 4351 | # endif | |
| 4352 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 4351 | 4353 | |
| 4352 | 4354 | #endif // _LIBCPP_STRING |
lib/libcxx/include/string.h+17-12| ... | ... | @@ -51,24 +51,28 @@ size_t strlen(const char* s); |
| 51 | 51 | |
| 52 | 52 | */ |
| 53 | 53 | |
| 54 | #include <__config> | |
| 54 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 55 | # include <__cxx03/string.h> | |
| 56 | #else | |
| 57 | # include <__config> | |
| 55 | 58 | |
| 56 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 57 | # pragma GCC system_header | |
| 58 | #endif | |
| 59 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 60 | # pragma GCC system_header | |
| 61 | # endif | |
| 59 | 62 | |
| 60 | #if __has_include_next(<string.h>) | |
| 61 | # include_next <string.h> | |
| 62 | #endif | |
| 63 | # if __has_include_next(<string.h>) | |
| 64 | # include_next <string.h> | |
| 65 | # endif | |
| 63 | 66 | |
| 64 | 67 | // MSVCRT, GNU libc and its derivates may already have the correct prototype in |
| 65 | 68 | // <string.h>. This macro can be defined by users if their C library provides |
| 66 | 69 | // the right signature. |
| 67 | #if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) | |
| 68 | # define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS | |
| 69 | #endif | |
| 70 | # if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \ | |
| 71 | defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_) | |
| 72 | # define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS | |
| 73 | # endif | |
| 70 | 74 | |
| 71 | #if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) | |
| 75 | # if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) | |
| 72 | 76 | extern "C++" { |
| 73 | 77 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD const char* strchr(const char* __s, int __c) { |
| 74 | 78 | return __builtin_strchr(__s, __c); |
| ... | ... | @@ -105,6 +109,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD char* strstr(char* __s1, |
| 105 | 109 | return __builtin_strstr(__s1, __s2); |
| 106 | 110 | } |
| 107 | 111 | } // extern "C++" |
| 108 | #endif | |
| 112 | # endif | |
| 113 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 109 | 114 | |
| 110 | 115 | #endif // _LIBCPP_STRING_H |
lib/libcxx/include/string_view+126-119| ... | ... | @@ -205,57 +205,63 @@ namespace std { |
| 205 | 205 | |
| 206 | 206 | // clang-format on |
| 207 | 207 | |
| 208 | #include <__algorithm/min.h> | |
| 209 | #include <__assert> | |
| 210 | #include <__config> | |
| 211 | #include <__functional/hash.h> | |
| 212 | #include <__functional/unary_function.h> | |
| 213 | #include <__fwd/ostream.h> | |
| 214 | #include <__fwd/string_view.h> | |
| 215 | #include <__iterator/bounded_iter.h> | |
| 216 | #include <__iterator/concepts.h> | |
| 217 | #include <__iterator/iterator_traits.h> | |
| 218 | #include <__iterator/reverse_iterator.h> | |
| 219 | #include <__iterator/wrap_iter.h> | |
| 220 | #include <__memory/pointer_traits.h> | |
| 221 | #include <__ranges/concepts.h> | |
| 222 | #include <__ranges/data.h> | |
| 223 | #include <__ranges/enable_borrowed_range.h> | |
| 224 | #include <__ranges/enable_view.h> | |
| 225 | #include <__ranges/size.h> | |
| 226 | #include <__string/char_traits.h> | |
| 227 | #include <__type_traits/is_array.h> | |
| 228 | #include <__type_traits/is_convertible.h> | |
| 229 | #include <__type_traits/is_same.h> | |
| 230 | #include <__type_traits/is_standard_layout.h> | |
| 231 | #include <__type_traits/is_trivial.h> | |
| 232 | #include <__type_traits/remove_cvref.h> | |
| 233 | #include <__type_traits/remove_reference.h> | |
| 234 | #include <__type_traits/type_identity.h> | |
| 235 | #include <cstddef> | |
| 236 | #include <iosfwd> | |
| 237 | #include <limits> | |
| 238 | #include <stdexcept> | |
| 239 | #include <version> | |
| 208 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 209 | # include <__cxx03/string_view> | |
| 210 | #else | |
| 211 | # include <__algorithm/min.h> | |
| 212 | # include <__assert> | |
| 213 | # include <__config> | |
| 214 | # include <__cstddef/nullptr_t.h> | |
| 215 | # include <__cstddef/ptrdiff_t.h> | |
| 216 | # include <__cstddef/size_t.h> | |
| 217 | # include <__functional/hash.h> | |
| 218 | # include <__functional/unary_function.h> | |
| 219 | # include <__fwd/ostream.h> | |
| 220 | # include <__fwd/string.h> | |
| 221 | # include <__fwd/string_view.h> | |
| 222 | # include <__iterator/bounded_iter.h> | |
| 223 | # include <__iterator/concepts.h> | |
| 224 | # include <__iterator/iterator_traits.h> | |
| 225 | # include <__iterator/reverse_iterator.h> | |
| 226 | # include <__iterator/wrap_iter.h> | |
| 227 | # include <__memory/pointer_traits.h> | |
| 228 | # include <__ranges/concepts.h> | |
| 229 | # include <__ranges/data.h> | |
| 230 | # include <__ranges/enable_borrowed_range.h> | |
| 231 | # include <__ranges/enable_view.h> | |
| 232 | # include <__ranges/size.h> | |
| 233 | # include <__string/char_traits.h> | |
| 234 | # include <__type_traits/is_array.h> | |
| 235 | # include <__type_traits/is_convertible.h> | |
| 236 | # include <__type_traits/is_same.h> | |
| 237 | # include <__type_traits/is_standard_layout.h> | |
| 238 | # include <__type_traits/is_trivial.h> | |
| 239 | # include <__type_traits/remove_cvref.h> | |
| 240 | # include <__type_traits/remove_reference.h> | |
| 241 | # include <__type_traits/type_identity.h> | |
| 242 | # include <iosfwd> | |
| 243 | # include <limits> | |
| 244 | # include <stdexcept> | |
| 245 | # include <version> | |
| 240 | 246 | |
| 241 | 247 | // standard-mandated includes |
| 242 | 248 | |
| 243 | 249 | // [iterator.range] |
| 244 | #include <__iterator/access.h> | |
| 245 | #include <__iterator/data.h> | |
| 246 | #include <__iterator/empty.h> | |
| 247 | #include <__iterator/reverse_access.h> | |
| 248 | #include <__iterator/size.h> | |
| 250 | # include <__iterator/access.h> | |
| 251 | # include <__iterator/data.h> | |
| 252 | # include <__iterator/empty.h> | |
| 253 | # include <__iterator/reverse_access.h> | |
| 254 | # include <__iterator/size.h> | |
| 249 | 255 | |
| 250 | 256 | // [string.view.synop] |
| 251 | #include <compare> | |
| 257 | # include <compare> | |
| 252 | 258 | |
| 253 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 254 | # pragma GCC system_header | |
| 255 | #endif | |
| 259 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 260 | # pragma GCC system_header | |
| 261 | # endif | |
| 256 | 262 | |
| 257 | 263 | _LIBCPP_PUSH_MACROS |
| 258 | #include <__undef_macros> | |
| 264 | # include <__undef_macros> | |
| 259 | 265 | |
| 260 | 266 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 261 | 267 | |
| ... | ... | @@ -280,13 +286,13 @@ public: |
| 280 | 286 | using const_pointer = const _CharT*; |
| 281 | 287 | using reference = _CharT&; |
| 282 | 288 | using const_reference = const _CharT&; |
| 283 | #if defined(_LIBCPP_ABI_BOUNDED_ITERATORS) | |
| 289 | # if defined(_LIBCPP_ABI_BOUNDED_ITERATORS) | |
| 284 | 290 | using const_iterator = __bounded_iter<const_pointer>; |
| 285 | #elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW) | |
| 291 | # elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW) | |
| 286 | 292 | using const_iterator = __wrap_iter<const_pointer>; |
| 287 | #else | |
| 293 | # else | |
| 288 | 294 | using const_iterator = const_pointer; |
| 289 | #endif | |
| 295 | # endif | |
| 290 | 296 | using iterator = const_iterator; |
| 291 | 297 | using const_reverse_iterator = std::reverse_iterator<const_iterator>; |
| 292 | 298 | using reverse_iterator = const_reverse_iterator; |
| ... | ... | @@ -310,7 +316,7 @@ public: |
| 310 | 316 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT |
| 311 | 317 | : __data_(__s), |
| 312 | 318 | __size_(__len) { |
| 313 | #if _LIBCPP_STD_VER >= 14 | |
| 319 | # if _LIBCPP_STD_VER >= 14 | |
| 314 | 320 | // Allocations must fit in `ptrdiff_t` for pointer arithmetic to work. If `__len` exceeds it, the input |
| 315 | 321 | // range could not have been valid. Most likely the caller underflowed some arithmetic and inadvertently |
| 316 | 322 | // passed in a negative length. |
| ... | ... | @@ -319,10 +325,10 @@ public: |
| 319 | 325 | "string_view::string_view(_CharT *, size_t): length does not fit in difference_type"); |
| 320 | 326 | _LIBCPP_ASSERT_NON_NULL( |
| 321 | 327 | __len == 0 || __s != nullptr, "string_view::string_view(_CharT *, size_t): received nullptr"); |
| 322 | #endif | |
| 328 | # endif | |
| 323 | 329 | } |
| 324 | 330 | |
| 325 | #if _LIBCPP_STD_VER >= 20 | |
| 331 | # if _LIBCPP_STD_VER >= 20 | |
| 326 | 332 | template <contiguous_iterator _It, sized_sentinel_for<_It> _End> |
| 327 | 333 | requires(is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>) |
| 328 | 334 | constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end) |
| ... | ... | @@ -330,9 +336,9 @@ public: |
| 330 | 336 | _LIBCPP_ASSERT_VALID_INPUT_RANGE( |
| 331 | 337 | (__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range"); |
| 332 | 338 | } |
| 333 | #endif // _LIBCPP_STD_VER >= 20 | |
| 339 | # endif // _LIBCPP_STD_VER >= 20 | |
| 334 | 340 | |
| 335 | #if _LIBCPP_STD_VER >= 23 | |
| 341 | # if _LIBCPP_STD_VER >= 23 | |
| 336 | 342 | template <class _Range> |
| 337 | 343 | requires(!is_same_v<remove_cvref_t<_Range>, basic_string_view> && ranges::contiguous_range<_Range> && |
| 338 | 344 | ranges::sized_range<_Range> && is_same_v<ranges::range_value_t<_Range>, _CharT> && |
| ... | ... | @@ -340,14 +346,14 @@ public: |
| 340 | 346 | (!requires(remove_cvref_t<_Range>& __d) { __d.operator std::basic_string_view<_CharT, _Traits>(); })) |
| 341 | 347 | constexpr explicit _LIBCPP_HIDE_FROM_ABI basic_string_view(_Range&& __r) |
| 342 | 348 | : __data_(ranges::data(__r)), __size_(ranges::size(__r)) {} |
| 343 | #endif // _LIBCPP_STD_VER >= 23 | |
| 349 | # endif // _LIBCPP_STD_VER >= 23 | |
| 344 | 350 | |
| 345 | 351 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view(const _CharT* __s) |
| 346 | 352 | : __data_(__s), __size_(std::__char_traits_length_checked<_Traits>(__s)) {} |
| 347 | 353 | |
| 348 | #if _LIBCPP_STD_VER >= 23 | |
| 354 | # if _LIBCPP_STD_VER >= 23 | |
| 349 | 355 | basic_string_view(nullptr_t) = delete; |
| 350 | #endif | |
| 356 | # endif | |
| 351 | 357 | |
| 352 | 358 | // [string.view.iterators], iterators |
| 353 | 359 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return cbegin(); } |
| ... | ... | @@ -355,19 +361,19 @@ public: |
| 355 | 361 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return cend(); } |
| 356 | 362 | |
| 357 | 363 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { |
| 358 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 364 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 359 | 365 | return std::__make_bounded_iter(data(), data(), data() + size()); |
| 360 | #else | |
| 366 | # else | |
| 361 | 367 | return const_iterator(__data_); |
| 362 | #endif | |
| 368 | # endif | |
| 363 | 369 | } |
| 364 | 370 | |
| 365 | 371 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { |
| 366 | #ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 372 | # ifdef _LIBCPP_ABI_BOUNDED_ITERATORS | |
| 367 | 373 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); |
| 368 | #else | |
| 374 | # else | |
| 369 | 375 | return const_iterator(__data_ + __size_); |
| 370 | #endif | |
| 376 | # endif | |
| 371 | 377 | } |
| 372 | 378 | |
| 373 | 379 | _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { |
| ... | ... | @@ -395,7 +401,7 @@ public: |
| 395 | 401 | return numeric_limits<size_type>::max() / sizeof(value_type); |
| 396 | 402 | } |
| 397 | 403 | |
| 398 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; } | |
| 404 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; } | |
| 399 | 405 | |
| 400 | 406 | // [string.view.access], element access |
| 401 | 407 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __pos) const _NOEXCEPT { |
| ... | ... | @@ -448,8 +454,11 @@ public: |
| 448 | 454 | } |
| 449 | 455 | |
| 450 | 456 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view substr(size_type __pos = 0, size_type __n = npos) const { |
| 457 | // Use the `__assume_valid` form of the constructor to avoid an unnecessary check. Any substring of a view is a | |
| 458 | // valid view. In particular, `size()` is known to be smaller than `numeric_limits<difference_type>::max()`, so the | |
| 459 | // new size is also smaller. See also https://github.com/llvm/llvm-project/issues/91634. | |
| 451 | 460 | return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view()) |
| 452 | : basic_string_view(data() + __pos, std::min(__n, size() - __pos)); | |
| 461 | : basic_string_view(__assume_valid(), data() + __pos, std::min(__n, size() - __pos)); | |
| 453 | 462 | } |
| 454 | 463 | |
| 455 | 464 | _LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT { |
| ... | ... | @@ -639,7 +648,7 @@ public: |
| 639 | 648 | data(), size(), __s, __pos, traits_type::length(__s)); |
| 640 | 649 | } |
| 641 | 650 | |
| 642 | #if _LIBCPP_STD_VER >= 20 | |
| 651 | # if _LIBCPP_STD_VER >= 20 | |
| 643 | 652 | constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(basic_string_view __s) const noexcept { |
| 644 | 653 | return size() >= __s.size() && compare(0, __s.size(), __s) == 0; |
| 645 | 654 | } |
| ... | ... | @@ -663,54 +672,70 @@ public: |
| 663 | 672 | constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept { |
| 664 | 673 | return ends_with(basic_string_view(__s)); |
| 665 | 674 | } |
| 666 | #endif | |
| 675 | # endif | |
| 667 | 676 | |
| 668 | #if _LIBCPP_STD_VER >= 23 | |
| 677 | # if _LIBCPP_STD_VER >= 23 | |
| 669 | 678 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(basic_string_view __sv) const noexcept { return find(__sv) != npos; } |
| 670 | 679 | |
| 671 | 680 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(value_type __c) const noexcept { return find(__c) != npos; } |
| 672 | 681 | |
| 673 | 682 | constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const { return find(__s) != npos; } |
| 674 | #endif | |
| 683 | # endif | |
| 675 | 684 | |
| 676 | 685 | private: |
| 686 | struct __assume_valid {}; | |
| 687 | ||
| 688 | // This is the same as the pointer and length constructor, but without the additional hardening checks. It is intended | |
| 689 | // for use within the class, when the class invariants already guarantee the resulting object is valid. The compiler | |
| 690 | // usually cannot eliminate the redundant checks because it does not know class invariants. | |
| 691 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI | |
| 692 | basic_string_view(__assume_valid, const _CharT* __s, size_type __len) _NOEXCEPT | |
| 693 | : __data_(__s), | |
| 694 | __size_(__len) {} | |
| 695 | ||
| 677 | 696 | const value_type* __data_; |
| 678 | 697 | size_type __size_; |
| 698 | ||
| 699 | template <class, class, class> | |
| 700 | friend class basic_string; | |
| 679 | 701 | }; |
| 680 | 702 | _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_string_view); |
| 681 | 703 | |
| 682 | #if _LIBCPP_STD_VER >= 20 | |
| 704 | # if _LIBCPP_STD_VER >= 20 | |
| 683 | 705 | template <class _CharT, class _Traits> |
| 684 | 706 | inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true; |
| 685 | 707 | |
| 686 | 708 | template <class _CharT, class _Traits> |
| 687 | 709 | inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true; |
| 688 | #endif // _LIBCPP_STD_VER >= 20 | |
| 710 | # endif // _LIBCPP_STD_VER >= 20 | |
| 689 | 711 | |
| 690 | 712 | // [string.view.deduct] |
| 691 | 713 | |
| 692 | #if _LIBCPP_STD_VER >= 20 | |
| 714 | # if _LIBCPP_STD_VER >= 20 | |
| 693 | 715 | template <contiguous_iterator _It, sized_sentinel_for<_It> _End> |
| 694 | 716 | basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>; |
| 695 | #endif // _LIBCPP_STD_VER >= 20 | |
| 717 | # endif // _LIBCPP_STD_VER >= 20 | |
| 696 | 718 | |
| 697 | #if _LIBCPP_STD_VER >= 23 | |
| 719 | # if _LIBCPP_STD_VER >= 23 | |
| 698 | 720 | template <ranges::contiguous_range _Range> |
| 699 | 721 | basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>; |
| 700 | #endif | |
| 722 | # endif | |
| 701 | 723 | |
| 702 | 724 | // [string.view.comparison] |
| 703 | 725 | |
| 704 | #if _LIBCPP_STD_VER >= 20 | |
| 705 | ||
| 706 | template <class _CharT, class _Traits> | |
| 707 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(basic_string_view<_CharT, _Traits> __lhs, | |
| 708 | type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept { | |
| 726 | // The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details. | |
| 727 | // This applies to the other sufficient overloads below for the other comparison operators. | |
| 728 | template <class _CharT, class _Traits, int = 1> | |
| 729 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool | |
| 730 | operator==(basic_string_view<_CharT, _Traits> __lhs, | |
| 731 | __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT { | |
| 709 | 732 | if (__lhs.size() != __rhs.size()) |
| 710 | 733 | return false; |
| 711 | 734 | return __lhs.compare(__rhs) == 0; |
| 712 | 735 | } |
| 713 | 736 | |
| 737 | # if _LIBCPP_STD_VER >= 20 | |
| 738 | ||
| 714 | 739 | template <class _CharT, class _Traits> |
| 715 | 740 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(basic_string_view<_CharT, _Traits> __lhs, |
| 716 | 741 | type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept { |
| ... | ... | @@ -724,7 +749,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(basic_string_view<_CharT, _Trai |
| 724 | 749 | } |
| 725 | 750 | } |
| 726 | 751 | |
| 727 | #else | |
| 752 | # else | |
| 728 | 753 | |
| 729 | 754 | // operator == |
| 730 | 755 | |
| ... | ... | @@ -736,51 +761,32 @@ operator==(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _ |
| 736 | 761 | return __lhs.compare(__rhs) == 0; |
| 737 | 762 | } |
| 738 | 763 | |
| 739 | // The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details. | |
| 740 | // This applies to the other sufficient overloads below for the other comparison operators. | |
| 741 | template <class _CharT, class _Traits, int = 1> | |
| 742 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool | |
| 743 | operator==(basic_string_view<_CharT, _Traits> __lhs, | |
| 744 | __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT { | |
| 745 | if (__lhs.size() != __rhs.size()) | |
| 746 | return false; | |
| 747 | return __lhs.compare(__rhs) == 0; | |
| 748 | } | |
| 749 | ||
| 750 | 764 | template <class _CharT, class _Traits, int = 2> |
| 751 | 765 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool |
| 752 | 766 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs, |
| 753 | 767 | basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { |
| 754 | if (__lhs.size() != __rhs.size()) | |
| 755 | return false; | |
| 756 | return __lhs.compare(__rhs) == 0; | |
| 768 | return __lhs == __rhs; | |
| 757 | 769 | } |
| 758 | 770 | |
| 759 | 771 | // operator != |
| 760 | 772 | template <class _CharT, class _Traits> |
| 761 | 773 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool |
| 762 | 774 | operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { |
| 763 | if (__lhs.size() != __rhs.size()) | |
| 764 | return true; | |
| 765 | return __lhs.compare(__rhs) != 0; | |
| 775 | return !(__lhs == __rhs); | |
| 766 | 776 | } |
| 767 | 777 | |
| 768 | 778 | template <class _CharT, class _Traits, int = 1> |
| 769 | 779 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool |
| 770 | 780 | operator!=(basic_string_view<_CharT, _Traits> __lhs, |
| 771 | 781 | __type_identity_t<basic_string_view<_CharT, _Traits> > __rhs) _NOEXCEPT { |
| 772 | if (__lhs.size() != __rhs.size()) | |
| 773 | return true; | |
| 774 | return __lhs.compare(__rhs) != 0; | |
| 782 | return !(__lhs == __rhs); | |
| 775 | 783 | } |
| 776 | 784 | |
| 777 | 785 | template <class _CharT, class _Traits, int = 2> |
| 778 | 786 | _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool |
| 779 | 787 | operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs, |
| 780 | 788 | basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT { |
| 781 | if (__lhs.size() != __rhs.size()) | |
| 782 | return true; | |
| 783 | return __lhs.compare(__rhs) != 0; | |
| 789 | return !(__lhs == __rhs); | |
| 784 | 790 | } |
| 785 | 791 | |
| 786 | 792 | // operator < |
| ... | ... | @@ -867,7 +873,7 @@ operator>=(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs, |
| 867 | 873 | return __lhs.compare(__rhs) >= 0; |
| 868 | 874 | } |
| 869 | 875 | |
| 870 | #endif // _LIBCPP_STD_VER >= 20 | |
| 876 | # endif // _LIBCPP_STD_VER >= 20 | |
| 871 | 877 | |
| 872 | 878 | template <class _CharT, class _Traits> |
| 873 | 879 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& |
| ... | ... | @@ -884,10 +890,10 @@ struct __string_view_hash : public __unary_function<basic_string_view<_CharT, ch |
| 884 | 890 | template <> |
| 885 | 891 | struct hash<basic_string_view<char, char_traits<char> > > : __string_view_hash<char> {}; |
| 886 | 892 | |
| 887 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 893 | # if _LIBCPP_HAS_CHAR8_T | |
| 888 | 894 | template <> |
| 889 | 895 | struct hash<basic_string_view<char8_t, char_traits<char8_t> > > : __string_view_hash<char8_t> {}; |
| 890 | #endif | |
| 896 | # endif | |
| 891 | 897 | |
| 892 | 898 | template <> |
| 893 | 899 | struct hash<basic_string_view<char16_t, char_traits<char16_t> > > : __string_view_hash<char16_t> {}; |
| ... | ... | @@ -895,31 +901,31 @@ struct hash<basic_string_view<char16_t, char_traits<char16_t> > > : __string_vie |
| 895 | 901 | template <> |
| 896 | 902 | struct hash<basic_string_view<char32_t, char_traits<char32_t> > > : __string_view_hash<char32_t> {}; |
| 897 | 903 | |
| 898 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 904 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 899 | 905 | template <> |
| 900 | 906 | struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_hash<wchar_t> {}; |
| 901 | #endif | |
| 907 | # endif | |
| 902 | 908 | |
| 903 | #if _LIBCPP_STD_VER >= 14 | |
| 909 | # if _LIBCPP_STD_VER >= 14 | |
| 904 | 910 | inline namespace literals { |
| 905 | 911 | inline namespace string_view_literals { |
| 906 | 912 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char> operator""sv(const char* __str, size_t __len) noexcept { |
| 907 | 913 | return basic_string_view<char>(__str, __len); |
| 908 | 914 | } |
| 909 | 915 | |
| 910 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 916 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 911 | 917 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<wchar_t> |
| 912 | 918 | operator""sv(const wchar_t* __str, size_t __len) noexcept { |
| 913 | 919 | return basic_string_view<wchar_t>(__str, __len); |
| 914 | 920 | } |
| 915 | # endif | |
| 921 | # endif | |
| 916 | 922 | |
| 917 | # ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 923 | # if _LIBCPP_HAS_CHAR8_T | |
| 918 | 924 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char8_t> |
| 919 | 925 | operator""sv(const char8_t* __str, size_t __len) noexcept { |
| 920 | 926 | return basic_string_view<char8_t>(__str, __len); |
| 921 | 927 | } |
| 922 | # endif | |
| 928 | # endif | |
| 923 | 929 | |
| 924 | 930 | inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char16_t> |
| 925 | 931 | operator""sv(const char16_t* __str, size_t __len) noexcept { |
| ... | ... | @@ -932,17 +938,18 @@ operator""sv(const char32_t* __str, size_t __len) noexcept { |
| 932 | 938 | } |
| 933 | 939 | } // namespace string_view_literals |
| 934 | 940 | } // namespace literals |
| 935 | #endif | |
| 941 | # endif | |
| 936 | 942 | _LIBCPP_END_NAMESPACE_STD |
| 937 | 943 | |
| 938 | 944 | _LIBCPP_POP_MACROS |
| 939 | 945 | |
| 940 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 941 | # include <algorithm> | |
| 942 | # include <concepts> | |
| 943 | # include <cstdlib> | |
| 944 | # include <iterator> | |
| 945 | # include <type_traits> | |
| 946 | #endif | |
| 946 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 947 | # include <algorithm> | |
| 948 | # include <concepts> | |
| 949 | # include <cstdlib> | |
| 950 | # include <iterator> | |
| 951 | # include <type_traits> | |
| 952 | # endif | |
| 953 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 947 | 954 | |
| 948 | 955 | #endif // _LIBCPP_STRING_VIEW |
lib/libcxx/include/strstream+29-24| ... | ... | @@ -129,30 +129,34 @@ private: |
| 129 | 129 | |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | #include <__config> | |
| 133 | #include <istream> | |
| 134 | #include <ostream> | |
| 135 | #include <version> | |
| 136 | ||
| 137 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 138 | # pragma GCC system_header | |
| 139 | #endif | |
| 132 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 133 | # include <__cxx03/strstream> | |
| 134 | #else | |
| 135 | # include <__config> | |
| 136 | # include <__ostream/basic_ostream.h> | |
| 137 | # include <istream> | |
| 138 | # include <streambuf> | |
| 139 | # include <version> | |
| 140 | ||
| 141 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 142 | # pragma GCC system_header | |
| 143 | # endif | |
| 140 | 144 | |
| 141 | #if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 145 | # if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 142 | 146 | |
| 143 | 147 | _LIBCPP_PUSH_MACROS |
| 144 | # include <__undef_macros> | |
| 148 | # include <__undef_macros> | |
| 145 | 149 | |
| 146 | 150 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 147 | 151 | |
| 148 | 152 | class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf { |
| 149 | 153 | public: |
| 150 | # ifndef _LIBCPP_CXX03_LANG | |
| 154 | # ifndef _LIBCPP_CXX03_LANG | |
| 151 | 155 | _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {} |
| 152 | 156 | explicit strstreambuf(streamsize __alsize); |
| 153 | # else | |
| 157 | # else | |
| 154 | 158 | explicit strstreambuf(streamsize __alsize = 0); |
| 155 | # endif | |
| 159 | # endif | |
| 156 | 160 | strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*)); |
| 157 | 161 | strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr); |
| 158 | 162 | strstreambuf(const char* __gnext, streamsize __n); |
| ... | ... | @@ -162,10 +166,10 @@ public: |
| 162 | 166 | strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr); |
| 163 | 167 | strstreambuf(const unsigned char* __gnext, streamsize __n); |
| 164 | 168 | |
| 165 | # ifndef _LIBCPP_CXX03_LANG | |
| 169 | # ifndef _LIBCPP_CXX03_LANG | |
| 166 | 170 | _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs); |
| 167 | 171 | _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs); |
| 168 | # endif // _LIBCPP_CXX03_LANG | |
| 172 | # endif // _LIBCPP_CXX03_LANG | |
| 169 | 173 | |
| 170 | 174 | ~strstreambuf() override; |
| 171 | 175 | |
| ... | ... | @@ -199,7 +203,7 @@ private: |
| 199 | 203 | void __init(char* __gnext, streamsize __n, char* __pbeg); |
| 200 | 204 | }; |
| 201 | 205 | |
| 202 | # ifndef _LIBCPP_CXX03_LANG | |
| 206 | # ifndef _LIBCPP_CXX03_LANG | |
| 203 | 207 | |
| 204 | 208 | inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs) |
| 205 | 209 | : streambuf(__rhs), |
| ... | ... | @@ -228,7 +232,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf& |
| 228 | 232 | return *this; |
| 229 | 233 | } |
| 230 | 234 | |
| 231 | # endif // _LIBCPP_CXX03_LANG | |
| 235 | # endif // _LIBCPP_CXX03_LANG | |
| 232 | 236 | |
| 233 | 237 | class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream { |
| 234 | 238 | public: |
| ... | ... | @@ -237,7 +241,7 @@ public: |
| 237 | 241 | _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} |
| 238 | 242 | _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {} |
| 239 | 243 | |
| 240 | # ifndef _LIBCPP_CXX03_LANG | |
| 244 | # ifndef _LIBCPP_CXX03_LANG | |
| 241 | 245 | _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension |
| 242 | 246 | : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { |
| 243 | 247 | istream::set_rdbuf(&__sb_); |
| ... | ... | @@ -248,7 +252,7 @@ public: |
| 248 | 252 | istream::operator=(std::move(__rhs)); |
| 249 | 253 | return *this; |
| 250 | 254 | } |
| 251 | # endif // _LIBCPP_CXX03_LANG | |
| 255 | # endif // _LIBCPP_CXX03_LANG | |
| 252 | 256 | |
| 253 | 257 | ~istrstream() override; |
| 254 | 258 | |
| ... | ... | @@ -270,7 +274,7 @@ public: |
| 270 | 274 | _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out) |
| 271 | 275 | : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} |
| 272 | 276 | |
| 273 | # ifndef _LIBCPP_CXX03_LANG | |
| 277 | # ifndef _LIBCPP_CXX03_LANG | |
| 274 | 278 | _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension |
| 275 | 279 | : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { |
| 276 | 280 | ostream::set_rdbuf(&__sb_); |
| ... | ... | @@ -281,7 +285,7 @@ public: |
| 281 | 285 | ostream::operator=(std::move(__rhs)); |
| 282 | 286 | return *this; |
| 283 | 287 | } |
| 284 | # endif // _LIBCPP_CXX03_LANG | |
| 288 | # endif // _LIBCPP_CXX03_LANG | |
| 285 | 289 | |
| 286 | 290 | ~ostrstream() override; |
| 287 | 291 | |
| ... | ... | @@ -312,7 +316,7 @@ public: |
| 312 | 316 | _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out) |
| 313 | 317 | : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {} |
| 314 | 318 | |
| 315 | # ifndef _LIBCPP_CXX03_LANG | |
| 319 | # ifndef _LIBCPP_CXX03_LANG | |
| 316 | 320 | _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension |
| 317 | 321 | : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) { |
| 318 | 322 | iostream::set_rdbuf(&__sb_); |
| ... | ... | @@ -323,7 +327,7 @@ public: |
| 323 | 327 | iostream::operator=(std::move(__rhs)); |
| 324 | 328 | return *this; |
| 325 | 329 | } |
| 326 | # endif // _LIBCPP_CXX03_LANG | |
| 330 | # endif // _LIBCPP_CXX03_LANG | |
| 327 | 331 | |
| 328 | 332 | ~strstream() override; |
| 329 | 333 | |
| ... | ... | @@ -346,6 +350,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 346 | 350 | |
| 347 | 351 | _LIBCPP_POP_MACROS |
| 348 | 352 | |
| 349 | #endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 353 | # endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 354 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 350 | 355 | |
| 351 | 356 | #endif // _LIBCPP_STRSTREAM |
lib/libcxx/include/syncstream+58-46| ... | ... | @@ -46,7 +46,9 @@ namespace std { |
| 46 | 46 | using streambuf_type = basic_streambuf<charT, traits>; |
| 47 | 47 | |
| 48 | 48 | // [syncstream.syncbuf.cons], construction and destruction |
| 49 | explicit basic_syncbuf(streambuf_type* obuf = nullptr) | |
| 49 | basic_syncbuf() | |
| 50 | : basic_syncbuf(nullptr) {} | |
| 51 | explicit basic_syncbuf(streambuf_type* obuf) | |
| 50 | 52 | : basic_syncbuf(obuf, Allocator()) {} |
| 51 | 53 | basic_syncbuf(streambuf_type*, const Allocator&); |
| 52 | 54 | basic_syncbuf(basic_syncbuf&&); |
| ... | ... | @@ -115,34 +117,40 @@ namespace std { |
| 115 | 117 | |
| 116 | 118 | */ |
| 117 | 119 | |
| 118 | #include <__config> | |
| 119 | #include <__utility/move.h> | |
| 120 | #include <ios> | |
| 121 | #include <iosfwd> // required for declaration of default arguments | |
| 122 | #include <streambuf> | |
| 123 | #include <string> | |
| 120 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 121 | # include <__cxx03/syncstream> | |
| 122 | #else | |
| 123 | # include <__config> | |
| 124 | 124 | |
| 125 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 126 | # include <map> | |
| 127 | # include <mutex> | |
| 128 | # include <shared_mutex> | |
| 129 | #endif | |
| 125 | # if _LIBCPP_HAS_LOCALIZATION | |
| 126 | ||
| 127 | # include <__mutex/lock_guard.h> | |
| 128 | # include <__utility/move.h> | |
| 129 | # include <ios> | |
| 130 | # include <iosfwd> // required for declaration of default arguments | |
| 131 | # include <streambuf> | |
| 132 | # include <string> | |
| 133 | ||
| 134 | # if _LIBCPP_HAS_THREADS | |
| 135 | # include <map> | |
| 136 | # include <shared_mutex> | |
| 137 | # endif | |
| 130 | 138 | |
| 131 | 139 | // standard-mandated includes |
| 132 | 140 | |
| 133 | 141 | // [syncstream.syn] |
| 134 | #include <ostream> | |
| 142 | # include <ostream> | |
| 135 | 143 | |
| 136 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 137 | # pragma GCC system_header | |
| 138 | #endif | |
| 144 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 145 | # pragma GCC system_header | |
| 146 | # endif | |
| 139 | 147 | |
| 140 | 148 | _LIBCPP_PUSH_MACROS |
| 141 | #include <__undef_macros> | |
| 149 | # include <__undef_macros> | |
| 142 | 150 | |
| 143 | 151 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 144 | 152 | |
| 145 | #if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) | |
| 153 | # if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM | |
| 146 | 154 | |
| 147 | 155 | // [syncstream.syncbuf.overview]/1 |
| 148 | 156 | // Class template basic_syncbuf stores character data written to it, |
| ... | ... | @@ -155,7 +163,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 155 | 163 | // |
| 156 | 164 | // This helper singleton is used to implement the required |
| 157 | 165 | // synchronisation guarantees. |
| 158 | # ifndef _LIBCPP_HAS_NO_THREADS | |
| 166 | # if _LIBCPP_HAS_THREADS | |
| 159 | 167 | class __wrapped_streambuf_mutex { |
| 160 | 168 | _LIBCPP_HIDE_FROM_ABI __wrapped_streambuf_mutex() = default; |
| 161 | 169 | |
| ... | ... | @@ -228,7 +236,7 @@ private: |
| 228 | 236 | return __it; |
| 229 | 237 | } |
| 230 | 238 | }; |
| 231 | # endif // _LIBCPP_HAS_NO_THREADS | |
| 239 | # endif // _LIBCPP_HAS_THREADS | |
| 232 | 240 | |
| 233 | 241 | // basic_syncbuf |
| 234 | 242 | |
| ... | ... | @@ -253,8 +261,9 @@ public: |
| 253 | 261 | |
| 254 | 262 | // [syncstream.syncbuf.cons], construction and destruction |
| 255 | 263 | |
| 256 | _LIBCPP_HIDE_FROM_ABI explicit basic_syncbuf(streambuf_type* __obuf = nullptr) | |
| 257 | : basic_syncbuf(__obuf, _Allocator()) {} | |
| 264 | _LIBCPP_HIDE_FROM_ABI basic_syncbuf() : basic_syncbuf(nullptr) {} | |
| 265 | ||
| 266 | _LIBCPP_HIDE_FROM_ABI explicit basic_syncbuf(streambuf_type* __obuf) : basic_syncbuf(__obuf, _Allocator()) {} | |
| 258 | 267 | |
| 259 | 268 | _LIBCPP_HIDE_FROM_ABI basic_syncbuf(streambuf_type* __obuf, _Allocator const& __alloc) |
| 260 | 269 | : __wrapped_(__obuf), __str_(__alloc) { |
| ... | ... | @@ -267,14 +276,14 @@ public: |
| 267 | 276 | } |
| 268 | 277 | |
| 269 | 278 | _LIBCPP_HIDE_FROM_ABI ~basic_syncbuf() { |
| 270 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 279 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 271 | 280 | try { |
| 272 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 281 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 273 | 282 | emit(); |
| 274 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 283 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 275 | 284 | } catch (...) { |
| 276 | 285 | } |
| 277 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 286 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 278 | 287 | __dec_reference(); |
| 279 | 288 | } |
| 280 | 289 | |
| ... | ... | @@ -331,9 +340,9 @@ protected: |
| 331 | 340 | return traits_type::not_eof(__c); |
| 332 | 341 | |
| 333 | 342 | if (this->pptr() == this->epptr()) { |
| 334 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 343 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 335 | 344 | try { |
| 336 | # endif | |
| 345 | # endif | |
| 337 | 346 | size_t __size = __str_.size(); |
| 338 | 347 | __str_.resize(__str_.capacity() + 1); |
| 339 | 348 | _LIBCPP_ASSERT_INTERNAL(__str_.size() > __size, "the buffer hasn't grown"); |
| ... | ... | @@ -342,11 +351,11 @@ protected: |
| 342 | 351 | this->setp(__p, __p + __str_.size()); |
| 343 | 352 | this->pbump(__size); |
| 344 | 353 | |
| 345 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 354 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 346 | 355 | } catch (...) { |
| 347 | 356 | return traits_type::eof(); |
| 348 | 357 | } |
| 349 | # endif | |
| 358 | # endif | |
| 350 | 359 | } |
| 351 | 360 | |
| 352 | 361 | return this->sputc(traits_type::to_char_type(__c)); |
| ... | ... | @@ -358,7 +367,7 @@ private: |
| 358 | 367 | // TODO Use a more generic buffer. |
| 359 | 368 | // That buffer should be light with almost no additional headers. Then |
| 360 | 369 | // it can be use here, the __retarget_buffer, and place that use |
| 361 | // the now deprecated get_temporary_buffer | |
| 370 | // the now removed get_temporary_buffer | |
| 362 | 371 | |
| 363 | 372 | basic_string<_CharT, _Traits, _Allocator> __str_; |
| 364 | 373 | bool __emit_on_sync_{false}; |
| ... | ... | @@ -367,9 +376,9 @@ private: |
| 367 | 376 | if (!__wrapped_) |
| 368 | 377 | return false; |
| 369 | 378 | |
| 370 | # ifndef _LIBCPP_HAS_NO_THREADS | |
| 379 | # if _LIBCPP_HAS_THREADS | |
| 371 | 380 | lock_guard<mutex> __lock = __wrapped_streambuf_mutex::__instance().__get_lock(__wrapped_); |
| 372 | # endif | |
| 381 | # endif | |
| 373 | 382 | |
| 374 | 383 | bool __result = true; |
| 375 | 384 | if (this->pptr() != this->pbase()) { |
| ... | ... | @@ -401,24 +410,24 @@ private: |
| 401 | 410 | } |
| 402 | 411 | |
| 403 | 412 | _LIBCPP_HIDE_FROM_ABI void __inc_reference() { |
| 404 | # ifndef _LIBCPP_HAS_NO_THREADS | |
| 413 | # if _LIBCPP_HAS_THREADS | |
| 405 | 414 | if (__wrapped_) |
| 406 | 415 | __wrapped_streambuf_mutex::__instance().__inc_reference(__wrapped_); |
| 407 | # endif | |
| 416 | # endif | |
| 408 | 417 | } |
| 409 | 418 | |
| 410 | 419 | _LIBCPP_HIDE_FROM_ABI void __dec_reference() noexcept { |
| 411 | # ifndef _LIBCPP_HAS_NO_THREADS | |
| 420 | # if _LIBCPP_HAS_THREADS | |
| 412 | 421 | if (__wrapped_) |
| 413 | 422 | __wrapped_streambuf_mutex::__instance().__dec_reference(__wrapped_); |
| 414 | # endif | |
| 423 | # endif | |
| 415 | 424 | } |
| 416 | 425 | }; |
| 417 | 426 | |
| 418 | 427 | using std::syncbuf; |
| 419 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 428 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 420 | 429 | using std::wsyncbuf; |
| 421 | # endif | |
| 430 | # endif | |
| 422 | 431 | |
| 423 | 432 | // [syncstream.syncbuf.special], specialized algorithms |
| 424 | 433 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -474,17 +483,17 @@ public: |
| 474 | 483 | // TODO validate other unformatted output functions. |
| 475 | 484 | typename basic_ostream<char_type, traits_type>::sentry __s(*this); |
| 476 | 485 | if (__s) { |
| 477 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 486 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 478 | 487 | try { |
| 479 | # endif | |
| 488 | # endif | |
| 480 | 489 | |
| 481 | 490 | if (__sb_.emit() == false) |
| 482 | 491 | this->setstate(ios::badbit); |
| 483 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 492 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 484 | 493 | } catch (...) { |
| 485 | 494 | this->__set_badbit_and_consider_rethrow(); |
| 486 | 495 | } |
| 487 | # endif | |
| 496 | # endif | |
| 488 | 497 | } |
| 489 | 498 | } |
| 490 | 499 | |
| ... | ... | @@ -499,14 +508,17 @@ private: |
| 499 | 508 | }; |
| 500 | 509 | |
| 501 | 510 | using std::osyncstream; |
| 502 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 511 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 503 | 512 | using std::wosyncstream; |
| 504 | # endif | |
| 513 | # endif | |
| 505 | 514 | |
| 506 | #endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) | |
| 515 | # endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM | |
| 507 | 516 | |
| 508 | 517 | _LIBCPP_END_NAMESPACE_STD |
| 509 | 518 | |
| 510 | 519 | _LIBCPP_POP_MACROS |
| 511 | 520 | |
| 521 | # endif // _LIBCPP_HAS_LOCALIZATION | |
| 522 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 523 | ||
| 512 | 524 | #endif // _LIBCPP_SYNCSTREAM |
lib/libcxx/include/system_error+23-19| ... | ... | @@ -144,28 +144,32 @@ template <> struct hash<std::error_condition>; |
| 144 | 144 | |
| 145 | 145 | */ |
| 146 | 146 | |
| 147 | #include <__config> | |
| 148 | #include <__system_error/errc.h> | |
| 149 | #include <__system_error/error_category.h> | |
| 150 | #include <__system_error/error_code.h> | |
| 151 | #include <__system_error/error_condition.h> | |
| 152 | #include <__system_error/system_error.h> | |
| 153 | #include <version> | |
| 147 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 148 | # include <__cxx03/system_error> | |
| 149 | #else | |
| 150 | # include <__config> | |
| 151 | # include <__system_error/errc.h> | |
| 152 | # include <__system_error/error_category.h> | |
| 153 | # include <__system_error/error_code.h> | |
| 154 | # include <__system_error/error_condition.h> | |
| 155 | # include <__system_error/system_error.h> | |
| 156 | # include <version> | |
| 154 | 157 | |
| 155 | 158 | // standard-mandated includes |
| 156 | 159 | |
| 157 | 160 | // [system.error.syn] |
| 158 | #include <compare> | |
| 159 | ||
| 160 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 161 | # pragma GCC system_header | |
| 162 | #endif | |
| 163 | ||
| 164 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 165 | # include <cstdint> | |
| 166 | # include <cstring> | |
| 167 | # include <limits> | |
| 168 | # include <type_traits> | |
| 169 | #endif | |
| 161 | # include <compare> | |
| 162 | ||
| 163 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 164 | # pragma GCC system_header | |
| 165 | # endif | |
| 166 | ||
| 167 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 168 | # include <cstdint> | |
| 169 | # include <cstring> | |
| 170 | # include <limits> | |
| 171 | # include <type_traits> | |
| 172 | # endif | |
| 173 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 170 | 174 | |
| 171 | 175 | #endif // _LIBCPP_SYSTEM_ERROR |
lib/libcxx/include/tgmath.h+15-10| ... | ... | @@ -17,18 +17,23 @@ |
| 17 | 17 | |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | #include <__config> | |
| 20 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 21 | # include <__cxx03/tgmath.h> | |
| 22 | #else | |
| 23 | # include <__config> | |
| 21 | 24 | |
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | # endif | |
| 25 | 28 | |
| 26 | #ifdef __cplusplus | |
| 27 | # include <ctgmath> | |
| 28 | #else | |
| 29 | # if __has_include_next(<tgmath.h>) | |
| 30 | # include_next <tgmath.h> | |
| 29 | # ifdef __cplusplus | |
| 30 | # include <cmath> | |
| 31 | # include <complex> | |
| 32 | # else | |
| 33 | # if __has_include_next(<tgmath.h>) | |
| 34 | # include_next <tgmath.h> | |
| 35 | # endif | |
| 31 | 36 | # endif |
| 32 | #endif | |
| 37 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 33 | 38 | |
| 34 | 39 | #endif // _LIBCPP_TGMATH_H |
lib/libcxx/include/thread+34-31| ... | ... | @@ -86,45 +86,48 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time); |
| 86 | 86 | |
| 87 | 87 | */ |
| 88 | 88 | |
| 89 | #include <__config> | |
| 89 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 90 | # include <__cxx03/thread> | |
| 91 | #else | |
| 92 | # include <__config> | |
| 90 | 93 | |
| 91 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 94 | # if _LIBCPP_HAS_THREADS | |
| 92 | 95 | |
| 93 | # include <__thread/formatter.h> | |
| 94 | # include <__thread/jthread.h> | |
| 95 | # include <__thread/support.h> | |
| 96 | # include <__thread/this_thread.h> | |
| 97 | # include <__thread/thread.h> | |
| 98 | # include <version> | |
| 96 | # include <__thread/this_thread.h> | |
| 97 | # include <__thread/thread.h> | |
| 98 | ||
| 99 | # if _LIBCPP_STD_VER >= 20 | |
| 100 | # include <__thread/jthread.h> | |
| 101 | # endif | |
| 102 | ||
| 103 | # if _LIBCPP_STD_VER >= 23 | |
| 104 | # include <__thread/formatter.h> | |
| 105 | # endif | |
| 106 | ||
| 107 | # include <version> | |
| 99 | 108 | |
| 100 | 109 | // standard-mandated includes |
| 101 | 110 | |
| 102 | 111 | // [thread.syn] |
| 103 | # include <compare> | |
| 112 | # include <compare> | |
| 104 | 113 | |
| 105 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 106 | # pragma GCC system_header | |
| 114 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 115 | # pragma GCC system_header | |
| 116 | # endif | |
| 117 | ||
| 118 | # endif // _LIBCPP_HAS_THREADS | |
| 119 | ||
| 120 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 121 | # include <chrono> | |
| 107 | 122 | # endif |
| 108 | 123 | |
| 109 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 110 | ||
| 111 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) | |
| 112 | # include <cstddef> | |
| 113 | # include <ctime> | |
| 114 | # include <iosfwd> | |
| 115 | # include <ratio> | |
| 116 | #endif | |
| 117 | ||
| 118 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 | |
| 119 | # include <chrono> | |
| 120 | #endif | |
| 121 | ||
| 122 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 123 | # include <cstring> | |
| 124 | # include <functional> | |
| 125 | # include <new> | |
| 126 | # include <system_error> | |
| 127 | # include <type_traits> | |
| 128 | #endif | |
| 124 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 125 | # include <cstring> | |
| 126 | # include <functional> | |
| 127 | # include <new> | |
| 128 | # include <system_error> | |
| 129 | # include <type_traits> | |
| 130 | # endif | |
| 131 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 129 | 132 | |
| 130 | 133 | #endif // _LIBCPP_THREAD |
lib/libcxx/include/tuple+159-136| ... | ... | @@ -210,73 +210,80 @@ template <class... Types> |
| 210 | 210 | |
| 211 | 211 | // clang-format on |
| 212 | 212 | |
| 213 | #include <__compare/common_comparison_category.h> | |
| 214 | #include <__compare/synth_three_way.h> | |
| 215 | #include <__config> | |
| 216 | #include <__functional/invoke.h> | |
| 217 | #include <__fwd/array.h> | |
| 218 | #include <__fwd/pair.h> | |
| 219 | #include <__fwd/tuple.h> | |
| 220 | #include <__memory/allocator_arg_t.h> | |
| 221 | #include <__memory/uses_allocator.h> | |
| 222 | #include <__tuple/find_index.h> | |
| 223 | #include <__tuple/ignore.h> | |
| 224 | #include <__tuple/make_tuple_types.h> | |
| 225 | #include <__tuple/sfinae_helpers.h> | |
| 226 | #include <__tuple/tuple_element.h> | |
| 227 | #include <__tuple/tuple_indices.h> | |
| 228 | #include <__tuple/tuple_like_ext.h> | |
| 229 | #include <__tuple/tuple_size.h> | |
| 230 | #include <__tuple/tuple_types.h> | |
| 231 | #include <__type_traits/common_reference.h> | |
| 232 | #include <__type_traits/common_type.h> | |
| 233 | #include <__type_traits/conditional.h> | |
| 234 | #include <__type_traits/conjunction.h> | |
| 235 | #include <__type_traits/copy_cvref.h> | |
| 236 | #include <__type_traits/disjunction.h> | |
| 237 | #include <__type_traits/is_arithmetic.h> | |
| 238 | #include <__type_traits/is_assignable.h> | |
| 239 | #include <__type_traits/is_constructible.h> | |
| 240 | #include <__type_traits/is_convertible.h> | |
| 241 | #include <__type_traits/is_empty.h> | |
| 242 | #include <__type_traits/is_final.h> | |
| 243 | #include <__type_traits/is_implicitly_default_constructible.h> | |
| 244 | #include <__type_traits/is_nothrow_assignable.h> | |
| 245 | #include <__type_traits/is_nothrow_constructible.h> | |
| 246 | #include <__type_traits/is_reference.h> | |
| 247 | #include <__type_traits/is_same.h> | |
| 248 | #include <__type_traits/is_swappable.h> | |
| 249 | #include <__type_traits/is_trivially_relocatable.h> | |
| 250 | #include <__type_traits/lazy.h> | |
| 251 | #include <__type_traits/maybe_const.h> | |
| 252 | #include <__type_traits/nat.h> | |
| 253 | #include <__type_traits/negation.h> | |
| 254 | #include <__type_traits/remove_cvref.h> | |
| 255 | #include <__type_traits/remove_reference.h> | |
| 256 | #include <__type_traits/unwrap_ref.h> | |
| 257 | #include <__utility/forward.h> | |
| 258 | #include <__utility/integer_sequence.h> | |
| 259 | #include <__utility/move.h> | |
| 260 | #include <__utility/piecewise_construct.h> | |
| 261 | #include <__utility/swap.h> | |
| 262 | #include <cstddef> | |
| 263 | #include <version> | |
| 213 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 214 | # include <__cxx03/tuple> | |
| 215 | #else | |
| 216 | # include <__compare/common_comparison_category.h> | |
| 217 | # include <__compare/ordering.h> | |
| 218 | # include <__compare/synth_three_way.h> | |
| 219 | # include <__config> | |
| 220 | # include <__cstddef/size_t.h> | |
| 221 | # include <__fwd/array.h> | |
| 222 | # include <__fwd/pair.h> | |
| 223 | # include <__fwd/tuple.h> | |
| 224 | # include <__memory/allocator_arg_t.h> | |
| 225 | # include <__memory/uses_allocator.h> | |
| 226 | # include <__tuple/find_index.h> | |
| 227 | # include <__tuple/ignore.h> | |
| 228 | # include <__tuple/make_tuple_types.h> | |
| 229 | # include <__tuple/sfinae_helpers.h> | |
| 230 | # include <__tuple/tuple_element.h> | |
| 231 | # include <__tuple/tuple_indices.h> | |
| 232 | # include <__tuple/tuple_like_ext.h> | |
| 233 | # include <__tuple/tuple_size.h> | |
| 234 | # include <__tuple/tuple_types.h> | |
| 235 | # include <__type_traits/common_reference.h> | |
| 236 | # include <__type_traits/common_type.h> | |
| 237 | # include <__type_traits/conditional.h> | |
| 238 | # include <__type_traits/conjunction.h> | |
| 239 | # include <__type_traits/copy_cvref.h> | |
| 240 | # include <__type_traits/disjunction.h> | |
| 241 | # include <__type_traits/enable_if.h> | |
| 242 | # include <__type_traits/invoke.h> | |
| 243 | # include <__type_traits/is_arithmetic.h> | |
| 244 | # include <__type_traits/is_assignable.h> | |
| 245 | # include <__type_traits/is_constructible.h> | |
| 246 | # include <__type_traits/is_convertible.h> | |
| 247 | # include <__type_traits/is_empty.h> | |
| 248 | # include <__type_traits/is_final.h> | |
| 249 | # include <__type_traits/is_implicitly_default_constructible.h> | |
| 250 | # include <__type_traits/is_nothrow_assignable.h> | |
| 251 | # include <__type_traits/is_nothrow_constructible.h> | |
| 252 | # include <__type_traits/is_reference.h> | |
| 253 | # include <__type_traits/is_same.h> | |
| 254 | # include <__type_traits/is_swappable.h> | |
| 255 | # include <__type_traits/is_trivially_relocatable.h> | |
| 256 | # include <__type_traits/lazy.h> | |
| 257 | # include <__type_traits/maybe_const.h> | |
| 258 | # include <__type_traits/nat.h> | |
| 259 | # include <__type_traits/negation.h> | |
| 260 | # include <__type_traits/remove_cv.h> | |
| 261 | # include <__type_traits/remove_cvref.h> | |
| 262 | # include <__type_traits/remove_reference.h> | |
| 263 | # include <__type_traits/unwrap_ref.h> | |
| 264 | # include <__utility/declval.h> | |
| 265 | # include <__utility/forward.h> | |
| 266 | # include <__utility/integer_sequence.h> | |
| 267 | # include <__utility/move.h> | |
| 268 | # include <__utility/piecewise_construct.h> | |
| 269 | # include <__utility/swap.h> | |
| 270 | # include <version> | |
| 264 | 271 | |
| 265 | 272 | // standard-mandated includes |
| 266 | 273 | |
| 267 | 274 | // [tuple.syn] |
| 268 | #include <compare> | |
| 275 | # include <compare> | |
| 269 | 276 | |
| 270 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 271 | # pragma GCC system_header | |
| 272 | #endif | |
| 277 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 278 | # pragma GCC system_header | |
| 279 | # endif | |
| 273 | 280 | |
| 274 | 281 | _LIBCPP_PUSH_MACROS |
| 275 | #include <__undef_macros> | |
| 282 | # include <__undef_macros> | |
| 276 | 283 | |
| 277 | 284 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 278 | 285 | |
| 279 | #ifndef _LIBCPP_CXX03_LANG | |
| 286 | # ifndef _LIBCPP_CXX03_LANG | |
| 280 | 287 | |
| 281 | 288 | // __tuple_leaf |
| 282 | 289 | |
| ... | ... | @@ -302,11 +309,11 @@ class __tuple_leaf { |
| 302 | 309 | |
| 303 | 310 | template <class _Tp> |
| 304 | 311 | static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() { |
| 305 | # if __has_keyword(__reference_binds_to_temporary) | |
| 312 | # if __has_keyword(__reference_binds_to_temporary) | |
| 306 | 313 | return !__reference_binds_to_temporary(_Hp, _Tp); |
| 307 | # else | |
| 314 | # else | |
| 308 | 315 | return true; |
| 309 | # endif | |
| 316 | # endif | |
| 310 | 317 | } |
| 311 | 318 | |
| 312 | 319 | public: |
| ... | ... | @@ -384,7 +391,7 @@ public: |
| 384 | 391 | }; |
| 385 | 392 | |
| 386 | 393 | template <size_t _Ip, class _Hp> |
| 387 | class __tuple_leaf<_Ip, _Hp, true> : private _Hp { | |
| 394 | class __tuple_leaf<_Ip, _Hp, true> : private __remove_cv_t<_Hp> { | |
| 388 | 395 | public: |
| 389 | 396 | _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete; |
| 390 | 397 | |
| ... | ... | @@ -546,7 +553,8 @@ class _LIBCPP_TEMPLATE_VIS tuple { |
| 546 | 553 | get(const tuple<_Up...>&&) _NOEXCEPT; |
| 547 | 554 | |
| 548 | 555 | public: |
| 549 | using __trivially_relocatable = __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>; | |
| 556 | using __trivially_relocatable _LIBCPP_NODEBUG = | |
| 557 | __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>; | |
| 550 | 558 | |
| 551 | 559 | // [tuple.cnstr] |
| 552 | 560 | |
| ... | ... | @@ -690,7 +698,7 @@ public: |
| 690 | 698 | tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) |
| 691 | 699 | : __base_(allocator_arg_t(), __a, __t) {} |
| 692 | 700 | |
| 693 | # if _LIBCPP_STD_VER >= 23 | |
| 701 | # if _LIBCPP_STD_VER >= 23 | |
| 694 | 702 | // tuple(tuple<U...>&) constructors (including allocator_arg_t variants) |
| 695 | 703 | |
| 696 | 704 | template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr> |
| ... | ... | @@ -701,7 +709,7 @@ public: |
| 701 | 709 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) |
| 702 | 710 | tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t) |
| 703 | 711 | : __base_(allocator_arg_t(), __alloc, __t) {} |
| 704 | # endif // _LIBCPP_STD_VER >= 23 | |
| 712 | # endif // _LIBCPP_STD_VER >= 23 | |
| 705 | 713 | |
| 706 | 714 | // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants) |
| 707 | 715 | template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0> |
| ... | ... | @@ -716,7 +724,7 @@ public: |
| 716 | 724 | tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t) |
| 717 | 725 | : __base_(allocator_arg_t(), __a, std::move(__t)) {} |
| 718 | 726 | |
| 719 | # if _LIBCPP_STD_VER >= 23 | |
| 727 | # if _LIBCPP_STD_VER >= 23 | |
| 720 | 728 | // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants) |
| 721 | 729 | |
| 722 | 730 | template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr> |
| ... | ... | @@ -730,7 +738,7 @@ public: |
| 730 | 738 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value) |
| 731 | 739 | tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t) |
| 732 | 740 | : __base_(allocator_arg_t(), __alloc, std::move(__t)) {} |
| 733 | # endif // _LIBCPP_STD_VER >= 23 | |
| 741 | # endif // _LIBCPP_STD_VER >= 23 | |
| 734 | 742 | |
| 735 | 743 | // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants) |
| 736 | 744 | |
| ... | ... | @@ -776,7 +784,7 @@ public: |
| 776 | 784 | tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) |
| 777 | 785 | : __base_(allocator_arg_t(), __a, __p) {} |
| 778 | 786 | |
| 779 | # if _LIBCPP_STD_VER >= 23 | |
| 787 | # if _LIBCPP_STD_VER >= 23 | |
| 780 | 788 | // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants) |
| 781 | 789 | |
| 782 | 790 | template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr> |
| ... | ... | @@ -791,7 +799,7 @@ public: |
| 791 | 799 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value) |
| 792 | 800 | tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p) |
| 793 | 801 | : __base_(allocator_arg_t(), __alloc, __p) {} |
| 794 | # endif | |
| 802 | # endif | |
| 795 | 803 | |
| 796 | 804 | // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants) |
| 797 | 805 | |
| ... | ... | @@ -814,7 +822,7 @@ public: |
| 814 | 822 | tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) |
| 815 | 823 | : __base_(allocator_arg_t(), __a, std::move(__p)) {} |
| 816 | 824 | |
| 817 | # if _LIBCPP_STD_VER >= 23 | |
| 825 | # if _LIBCPP_STD_VER >= 23 | |
| 818 | 826 | // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants) |
| 819 | 827 | |
| 820 | 828 | template <class _U1, class _U2, enable_if_t< _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr> |
| ... | ... | @@ -829,17 +837,17 @@ public: |
| 829 | 837 | _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value) |
| 830 | 838 | tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p) |
| 831 | 839 | : __base_(allocator_arg_t(), __alloc, std::move(__p)) {} |
| 832 | # endif // _LIBCPP_STD_VER >= 23 | |
| 840 | # endif // _LIBCPP_STD_VER >= 23 | |
| 833 | 841 | |
| 834 | 842 | // [tuple.assign] |
| 835 | 843 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& |
| 836 | operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) | |
| 837 | noexcept(_And<is_nothrow_copy_assignable<_Tp>...>::value) { | |
| 844 | operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) noexcept( | |
| 845 | _And<is_nothrow_copy_assignable<_Tp>...>::value) { | |
| 838 | 846 | std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 839 | 847 | return *this; |
| 840 | 848 | } |
| 841 | 849 | |
| 842 | # if _LIBCPP_STD_VER >= 23 | |
| 850 | # if _LIBCPP_STD_VER >= 23 | |
| 843 | 851 | _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple const& __tuple) const |
| 844 | 852 | requires(_And<is_copy_assignable<const _Tp>...>::value) |
| 845 | 853 | { |
| ... | ... | @@ -854,11 +862,11 @@ public: |
| 854 | 862 | *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 855 | 863 | return *this; |
| 856 | 864 | } |
| 857 | # endif // _LIBCPP_STD_VER >= 23 | |
| 865 | # endif // _LIBCPP_STD_VER >= 23 | |
| 858 | 866 | |
| 859 | 867 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& |
| 860 | operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) | |
| 861 | noexcept(_And<is_nothrow_move_assignable<_Tp>...>::value) { | |
| 868 | operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) noexcept( | |
| 869 | _And<is_nothrow_move_assignable<_Tp>...>::value) { | |
| 862 | 870 | std::__memberwise_forward_assign( |
| 863 | 871 | *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 864 | 872 | return *this; |
| ... | ... | @@ -868,8 +876,8 @@ public: |
| 868 | 876 | class... _Up, |
| 869 | 877 | __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up const&>... >::value, |
| 870 | 878 | int> = 0> |
| 871 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...> const& __tuple) | |
| 872 | noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { | |
| 879 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | |
| 880 | operator=(tuple<_Up...> const& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { | |
| 873 | 881 | std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 874 | 882 | return *this; |
| 875 | 883 | } |
| ... | ... | @@ -877,14 +885,14 @@ public: |
| 877 | 885 | template <class... _Up, |
| 878 | 886 | __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up>... >::value, |
| 879 | 887 | int> = 0> |
| 880 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...>&& __tuple) | |
| 881 | noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { | |
| 888 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | |
| 889 | operator=(tuple<_Up...>&& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { | |
| 882 | 890 | std::__memberwise_forward_assign( |
| 883 | 891 | *this, std::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 884 | 892 | return *this; |
| 885 | 893 | } |
| 886 | 894 | |
| 887 | # if _LIBCPP_STD_VER >= 23 | |
| 895 | # if _LIBCPP_STD_VER >= 23 | |
| 888 | 896 | template <class... _UTypes, |
| 889 | 897 | enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>, |
| 890 | 898 | is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr> |
| ... | ... | @@ -901,7 +909,7 @@ public: |
| 901 | 909 | *this, __u, __tuple_types<_UTypes...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 902 | 910 | return *this; |
| 903 | 911 | } |
| 904 | # endif // _LIBCPP_STD_VER >= 23 | |
| 912 | # endif // _LIBCPP_STD_VER >= 23 | |
| 905 | 913 | |
| 906 | 914 | template <template <class...> class _Pred, |
| 907 | 915 | bool _Const, |
| ... | ... | @@ -921,7 +929,7 @@ public: |
| 921 | 929 | template <bool _Const, class _Pair> |
| 922 | 930 | struct _NothrowAssignFromPair : _AssignPredicateFromPair<is_nothrow_assignable, _Const, _Pair> {}; |
| 923 | 931 | |
| 924 | # if _LIBCPP_STD_VER >= 23 | |
| 932 | # if _LIBCPP_STD_VER >= 23 | |
| 925 | 933 | template <class _U1, class _U2, enable_if_t< _EnableAssignFromPair<true, const pair<_U1, _U2>&>::value>* = nullptr> |
| 926 | 934 | _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const pair<_U1, _U2>& __pair) const |
| 927 | 935 | noexcept(_NothrowAssignFromPair<true, const pair<_U1, _U2>&>::value) { |
| ... | ... | @@ -937,21 +945,21 @@ public: |
| 937 | 945 | std::get<1>(*this) = std::move(__pair.second); |
| 938 | 946 | return *this; |
| 939 | 947 | } |
| 940 | # endif // _LIBCPP_STD_VER >= 23 | |
| 948 | # endif // _LIBCPP_STD_VER >= 23 | |
| 941 | 949 | |
| 942 | 950 | template <class _Up1, |
| 943 | 951 | class _Up2, |
| 944 | 952 | __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value, int> = 0> |
| 945 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2> const& __pair) | |
| 946 | noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value) { | |
| 953 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | |
| 954 | operator=(pair<_Up1, _Up2> const& __pair) noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value) { | |
| 947 | 955 | std::get<0>(*this) = __pair.first; |
| 948 | 956 | std::get<1>(*this) = __pair.second; |
| 949 | 957 | return *this; |
| 950 | 958 | } |
| 951 | 959 | |
| 952 | 960 | template <class _Up1, class _Up2, __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value, int> = 0> |
| 953 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2>&& __pair) | |
| 954 | noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value) { | |
| 961 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | |
| 962 | operator=(pair<_Up1, _Up2>&& __pair) noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value) { | |
| 955 | 963 | std::get<0>(*this) = std::forward<_Up1>(__pair.first); |
| 956 | 964 | std::get<1>(*this) = std::forward<_Up2>(__pair.second); |
| 957 | 965 | return *this; |
| ... | ... | @@ -962,8 +970,8 @@ public: |
| 962 | 970 | class _Up, |
| 963 | 971 | size_t _Np, |
| 964 | 972 | __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0> |
| 965 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np> const& __array) | |
| 966 | noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { | |
| 973 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | |
| 974 | operator=(array<_Up, _Np> const& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) { | |
| 967 | 975 | std::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices<sizeof...(_Tp)>::type()); |
| 968 | 976 | return *this; |
| 969 | 977 | } |
| ... | ... | @@ -973,8 +981,8 @@ public: |
| 973 | 981 | size_t _Np, |
| 974 | 982 | class = void, |
| 975 | 983 | __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up>... >::value, int> = 0> |
| 976 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np>&& __array) | |
| 977 | noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { | |
| 984 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& | |
| 985 | operator=(array<_Up, _Np>&& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) { | |
| 978 | 986 | std::__memberwise_forward_assign( |
| 979 | 987 | *this, |
| 980 | 988 | std::move(__array), |
| ... | ... | @@ -984,17 +992,17 @@ public: |
| 984 | 992 | } |
| 985 | 993 | |
| 986 | 994 | // [tuple.swap] |
| 987 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple& __t) | |
| 988 | noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { | |
| 995 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 996 | swap(tuple& __t) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { | |
| 989 | 997 | __base_.swap(__t.__base_); |
| 990 | 998 | } |
| 991 | 999 | |
| 992 | # if _LIBCPP_STD_VER >= 23 | |
| 1000 | # if _LIBCPP_STD_VER >= 23 | |
| 993 | 1001 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple& __t) const |
| 994 | 1002 | noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) { |
| 995 | 1003 | __base_.swap(__t.__base_); |
| 996 | 1004 | } |
| 997 | # endif // _LIBCPP_STD_VER >= 23 | |
| 1005 | # endif // _LIBCPP_STD_VER >= 23 | |
| 998 | 1006 | }; |
| 999 | 1007 | |
| 1000 | 1008 | template <> |
| ... | ... | @@ -1010,12 +1018,12 @@ public: |
| 1010 | 1018 | template <class _Alloc, class _Up> |
| 1011 | 1019 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {} |
| 1012 | 1020 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple&) _NOEXCEPT {} |
| 1013 | # if _LIBCPP_STD_VER >= 23 | |
| 1021 | # if _LIBCPP_STD_VER >= 23 | |
| 1014 | 1022 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {} |
| 1015 | # endif | |
| 1023 | # endif | |
| 1016 | 1024 | }; |
| 1017 | 1025 | |
| 1018 | # if _LIBCPP_STD_VER >= 23 | |
| 1026 | # if _LIBCPP_STD_VER >= 23 | |
| 1019 | 1027 | template <class... _TTypes, class... _UTypes, template <class> class _TQual, template <class> class _UQual> |
| 1020 | 1028 | requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; } |
| 1021 | 1029 | struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> { |
| ... | ... | @@ -1027,9 +1035,9 @@ template <class... _TTypes, class... _UTypes> |
| 1027 | 1035 | struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> { |
| 1028 | 1036 | using type = tuple<common_type_t<_TTypes, _UTypes>...>; |
| 1029 | 1037 | }; |
| 1030 | # endif // _LIBCPP_STD_VER >= 23 | |
| 1038 | # endif // _LIBCPP_STD_VER >= 23 | |
| 1031 | 1039 | |
| 1032 | # if _LIBCPP_STD_VER >= 17 | |
| 1040 | # if _LIBCPP_STD_VER >= 17 | |
| 1033 | 1041 | template <class... _Tp> |
| 1034 | 1042 | tuple(_Tp...) -> tuple<_Tp...>; |
| 1035 | 1043 | template <class _Tp1, class _Tp2> |
| ... | ... | @@ -1040,54 +1048,54 @@ template <class _Alloc, class _Tp1, class _Tp2> |
| 1040 | 1048 | tuple(allocator_arg_t, _Alloc, pair<_Tp1, _Tp2>) -> tuple<_Tp1, _Tp2>; |
| 1041 | 1049 | template <class _Alloc, class... _Tp> |
| 1042 | 1050 | tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>; |
| 1043 | # endif | |
| 1051 | # endif | |
| 1044 | 1052 | |
| 1045 | 1053 | template <class... _Tp, __enable_if_t<__all<__is_swappable_v<_Tp>...>::value, int> = 0> |
| 1046 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) | |
| 1047 | noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { | |
| 1054 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 1055 | swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) { | |
| 1048 | 1056 | __t.swap(__u); |
| 1049 | 1057 | } |
| 1050 | 1058 | |
| 1051 | # if _LIBCPP_STD_VER >= 23 | |
| 1059 | # if _LIBCPP_STD_VER >= 23 | |
| 1052 | 1060 | template <class... _Tp> |
| 1053 | 1061 | _LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<__all<is_swappable_v<const _Tp>...>::value, void> |
| 1054 | 1062 | swap(const tuple<_Tp...>& __lhs, |
| 1055 | 1063 | const tuple<_Tp...>& __rhs) noexcept(__all<is_nothrow_swappable_v<const _Tp>...>::value) { |
| 1056 | 1064 | __lhs.swap(__rhs); |
| 1057 | 1065 | } |
| 1058 | # endif | |
| 1066 | # endif | |
| 1059 | 1067 | |
| 1060 | 1068 | // get |
| 1061 | 1069 | |
| 1062 | 1070 | template <size_t _Ip, class... _Tp> |
| 1063 | 1071 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type& |
| 1064 | 1072 | get(tuple<_Tp...>& __t) _NOEXCEPT { |
| 1065 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1073 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; | |
| 1066 | 1074 | return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get(); |
| 1067 | 1075 | } |
| 1068 | 1076 | |
| 1069 | 1077 | template <size_t _Ip, class... _Tp> |
| 1070 | 1078 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type& |
| 1071 | 1079 | get(const tuple<_Tp...>& __t) _NOEXCEPT { |
| 1072 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1080 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; | |
| 1073 | 1081 | return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get(); |
| 1074 | 1082 | } |
| 1075 | 1083 | |
| 1076 | 1084 | template <size_t _Ip, class... _Tp> |
| 1077 | 1085 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&& |
| 1078 | 1086 | get(tuple<_Tp...>&& __t) _NOEXCEPT { |
| 1079 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1087 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; | |
| 1080 | 1088 | return static_cast<type&&>(static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get()); |
| 1081 | 1089 | } |
| 1082 | 1090 | |
| 1083 | 1091 | template <size_t _Ip, class... _Tp> |
| 1084 | 1092 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&& |
| 1085 | 1093 | get(const tuple<_Tp...>&& __t) _NOEXCEPT { |
| 1086 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1094 | using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, tuple<_Tp...> >::type; | |
| 1087 | 1095 | return static_cast<const type&&>(static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get()); |
| 1088 | 1096 | } |
| 1089 | 1097 | |
| 1090 | # if _LIBCPP_STD_VER >= 14 | |
| 1098 | # if _LIBCPP_STD_VER >= 14 | |
| 1091 | 1099 | |
| 1092 | 1100 | template <class _T1, class... _Args> |
| 1093 | 1101 | inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(tuple<_Args...>& __tup) noexcept { |
| ... | ... | @@ -1109,7 +1117,7 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(tuple<_Args...> const&& _ |
| 1109 | 1117 | return std::get<__find_exactly_one_t<_T1, _Args...>::value>(std::move(__tup)); |
| 1110 | 1118 | } |
| 1111 | 1119 | |
| 1112 | # endif | |
| 1120 | # endif | |
| 1113 | 1121 | |
| 1114 | 1122 | // tie |
| 1115 | 1123 | |
| ... | ... | @@ -1119,9 +1127,9 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_T |
| 1119 | 1127 | } |
| 1120 | 1128 | |
| 1121 | 1129 | template <class... _Tp> |
| 1122 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<typename __unwrap_ref_decay<_Tp>::type...> | |
| 1130 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<__unwrap_ref_decay_t<_Tp>...> | |
| 1123 | 1131 | make_tuple(_Tp&&... __t) { |
| 1124 | return tuple<typename __unwrap_ref_decay<_Tp>::type...>(std::forward<_Tp>(__t)...); | |
| 1132 | return tuple<__unwrap_ref_decay_t<_Tp>...>(std::forward<_Tp>(__t)...); | |
| 1125 | 1133 | } |
| 1126 | 1134 | |
| 1127 | 1135 | template <class... _Tp> |
| ... | ... | @@ -1152,7 +1160,7 @@ operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { |
| 1152 | 1160 | return __tuple_equal<sizeof...(_Tp)>()(__x, __y); |
| 1153 | 1161 | } |
| 1154 | 1162 | |
| 1155 | # if _LIBCPP_STD_VER >= 20 | |
| 1163 | # if _LIBCPP_STD_VER >= 20 | |
| 1156 | 1164 | |
| 1157 | 1165 | // operator<=> |
| 1158 | 1166 | |
| ... | ... | @@ -1172,7 +1180,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { |
| 1172 | 1180 | return std::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{}); |
| 1173 | 1181 | } |
| 1174 | 1182 | |
| 1175 | # else // _LIBCPP_STD_VER >= 20 | |
| 1183 | # else // _LIBCPP_STD_VER >= 20 | |
| 1176 | 1184 | |
| 1177 | 1185 | template <class... _Tp, class... _Up> |
| 1178 | 1186 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool |
| ... | ... | @@ -1226,7 +1234,7 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) { |
| 1226 | 1234 | return !(__y < __x); |
| 1227 | 1235 | } |
| 1228 | 1236 | |
| 1229 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1237 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1230 | 1238 | |
| 1231 | 1239 | // tuple_cat |
| 1232 | 1240 | |
| ... | ... | @@ -1235,7 +1243,7 @@ struct __tuple_cat_type; |
| 1235 | 1243 | |
| 1236 | 1244 | template <class... _Ttypes, class... _Utypes> |
| 1237 | 1245 | struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> > { |
| 1238 | typedef _LIBCPP_NODEBUG tuple<_Ttypes..., _Utypes...> type; | |
| 1246 | using type _LIBCPP_NODEBUG = tuple<_Ttypes..., _Utypes...>; | |
| 1239 | 1247 | }; |
| 1240 | 1248 | |
| 1241 | 1249 | template <class _ResultTuple, bool _Is_Tuple0TupleLike, class... _Tuples> |
| ... | ... | @@ -1269,7 +1277,7 @@ struct __tuple_cat_return<_Tuple0, _Tuples...> |
| 1269 | 1277 | |
| 1270 | 1278 | template <> |
| 1271 | 1279 | struct __tuple_cat_return<> { |
| 1272 | typedef _LIBCPP_NODEBUG tuple<> type; | |
| 1280 | using type _LIBCPP_NODEBUG = tuple<>; | |
| 1273 | 1281 | }; |
| 1274 | 1282 | |
| 1275 | 1283 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<> tuple_cat() { return tuple<>(); } |
| ... | ... | @@ -1279,7 +1287,7 @@ struct __tuple_cat_return_ref_imp; |
| 1279 | 1287 | |
| 1280 | 1288 | template <class... _Types, size_t... _I0, class _Tuple0> |
| 1281 | 1289 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> { |
| 1282 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0; | |
| 1290 | using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>; | |
| 1283 | 1291 | typedef tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type; |
| 1284 | 1292 | }; |
| 1285 | 1293 | |
| ... | ... | @@ -1319,8 +1327,8 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J |
| 1319 | 1327 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type |
| 1320 | 1328 | operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&&... __tpls) { |
| 1321 | 1329 | (void)__t; // avoid unused parameter warning on GCC when _I0 is empty |
| 1322 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0; | |
| 1323 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1; | |
| 1330 | using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>; | |
| 1331 | using _T1 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple1>; | |
| 1324 | 1332 | return __tuple_cat<tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>, |
| 1325 | 1333 | typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type, |
| 1326 | 1334 | typename __make_tuple_indices<tuple_size<_T1>::value>::type>()( |
| ... | ... | @@ -1331,20 +1339,33 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J |
| 1331 | 1339 | } |
| 1332 | 1340 | }; |
| 1333 | 1341 | |
| 1342 | template <class _TupleDst, class _TupleSrc, size_t... _Indices> | |
| 1343 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _TupleDst | |
| 1344 | __tuple_cat_select_element_wise(_TupleSrc&& __src, __tuple_indices<_Indices...>) { | |
| 1345 | static_assert(tuple_size<_TupleDst>::value == tuple_size<_TupleSrc>::value, | |
| 1346 | "misuse of __tuple_cat_select_element_wise with tuples of different sizes"); | |
| 1347 | return _TupleDst(std::get<_Indices>(std::forward<_TupleSrc>(__src))...); | |
| 1348 | } | |
| 1349 | ||
| 1334 | 1350 | template <class _Tuple0, class... _Tuples> |
| 1335 | 1351 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __tuple_cat_return<_Tuple0, _Tuples...>::type |
| 1336 | 1352 | tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) { |
| 1337 | typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0; | |
| 1338 | return __tuple_cat<tuple<>, __tuple_indices<>, typename __make_tuple_indices<tuple_size<_T0>::value>::type>()( | |
| 1339 | tuple<>(), std::forward<_Tuple0>(__t0), std::forward<_Tuples>(__tpls)...); | |
| 1353 | using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>; | |
| 1354 | using _TRet _LIBCPP_NODEBUG = typename __tuple_cat_return<_Tuple0, _Tuples...>::type; | |
| 1355 | using _T0Indices _LIBCPP_NODEBUG = typename __make_tuple_indices<tuple_size<_T0>::value>::type; | |
| 1356 | using _TRetIndices _LIBCPP_NODEBUG = typename __make_tuple_indices<tuple_size<_TRet>::value>::type; | |
| 1357 | return std::__tuple_cat_select_element_wise<_TRet>( | |
| 1358 | __tuple_cat<tuple<>, __tuple_indices<>, _T0Indices>()( | |
| 1359 | tuple<>(), std::forward<_Tuple0>(__t0), std::forward<_Tuples>(__tpls)...), | |
| 1360 | _TRetIndices()); | |
| 1340 | 1361 | } |
| 1341 | 1362 | |
| 1342 | 1363 | template <class... _Tp, class _Alloc> |
| 1343 | 1364 | struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {}; |
| 1344 | 1365 | |
| 1345 | # if _LIBCPP_STD_VER >= 17 | |
| 1346 | # define _LIBCPP_NOEXCEPT_RETURN(...) \ | |
| 1347 | noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; } | |
| 1366 | # if _LIBCPP_STD_VER >= 17 | |
| 1367 | # define _LIBCPP_NOEXCEPT_RETURN(...) \ | |
| 1368 | noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; } | |
| 1348 | 1369 | |
| 1349 | 1370 | // The _LIBCPP_NOEXCEPT_RETURN macro breaks formatting. |
| 1350 | 1371 | // clang-format off |
| ... | ... | @@ -1407,13 +1428,15 @@ _LIBCPP_POP_MACROS |
| 1407 | 1428 | |
| 1408 | 1429 | // clang-format on |
| 1409 | 1430 | |
| 1410 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1411 | # include <exception> | |
| 1412 | # include <iosfwd> | |
| 1413 | # include <new> | |
| 1414 | # include <type_traits> | |
| 1415 | # include <typeinfo> | |
| 1416 | # include <utility> | |
| 1417 | #endif | |
| 1431 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1432 | # include <cstddef> | |
| 1433 | # include <exception> | |
| 1434 | # include <iosfwd> | |
| 1435 | # include <new> | |
| 1436 | # include <type_traits> | |
| 1437 | # include <typeinfo> | |
| 1438 | # include <utility> | |
| 1439 | # endif | |
| 1440 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1418 | 1441 | |
| 1419 | 1442 | #endif // _LIBCPP_TUPLE |
lib/libcxx/include/type_traits+114-102| ... | ... | @@ -137,6 +137,8 @@ namespace std |
| 137 | 137 | template <class T> struct is_nothrow_swappable; // C++17 |
| 138 | 138 | template <class T> struct is_nothrow_destructible; |
| 139 | 139 | |
| 140 | template<class T> struct is_implicit_lifetime; // Since C++23 | |
| 141 | ||
| 140 | 142 | template <class T> struct has_virtual_destructor; |
| 141 | 143 | |
| 142 | 144 | template<class T> struct has_unique_object_representations; // C++17 |
| ... | ... | @@ -144,6 +146,7 @@ namespace std |
| 144 | 146 | // Relationships between types: |
| 145 | 147 | template <class T, class U> struct is_same; |
| 146 | 148 | template <class Base, class Derived> struct is_base_of; |
| 149 | template <class Base, class Derived> struct is_virtual_base_of; // C++26 | |
| 147 | 150 | |
| 148 | 151 | template <class From, class To> struct is_convertible; |
| 149 | 152 | template <typename From, typename To> struct is_nothrow_convertible; // C++20 |
| ... | ... | @@ -373,6 +376,8 @@ namespace std |
| 373 | 376 | = is_nothrow_swappable<T>::value; // C++17 |
| 374 | 377 | template <class T> inline constexpr bool is_nothrow_destructible_v |
| 375 | 378 | = is_nothrow_destructible<T>::value; // C++17 |
| 379 | template<class T> | |
| 380 | constexpr bool is_implicit_lifetime_v = is_implicit_lifetime<T>::value; // Since C++23 | |
| 376 | 381 | template <class T> inline constexpr bool has_virtual_destructor_v |
| 377 | 382 | = has_virtual_destructor<T>::value; // C++17 |
| 378 | 383 | template<class T> inline constexpr bool has_unique_object_representations_v // C++17 |
| ... | ... | @@ -391,6 +396,8 @@ namespace std |
| 391 | 396 | = is_same<T, U>::value; // C++17 |
| 392 | 397 | template <class Base, class Derived> inline constexpr bool is_base_of_v |
| 393 | 398 | = is_base_of<Base, Derived>::value; // C++17 |
| 399 | template <class Base, class Derived> inline constexpr bool is_virtual_base_of_v | |
| 400 | = is_virtual_base_of<Base, Derived>::value; // C++26 | |
| 394 | 401 | template <class From, class To> inline constexpr bool is_convertible_v |
| 395 | 402 | = is_convertible<From, To>::value; // C++17 |
| 396 | 403 | template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v |
| ... | ... | @@ -417,107 +424,112 @@ namespace std |
| 417 | 424 | |
| 418 | 425 | */ |
| 419 | 426 | |
| 420 | #include <__config> | |
| 421 | #include <__fwd/functional.h> // This is https://llvm.org/PR56938 | |
| 422 | #include <__type_traits/add_const.h> | |
| 423 | #include <__type_traits/add_cv.h> | |
| 424 | #include <__type_traits/add_lvalue_reference.h> | |
| 425 | #include <__type_traits/add_pointer.h> | |
| 426 | #include <__type_traits/add_rvalue_reference.h> | |
| 427 | #include <__type_traits/add_volatile.h> | |
| 428 | #include <__type_traits/aligned_storage.h> | |
| 429 | #include <__type_traits/aligned_union.h> | |
| 430 | #include <__type_traits/alignment_of.h> | |
| 431 | #include <__type_traits/common_type.h> | |
| 432 | #include <__type_traits/conditional.h> | |
| 433 | #include <__type_traits/decay.h> | |
| 434 | #include <__type_traits/enable_if.h> | |
| 435 | #include <__type_traits/extent.h> | |
| 436 | #include <__type_traits/has_virtual_destructor.h> | |
| 437 | #include <__type_traits/integral_constant.h> | |
| 438 | #include <__type_traits/is_abstract.h> | |
| 439 | #include <__type_traits/is_arithmetic.h> | |
| 440 | #include <__type_traits/is_array.h> | |
| 441 | #include <__type_traits/is_assignable.h> | |
| 442 | #include <__type_traits/is_base_of.h> | |
| 443 | #include <__type_traits/is_class.h> | |
| 444 | #include <__type_traits/is_compound.h> | |
| 445 | #include <__type_traits/is_const.h> | |
| 446 | #include <__type_traits/is_constructible.h> | |
| 447 | #include <__type_traits/is_convertible.h> | |
| 448 | #include <__type_traits/is_destructible.h> | |
| 449 | #include <__type_traits/is_empty.h> | |
| 450 | #include <__type_traits/is_enum.h> | |
| 451 | #include <__type_traits/is_floating_point.h> | |
| 452 | #include <__type_traits/is_function.h> | |
| 453 | #include <__type_traits/is_fundamental.h> | |
| 454 | #include <__type_traits/is_integral.h> | |
| 455 | #include <__type_traits/is_literal_type.h> | |
| 456 | #include <__type_traits/is_member_pointer.h> | |
| 457 | #include <__type_traits/is_nothrow_assignable.h> | |
| 458 | #include <__type_traits/is_nothrow_constructible.h> | |
| 459 | #include <__type_traits/is_nothrow_destructible.h> | |
| 460 | #include <__type_traits/is_object.h> | |
| 461 | #include <__type_traits/is_pod.h> | |
| 462 | #include <__type_traits/is_pointer.h> | |
| 463 | #include <__type_traits/is_polymorphic.h> | |
| 464 | #include <__type_traits/is_reference.h> | |
| 465 | #include <__type_traits/is_same.h> | |
| 466 | #include <__type_traits/is_scalar.h> | |
| 467 | #include <__type_traits/is_signed.h> | |
| 468 | #include <__type_traits/is_standard_layout.h> | |
| 469 | #include <__type_traits/is_trivial.h> | |
| 470 | #include <__type_traits/is_trivially_assignable.h> | |
| 471 | #include <__type_traits/is_trivially_constructible.h> | |
| 472 | #include <__type_traits/is_trivially_copyable.h> | |
| 473 | #include <__type_traits/is_trivially_destructible.h> | |
| 474 | #include <__type_traits/is_union.h> | |
| 475 | #include <__type_traits/is_unsigned.h> | |
| 476 | #include <__type_traits/is_void.h> | |
| 477 | #include <__type_traits/is_volatile.h> | |
| 478 | #include <__type_traits/make_signed.h> | |
| 479 | #include <__type_traits/make_unsigned.h> | |
| 480 | #include <__type_traits/rank.h> | |
| 481 | #include <__type_traits/remove_all_extents.h> | |
| 482 | #include <__type_traits/remove_const.h> | |
| 483 | #include <__type_traits/remove_cv.h> | |
| 484 | #include <__type_traits/remove_extent.h> | |
| 485 | #include <__type_traits/remove_pointer.h> | |
| 486 | #include <__type_traits/remove_reference.h> | |
| 487 | #include <__type_traits/remove_volatile.h> | |
| 488 | #include <__type_traits/result_of.h> | |
| 489 | #include <__type_traits/underlying_type.h> | |
| 490 | ||
| 491 | #if _LIBCPP_STD_VER >= 14 | |
| 492 | # include <__type_traits/is_final.h> | |
| 493 | # include <__type_traits/is_null_pointer.h> | |
| 494 | #endif | |
| 495 | ||
| 496 | #if _LIBCPP_STD_VER >= 17 | |
| 497 | # include <__type_traits/conjunction.h> | |
| 498 | # include <__type_traits/disjunction.h> | |
| 499 | # include <__type_traits/has_unique_object_representation.h> | |
| 500 | # include <__type_traits/invoke.h> | |
| 501 | # include <__type_traits/is_aggregate.h> | |
| 502 | # include <__type_traits/is_swappable.h> | |
| 503 | # include <__type_traits/negation.h> | |
| 504 | # include <__type_traits/void_t.h> | |
| 505 | #endif | |
| 506 | ||
| 507 | #if _LIBCPP_STD_VER >= 20 | |
| 508 | # include <__type_traits/common_reference.h> | |
| 509 | # include <__type_traits/is_bounded_array.h> | |
| 510 | # include <__type_traits/is_constant_evaluated.h> | |
| 511 | # include <__type_traits/is_nothrow_convertible.h> | |
| 512 | # include <__type_traits/is_unbounded_array.h> | |
| 513 | # include <__type_traits/type_identity.h> | |
| 514 | # include <__type_traits/unwrap_ref.h> | |
| 515 | #endif | |
| 516 | ||
| 517 | #include <version> | |
| 518 | ||
| 519 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 520 | # pragma GCC system_header | |
| 521 | #endif | |
| 427 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 428 | # include <__cxx03/type_traits> | |
| 429 | #else | |
| 430 | # include <__config> | |
| 431 | # include <__type_traits/add_cv_quals.h> | |
| 432 | # include <__type_traits/add_lvalue_reference.h> | |
| 433 | # include <__type_traits/add_pointer.h> | |
| 434 | # include <__type_traits/add_rvalue_reference.h> | |
| 435 | # include <__type_traits/aligned_storage.h> | |
| 436 | # include <__type_traits/aligned_union.h> | |
| 437 | # include <__type_traits/alignment_of.h> | |
| 438 | # include <__type_traits/common_type.h> | |
| 439 | # include <__type_traits/conditional.h> | |
| 440 | # include <__type_traits/decay.h> | |
| 441 | # include <__type_traits/enable_if.h> | |
| 442 | # include <__type_traits/extent.h> | |
| 443 | # include <__type_traits/has_virtual_destructor.h> | |
| 444 | # include <__type_traits/integral_constant.h> | |
| 445 | # include <__type_traits/is_abstract.h> | |
| 446 | # include <__type_traits/is_arithmetic.h> | |
| 447 | # include <__type_traits/is_array.h> | |
| 448 | # include <__type_traits/is_assignable.h> | |
| 449 | # include <__type_traits/is_base_of.h> | |
| 450 | # include <__type_traits/is_class.h> | |
| 451 | # include <__type_traits/is_compound.h> | |
| 452 | # include <__type_traits/is_const.h> | |
| 453 | # include <__type_traits/is_constructible.h> | |
| 454 | # include <__type_traits/is_convertible.h> | |
| 455 | # include <__type_traits/is_destructible.h> | |
| 456 | # include <__type_traits/is_empty.h> | |
| 457 | # include <__type_traits/is_enum.h> | |
| 458 | # include <__type_traits/is_floating_point.h> | |
| 459 | # include <__type_traits/is_function.h> | |
| 460 | # include <__type_traits/is_fundamental.h> | |
| 461 | # include <__type_traits/is_integral.h> | |
| 462 | # include <__type_traits/is_literal_type.h> | |
| 463 | # include <__type_traits/is_member_pointer.h> | |
| 464 | # include <__type_traits/is_nothrow_assignable.h> | |
| 465 | # include <__type_traits/is_nothrow_constructible.h> | |
| 466 | # include <__type_traits/is_nothrow_destructible.h> | |
| 467 | # include <__type_traits/is_object.h> | |
| 468 | # include <__type_traits/is_pod.h> | |
| 469 | # include <__type_traits/is_pointer.h> | |
| 470 | # include <__type_traits/is_polymorphic.h> | |
| 471 | # include <__type_traits/is_reference.h> | |
| 472 | # include <__type_traits/is_same.h> | |
| 473 | # include <__type_traits/is_scalar.h> | |
| 474 | # include <__type_traits/is_signed.h> | |
| 475 | # include <__type_traits/is_standard_layout.h> | |
| 476 | # include <__type_traits/is_trivial.h> | |
| 477 | # include <__type_traits/is_trivially_assignable.h> | |
| 478 | # include <__type_traits/is_trivially_constructible.h> | |
| 479 | # include <__type_traits/is_trivially_copyable.h> | |
| 480 | # include <__type_traits/is_trivially_destructible.h> | |
| 481 | # include <__type_traits/is_union.h> | |
| 482 | # include <__type_traits/is_unsigned.h> | |
| 483 | # include <__type_traits/is_void.h> | |
| 484 | # include <__type_traits/is_volatile.h> | |
| 485 | # include <__type_traits/make_signed.h> | |
| 486 | # include <__type_traits/make_unsigned.h> | |
| 487 | # include <__type_traits/rank.h> | |
| 488 | # include <__type_traits/remove_all_extents.h> | |
| 489 | # include <__type_traits/remove_const.h> | |
| 490 | # include <__type_traits/remove_cv.h> | |
| 491 | # include <__type_traits/remove_extent.h> | |
| 492 | # include <__type_traits/remove_pointer.h> | |
| 493 | # include <__type_traits/remove_reference.h> | |
| 494 | # include <__type_traits/remove_volatile.h> | |
| 495 | # include <__type_traits/result_of.h> | |
| 496 | # include <__type_traits/underlying_type.h> | |
| 497 | ||
| 498 | # if _LIBCPP_STD_VER >= 14 | |
| 499 | # include <__type_traits/is_final.h> | |
| 500 | # include <__type_traits/is_null_pointer.h> | |
| 501 | # endif | |
| 502 | ||
| 503 | # if _LIBCPP_STD_VER >= 17 | |
| 504 | # include <__type_traits/conjunction.h> | |
| 505 | # include <__type_traits/disjunction.h> | |
| 506 | # include <__type_traits/has_unique_object_representation.h> | |
| 507 | # include <__type_traits/invoke.h> | |
| 508 | # include <__type_traits/is_aggregate.h> | |
| 509 | # include <__type_traits/is_swappable.h> | |
| 510 | # include <__type_traits/negation.h> | |
| 511 | # include <__type_traits/void_t.h> | |
| 512 | # endif | |
| 513 | ||
| 514 | # if _LIBCPP_STD_VER >= 20 | |
| 515 | # include <__type_traits/common_reference.h> | |
| 516 | # include <__type_traits/is_bounded_array.h> | |
| 517 | # include <__type_traits/is_constant_evaluated.h> | |
| 518 | # include <__type_traits/is_nothrow_convertible.h> | |
| 519 | # include <__type_traits/is_unbounded_array.h> | |
| 520 | # include <__type_traits/type_identity.h> | |
| 521 | # include <__type_traits/unwrap_ref.h> | |
| 522 | # endif | |
| 523 | ||
| 524 | # if _LIBCPP_STD_VER >= 23 | |
| 525 | # include <__type_traits/is_implicit_lifetime.h> | |
| 526 | # endif | |
| 527 | ||
| 528 | # include <version> | |
| 529 | ||
| 530 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 531 | # pragma GCC system_header | |
| 532 | # endif | |
| 533 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 522 | 534 | |
| 523 | 535 | #endif // _LIBCPP_TYPE_TRAITS |
lib/libcxx/include/typeindex+22-17| ... | ... | @@ -45,17 +45,20 @@ struct hash<type_index> |
| 45 | 45 | |
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | #include <__config> | |
| 49 | #include <__functional/unary_function.h> | |
| 50 | #include <typeinfo> | |
| 51 | #include <version> | |
| 48 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 49 | # include <__cxx03/typeindex> | |
| 50 | #else | |
| 51 | # include <__config> | |
| 52 | # include <__functional/unary_function.h> | |
| 53 | # include <typeinfo> | |
| 54 | # include <version> | |
| 52 | 55 | |
| 53 | 56 | // standard-mandated includes |
| 54 | #include <compare> | |
| 57 | # include <compare> | |
| 55 | 58 | |
| 56 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 57 | # pragma GCC system_header | |
| 58 | #endif | |
| 59 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 60 | # pragma GCC system_header | |
| 61 | # endif | |
| 59 | 62 | |
| 60 | 63 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 61 | 64 | |
| ... | ... | @@ -66,14 +69,14 @@ public: |
| 66 | 69 | _LIBCPP_HIDE_FROM_ABI type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {} |
| 67 | 70 | |
| 68 | 71 | _LIBCPP_HIDE_FROM_ABI bool operator==(const type_index& __y) const _NOEXCEPT { return *__t_ == *__y.__t_; } |
| 69 | #if _LIBCPP_STD_VER <= 17 | |
| 72 | # if _LIBCPP_STD_VER <= 17 | |
| 70 | 73 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_index& __y) const _NOEXCEPT { return *__t_ != *__y.__t_; } |
| 71 | #endif | |
| 74 | # endif | |
| 72 | 75 | _LIBCPP_HIDE_FROM_ABI bool operator<(const type_index& __y) const _NOEXCEPT { return __t_->before(*__y.__t_); } |
| 73 | 76 | _LIBCPP_HIDE_FROM_ABI bool operator<=(const type_index& __y) const _NOEXCEPT { return !__y.__t_->before(*__t_); } |
| 74 | 77 | _LIBCPP_HIDE_FROM_ABI bool operator>(const type_index& __y) const _NOEXCEPT { return __y.__t_->before(*__t_); } |
| 75 | 78 | _LIBCPP_HIDE_FROM_ABI bool operator>=(const type_index& __y) const _NOEXCEPT { return !__t_->before(*__y.__t_); } |
| 76 | #if _LIBCPP_STD_VER >= 20 | |
| 79 | # if _LIBCPP_STD_VER >= 20 | |
| 77 | 80 | _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const type_index& __y) const noexcept { |
| 78 | 81 | if (*__t_ == *__y.__t_) |
| 79 | 82 | return strong_ordering::equal; |
| ... | ... | @@ -81,7 +84,7 @@ public: |
| 81 | 84 | return strong_ordering::less; |
| 82 | 85 | return strong_ordering::greater; |
| 83 | 86 | } |
| 84 | #endif | |
| 87 | # endif | |
| 85 | 88 | |
| 86 | 89 | _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __t_->hash_code(); } |
| 87 | 90 | _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { return __t_->name(); } |
| ... | ... | @@ -97,10 +100,12 @@ struct _LIBCPP_TEMPLATE_VIS hash<type_index> : public __unary_function<type_inde |
| 97 | 100 | |
| 98 | 101 | _LIBCPP_END_NAMESPACE_STD |
| 99 | 102 | |
| 100 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 101 | # include <iosfwd> | |
| 102 | # include <new> | |
| 103 | # include <utility> | |
| 104 | #endif | |
| 103 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 104 | # include <cstddef> | |
| 105 | # include <iosfwd> | |
| 106 | # include <new> | |
| 107 | # include <utility> | |
| 108 | # endif | |
| 109 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 105 | 110 | |
| 106 | 111 | #endif // _LIBCPP_TYPEINDEX |
lib/libcxx/include/typeinfo+62-55| ... | ... | @@ -56,25 +56,30 @@ public: |
| 56 | 56 | |
| 57 | 57 | */ |
| 58 | 58 | |
| 59 | #include <__config> | |
| 60 | #include <__exception/exception.h> | |
| 61 | #include <__type_traits/is_constant_evaluated.h> | |
| 62 | #include <__verbose_abort> | |
| 63 | #include <cstddef> | |
| 64 | #include <cstdint> | |
| 65 | ||
| 66 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 67 | # pragma GCC system_header | |
| 68 | #endif | |
| 69 | ||
| 70 | #if defined(_LIBCPP_ABI_VCRUNTIME) | |
| 71 | # include <vcruntime_typeinfo.h> | |
| 59 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 60 | # include <__cxx03/typeinfo> | |
| 72 | 61 | #else |
| 62 | # include <__config> | |
| 63 | # include <__cstddef/size_t.h> | |
| 64 | # include <__exception/exception.h> | |
| 65 | # include <__type_traits/integral_constant.h> | |
| 66 | # include <__type_traits/is_constant_evaluated.h> | |
| 67 | # include <__verbose_abort> | |
| 68 | # include <cstdint> | |
| 69 | # include <version> | |
| 70 | ||
| 71 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 72 | # pragma GCC system_header | |
| 73 | # endif | |
| 74 | ||
| 75 | # if defined(_LIBCPP_ABI_VCRUNTIME) | |
| 76 | # include <vcruntime_typeinfo.h> | |
| 77 | # else | |
| 73 | 78 | |
| 74 | 79 | namespace std // purposefully not using versioning namespace |
| 75 | 80 | { |
| 76 | 81 | |
| 77 | # if defined(_LIBCPP_ABI_MICROSOFT) | |
| 82 | # if defined(_LIBCPP_ABI_MICROSOFT) | |
| 78 | 83 | |
| 79 | 84 | class _LIBCPP_EXPORTED_FROM_ABI type_info { |
| 80 | 85 | type_info& operator=(const type_info&); |
| ... | ... | @@ -105,12 +110,12 @@ public: |
| 105 | 110 | return __compare(__arg) == 0; |
| 106 | 111 | } |
| 107 | 112 | |
| 108 | # if _LIBCPP_STD_VER <= 17 | |
| 113 | # if _LIBCPP_STD_VER <= 17 | |
| 109 | 114 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); } |
| 110 | # endif | |
| 115 | # endif | |
| 111 | 116 | }; |
| 112 | 117 | |
| 113 | # else // !defined(_LIBCPP_ABI_MICROSOFT) | |
| 118 | # else // !defined(_LIBCPP_ABI_MICROSOFT) | |
| 114 | 119 | |
| 115 | 120 | // ========================================================================== // |
| 116 | 121 | // Implementations |
| ... | ... | @@ -165,21 +170,21 @@ public: |
| 165 | 170 | |
| 166 | 171 | // This value can be overriden in the __config_site. When it's not overriden, |
| 167 | 172 | // we pick a default implementation based on the platform here. |
| 168 | # ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION | |
| 173 | # ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION | |
| 169 | 174 | |
| 170 | 175 | // Windows and AIX binaries can't merge typeinfos, so use the NonUnique implementation. |
| 171 | # if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF) | |
| 172 | # define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2 | |
| 176 | # if defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF) | |
| 177 | # define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 2 | |
| 173 | 178 | |
| 174 | 179 | // On arm64 on Apple platforms, use the special NonUniqueARMRTTIBit implementation. |
| 175 | # elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) | |
| 176 | # define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3 | |
| 180 | # elif defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__) | |
| 181 | # define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 3 | |
| 177 | 182 | |
| 178 | 183 | // On all other platforms, assume the Itanium C++ ABI and use the Unique implementation. |
| 179 | # else | |
| 180 | # define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1 | |
| 184 | # else | |
| 185 | # define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1 | |
| 186 | # endif | |
| 181 | 187 | # endif |
| 182 | # endif | |
| 183 | 188 | |
| 184 | 189 | struct __type_info_implementations { |
| 185 | 190 | struct __string_impl_base { |
| ... | ... | @@ -263,30 +268,30 @@ struct __type_info_implementations { |
| 263 | 268 | }; |
| 264 | 269 | |
| 265 | 270 | typedef |
| 266 | # if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1 | |
| 271 | # if _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 1 | |
| 267 | 272 | __unique_impl |
| 268 | # elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2 | |
| 273 | # elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 2 | |
| 269 | 274 | __non_unique_impl |
| 270 | # elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3 | |
| 275 | # elif _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION == 3 | |
| 271 | 276 | __non_unique_arm_rtti_bit_impl |
| 272 | # else | |
| 273 | # error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION | |
| 274 | # endif | |
| 277 | # else | |
| 278 | # error invalid configuration for _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION | |
| 279 | # endif | |
| 275 | 280 | __impl; |
| 276 | 281 | }; |
| 277 | 282 | |
| 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)]] | |
| 283 | # if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__) | |
| 284 | # if __has_feature(ptrauth_type_info_vtable_pointer_discrimination) | |
| 285 | # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \ | |
| 286 | [[_Clang::__ptrauth_vtable_pointer__(process_independent, address_discrimination, type_discrimination)]] | |
| 287 | # else | |
| 288 | # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \ | |
| 289 | [[_Clang::__ptrauth_vtable_pointer__( \ | |
| 290 | process_independent, no_address_discrimination, no_extra_discrimination)]] | |
| 291 | # endif | |
| 282 | 292 | # else |
| 283 | # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \ | |
| 284 | [[_Clang::__ptrauth_vtable_pointer__( \ | |
| 285 | process_independent, no_address_discrimination, no_extra_discrimination)]] | |
| 293 | # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH | |
| 286 | 294 | # endif |
| 287 | # else | |
| 288 | # define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH | |
| 289 | # endif | |
| 290 | 295 | |
| 291 | 296 | class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH type_info { |
| 292 | 297 | type_info& operator=(const type_info&); |
| ... | ... | @@ -319,11 +324,11 @@ public: |
| 319 | 324 | return __impl::__eq(__type_name, __arg.__type_name); |
| 320 | 325 | } |
| 321 | 326 | |
| 322 | # if _LIBCPP_STD_VER <= 17 | |
| 327 | # if _LIBCPP_STD_VER <= 17 | |
| 323 | 328 | _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_info& __arg) const _NOEXCEPT { return !operator==(__arg); } |
| 324 | # endif | |
| 329 | # endif | |
| 325 | 330 | }; |
| 326 | # endif // defined(_LIBCPP_ABI_MICROSOFT) | |
| 331 | # endif // defined(_LIBCPP_ABI_MICROSOFT) | |
| 327 | 332 | |
| 328 | 333 | class _LIBCPP_EXPORTED_FROM_ABI bad_cast : public exception { |
| 329 | 334 | public: |
| ... | ... | @@ -345,9 +350,9 @@ public: |
| 345 | 350 | |
| 346 | 351 | } // namespace std |
| 347 | 352 | |
| 348 | #endif // defined(_LIBCPP_ABI_VCRUNTIME) | |
| 353 | # endif // defined(_LIBCPP_ABI_VCRUNTIME) | |
| 349 | 354 | |
| 350 | #if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0 | |
| 355 | # if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0 | |
| 351 | 356 | |
| 352 | 357 | namespace std { |
| 353 | 358 | |
| ... | ... | @@ -369,21 +374,23 @@ private: |
| 369 | 374 | |
| 370 | 375 | } // namespace std |
| 371 | 376 | |
| 372 | #endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0 | |
| 377 | # endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0 | |
| 373 | 378 | |
| 374 | 379 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 375 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_cast() { | |
| 376 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 380 | [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_cast() { | |
| 381 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 377 | 382 | throw bad_cast(); |
| 378 | #else | |
| 383 | # else | |
| 379 | 384 | _LIBCPP_VERBOSE_ABORT("bad_cast was thrown in -fno-exceptions mode"); |
| 380 | #endif | |
| 385 | # endif | |
| 381 | 386 | } |
| 382 | 387 | _LIBCPP_END_NAMESPACE_STD |
| 383 | 388 | |
| 384 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 385 | # include <cstdlib> | |
| 386 | # include <type_traits> | |
| 387 | #endif | |
| 389 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 390 | # include <cstddef> | |
| 391 | # include <cstdlib> | |
| 392 | # include <type_traits> | |
| 393 | # endif | |
| 394 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 388 | 395 | |
| 389 | 396 | #endif // _LIBCPP_TYPEINFO |
lib/libcxx/include/uchar.h+17-13| ... | ... | @@ -32,25 +32,29 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps); |
| 32 | 32 | |
| 33 | 33 | */ |
| 34 | 34 | |
| 35 | #include <__config> | |
| 35 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 36 | # include <__cxx03/uchar.h> | |
| 37 | #else | |
| 38 | # include <__config> | |
| 36 | 39 | |
| 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 38 | # pragma GCC system_header | |
| 39 | #endif | |
| 40 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 41 | # pragma GCC system_header | |
| 42 | # endif | |
| 40 | 43 | |
| 41 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 44 | # if !defined(_LIBCPP_CXX03_LANG) | |
| 42 | 45 | |
| 43 | 46 | // Some platforms don't implement <uchar.h> and we don't want to give a hard |
| 44 | 47 | // error on those platforms. When the platform doesn't provide <uchar.h>, at |
| 45 | 48 | // least include <stddef.h> so we get the declaration for size_t, and try to |
| 46 | 49 | // get the declaration of mbstate_t too. |
| 47 | # if __has_include_next(<uchar.h>) | |
| 48 | # include_next <uchar.h> | |
| 49 | # else | |
| 50 | # include <__mbstate_t.h> | |
| 51 | # include <stddef.h> | |
| 52 | # endif | |
| 53 | ||
| 54 | #endif // _LIBCPP_CXX03_LANG | |
| 50 | # if __has_include_next(<uchar.h>) | |
| 51 | # include_next <uchar.h> | |
| 52 | # else | |
| 53 | # include <__mbstate_t.h> | |
| 54 | # include <stddef.h> | |
| 55 | # endif | |
| 56 | ||
| 57 | # endif // _LIBCPP_CXX03_LANG | |
| 58 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 55 | 59 | |
| 56 | 60 | #endif // _LIBCPP_UCHAR_H |
lib/libcxx/include/unordered_map+197-161| ... | ... | @@ -583,49 +583,63 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 583 | 583 | |
| 584 | 584 | */ |
| 585 | 585 | |
| 586 | #include <__algorithm/is_permutation.h> | |
| 587 | #include <__assert> | |
| 588 | #include <__config> | |
| 589 | #include <__functional/is_transparent.h> | |
| 590 | #include <__functional/operations.h> | |
| 591 | #include <__hash_table> | |
| 592 | #include <__iterator/distance.h> | |
| 593 | #include <__iterator/erase_if_container.h> | |
| 594 | #include <__iterator/iterator_traits.h> | |
| 595 | #include <__iterator/ranges_iterator_traits.h> | |
| 596 | #include <__memory/addressof.h> | |
| 597 | #include <__memory/allocator.h> | |
| 598 | #include <__memory_resource/polymorphic_allocator.h> | |
| 599 | #include <__node_handle> | |
| 600 | #include <__ranges/concepts.h> | |
| 601 | #include <__ranges/container_compatible_range.h> | |
| 602 | #include <__ranges/from_range.h> | |
| 603 | #include <__type_traits/is_allocator.h> | |
| 604 | #include <__type_traits/type_identity.h> | |
| 605 | #include <__utility/forward.h> | |
| 606 | #include <stdexcept> | |
| 607 | #include <tuple> | |
| 608 | #include <version> | |
| 586 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 587 | # include <__cxx03/unordered_map> | |
| 588 | #else | |
| 589 | # include <__algorithm/is_permutation.h> | |
| 590 | # include <__assert> | |
| 591 | # include <__config> | |
| 592 | # include <__functional/hash.h> | |
| 593 | # include <__functional/is_transparent.h> | |
| 594 | # include <__functional/operations.h> | |
| 595 | # include <__hash_table> | |
| 596 | # include <__iterator/distance.h> | |
| 597 | # include <__iterator/erase_if_container.h> | |
| 598 | # include <__iterator/iterator_traits.h> | |
| 599 | # include <__iterator/ranges_iterator_traits.h> | |
| 600 | # include <__memory/addressof.h> | |
| 601 | # include <__memory/allocator.h> | |
| 602 | # include <__memory/allocator_traits.h> | |
| 603 | # include <__memory/pointer_traits.h> | |
| 604 | # include <__memory/unique_ptr.h> | |
| 605 | # include <__memory_resource/polymorphic_allocator.h> | |
| 606 | # include <__new/launder.h> | |
| 607 | # include <__node_handle> | |
| 608 | # include <__ranges/concepts.h> | |
| 609 | # include <__ranges/container_compatible_range.h> | |
| 610 | # include <__ranges/from_range.h> | |
| 611 | # include <__type_traits/container_traits.h> | |
| 612 | # include <__type_traits/enable_if.h> | |
| 613 | # include <__type_traits/invoke.h> | |
| 614 | # include <__type_traits/is_allocator.h> | |
| 615 | # include <__type_traits/is_integral.h> | |
| 616 | # include <__type_traits/remove_const.h> | |
| 617 | # include <__type_traits/type_identity.h> | |
| 618 | # include <__utility/forward.h> | |
| 619 | # include <__utility/pair.h> | |
| 620 | # include <stdexcept> | |
| 621 | # include <tuple> | |
| 622 | # include <version> | |
| 609 | 623 | |
| 610 | 624 | // standard-mandated includes |
| 611 | 625 | |
| 612 | 626 | // [iterator.range] |
| 613 | #include <__iterator/access.h> | |
| 614 | #include <__iterator/data.h> | |
| 615 | #include <__iterator/empty.h> | |
| 616 | #include <__iterator/reverse_access.h> | |
| 617 | #include <__iterator/size.h> | |
| 627 | # include <__iterator/access.h> | |
| 628 | # include <__iterator/data.h> | |
| 629 | # include <__iterator/empty.h> | |
| 630 | # include <__iterator/reverse_access.h> | |
| 631 | # include <__iterator/size.h> | |
| 618 | 632 | |
| 619 | 633 | // [unord.map.syn] |
| 620 | #include <compare> | |
| 621 | #include <initializer_list> | |
| 634 | # include <compare> | |
| 635 | # include <initializer_list> | |
| 622 | 636 | |
| 623 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 624 | # pragma GCC system_header | |
| 625 | #endif | |
| 637 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 638 | # pragma GCC system_header | |
| 639 | # endif | |
| 626 | 640 | |
| 627 | 641 | _LIBCPP_PUSH_MACROS |
| 628 | #include <__undef_macros> | |
| 642 | # include <__undef_macros> | |
| 629 | 643 | |
| 630 | 644 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 631 | 645 | |
| ... | ... | @@ -644,12 +658,12 @@ public: |
| 644 | 658 | return static_cast<const _Hash&>(*this)(__x.__get_value().first); |
| 645 | 659 | } |
| 646 | 660 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return static_cast<const _Hash&>(*this)(__x); } |
| 647 | #if _LIBCPP_STD_VER >= 20 | |
| 661 | # if _LIBCPP_STD_VER >= 20 | |
| 648 | 662 | template <typename _K2> |
| 649 | 663 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _K2& __x) const { |
| 650 | 664 | return static_cast<const _Hash&>(*this)(__x); |
| 651 | 665 | } |
| 652 | #endif | |
| 666 | # endif | |
| 653 | 667 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) { |
| 654 | 668 | using std::swap; |
| 655 | 669 | swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y)); |
| ... | ... | @@ -668,12 +682,12 @@ public: |
| 668 | 682 | _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return __hash_; } |
| 669 | 683 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return __hash_(__x.__get_value().first); } |
| 670 | 684 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return __hash_(__x); } |
| 671 | #if _LIBCPP_STD_VER >= 20 | |
| 685 | # if _LIBCPP_STD_VER >= 20 | |
| 672 | 686 | template <typename _K2> |
| 673 | 687 | _LIBCPP_HIDE_FROM_ABI size_t operator()(const _K2& __x) const { |
| 674 | 688 | return __hash_(__x); |
| 675 | 689 | } |
| 676 | #endif | |
| 690 | # endif | |
| 677 | 691 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) { |
| 678 | 692 | using std::swap; |
| 679 | 693 | swap(__hash_, __y.__hash_); |
| ... | ... | @@ -707,7 +721,7 @@ public: |
| 707 | 721 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const { |
| 708 | 722 | return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first); |
| 709 | 723 | } |
| 710 | #if _LIBCPP_STD_VER >= 20 | |
| 724 | # if _LIBCPP_STD_VER >= 20 | |
| 711 | 725 | template <typename _K2> |
| 712 | 726 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const { |
| 713 | 727 | return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y); |
| ... | ... | @@ -724,7 +738,7 @@ public: |
| 724 | 738 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Key& __y) const { |
| 725 | 739 | return static_cast<const _Pred&>(*this)(__x, __y); |
| 726 | 740 | } |
| 727 | #endif | |
| 741 | # endif | |
| 728 | 742 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) { |
| 729 | 743 | using std::swap; |
| 730 | 744 | swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y)); |
| ... | ... | @@ -750,7 +764,7 @@ public: |
| 750 | 764 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const { |
| 751 | 765 | return __pred_(__x, __y.__get_value().first); |
| 752 | 766 | } |
| 753 | #if _LIBCPP_STD_VER >= 20 | |
| 767 | # if _LIBCPP_STD_VER >= 20 | |
| 754 | 768 | template <typename _K2> |
| 755 | 769 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const { |
| 756 | 770 | return __pred_(__x.__get_value().first, __y); |
| ... | ... | @@ -767,7 +781,7 @@ public: |
| 767 | 781 | _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Key& __y) const { |
| 768 | 782 | return __pred_(__x, __y); |
| 769 | 783 | } |
| 770 | #endif | |
| 784 | # endif | |
| 771 | 785 | _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) { |
| 772 | 786 | using std::swap; |
| 773 | 787 | swap(__pred_, __y.__pred_); |
| ... | ... | @@ -803,19 +817,19 @@ public: |
| 803 | 817 | __first_constructed(false), |
| 804 | 818 | __second_constructed(false) {} |
| 805 | 819 | |
| 806 | #ifndef _LIBCPP_CXX03_LANG | |
| 820 | # ifndef _LIBCPP_CXX03_LANG | |
| 807 | 821 | _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x) _NOEXCEPT |
| 808 | 822 | : __na_(__x.__na_), |
| 809 | 823 | __first_constructed(__x.__value_constructed), |
| 810 | 824 | __second_constructed(__x.__value_constructed) { |
| 811 | 825 | __x.__value_constructed = false; |
| 812 | 826 | } |
| 813 | #else // _LIBCPP_CXX03_LANG | |
| 827 | # else // _LIBCPP_CXX03_LANG | |
| 814 | 828 | _LIBCPP_HIDE_FROM_ABI __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x) |
| 815 | 829 | : __na_(__x.__na_), __first_constructed(__x.__value_constructed), __second_constructed(__x.__value_constructed) { |
| 816 | 830 | const_cast<bool&>(__x.__value_constructed) = false; |
| 817 | 831 | } |
| 818 | #endif // _LIBCPP_CXX03_LANG | |
| 832 | # endif // _LIBCPP_CXX03_LANG | |
| 819 | 833 | |
| 820 | 834 | _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT { |
| 821 | 835 | if (__second_constructed) |
| ... | ... | @@ -827,7 +841,7 @@ public: |
| 827 | 841 | } |
| 828 | 842 | }; |
| 829 | 843 | |
| 830 | #ifndef _LIBCPP_CXX03_LANG | |
| 844 | # ifndef _LIBCPP_CXX03_LANG | |
| 831 | 845 | template <class _Key, class _Tp> |
| 832 | 846 | struct _LIBCPP_STANDALONE_DEBUG __hash_value_type { |
| 833 | 847 | typedef _Key key_type; |
| ... | ... | @@ -841,19 +855,19 @@ private: |
| 841 | 855 | |
| 842 | 856 | public: |
| 843 | 857 | _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { |
| 844 | # if _LIBCPP_STD_VER >= 17 | |
| 858 | # if _LIBCPP_STD_VER >= 17 | |
| 845 | 859 | return *std::launder(std::addressof(__cc_)); |
| 846 | # else | |
| 860 | # else | |
| 847 | 861 | return __cc_; |
| 848 | # endif | |
| 862 | # endif | |
| 849 | 863 | } |
| 850 | 864 | |
| 851 | 865 | _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { |
| 852 | # if _LIBCPP_STD_VER >= 17 | |
| 866 | # if _LIBCPP_STD_VER >= 17 | |
| 853 | 867 | return *std::launder(std::addressof(__cc_)); |
| 854 | # else | |
| 868 | # else | |
| 855 | 869 | return __cc_; |
| 856 | # endif | |
| 870 | # endif | |
| 857 | 871 | } |
| 858 | 872 | |
| 859 | 873 | _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() { |
| ... | ... | @@ -890,7 +904,7 @@ public: |
| 890 | 904 | ~__hash_value_type() = delete; |
| 891 | 905 | }; |
| 892 | 906 | |
| 893 | #else | |
| 907 | # else | |
| 894 | 908 | |
| 895 | 909 | template <class _Key, class _Tp> |
| 896 | 910 | struct __hash_value_type { |
| ... | ... | @@ -908,7 +922,7 @@ public: |
| 908 | 922 | ~__hash_value_type() = delete; |
| 909 | 923 | }; |
| 910 | 924 | |
| 911 | #endif | |
| 925 | # endif | |
| 912 | 926 | |
| 913 | 927 | template <class _HashIterator> |
| 914 | 928 | class _LIBCPP_TEMPLATE_VIS __hash_map_iterator { |
| ... | ... | @@ -943,11 +957,11 @@ public: |
| 943 | 957 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y) { |
| 944 | 958 | return __x.__i_ == __y.__i_; |
| 945 | 959 | } |
| 946 | #if _LIBCPP_STD_VER <= 17 | |
| 960 | # if _LIBCPP_STD_VER <= 17 | |
| 947 | 961 | friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) { |
| 948 | 962 | return __x.__i_ != __y.__i_; |
| 949 | 963 | } |
| 950 | #endif | |
| 964 | # endif | |
| 951 | 965 | |
| 952 | 966 | template <class, class, class, class, class> |
| 953 | 967 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; |
| ... | ... | @@ -998,12 +1012,12 @@ public: |
| 998 | 1012 | operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) { |
| 999 | 1013 | return __x.__i_ == __y.__i_; |
| 1000 | 1014 | } |
| 1001 | #if _LIBCPP_STD_VER <= 17 | |
| 1015 | # if _LIBCPP_STD_VER <= 17 | |
| 1002 | 1016 | friend _LIBCPP_HIDE_FROM_ABI bool |
| 1003 | 1017 | operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) { |
| 1004 | 1018 | return __x.__i_ != __y.__i_; |
| 1005 | 1019 | } |
| 1006 | #endif | |
| 1020 | # endif | |
| 1007 | 1021 | |
| 1008 | 1022 | template <class, class, class, class, class> |
| 1009 | 1023 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; |
| ... | ... | @@ -1073,10 +1087,10 @@ public: |
| 1073 | 1087 | typedef __hash_map_iterator<typename __table::local_iterator> local_iterator; |
| 1074 | 1088 | typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator; |
| 1075 | 1089 | |
| 1076 | #if _LIBCPP_STD_VER >= 17 | |
| 1090 | # if _LIBCPP_STD_VER >= 17 | |
| 1077 | 1091 | typedef __map_node_handle<__node, allocator_type> node_type; |
| 1078 | 1092 | typedef __insert_return_type<iterator, node_type> insert_return_type; |
| 1079 | #endif | |
| 1093 | # endif | |
| 1080 | 1094 | |
| 1081 | 1095 | template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> |
| 1082 | 1096 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; |
| ... | ... | @@ -1106,7 +1120,7 @@ public: |
| 1106 | 1120 | const key_equal& __eql, |
| 1107 | 1121 | const allocator_type& __a); |
| 1108 | 1122 | |
| 1109 | #if _LIBCPP_STD_VER >= 23 | |
| 1123 | # if _LIBCPP_STD_VER >= 23 | |
| 1110 | 1124 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1111 | 1125 | _LIBCPP_HIDE_FROM_ABI unordered_map( |
| 1112 | 1126 | from_range_t, |
| ... | ... | @@ -1121,12 +1135,12 @@ public: |
| 1121 | 1135 | } |
| 1122 | 1136 | insert_range(std::forward<_Range>(__range)); |
| 1123 | 1137 | } |
| 1124 | #endif | |
| 1138 | # endif | |
| 1125 | 1139 | |
| 1126 | 1140 | _LIBCPP_HIDE_FROM_ABI explicit unordered_map(const allocator_type& __a); |
| 1127 | 1141 | _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u); |
| 1128 | 1142 | _LIBCPP_HIDE_FROM_ABI unordered_map(const unordered_map& __u, const allocator_type& __a); |
| 1129 | #ifndef _LIBCPP_CXX03_LANG | |
| 1143 | # ifndef _LIBCPP_CXX03_LANG | |
| 1130 | 1144 | _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); |
| 1131 | 1145 | _LIBCPP_HIDE_FROM_ABI unordered_map(unordered_map&& __u, const allocator_type& __a); |
| 1132 | 1146 | _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il); |
| ... | ... | @@ -1141,8 +1155,8 @@ public: |
| 1141 | 1155 | const hasher& __hf, |
| 1142 | 1156 | const key_equal& __eql, |
| 1143 | 1157 | const allocator_type& __a); |
| 1144 | #endif // _LIBCPP_CXX03_LANG | |
| 1145 | #if _LIBCPP_STD_VER >= 14 | |
| 1158 | # endif // _LIBCPP_CXX03_LANG | |
| 1159 | # if _LIBCPP_STD_VER >= 14 | |
| 1146 | 1160 | _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const allocator_type& __a) |
| 1147 | 1161 | : unordered_map(__n, hasher(), key_equal(), __a) {} |
| 1148 | 1162 | _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a) |
| ... | ... | @@ -1156,7 +1170,7 @@ public: |
| 1156 | 1170 | _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1157 | 1171 | : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {} |
| 1158 | 1172 | |
| 1159 | # if _LIBCPP_STD_VER >= 23 | |
| 1173 | # if _LIBCPP_STD_VER >= 23 | |
| 1160 | 1174 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1161 | 1175 | _LIBCPP_HIDE_FROM_ABI unordered_map(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a) |
| 1162 | 1176 | : unordered_map(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {} |
| ... | ... | @@ -1165,22 +1179,22 @@ public: |
| 1165 | 1179 | _LIBCPP_HIDE_FROM_ABI |
| 1166 | 1180 | unordered_map(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1167 | 1181 | : unordered_map(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {} |
| 1168 | # endif | |
| 1182 | # endif | |
| 1169 | 1183 | |
| 1170 | 1184 | _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) |
| 1171 | 1185 | : unordered_map(__il, __n, hasher(), key_equal(), __a) {} |
| 1172 | 1186 | _LIBCPP_HIDE_FROM_ABI |
| 1173 | 1187 | unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1174 | 1188 | : unordered_map(__il, __n, __hf, key_equal(), __a) {} |
| 1175 | #endif | |
| 1189 | # endif | |
| 1176 | 1190 | _LIBCPP_HIDE_FROM_ABI ~unordered_map() { |
| 1177 | 1191 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), ""); |
| 1178 | 1192 | } |
| 1179 | 1193 | |
| 1180 | 1194 | _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(const unordered_map& __u) { |
| 1181 | #ifndef _LIBCPP_CXX03_LANG | |
| 1195 | # ifndef _LIBCPP_CXX03_LANG | |
| 1182 | 1196 | __table_ = __u.__table_; |
| 1183 | #else | |
| 1197 | # else | |
| 1184 | 1198 | if (this != std::addressof(__u)) { |
| 1185 | 1199 | __table_.clear(); |
| 1186 | 1200 | __table_.hash_function() = __u.__table_.hash_function(); |
| ... | ... | @@ -1189,20 +1203,20 @@ public: |
| 1189 | 1203 | __table_.__copy_assign_alloc(__u.__table_); |
| 1190 | 1204 | insert(__u.begin(), __u.end()); |
| 1191 | 1205 | } |
| 1192 | #endif | |
| 1206 | # endif | |
| 1193 | 1207 | return *this; |
| 1194 | 1208 | } |
| 1195 | #ifndef _LIBCPP_CXX03_LANG | |
| 1209 | # ifndef _LIBCPP_CXX03_LANG | |
| 1196 | 1210 | _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(unordered_map&& __u) |
| 1197 | 1211 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); |
| 1198 | 1212 | _LIBCPP_HIDE_FROM_ABI unordered_map& operator=(initializer_list<value_type> __il); |
| 1199 | #endif // _LIBCPP_CXX03_LANG | |
| 1213 | # endif // _LIBCPP_CXX03_LANG | |
| 1200 | 1214 | |
| 1201 | 1215 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 1202 | 1216 | return allocator_type(__table_.__node_alloc()); |
| 1203 | 1217 | } |
| 1204 | 1218 | |
| 1205 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | |
| 1219 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | |
| 1206 | 1220 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 1207 | 1221 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 1208 | 1222 | |
| ... | ... | @@ -1220,16 +1234,16 @@ public: |
| 1220 | 1234 | template <class _InputIterator> |
| 1221 | 1235 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last); |
| 1222 | 1236 | |
| 1223 | #if _LIBCPP_STD_VER >= 23 | |
| 1237 | # if _LIBCPP_STD_VER >= 23 | |
| 1224 | 1238 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1225 | 1239 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1226 | 1240 | for (auto&& __element : __range) { |
| 1227 | 1241 | __table_.__insert_unique(std::forward<decltype(__element)>(__element)); |
| 1228 | 1242 | } |
| 1229 | 1243 | } |
| 1230 | #endif | |
| 1244 | # endif | |
| 1231 | 1245 | |
| 1232 | #ifndef _LIBCPP_CXX03_LANG | |
| 1246 | # ifndef _LIBCPP_CXX03_LANG | |
| 1233 | 1247 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 1234 | 1248 | |
| 1235 | 1249 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) { |
| ... | ... | @@ -1260,9 +1274,9 @@ public: |
| 1260 | 1274 | return __table_.__emplace_unique(std::forward<_Args>(__args)...).first; |
| 1261 | 1275 | } |
| 1262 | 1276 | |
| 1263 | #endif // _LIBCPP_CXX03_LANG | |
| 1277 | # endif // _LIBCPP_CXX03_LANG | |
| 1264 | 1278 | |
| 1265 | #if _LIBCPP_STD_VER >= 17 | |
| 1279 | # if _LIBCPP_STD_VER >= 17 | |
| 1266 | 1280 | template <class... _Args> |
| 1267 | 1281 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) { |
| 1268 | 1282 | return __table_.__emplace_unique_key_args( |
| ... | ... | @@ -1315,7 +1329,7 @@ public: |
| 1315 | 1329 | _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator, key_type&& __k, _Vp&& __v) { |
| 1316 | 1330 | return insert_or_assign(std::move(__k), std::forward<_Vp>(__v)).first; |
| 1317 | 1331 | } |
| 1318 | #endif // _LIBCPP_STD_VER >= 17 | |
| 1332 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1319 | 1333 | |
| 1320 | 1334 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p.__i_); } |
| 1321 | 1335 | _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __table_.erase(__p.__i_); } |
| ... | ... | @@ -1325,7 +1339,7 @@ public: |
| 1325 | 1339 | } |
| 1326 | 1340 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); } |
| 1327 | 1341 | |
| 1328 | #if _LIBCPP_STD_VER >= 17 | |
| 1342 | # if _LIBCPP_STD_VER >= 17 | |
| 1329 | 1343 | _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) { |
| 1330 | 1344 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1331 | 1345 | "node_type with incompatible allocator passed to unordered_map::insert()"); |
| ... | ... | @@ -1367,7 +1381,7 @@ public: |
| 1367 | 1381 | __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); |
| 1368 | 1382 | return __table_.__node_handle_merge_unique(__source.__table_); |
| 1369 | 1383 | } |
| 1370 | #endif | |
| 1384 | # endif | |
| 1371 | 1385 | |
| 1372 | 1386 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_map& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) { |
| 1373 | 1387 | __table_.swap(__u.__table_); |
| ... | ... | @@ -1378,7 +1392,7 @@ public: |
| 1378 | 1392 | |
| 1379 | 1393 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 1380 | 1394 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 1381 | #if _LIBCPP_STD_VER >= 20 | |
| 1395 | # if _LIBCPP_STD_VER >= 20 | |
| 1382 | 1396 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1383 | 1397 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1384 | 1398 | return __table_.find(__k); |
| ... | ... | @@ -1387,24 +1401,24 @@ public: |
| 1387 | 1401 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1388 | 1402 | return __table_.find(__k); |
| 1389 | 1403 | } |
| 1390 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1404 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1391 | 1405 | |
| 1392 | 1406 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); } |
| 1393 | #if _LIBCPP_STD_VER >= 20 | |
| 1407 | # if _LIBCPP_STD_VER >= 20 | |
| 1394 | 1408 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1395 | 1409 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1396 | 1410 | return __table_.__count_unique(__k); |
| 1397 | 1411 | } |
| 1398 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1412 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1399 | 1413 | |
| 1400 | #if _LIBCPP_STD_VER >= 20 | |
| 1414 | # if _LIBCPP_STD_VER >= 20 | |
| 1401 | 1415 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1402 | 1416 | |
| 1403 | 1417 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1404 | 1418 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1405 | 1419 | return find(__k) != end(); |
| 1406 | 1420 | } |
| 1407 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1421 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1408 | 1422 | |
| 1409 | 1423 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 1410 | 1424 | return __table_.__equal_range_unique(__k); |
| ... | ... | @@ -1412,7 +1426,7 @@ public: |
| 1412 | 1426 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 1413 | 1427 | return __table_.__equal_range_unique(__k); |
| 1414 | 1428 | } |
| 1415 | #if _LIBCPP_STD_VER >= 20 | |
| 1429 | # if _LIBCPP_STD_VER >= 20 | |
| 1416 | 1430 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1417 | 1431 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1418 | 1432 | return __table_.__equal_range_unique(__k); |
| ... | ... | @@ -1421,12 +1435,12 @@ public: |
| 1421 | 1435 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1422 | 1436 | return __table_.__equal_range_unique(__k); |
| 1423 | 1437 | } |
| 1424 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1438 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1425 | 1439 | |
| 1426 | 1440 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k); |
| 1427 | #ifndef _LIBCPP_CXX03_LANG | |
| 1441 | # ifndef _LIBCPP_CXX03_LANG | |
| 1428 | 1442 | _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k); |
| 1429 | #endif | |
| 1443 | # endif | |
| 1430 | 1444 | |
| 1431 | 1445 | _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k); |
| 1432 | 1446 | _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const; |
| ... | ... | @@ -1451,12 +1465,12 @@ public: |
| 1451 | 1465 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); } |
| 1452 | 1466 | |
| 1453 | 1467 | private: |
| 1454 | #ifdef _LIBCPP_CXX03_LANG | |
| 1468 | # ifdef _LIBCPP_CXX03_LANG | |
| 1455 | 1469 | _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node_with_key(const key_type& __k); |
| 1456 | #endif | |
| 1470 | # endif | |
| 1457 | 1471 | }; |
| 1458 | 1472 | |
| 1459 | #if _LIBCPP_STD_VER >= 17 | |
| 1473 | # if _LIBCPP_STD_VER >= 17 | |
| 1460 | 1474 | template <class _InputIterator, |
| 1461 | 1475 | class _Hash = hash<__iter_key_type<_InputIterator>>, |
| 1462 | 1476 | class _Pred = equal_to<__iter_key_type<_InputIterator>>, |
| ... | ... | @@ -1474,7 +1488,7 @@ unordered_map(_InputIterator, |
| 1474 | 1488 | _Allocator = _Allocator()) |
| 1475 | 1489 | -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>; |
| 1476 | 1490 | |
| 1477 | # if _LIBCPP_STD_VER >= 23 | |
| 1491 | # if _LIBCPP_STD_VER >= 23 | |
| 1478 | 1492 | template <ranges::input_range _Range, |
| 1479 | 1493 | class _Hash = hash<__range_key_type<_Range>>, |
| 1480 | 1494 | class _Pred = equal_to<__range_key_type<_Range>>, |
| ... | ... | @@ -1490,7 +1504,7 @@ unordered_map(from_range_t, |
| 1490 | 1504 | _Pred = _Pred(), |
| 1491 | 1505 | _Allocator = _Allocator()) |
| 1492 | 1506 | -> unordered_map<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash, _Pred, _Allocator>; // C++23 |
| 1493 | # endif | |
| 1507 | # endif | |
| 1494 | 1508 | |
| 1495 | 1509 | template <class _Key, |
| 1496 | 1510 | class _Tp, |
| ... | ... | @@ -1543,7 +1557,7 @@ unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocat |
| 1543 | 1557 | equal_to<__iter_key_type<_InputIterator>>, |
| 1544 | 1558 | _Allocator>; |
| 1545 | 1559 | |
| 1546 | # if _LIBCPP_STD_VER >= 23 | |
| 1560 | # if _LIBCPP_STD_VER >= 23 | |
| 1547 | 1561 | |
| 1548 | 1562 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 1549 | 1563 | unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| ... | ... | @@ -1574,7 +1588,7 @@ unordered_map(from_range_t, _Range&&, typename allocator_traits<_Allocator>::siz |
| 1574 | 1588 | equal_to<__range_key_type<_Range>>, |
| 1575 | 1589 | _Allocator>; |
| 1576 | 1590 | |
| 1577 | # endif | |
| 1591 | # endif | |
| 1578 | 1592 | |
| 1579 | 1593 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 1580 | 1594 | unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| ... | ... | @@ -1593,7 +1607,7 @@ template <class _Key, |
| 1593 | 1607 | class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 1594 | 1608 | unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1595 | 1609 | -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>; |
| 1596 | #endif | |
| 1610 | # endif | |
| 1597 | 1611 | |
| 1598 | 1612 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1599 | 1613 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(size_type __n, const hasher& __hf, const key_equal& __eql) |
| ... | ... | @@ -1654,7 +1668,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(const unordered_ma |
| 1654 | 1668 | insert(__u.begin(), __u.end()); |
| 1655 | 1669 | } |
| 1656 | 1670 | |
| 1657 | #ifndef _LIBCPP_CXX03_LANG | |
| 1671 | # ifndef _LIBCPP_CXX03_LANG | |
| 1658 | 1672 | |
| 1659 | 1673 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1660 | 1674 | inline unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __u) |
| ... | ... | @@ -1712,7 +1726,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list<value |
| 1712 | 1726 | return *this; |
| 1713 | 1727 | } |
| 1714 | 1728 | |
| 1715 | #endif // _LIBCPP_CXX03_LANG | |
| 1729 | # endif // _LIBCPP_CXX03_LANG | |
| 1716 | 1730 | |
| 1717 | 1731 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1718 | 1732 | template <class _InputIterator> |
| ... | ... | @@ -1721,7 +1735,7 @@ inline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterato |
| 1721 | 1735 | __table_.__insert_unique(*__first); |
| 1722 | 1736 | } |
| 1723 | 1737 | |
| 1724 | #ifndef _LIBCPP_CXX03_LANG | |
| 1738 | # ifndef _LIBCPP_CXX03_LANG | |
| 1725 | 1739 | |
| 1726 | 1740 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1727 | 1741 | _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) { |
| ... | ... | @@ -1739,7 +1753,7 @@ _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k) |
| 1739 | 1753 | .first->__get_value() |
| 1740 | 1754 | .second; |
| 1741 | 1755 | } |
| 1742 | #else // _LIBCPP_CXX03_LANG | |
| 1756 | # else // _LIBCPP_CXX03_LANG | |
| 1743 | 1757 | |
| 1744 | 1758 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1745 | 1759 | typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder |
| ... | ... | @@ -1764,7 +1778,7 @@ _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& |
| 1764 | 1778 | return __r.first->second; |
| 1765 | 1779 | } |
| 1766 | 1780 | |
| 1767 | #endif // _LIBCPP_CXX03_LANG | |
| 1781 | # endif // _LIBCPP_CXX03_LANG | |
| 1768 | 1782 | |
| 1769 | 1783 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1770 | 1784 | _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) { |
| ... | ... | @@ -1789,13 +1803,13 @@ swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_map<_Key, _T |
| 1789 | 1803 | __x.swap(__y); |
| 1790 | 1804 | } |
| 1791 | 1805 | |
| 1792 | #if _LIBCPP_STD_VER >= 20 | |
| 1806 | # if _LIBCPP_STD_VER >= 20 | |
| 1793 | 1807 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate> |
| 1794 | 1808 | inline _LIBCPP_HIDE_FROM_ABI typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type |
| 1795 | 1809 | erase_if(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) { |
| 1796 | 1810 | return std::__libcpp_erase_if_container(__c, __pred); |
| 1797 | 1811 | } |
| 1798 | #endif | |
| 1812 | # endif | |
| 1799 | 1813 | |
| 1800 | 1814 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1801 | 1815 | _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| ... | ... | @@ -1811,7 +1825,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_map<_Key, _Tp, _Hash, _Pre |
| 1811 | 1825 | return true; |
| 1812 | 1826 | } |
| 1813 | 1827 | |
| 1814 | #if _LIBCPP_STD_VER <= 17 | |
| 1828 | # if _LIBCPP_STD_VER <= 17 | |
| 1815 | 1829 | |
| 1816 | 1830 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1817 | 1831 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| ... | ... | @@ -1819,7 +1833,17 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_map<_Key, _Tp, _Has |
| 1819 | 1833 | return !(__x == __y); |
| 1820 | 1834 | } |
| 1821 | 1835 | |
| 1822 | #endif | |
| 1836 | # endif | |
| 1837 | ||
| 1838 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | |
| 1839 | struct __container_traits<unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> > { | |
| 1840 | // http://eel.is/c++draft/unord.req.except#2 | |
| 1841 | // For unordered associative containers, if an exception is thrown by any operation | |
| 1842 | // other than the container's hash function from within an insert or emplace function | |
| 1843 | // inserting a single element, the insertion has no effect. | |
| 1844 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | |
| 1845 | __is_nothrow_invocable_v<_Hash, const _Key&>; | |
| 1846 | }; | |
| 1823 | 1847 | |
| 1824 | 1848 | template <class _Key, |
| 1825 | 1849 | class _Tp, |
| ... | ... | @@ -1872,9 +1896,9 @@ public: |
| 1872 | 1896 | typedef __hash_map_iterator<typename __table::local_iterator> local_iterator; |
| 1873 | 1897 | typedef __hash_map_const_iterator<typename __table::const_local_iterator> const_local_iterator; |
| 1874 | 1898 | |
| 1875 | #if _LIBCPP_STD_VER >= 17 | |
| 1899 | # if _LIBCPP_STD_VER >= 17 | |
| 1876 | 1900 | typedef __map_node_handle<__node, allocator_type> node_type; |
| 1877 | #endif | |
| 1901 | # endif | |
| 1878 | 1902 | |
| 1879 | 1903 | template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2> |
| 1880 | 1904 | friend class _LIBCPP_TEMPLATE_VIS unordered_map; |
| ... | ... | @@ -1904,7 +1928,7 @@ public: |
| 1904 | 1928 | const key_equal& __eql, |
| 1905 | 1929 | const allocator_type& __a); |
| 1906 | 1930 | |
| 1907 | #if _LIBCPP_STD_VER >= 23 | |
| 1931 | # if _LIBCPP_STD_VER >= 23 | |
| 1908 | 1932 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1909 | 1933 | _LIBCPP_HIDE_FROM_ABI unordered_multimap( |
| 1910 | 1934 | from_range_t, |
| ... | ... | @@ -1919,12 +1943,12 @@ public: |
| 1919 | 1943 | } |
| 1920 | 1944 | insert_range(std::forward<_Range>(__range)); |
| 1921 | 1945 | } |
| 1922 | #endif | |
| 1946 | # endif | |
| 1923 | 1947 | |
| 1924 | 1948 | _LIBCPP_HIDE_FROM_ABI explicit unordered_multimap(const allocator_type& __a); |
| 1925 | 1949 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u); |
| 1926 | 1950 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(const unordered_multimap& __u, const allocator_type& __a); |
| 1927 | #ifndef _LIBCPP_CXX03_LANG | |
| 1951 | # ifndef _LIBCPP_CXX03_LANG | |
| 1928 | 1952 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u) |
| 1929 | 1953 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); |
| 1930 | 1954 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(unordered_multimap&& __u, const allocator_type& __a); |
| ... | ... | @@ -1940,8 +1964,8 @@ public: |
| 1940 | 1964 | const hasher& __hf, |
| 1941 | 1965 | const key_equal& __eql, |
| 1942 | 1966 | const allocator_type& __a); |
| 1943 | #endif // _LIBCPP_CXX03_LANG | |
| 1944 | #if _LIBCPP_STD_VER >= 14 | |
| 1967 | # endif // _LIBCPP_CXX03_LANG | |
| 1968 | # if _LIBCPP_STD_VER >= 14 | |
| 1945 | 1969 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const allocator_type& __a) |
| 1946 | 1970 | : unordered_multimap(__n, hasher(), key_equal(), __a) {} |
| 1947 | 1971 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a) |
| ... | ... | @@ -1955,7 +1979,7 @@ public: |
| 1955 | 1979 | _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1956 | 1980 | : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {} |
| 1957 | 1981 | |
| 1958 | # if _LIBCPP_STD_VER >= 23 | |
| 1982 | # if _LIBCPP_STD_VER >= 23 | |
| 1959 | 1983 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1960 | 1984 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a) |
| 1961 | 1985 | : unordered_multimap(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {} |
| ... | ... | @@ -1964,22 +1988,22 @@ public: |
| 1964 | 1988 | _LIBCPP_HIDE_FROM_ABI |
| 1965 | 1989 | unordered_multimap(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1966 | 1990 | : unordered_multimap(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {} |
| 1967 | # endif | |
| 1991 | # endif | |
| 1968 | 1992 | |
| 1969 | 1993 | _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) |
| 1970 | 1994 | : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {} |
| 1971 | 1995 | _LIBCPP_HIDE_FROM_ABI |
| 1972 | 1996 | unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1973 | 1997 | : unordered_multimap(__il, __n, __hf, key_equal(), __a) {} |
| 1974 | #endif | |
| 1998 | # endif | |
| 1975 | 1999 | _LIBCPP_HIDE_FROM_ABI ~unordered_multimap() { |
| 1976 | 2000 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Key, _Hash, _Pred>(0)), ""); |
| 1977 | 2001 | } |
| 1978 | 2002 | |
| 1979 | 2003 | _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(const unordered_multimap& __u) { |
| 1980 | #ifndef _LIBCPP_CXX03_LANG | |
| 2004 | # ifndef _LIBCPP_CXX03_LANG | |
| 1981 | 2005 | __table_ = __u.__table_; |
| 1982 | #else | |
| 2006 | # else | |
| 1983 | 2007 | if (this != std::addressof(__u)) { |
| 1984 | 2008 | __table_.clear(); |
| 1985 | 2009 | __table_.hash_function() = __u.__table_.hash_function(); |
| ... | ... | @@ -1988,20 +2012,20 @@ public: |
| 1988 | 2012 | __table_.__copy_assign_alloc(__u.__table_); |
| 1989 | 2013 | insert(__u.begin(), __u.end()); |
| 1990 | 2014 | } |
| 1991 | #endif | |
| 2015 | # endif | |
| 1992 | 2016 | return *this; |
| 1993 | 2017 | } |
| 1994 | #ifndef _LIBCPP_CXX03_LANG | |
| 2018 | # ifndef _LIBCPP_CXX03_LANG | |
| 1995 | 2019 | _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(unordered_multimap&& __u) |
| 1996 | 2020 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); |
| 1997 | 2021 | _LIBCPP_HIDE_FROM_ABI unordered_multimap& operator=(initializer_list<value_type> __il); |
| 1998 | #endif // _LIBCPP_CXX03_LANG | |
| 2022 | # endif // _LIBCPP_CXX03_LANG | |
| 1999 | 2023 | |
| 2000 | 2024 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 2001 | 2025 | return allocator_type(__table_.__node_alloc()); |
| 2002 | 2026 | } |
| 2003 | 2027 | |
| 2004 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | |
| 2028 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | |
| 2005 | 2029 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 2006 | 2030 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 2007 | 2031 | |
| ... | ... | @@ -2021,16 +2045,16 @@ public: |
| 2021 | 2045 | template <class _InputIterator> |
| 2022 | 2046 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last); |
| 2023 | 2047 | |
| 2024 | #if _LIBCPP_STD_VER >= 23 | |
| 2048 | # if _LIBCPP_STD_VER >= 23 | |
| 2025 | 2049 | template <_ContainerCompatibleRange<value_type> _Range> |
| 2026 | 2050 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 2027 | 2051 | for (auto&& __element : __range) { |
| 2028 | 2052 | __table_.__insert_multi(std::forward<decltype(__element)>(__element)); |
| 2029 | 2053 | } |
| 2030 | 2054 | } |
| 2031 | #endif | |
| 2055 | # endif | |
| 2032 | 2056 | |
| 2033 | #ifndef _LIBCPP_CXX03_LANG | |
| 2057 | # ifndef _LIBCPP_CXX03_LANG | |
| 2034 | 2058 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 2035 | 2059 | _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__insert_multi(std::move(__x)); } |
| 2036 | 2060 | |
| ... | ... | @@ -2057,7 +2081,7 @@ public: |
| 2057 | 2081 | _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) { |
| 2058 | 2082 | return __table_.__emplace_hint_multi(__p.__i_, std::forward<_Args>(__args)...); |
| 2059 | 2083 | } |
| 2060 | #endif // _LIBCPP_CXX03_LANG | |
| 2084 | # endif // _LIBCPP_CXX03_LANG | |
| 2061 | 2085 | |
| 2062 | 2086 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p.__i_); } |
| 2063 | 2087 | _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __table_.erase(__p.__i_); } |
| ... | ... | @@ -2067,7 +2091,7 @@ public: |
| 2067 | 2091 | } |
| 2068 | 2092 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); } |
| 2069 | 2093 | |
| 2070 | #if _LIBCPP_STD_VER >= 17 | |
| 2094 | # if _LIBCPP_STD_VER >= 17 | |
| 2071 | 2095 | _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) { |
| 2072 | 2096 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 2073 | 2097 | "node_type with incompatible allocator passed to unordered_multimap::insert()"); |
| ... | ... | @@ -2109,7 +2133,7 @@ public: |
| 2109 | 2133 | __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); |
| 2110 | 2134 | return __table_.__node_handle_merge_multi(__source.__table_); |
| 2111 | 2135 | } |
| 2112 | #endif | |
| 2136 | # endif | |
| 2113 | 2137 | |
| 2114 | 2138 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_multimap& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) { |
| 2115 | 2139 | __table_.swap(__u.__table_); |
| ... | ... | @@ -2120,7 +2144,7 @@ public: |
| 2120 | 2144 | |
| 2121 | 2145 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 2122 | 2146 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 2123 | #if _LIBCPP_STD_VER >= 20 | |
| 2147 | # if _LIBCPP_STD_VER >= 20 | |
| 2124 | 2148 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2125 | 2149 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 2126 | 2150 | return __table_.find(__k); |
| ... | ... | @@ -2129,24 +2153,24 @@ public: |
| 2129 | 2153 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 2130 | 2154 | return __table_.find(__k); |
| 2131 | 2155 | } |
| 2132 | #endif // _LIBCPP_STD_VER >= 20 | |
| 2156 | # endif // _LIBCPP_STD_VER >= 20 | |
| 2133 | 2157 | |
| 2134 | 2158 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); } |
| 2135 | #if _LIBCPP_STD_VER >= 20 | |
| 2159 | # if _LIBCPP_STD_VER >= 20 | |
| 2136 | 2160 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2137 | 2161 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 2138 | 2162 | return __table_.__count_multi(__k); |
| 2139 | 2163 | } |
| 2140 | #endif // _LIBCPP_STD_VER >= 20 | |
| 2164 | # endif // _LIBCPP_STD_VER >= 20 | |
| 2141 | 2165 | |
| 2142 | #if _LIBCPP_STD_VER >= 20 | |
| 2166 | # if _LIBCPP_STD_VER >= 20 | |
| 2143 | 2167 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 2144 | 2168 | |
| 2145 | 2169 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2146 | 2170 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 2147 | 2171 | return find(__k) != end(); |
| 2148 | 2172 | } |
| 2149 | #endif // _LIBCPP_STD_VER >= 20 | |
| 2173 | # endif // _LIBCPP_STD_VER >= 20 | |
| 2150 | 2174 | |
| 2151 | 2175 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 2152 | 2176 | return __table_.__equal_range_multi(__k); |
| ... | ... | @@ -2154,7 +2178,7 @@ public: |
| 2154 | 2178 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 2155 | 2179 | return __table_.__equal_range_multi(__k); |
| 2156 | 2180 | } |
| 2157 | #if _LIBCPP_STD_VER >= 20 | |
| 2181 | # if _LIBCPP_STD_VER >= 20 | |
| 2158 | 2182 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 2159 | 2183 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 2160 | 2184 | return __table_.__equal_range_multi(__k); |
| ... | ... | @@ -2163,7 +2187,7 @@ public: |
| 2163 | 2187 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 2164 | 2188 | return __table_.__equal_range_multi(__k); |
| 2165 | 2189 | } |
| 2166 | #endif // _LIBCPP_STD_VER >= 20 | |
| 2190 | # endif // _LIBCPP_STD_VER >= 20 | |
| 2167 | 2191 | |
| 2168 | 2192 | _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } |
| 2169 | 2193 | _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); } |
| ... | ... | @@ -2185,7 +2209,7 @@ public: |
| 2185 | 2209 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); } |
| 2186 | 2210 | }; |
| 2187 | 2211 | |
| 2188 | #if _LIBCPP_STD_VER >= 17 | |
| 2212 | # if _LIBCPP_STD_VER >= 17 | |
| 2189 | 2213 | template <class _InputIterator, |
| 2190 | 2214 | class _Hash = hash<__iter_key_type<_InputIterator>>, |
| 2191 | 2215 | class _Pred = equal_to<__iter_key_type<_InputIterator>>, |
| ... | ... | @@ -2207,7 +2231,7 @@ unordered_multimap(_InputIterator, |
| 2207 | 2231 | _Pred, |
| 2208 | 2232 | _Allocator>; |
| 2209 | 2233 | |
| 2210 | # if _LIBCPP_STD_VER >= 23 | |
| 2234 | # if _LIBCPP_STD_VER >= 23 | |
| 2211 | 2235 | template <ranges::input_range _Range, |
| 2212 | 2236 | class _Hash = hash<__range_key_type<_Range>>, |
| 2213 | 2237 | class _Pred = equal_to<__range_key_type<_Range>>, |
| ... | ... | @@ -2223,7 +2247,7 @@ unordered_multimap(from_range_t, |
| 2223 | 2247 | _Pred = _Pred(), |
| 2224 | 2248 | _Allocator = _Allocator()) |
| 2225 | 2249 | -> unordered_multimap<__range_key_type<_Range>, __range_mapped_type<_Range>, _Hash, _Pred, _Allocator>; |
| 2226 | # endif | |
| 2250 | # endif | |
| 2227 | 2251 | |
| 2228 | 2252 | template <class _Key, |
| 2229 | 2253 | class _Tp, |
| ... | ... | @@ -2277,7 +2301,7 @@ unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Al |
| 2277 | 2301 | equal_to<__iter_key_type<_InputIterator>>, |
| 2278 | 2302 | _Allocator>; |
| 2279 | 2303 | |
| 2280 | # if _LIBCPP_STD_VER >= 23 | |
| 2304 | # if _LIBCPP_STD_VER >= 23 | |
| 2281 | 2305 | |
| 2282 | 2306 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 2283 | 2307 | unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| ... | ... | @@ -2308,7 +2332,7 @@ unordered_multimap(from_range_t, _Range&&, typename allocator_traits<_Allocator> |
| 2308 | 2332 | equal_to<__range_key_type<_Range>>, |
| 2309 | 2333 | _Allocator>; |
| 2310 | 2334 | |
| 2311 | # endif | |
| 2335 | # endif | |
| 2312 | 2336 | |
| 2313 | 2337 | template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 2314 | 2338 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| ... | ... | @@ -2336,7 +2360,7 @@ template <class _Key, |
| 2336 | 2360 | unordered_multimap( |
| 2337 | 2361 | initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 2338 | 2362 | -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, equal_to<remove_const_t<_Key>>, _Allocator>; |
| 2339 | #endif | |
| 2363 | # endif | |
| 2340 | 2364 | |
| 2341 | 2365 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2342 | 2366 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| ... | ... | @@ -2400,7 +2424,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2400 | 2424 | insert(__u.begin(), __u.end()); |
| 2401 | 2425 | } |
| 2402 | 2426 | |
| 2403 | #ifndef _LIBCPP_CXX03_LANG | |
| 2427 | # ifndef _LIBCPP_CXX03_LANG | |
| 2404 | 2428 | |
| 2405 | 2429 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2406 | 2430 | inline unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(unordered_multimap&& __u) |
| ... | ... | @@ -2459,7 +2483,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::operator=(initializer_list< |
| 2459 | 2483 | return *this; |
| 2460 | 2484 | } |
| 2461 | 2485 | |
| 2462 | #endif // _LIBCPP_CXX03_LANG | |
| 2486 | # endif // _LIBCPP_CXX03_LANG | |
| 2463 | 2487 | |
| 2464 | 2488 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2465 | 2489 | template <class _InputIterator> |
| ... | ... | @@ -2475,13 +2499,13 @@ swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, unordered_multima |
| 2475 | 2499 | __x.swap(__y); |
| 2476 | 2500 | } |
| 2477 | 2501 | |
| 2478 | #if _LIBCPP_STD_VER >= 20 | |
| 2502 | # if _LIBCPP_STD_VER >= 20 | |
| 2479 | 2503 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc, class _Predicate> |
| 2480 | 2504 | inline _LIBCPP_HIDE_FROM_ABI typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::size_type |
| 2481 | 2505 | erase_if(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) { |
| 2482 | 2506 | return std::__libcpp_erase_if_container(__c, __pred); |
| 2483 | 2507 | } |
| 2484 | #endif | |
| 2508 | # endif | |
| 2485 | 2509 | |
| 2486 | 2510 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2487 | 2511 | _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| ... | ... | @@ -2501,7 +2525,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multimap<_Key, _Tp, _Hash, |
| 2501 | 2525 | return true; |
| 2502 | 2526 | } |
| 2503 | 2527 | |
| 2504 | #if _LIBCPP_STD_VER <= 17 | |
| 2528 | # if _LIBCPP_STD_VER <= 17 | |
| 2505 | 2529 | |
| 2506 | 2530 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2507 | 2531 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| ... | ... | @@ -2509,11 +2533,21 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multimap<_Key, _Tp, |
| 2509 | 2533 | return !(__x == __y); |
| 2510 | 2534 | } |
| 2511 | 2535 | |
| 2512 | #endif | |
| 2536 | # endif | |
| 2537 | ||
| 2538 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> | |
| 2539 | struct __container_traits<unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> > { | |
| 2540 | // http://eel.is/c++draft/unord.req.except#2 | |
| 2541 | // For unordered associative containers, if an exception is thrown by any operation | |
| 2542 | // other than the container's hash function from within an insert or emplace function | |
| 2543 | // inserting a single element, the insertion has no effect. | |
| 2544 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | |
| 2545 | __is_nothrow_invocable_v<_Hash, const _Key&>; | |
| 2546 | }; | |
| 2513 | 2547 | |
| 2514 | 2548 | _LIBCPP_END_NAMESPACE_STD |
| 2515 | 2549 | |
| 2516 | #if _LIBCPP_STD_VER >= 17 | |
| 2550 | # if _LIBCPP_STD_VER >= 17 | |
| 2517 | 2551 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 2518 | 2552 | namespace pmr { |
| 2519 | 2553 | template <class _KeyT, class _ValueT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>> |
| ... | ... | @@ -2525,17 +2559,19 @@ using unordered_multimap _LIBCPP_AVAILABILITY_PMR = |
| 2525 | 2559 | std::unordered_multimap<_KeyT, _ValueT, _HashT, _PredT, polymorphic_allocator<std::pair<const _KeyT, _ValueT>>>; |
| 2526 | 2560 | } // namespace pmr |
| 2527 | 2561 | _LIBCPP_END_NAMESPACE_STD |
| 2528 | #endif | |
| 2562 | # endif | |
| 2529 | 2563 | |
| 2530 | 2564 | _LIBCPP_POP_MACROS |
| 2531 | 2565 | |
| 2532 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 2533 | # include <algorithm> | |
| 2534 | # include <bit> | |
| 2535 | # include <concepts> | |
| 2536 | # include <cstdlib> | |
| 2537 | # include <iterator> | |
| 2538 | # include <type_traits> | |
| 2539 | #endif | |
| 2566 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 2567 | # include <algorithm> | |
| 2568 | # include <bit> | |
| 2569 | # include <cmath> | |
| 2570 | # include <concepts> | |
| 2571 | # include <cstdlib> | |
| 2572 | # include <iterator> | |
| 2573 | # include <type_traits> | |
| 2574 | # endif | |
| 2575 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 2540 | 2576 | |
| 2541 | 2577 | #endif // _LIBCPP_UNORDERED_MAP |
lib/libcxx/include/unordered_set+165-127| ... | ... | @@ -531,46 +531,62 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 531 | 531 | |
| 532 | 532 | // clang-format on |
| 533 | 533 | |
| 534 | #include <__algorithm/is_permutation.h> | |
| 535 | #include <__assert> | |
| 536 | #include <__config> | |
| 537 | #include <__functional/is_transparent.h> | |
| 538 | #include <__functional/operations.h> | |
| 539 | #include <__hash_table> | |
| 540 | #include <__iterator/distance.h> | |
| 541 | #include <__iterator/erase_if_container.h> | |
| 542 | #include <__iterator/iterator_traits.h> | |
| 543 | #include <__iterator/ranges_iterator_traits.h> | |
| 544 | #include <__memory/addressof.h> | |
| 545 | #include <__memory/allocator.h> | |
| 546 | #include <__memory_resource/polymorphic_allocator.h> | |
| 547 | #include <__node_handle> | |
| 548 | #include <__ranges/concepts.h> | |
| 549 | #include <__ranges/container_compatible_range.h> | |
| 550 | #include <__ranges/from_range.h> | |
| 551 | #include <__type_traits/is_allocator.h> | |
| 552 | #include <__utility/forward.h> | |
| 553 | #include <version> | |
| 534 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 535 | # include <__cxx03/unordered_set> | |
| 536 | #else | |
| 537 | # include <__algorithm/is_permutation.h> | |
| 538 | # include <__assert> | |
| 539 | # include <__config> | |
| 540 | # include <__functional/hash.h> | |
| 541 | # include <__functional/is_transparent.h> | |
| 542 | # include <__functional/operations.h> | |
| 543 | # include <__hash_table> | |
| 544 | # include <__iterator/distance.h> | |
| 545 | # include <__iterator/erase_if_container.h> | |
| 546 | # include <__iterator/iterator_traits.h> | |
| 547 | # include <__iterator/ranges_iterator_traits.h> | |
| 548 | # include <__memory/addressof.h> | |
| 549 | # include <__memory/allocator.h> | |
| 550 | # include <__memory/allocator_traits.h> | |
| 551 | # include <__memory_resource/polymorphic_allocator.h> | |
| 552 | # include <__node_handle> | |
| 553 | # include <__ranges/concepts.h> | |
| 554 | # include <__ranges/container_compatible_range.h> | |
| 555 | # include <__ranges/from_range.h> | |
| 556 | # include <__type_traits/container_traits.h> | |
| 557 | # include <__type_traits/enable_if.h> | |
| 558 | # include <__type_traits/invoke.h> | |
| 559 | # include <__type_traits/is_allocator.h> | |
| 560 | # include <__type_traits/is_integral.h> | |
| 561 | # include <__type_traits/is_nothrow_assignable.h> | |
| 562 | # include <__type_traits/is_nothrow_constructible.h> | |
| 563 | # include <__type_traits/is_same.h> | |
| 564 | # include <__type_traits/is_swappable.h> | |
| 565 | # include <__type_traits/type_identity.h> | |
| 566 | # include <__utility/forward.h> | |
| 567 | # include <__utility/move.h> | |
| 568 | # include <__utility/pair.h> | |
| 569 | # include <version> | |
| 554 | 570 | |
| 555 | 571 | // standard-mandated includes |
| 556 | 572 | |
| 557 | 573 | // [iterator.range] |
| 558 | #include <__iterator/access.h> | |
| 559 | #include <__iterator/data.h> | |
| 560 | #include <__iterator/empty.h> | |
| 561 | #include <__iterator/reverse_access.h> | |
| 562 | #include <__iterator/size.h> | |
| 574 | # include <__iterator/access.h> | |
| 575 | # include <__iterator/data.h> | |
| 576 | # include <__iterator/empty.h> | |
| 577 | # include <__iterator/reverse_access.h> | |
| 578 | # include <__iterator/size.h> | |
| 563 | 579 | |
| 564 | 580 | // [unord.set.syn] |
| 565 | #include <compare> | |
| 566 | #include <initializer_list> | |
| 581 | # include <compare> | |
| 582 | # include <initializer_list> | |
| 567 | 583 | |
| 568 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 569 | # pragma GCC system_header | |
| 570 | #endif | |
| 584 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 585 | # pragma GCC system_header | |
| 586 | # endif | |
| 571 | 587 | |
| 572 | 588 | _LIBCPP_PUSH_MACROS |
| 573 | #include <__undef_macros> | |
| 589 | # include <__undef_macros> | |
| 574 | 590 | |
| 575 | 591 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 576 | 592 | |
| ... | ... | @@ -608,10 +624,10 @@ public: |
| 608 | 624 | typedef typename __table::const_local_iterator local_iterator; |
| 609 | 625 | typedef typename __table::const_local_iterator const_local_iterator; |
| 610 | 626 | |
| 611 | #if _LIBCPP_STD_VER >= 17 | |
| 627 | # if _LIBCPP_STD_VER >= 17 | |
| 612 | 628 | typedef __set_node_handle<typename __table::__node, allocator_type> node_type; |
| 613 | 629 | typedef __insert_return_type<iterator, node_type> insert_return_type; |
| 614 | #endif | |
| 630 | # endif | |
| 615 | 631 | |
| 616 | 632 | template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> |
| 617 | 633 | friend class _LIBCPP_TEMPLATE_VIS unordered_set; |
| ... | ... | @@ -621,12 +637,12 @@ public: |
| 621 | 637 | _LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {} |
| 622 | 638 | explicit _LIBCPP_HIDE_FROM_ABI |
| 623 | 639 | unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); |
| 624 | #if _LIBCPP_STD_VER >= 14 | |
| 640 | # if _LIBCPP_STD_VER >= 14 | |
| 625 | 641 | inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const allocator_type& __a) |
| 626 | 642 | : unordered_set(__n, hasher(), key_equal(), __a) {} |
| 627 | 643 | inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a) |
| 628 | 644 | : unordered_set(__n, __hf, key_equal(), __a) {} |
| 629 | #endif | |
| 645 | # endif | |
| 630 | 646 | _LIBCPP_HIDE_FROM_ABI |
| 631 | 647 | unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); |
| 632 | 648 | template <class _InputIterator> |
| ... | ... | @@ -647,7 +663,7 @@ public: |
| 647 | 663 | const key_equal& __eql, |
| 648 | 664 | const allocator_type& __a); |
| 649 | 665 | |
| 650 | #if _LIBCPP_STD_VER >= 23 | |
| 666 | # if _LIBCPP_STD_VER >= 23 | |
| 651 | 667 | template <_ContainerCompatibleRange<value_type> _Range> |
| 652 | 668 | _LIBCPP_HIDE_FROM_ABI unordered_set( |
| 653 | 669 | from_range_t, |
| ... | ... | @@ -662,9 +678,9 @@ public: |
| 662 | 678 | } |
| 663 | 679 | insert_range(std::forward<_Range>(__range)); |
| 664 | 680 | } |
| 665 | #endif | |
| 681 | # endif | |
| 666 | 682 | |
| 667 | #if _LIBCPP_STD_VER >= 14 | |
| 683 | # if _LIBCPP_STD_VER >= 14 | |
| 668 | 684 | template <class _InputIterator> |
| 669 | 685 | inline _LIBCPP_HIDE_FROM_ABI |
| 670 | 686 | unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) |
| ... | ... | @@ -673,9 +689,9 @@ public: |
| 673 | 689 | _LIBCPP_HIDE_FROM_ABI unordered_set( |
| 674 | 690 | _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 675 | 691 | : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {} |
| 676 | #endif | |
| 692 | # endif | |
| 677 | 693 | |
| 678 | #if _LIBCPP_STD_VER >= 23 | |
| 694 | # if _LIBCPP_STD_VER >= 23 | |
| 679 | 695 | template <_ContainerCompatibleRange<value_type> _Range> |
| 680 | 696 | _LIBCPP_HIDE_FROM_ABI unordered_set(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a) |
| 681 | 697 | : unordered_set(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {} |
| ... | ... | @@ -684,12 +700,12 @@ public: |
| 684 | 700 | _LIBCPP_HIDE_FROM_ABI |
| 685 | 701 | unordered_set(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 686 | 702 | : unordered_set(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {} |
| 687 | #endif | |
| 703 | # endif | |
| 688 | 704 | |
| 689 | 705 | _LIBCPP_HIDE_FROM_ABI explicit unordered_set(const allocator_type& __a); |
| 690 | 706 | _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u); |
| 691 | 707 | _LIBCPP_HIDE_FROM_ABI unordered_set(const unordered_set& __u, const allocator_type& __a); |
| 692 | #ifndef _LIBCPP_CXX03_LANG | |
| 708 | # ifndef _LIBCPP_CXX03_LANG | |
| 693 | 709 | _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u) _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); |
| 694 | 710 | _LIBCPP_HIDE_FROM_ABI unordered_set(unordered_set&& __u, const allocator_type& __a); |
| 695 | 711 | _LIBCPP_HIDE_FROM_ABI unordered_set(initializer_list<value_type> __il); |
| ... | ... | @@ -704,15 +720,15 @@ public: |
| 704 | 720 | const hasher& __hf, |
| 705 | 721 | const key_equal& __eql, |
| 706 | 722 | const allocator_type& __a); |
| 707 | # if _LIBCPP_STD_VER >= 14 | |
| 723 | # if _LIBCPP_STD_VER >= 14 | |
| 708 | 724 | inline _LIBCPP_HIDE_FROM_ABI |
| 709 | 725 | unordered_set(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) |
| 710 | 726 | : unordered_set(__il, __n, hasher(), key_equal(), __a) {} |
| 711 | 727 | inline _LIBCPP_HIDE_FROM_ABI |
| 712 | 728 | unordered_set(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 713 | 729 | : unordered_set(__il, __n, __hf, key_equal(), __a) {} |
| 714 | # endif | |
| 715 | #endif // _LIBCPP_CXX03_LANG | |
| 730 | # endif | |
| 731 | # endif // _LIBCPP_CXX03_LANG | |
| 716 | 732 | _LIBCPP_HIDE_FROM_ABI ~unordered_set() { |
| 717 | 733 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), ""); |
| 718 | 734 | } |
| ... | ... | @@ -721,17 +737,17 @@ public: |
| 721 | 737 | __table_ = __u.__table_; |
| 722 | 738 | return *this; |
| 723 | 739 | } |
| 724 | #ifndef _LIBCPP_CXX03_LANG | |
| 740 | # ifndef _LIBCPP_CXX03_LANG | |
| 725 | 741 | _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(unordered_set&& __u) |
| 726 | 742 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); |
| 727 | 743 | _LIBCPP_HIDE_FROM_ABI unordered_set& operator=(initializer_list<value_type> __il); |
| 728 | #endif // _LIBCPP_CXX03_LANG | |
| 744 | # endif // _LIBCPP_CXX03_LANG | |
| 729 | 745 | |
| 730 | 746 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 731 | 747 | return allocator_type(__table_.__node_alloc()); |
| 732 | 748 | } |
| 733 | 749 | |
| 734 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | |
| 750 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | |
| 735 | 751 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 736 | 752 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 737 | 753 | |
| ... | ... | @@ -742,7 +758,7 @@ public: |
| 742 | 758 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } |
| 743 | 759 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } |
| 744 | 760 | |
| 745 | #ifndef _LIBCPP_CXX03_LANG | |
| 761 | # ifndef _LIBCPP_CXX03_LANG | |
| 746 | 762 | template <class... _Args> |
| 747 | 763 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) { |
| 748 | 764 | return __table_.__emplace_unique(std::forward<_Args>(__args)...); |
| ... | ... | @@ -758,21 +774,21 @@ public: |
| 758 | 774 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { return insert(std::move(__x)).first; } |
| 759 | 775 | |
| 760 | 776 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 761 | #endif // _LIBCPP_CXX03_LANG | |
| 777 | # endif // _LIBCPP_CXX03_LANG | |
| 762 | 778 | _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__insert_unique(__x); } |
| 763 | 779 | |
| 764 | 780 | _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; } |
| 765 | 781 | template <class _InputIterator> |
| 766 | 782 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last); |
| 767 | 783 | |
| 768 | #if _LIBCPP_STD_VER >= 23 | |
| 784 | # if _LIBCPP_STD_VER >= 23 | |
| 769 | 785 | template <_ContainerCompatibleRange<value_type> _Range> |
| 770 | 786 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 771 | 787 | for (auto&& __element : __range) { |
| 772 | 788 | __table_.__insert_unique(std::forward<decltype(__element)>(__element)); |
| 773 | 789 | } |
| 774 | 790 | } |
| 775 | #endif | |
| 791 | # endif | |
| 776 | 792 | |
| 777 | 793 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p); } |
| 778 | 794 | _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_unique(__k); } |
| ... | ... | @@ -781,7 +797,7 @@ public: |
| 781 | 797 | } |
| 782 | 798 | _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); } |
| 783 | 799 | |
| 784 | #if _LIBCPP_STD_VER >= 17 | |
| 800 | # if _LIBCPP_STD_VER >= 17 | |
| 785 | 801 | _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) { |
| 786 | 802 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 787 | 803 | "node_type with incompatible allocator passed to unordered_set::insert()"); |
| ... | ... | @@ -823,7 +839,7 @@ public: |
| 823 | 839 | __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); |
| 824 | 840 | __table_.__node_handle_merge_unique(__source.__table_); |
| 825 | 841 | } |
| 826 | #endif | |
| 842 | # endif | |
| 827 | 843 | |
| 828 | 844 | _LIBCPP_HIDE_FROM_ABI void swap(unordered_set& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) { |
| 829 | 845 | __table_.swap(__u.__table_); |
| ... | ... | @@ -834,7 +850,7 @@ public: |
| 834 | 850 | |
| 835 | 851 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 836 | 852 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 837 | #if _LIBCPP_STD_VER >= 20 | |
| 853 | # if _LIBCPP_STD_VER >= 20 | |
| 838 | 854 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 839 | 855 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 840 | 856 | return __table_.find(__k); |
| ... | ... | @@ -843,24 +859,24 @@ public: |
| 843 | 859 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 844 | 860 | return __table_.find(__k); |
| 845 | 861 | } |
| 846 | #endif // _LIBCPP_STD_VER >= 20 | |
| 862 | # endif // _LIBCPP_STD_VER >= 20 | |
| 847 | 863 | |
| 848 | 864 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); } |
| 849 | #if _LIBCPP_STD_VER >= 20 | |
| 865 | # if _LIBCPP_STD_VER >= 20 | |
| 850 | 866 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 851 | 867 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 852 | 868 | return __table_.__count_unique(__k); |
| 853 | 869 | } |
| 854 | #endif // _LIBCPP_STD_VER >= 20 | |
| 870 | # endif // _LIBCPP_STD_VER >= 20 | |
| 855 | 871 | |
| 856 | #if _LIBCPP_STD_VER >= 20 | |
| 872 | # if _LIBCPP_STD_VER >= 20 | |
| 857 | 873 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 858 | 874 | |
| 859 | 875 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 860 | 876 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 861 | 877 | return find(__k) != end(); |
| 862 | 878 | } |
| 863 | #endif // _LIBCPP_STD_VER >= 20 | |
| 879 | # endif // _LIBCPP_STD_VER >= 20 | |
| 864 | 880 | |
| 865 | 881 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 866 | 882 | return __table_.__equal_range_unique(__k); |
| ... | ... | @@ -868,7 +884,7 @@ public: |
| 868 | 884 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 869 | 885 | return __table_.__equal_range_unique(__k); |
| 870 | 886 | } |
| 871 | #if _LIBCPP_STD_VER >= 20 | |
| 887 | # if _LIBCPP_STD_VER >= 20 | |
| 872 | 888 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 873 | 889 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 874 | 890 | return __table_.__equal_range_unique(__k); |
| ... | ... | @@ -877,7 +893,7 @@ public: |
| 877 | 893 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 878 | 894 | return __table_.__equal_range_unique(__k); |
| 879 | 895 | } |
| 880 | #endif // _LIBCPP_STD_VER >= 20 | |
| 896 | # endif // _LIBCPP_STD_VER >= 20 | |
| 881 | 897 | |
| 882 | 898 | _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } |
| 883 | 899 | _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); } |
| ... | ... | @@ -899,7 +915,7 @@ public: |
| 899 | 915 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_unique(__n); } |
| 900 | 916 | }; |
| 901 | 917 | |
| 902 | #if _LIBCPP_STD_VER >= 17 | |
| 918 | # if _LIBCPP_STD_VER >= 17 | |
| 903 | 919 | template <class _InputIterator, |
| 904 | 920 | class _Hash = hash<__iter_value_type<_InputIterator>>, |
| 905 | 921 | class _Pred = equal_to<__iter_value_type<_InputIterator>>, |
| ... | ... | @@ -916,7 +932,7 @@ unordered_set(_InputIterator, |
| 916 | 932 | _Pred = _Pred(), |
| 917 | 933 | _Allocator = _Allocator()) -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; |
| 918 | 934 | |
| 919 | # if _LIBCPP_STD_VER >= 23 | |
| 935 | # if _LIBCPP_STD_VER >= 23 | |
| 920 | 936 | template <ranges::input_range _Range, |
| 921 | 937 | class _Hash = hash<ranges::range_value_t<_Range>>, |
| 922 | 938 | class _Pred = equal_to<ranges::range_value_t<_Range>>, |
| ... | ... | @@ -932,7 +948,7 @@ unordered_set( |
| 932 | 948 | _Hash = _Hash(), |
| 933 | 949 | _Pred = _Pred(), |
| 934 | 950 | _Allocator = _Allocator()) -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23 |
| 935 | # endif | |
| 951 | # endif | |
| 936 | 952 | |
| 937 | 953 | template <class _Tp, |
| 938 | 954 | class _Hash = hash<_Tp>, |
| ... | ... | @@ -968,7 +984,7 @@ template <class _InputIterator, |
| 968 | 984 | unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 969 | 985 | -> unordered_set<__iter_value_type<_InputIterator>, _Hash, equal_to<__iter_value_type<_InputIterator>>, _Allocator>; |
| 970 | 986 | |
| 971 | # if _LIBCPP_STD_VER >= 23 | |
| 987 | # if _LIBCPP_STD_VER >= 23 | |
| 972 | 988 | |
| 973 | 989 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 974 | 990 | unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| ... | ... | @@ -993,7 +1009,7 @@ template <ranges::input_range _Range, |
| 993 | 1009 | unordered_set(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 994 | 1010 | -> unordered_set<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>; |
| 995 | 1011 | |
| 996 | # endif | |
| 1012 | # endif | |
| 997 | 1013 | |
| 998 | 1014 | template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 999 | 1015 | unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| ... | ... | @@ -1007,7 +1023,7 @@ template <class _Tp, |
| 1007 | 1023 | class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 1008 | 1024 | unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1009 | 1025 | -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; |
| 1010 | #endif | |
| 1026 | # endif | |
| 1011 | 1027 | |
| 1012 | 1028 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1013 | 1029 | unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql) |
| ... | ... | @@ -1067,7 +1083,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(const unordered_set& |
| 1067 | 1083 | insert(__u.begin(), __u.end()); |
| 1068 | 1084 | } |
| 1069 | 1085 | |
| 1070 | #ifndef _LIBCPP_CXX03_LANG | |
| 1086 | # ifndef _LIBCPP_CXX03_LANG | |
| 1071 | 1087 | |
| 1072 | 1088 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1073 | 1089 | inline unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u) |
| ... | ... | @@ -1124,7 +1140,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<value_ty |
| 1124 | 1140 | return *this; |
| 1125 | 1141 | } |
| 1126 | 1142 | |
| 1127 | #endif // _LIBCPP_CXX03_LANG | |
| 1143 | # endif // _LIBCPP_CXX03_LANG | |
| 1128 | 1144 | |
| 1129 | 1145 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1130 | 1146 | template <class _InputIterator> |
| ... | ... | @@ -1140,13 +1156,13 @@ swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, unordered_set<_Value, _Ha |
| 1140 | 1156 | __x.swap(__y); |
| 1141 | 1157 | } |
| 1142 | 1158 | |
| 1143 | #if _LIBCPP_STD_VER >= 20 | |
| 1159 | # if _LIBCPP_STD_VER >= 20 | |
| 1144 | 1160 | template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate> |
| 1145 | 1161 | inline _LIBCPP_HIDE_FROM_ABI typename unordered_set<_Value, _Hash, _Pred, _Alloc>::size_type |
| 1146 | 1162 | erase_if(unordered_set<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) { |
| 1147 | 1163 | return std::__libcpp_erase_if_container(__c, __pred); |
| 1148 | 1164 | } |
| 1149 | #endif | |
| 1165 | # endif | |
| 1150 | 1166 | |
| 1151 | 1167 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1152 | 1168 | _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, |
| ... | ... | @@ -1162,7 +1178,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_set<_Value, _Hash, _Pred, |
| 1162 | 1178 | return true; |
| 1163 | 1179 | } |
| 1164 | 1180 | |
| 1165 | #if _LIBCPP_STD_VER <= 17 | |
| 1181 | # if _LIBCPP_STD_VER <= 17 | |
| 1166 | 1182 | |
| 1167 | 1183 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1168 | 1184 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, |
| ... | ... | @@ -1170,7 +1186,17 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_set<_Value, _Hash, |
| 1170 | 1186 | return !(__x == __y); |
| 1171 | 1187 | } |
| 1172 | 1188 | |
| 1173 | #endif | |
| 1189 | # endif | |
| 1190 | ||
| 1191 | template <class _Value, class _Hash, class _Pred, class _Alloc> | |
| 1192 | struct __container_traits<unordered_set<_Value, _Hash, _Pred, _Alloc> > { | |
| 1193 | // http://eel.is/c++draft/unord.req.except#2 | |
| 1194 | // For unordered associative containers, if an exception is thrown by any operation | |
| 1195 | // other than the container's hash function from within an insert or emplace function | |
| 1196 | // inserting a single element, the insertion has no effect. | |
| 1197 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | |
| 1198 | __is_nothrow_invocable_v<_Hash, const _Value&>; | |
| 1199 | }; | |
| 1174 | 1200 | |
| 1175 | 1201 | template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > |
| 1176 | 1202 | class _LIBCPP_TEMPLATE_VIS unordered_multiset { |
| ... | ... | @@ -1202,9 +1228,9 @@ public: |
| 1202 | 1228 | typedef typename __table::const_local_iterator local_iterator; |
| 1203 | 1229 | typedef typename __table::const_local_iterator const_local_iterator; |
| 1204 | 1230 | |
| 1205 | #if _LIBCPP_STD_VER >= 17 | |
| 1231 | # if _LIBCPP_STD_VER >= 17 | |
| 1206 | 1232 | typedef __set_node_handle<typename __table::__node, allocator_type> node_type; |
| 1207 | #endif | |
| 1233 | # endif | |
| 1208 | 1234 | |
| 1209 | 1235 | template <class _Value2, class _Hash2, class _Pred2, class _Alloc2> |
| 1210 | 1236 | friend class _LIBCPP_TEMPLATE_VIS unordered_set; |
| ... | ... | @@ -1216,12 +1242,12 @@ public: |
| 1216 | 1242 | unordered_multiset(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); |
| 1217 | 1243 | _LIBCPP_HIDE_FROM_ABI |
| 1218 | 1244 | unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); |
| 1219 | #if _LIBCPP_STD_VER >= 14 | |
| 1245 | # if _LIBCPP_STD_VER >= 14 | |
| 1220 | 1246 | inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const allocator_type& __a) |
| 1221 | 1247 | : unordered_multiset(__n, hasher(), key_equal(), __a) {} |
| 1222 | 1248 | inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1223 | 1249 | : unordered_multiset(__n, __hf, key_equal(), __a) {} |
| 1224 | #endif | |
| 1250 | # endif | |
| 1225 | 1251 | template <class _InputIterator> |
| 1226 | 1252 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(_InputIterator __first, _InputIterator __last); |
| 1227 | 1253 | template <class _InputIterator> |
| ... | ... | @@ -1240,7 +1266,7 @@ public: |
| 1240 | 1266 | const key_equal& __eql, |
| 1241 | 1267 | const allocator_type& __a); |
| 1242 | 1268 | |
| 1243 | #if _LIBCPP_STD_VER >= 23 | |
| 1269 | # if _LIBCPP_STD_VER >= 23 | |
| 1244 | 1270 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1245 | 1271 | _LIBCPP_HIDE_FROM_ABI unordered_multiset( |
| 1246 | 1272 | from_range_t, |
| ... | ... | @@ -1255,9 +1281,9 @@ public: |
| 1255 | 1281 | } |
| 1256 | 1282 | insert_range(std::forward<_Range>(__range)); |
| 1257 | 1283 | } |
| 1258 | #endif | |
| 1284 | # endif | |
| 1259 | 1285 | |
| 1260 | #if _LIBCPP_STD_VER >= 14 | |
| 1286 | # if _LIBCPP_STD_VER >= 14 | |
| 1261 | 1287 | template <class _InputIterator> |
| 1262 | 1288 | inline _LIBCPP_HIDE_FROM_ABI |
| 1263 | 1289 | unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) |
| ... | ... | @@ -1266,9 +1292,9 @@ public: |
| 1266 | 1292 | inline _LIBCPP_HIDE_FROM_ABI unordered_multiset( |
| 1267 | 1293 | _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1268 | 1294 | : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {} |
| 1269 | #endif | |
| 1295 | # endif | |
| 1270 | 1296 | |
| 1271 | #if _LIBCPP_STD_VER >= 23 | |
| 1297 | # if _LIBCPP_STD_VER >= 23 | |
| 1272 | 1298 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1273 | 1299 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a) |
| 1274 | 1300 | : unordered_multiset(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {} |
| ... | ... | @@ -1277,12 +1303,12 @@ public: |
| 1277 | 1303 | _LIBCPP_HIDE_FROM_ABI |
| 1278 | 1304 | unordered_multiset(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1279 | 1305 | : unordered_multiset(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {} |
| 1280 | #endif | |
| 1306 | # endif | |
| 1281 | 1307 | |
| 1282 | 1308 | _LIBCPP_HIDE_FROM_ABI explicit unordered_multiset(const allocator_type& __a); |
| 1283 | 1309 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u); |
| 1284 | 1310 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(const unordered_multiset& __u, const allocator_type& __a); |
| 1285 | #ifndef _LIBCPP_CXX03_LANG | |
| 1311 | # ifndef _LIBCPP_CXX03_LANG | |
| 1286 | 1312 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u) |
| 1287 | 1313 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value); |
| 1288 | 1314 | _LIBCPP_HIDE_FROM_ABI unordered_multiset(unordered_multiset&& __u, const allocator_type& __a); |
| ... | ... | @@ -1298,15 +1324,15 @@ public: |
| 1298 | 1324 | const hasher& __hf, |
| 1299 | 1325 | const key_equal& __eql, |
| 1300 | 1326 | const allocator_type& __a); |
| 1301 | # if _LIBCPP_STD_VER >= 14 | |
| 1327 | # if _LIBCPP_STD_VER >= 14 | |
| 1302 | 1328 | inline _LIBCPP_HIDE_FROM_ABI |
| 1303 | 1329 | unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) |
| 1304 | 1330 | : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {} |
| 1305 | 1331 | inline _LIBCPP_HIDE_FROM_ABI |
| 1306 | 1332 | unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a) |
| 1307 | 1333 | : unordered_multiset(__il, __n, __hf, key_equal(), __a) {} |
| 1308 | # endif | |
| 1309 | #endif // _LIBCPP_CXX03_LANG | |
| 1334 | # endif | |
| 1335 | # endif // _LIBCPP_CXX03_LANG | |
| 1310 | 1336 | _LIBCPP_HIDE_FROM_ABI ~unordered_multiset() { |
| 1311 | 1337 | static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), ""); |
| 1312 | 1338 | } |
| ... | ... | @@ -1315,17 +1341,17 @@ public: |
| 1315 | 1341 | __table_ = __u.__table_; |
| 1316 | 1342 | return *this; |
| 1317 | 1343 | } |
| 1318 | #ifndef _LIBCPP_CXX03_LANG | |
| 1344 | # ifndef _LIBCPP_CXX03_LANG | |
| 1319 | 1345 | _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(unordered_multiset&& __u) |
| 1320 | 1346 | _NOEXCEPT_(is_nothrow_move_assignable<__table>::value); |
| 1321 | 1347 | _LIBCPP_HIDE_FROM_ABI unordered_multiset& operator=(initializer_list<value_type> __il); |
| 1322 | #endif // _LIBCPP_CXX03_LANG | |
| 1348 | # endif // _LIBCPP_CXX03_LANG | |
| 1323 | 1349 | |
| 1324 | 1350 | _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { |
| 1325 | 1351 | return allocator_type(__table_.__node_alloc()); |
| 1326 | 1352 | } |
| 1327 | 1353 | |
| 1328 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | |
| 1354 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; } | |
| 1329 | 1355 | _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); } |
| 1330 | 1356 | _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); } |
| 1331 | 1357 | |
| ... | ... | @@ -1336,7 +1362,7 @@ public: |
| 1336 | 1362 | _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); } |
| 1337 | 1363 | _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); } |
| 1338 | 1364 | |
| 1339 | #ifndef _LIBCPP_CXX03_LANG | |
| 1365 | # ifndef _LIBCPP_CXX03_LANG | |
| 1340 | 1366 | template <class... _Args> |
| 1341 | 1367 | _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { |
| 1342 | 1368 | return __table_.__emplace_multi(std::forward<_Args>(__args)...); |
| ... | ... | @@ -1351,7 +1377,7 @@ public: |
| 1351 | 1377 | return __table_.__insert_multi(__p, std::move(__x)); |
| 1352 | 1378 | } |
| 1353 | 1379 | _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); } |
| 1354 | #endif // _LIBCPP_CXX03_LANG | |
| 1380 | # endif // _LIBCPP_CXX03_LANG | |
| 1355 | 1381 | |
| 1356 | 1382 | _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); } |
| 1357 | 1383 | |
| ... | ... | @@ -1362,16 +1388,16 @@ public: |
| 1362 | 1388 | template <class _InputIterator> |
| 1363 | 1389 | _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last); |
| 1364 | 1390 | |
| 1365 | #if _LIBCPP_STD_VER >= 23 | |
| 1391 | # if _LIBCPP_STD_VER >= 23 | |
| 1366 | 1392 | template <_ContainerCompatibleRange<value_type> _Range> |
| 1367 | 1393 | _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { |
| 1368 | 1394 | for (auto&& __element : __range) { |
| 1369 | 1395 | __table_.__insert_multi(std::forward<decltype(__element)>(__element)); |
| 1370 | 1396 | } |
| 1371 | 1397 | } |
| 1372 | #endif | |
| 1398 | # endif | |
| 1373 | 1399 | |
| 1374 | #if _LIBCPP_STD_VER >= 17 | |
| 1400 | # if _LIBCPP_STD_VER >= 17 | |
| 1375 | 1401 | _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) { |
| 1376 | 1402 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), |
| 1377 | 1403 | "node_type with incompatible allocator passed to unordered_multiset::insert()"); |
| ... | ... | @@ -1413,7 +1439,7 @@ public: |
| 1413 | 1439 | __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); |
| 1414 | 1440 | return __table_.__node_handle_merge_multi(__source.__table_); |
| 1415 | 1441 | } |
| 1416 | #endif | |
| 1442 | # endif | |
| 1417 | 1443 | |
| 1418 | 1444 | _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __table_.erase(__p); } |
| 1419 | 1445 | _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __table_.__erase_multi(__k); } |
| ... | ... | @@ -1431,7 +1457,7 @@ public: |
| 1431 | 1457 | |
| 1432 | 1458 | _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); } |
| 1433 | 1459 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); } |
| 1434 | #if _LIBCPP_STD_VER >= 20 | |
| 1460 | # if _LIBCPP_STD_VER >= 20 | |
| 1435 | 1461 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1436 | 1462 | _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) { |
| 1437 | 1463 | return __table_.find(__k); |
| ... | ... | @@ -1440,24 +1466,24 @@ public: |
| 1440 | 1466 | _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const { |
| 1441 | 1467 | return __table_.find(__k); |
| 1442 | 1468 | } |
| 1443 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1469 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1444 | 1470 | |
| 1445 | 1471 | _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); } |
| 1446 | #if _LIBCPP_STD_VER >= 20 | |
| 1472 | # if _LIBCPP_STD_VER >= 20 | |
| 1447 | 1473 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1448 | 1474 | _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const { |
| 1449 | 1475 | return __table_.__count_multi(__k); |
| 1450 | 1476 | } |
| 1451 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1477 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1452 | 1478 | |
| 1453 | #if _LIBCPP_STD_VER >= 20 | |
| 1479 | # if _LIBCPP_STD_VER >= 20 | |
| 1454 | 1480 | _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); } |
| 1455 | 1481 | |
| 1456 | 1482 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1457 | 1483 | _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const { |
| 1458 | 1484 | return find(__k) != end(); |
| 1459 | 1485 | } |
| 1460 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1486 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1461 | 1487 | |
| 1462 | 1488 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) { |
| 1463 | 1489 | return __table_.__equal_range_multi(__k); |
| ... | ... | @@ -1465,7 +1491,7 @@ public: |
| 1465 | 1491 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const { |
| 1466 | 1492 | return __table_.__equal_range_multi(__k); |
| 1467 | 1493 | } |
| 1468 | #if _LIBCPP_STD_VER >= 20 | |
| 1494 | # if _LIBCPP_STD_VER >= 20 | |
| 1469 | 1495 | template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr> |
| 1470 | 1496 | _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) { |
| 1471 | 1497 | return __table_.__equal_range_multi(__k); |
| ... | ... | @@ -1474,7 +1500,7 @@ public: |
| 1474 | 1500 | _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const { |
| 1475 | 1501 | return __table_.__equal_range_multi(__k); |
| 1476 | 1502 | } |
| 1477 | #endif // _LIBCPP_STD_VER >= 20 | |
| 1503 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1478 | 1504 | |
| 1479 | 1505 | _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __table_.bucket_count(); } |
| 1480 | 1506 | _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return __table_.max_bucket_count(); } |
| ... | ... | @@ -1496,7 +1522,7 @@ public: |
| 1496 | 1522 | _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n) { __table_.__reserve_multi(__n); } |
| 1497 | 1523 | }; |
| 1498 | 1524 | |
| 1499 | #if _LIBCPP_STD_VER >= 17 | |
| 1525 | # if _LIBCPP_STD_VER >= 17 | |
| 1500 | 1526 | template <class _InputIterator, |
| 1501 | 1527 | class _Hash = hash<__iter_value_type<_InputIterator>>, |
| 1502 | 1528 | class _Pred = equal_to<__iter_value_type<_InputIterator>>, |
| ... | ... | @@ -1514,7 +1540,7 @@ unordered_multiset( |
| 1514 | 1540 | _Pred = _Pred(), |
| 1515 | 1541 | _Allocator = _Allocator()) -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; |
| 1516 | 1542 | |
| 1517 | # if _LIBCPP_STD_VER >= 23 | |
| 1543 | # if _LIBCPP_STD_VER >= 23 | |
| 1518 | 1544 | template <ranges::input_range _Range, |
| 1519 | 1545 | class _Hash = hash<ranges::range_value_t<_Range>>, |
| 1520 | 1546 | class _Pred = equal_to<ranges::range_value_t<_Range>>, |
| ... | ... | @@ -1530,7 +1556,7 @@ unordered_multiset( |
| 1530 | 1556 | _Hash = _Hash(), |
| 1531 | 1557 | _Pred = _Pred(), |
| 1532 | 1558 | _Allocator = _Allocator()) -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23 |
| 1533 | # endif | |
| 1559 | # endif | |
| 1534 | 1560 | |
| 1535 | 1561 | template <class _Tp, |
| 1536 | 1562 | class _Hash = hash<_Tp>, |
| ... | ... | @@ -1569,7 +1595,7 @@ unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Al |
| 1569 | 1595 | equal_to<__iter_value_type<_InputIterator>>, |
| 1570 | 1596 | _Allocator>; |
| 1571 | 1597 | |
| 1572 | # if _LIBCPP_STD_VER >= 23 | |
| 1598 | # if _LIBCPP_STD_VER >= 23 | |
| 1573 | 1599 | |
| 1574 | 1600 | template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 1575 | 1601 | unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| ... | ... | @@ -1594,7 +1620,7 @@ template <ranges::input_range _Range, |
| 1594 | 1620 | unordered_multiset(from_range_t, _Range&&, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1595 | 1621 | -> unordered_multiset<ranges::range_value_t<_Range>, _Hash, equal_to<ranges::range_value_t<_Range>>, _Allocator>; |
| 1596 | 1622 | |
| 1597 | # endif | |
| 1623 | # endif | |
| 1598 | 1624 | |
| 1599 | 1625 | template <class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 1600 | 1626 | unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| ... | ... | @@ -1608,7 +1634,7 @@ template <class _Tp, |
| 1608 | 1634 | class = enable_if_t<__is_allocator<_Allocator>::value>> |
| 1609 | 1635 | unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1610 | 1636 | -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; |
| 1611 | #endif | |
| 1637 | # endif | |
| 1612 | 1638 | |
| 1613 | 1639 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1614 | 1640 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| ... | ... | @@ -1672,7 +1698,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1672 | 1698 | insert(__u.begin(), __u.end()); |
| 1673 | 1699 | } |
| 1674 | 1700 | |
| 1675 | #ifndef _LIBCPP_CXX03_LANG | |
| 1701 | # ifndef _LIBCPP_CXX03_LANG | |
| 1676 | 1702 | |
| 1677 | 1703 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1678 | 1704 | inline unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(unordered_multiset&& __u) |
| ... | ... | @@ -1730,7 +1756,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(initializer_list<val |
| 1730 | 1756 | return *this; |
| 1731 | 1757 | } |
| 1732 | 1758 | |
| 1733 | #endif // _LIBCPP_CXX03_LANG | |
| 1759 | # endif // _LIBCPP_CXX03_LANG | |
| 1734 | 1760 | |
| 1735 | 1761 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1736 | 1762 | template <class _InputIterator> |
| ... | ... | @@ -1746,13 +1772,13 @@ swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, unordered_multiset<_ |
| 1746 | 1772 | __x.swap(__y); |
| 1747 | 1773 | } |
| 1748 | 1774 | |
| 1749 | #if _LIBCPP_STD_VER >= 20 | |
| 1775 | # if _LIBCPP_STD_VER >= 20 | |
| 1750 | 1776 | template <class _Value, class _Hash, class _Pred, class _Alloc, class _Predicate> |
| 1751 | 1777 | inline _LIBCPP_HIDE_FROM_ABI typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::size_type |
| 1752 | 1778 | erase_if(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __c, _Predicate __pred) { |
| 1753 | 1779 | return std::__libcpp_erase_if_container(__c, __pred); |
| 1754 | 1780 | } |
| 1755 | #endif | |
| 1781 | # endif | |
| 1756 | 1782 | |
| 1757 | 1783 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1758 | 1784 | _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, |
| ... | ... | @@ -1772,7 +1798,7 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const unordered_multiset<_Value, _Hash, _P |
| 1772 | 1798 | return true; |
| 1773 | 1799 | } |
| 1774 | 1800 | |
| 1775 | #if _LIBCPP_STD_VER <= 17 | |
| 1801 | # if _LIBCPP_STD_VER <= 17 | |
| 1776 | 1802 | |
| 1777 | 1803 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1778 | 1804 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, |
| ... | ... | @@ -1780,11 +1806,21 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const unordered_multiset<_Value, _H |
| 1780 | 1806 | return !(__x == __y); |
| 1781 | 1807 | } |
| 1782 | 1808 | |
| 1783 | #endif | |
| 1809 | # endif | |
| 1810 | ||
| 1811 | template <class _Value, class _Hash, class _Pred, class _Alloc> | |
| 1812 | struct __container_traits<unordered_multiset<_Value, _Hash, _Pred, _Alloc> > { | |
| 1813 | // http://eel.is/c++draft/unord.req.except#2 | |
| 1814 | // For unordered associative containers, if an exception is thrown by any operation | |
| 1815 | // other than the container's hash function from within an insert or emplace function | |
| 1816 | // inserting a single element, the insertion has no effect. | |
| 1817 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = | |
| 1818 | __is_nothrow_invocable_v<_Hash, const _Value&>; | |
| 1819 | }; | |
| 1784 | 1820 | |
| 1785 | 1821 | _LIBCPP_END_NAMESPACE_STD |
| 1786 | 1822 | |
| 1787 | #if _LIBCPP_STD_VER >= 17 | |
| 1823 | # if _LIBCPP_STD_VER >= 17 | |
| 1788 | 1824 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 1789 | 1825 | namespace pmr { |
| 1790 | 1826 | template <class _KeyT, class _HashT = std::hash<_KeyT>, class _PredT = std::equal_to<_KeyT>> |
| ... | ... | @@ -1795,17 +1831,19 @@ using unordered_multiset _LIBCPP_AVAILABILITY_PMR = |
| 1795 | 1831 | std::unordered_multiset<_KeyT, _HashT, _PredT, polymorphic_allocator<_KeyT>>; |
| 1796 | 1832 | } // namespace pmr |
| 1797 | 1833 | _LIBCPP_END_NAMESPACE_STD |
| 1798 | #endif | |
| 1834 | # endif | |
| 1799 | 1835 | |
| 1800 | 1836 | _LIBCPP_POP_MACROS |
| 1801 | 1837 | |
| 1802 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1803 | # include <concepts> | |
| 1804 | # include <cstdlib> | |
| 1805 | # include <functional> | |
| 1806 | # include <iterator> | |
| 1807 | # include <stdexcept> | |
| 1808 | # include <type_traits> | |
| 1809 | #endif | |
| 1838 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1839 | # include <cmath> | |
| 1840 | # include <concepts> | |
| 1841 | # include <cstdlib> | |
| 1842 | # include <functional> | |
| 1843 | # include <iterator> | |
| 1844 | # include <stdexcept> | |
| 1845 | # include <type_traits> | |
| 1846 | # endif | |
| 1847 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1810 | 1848 | |
| 1811 | 1849 | #endif // _LIBCPP_UNORDERED_SET |
lib/libcxx/include/utility+55-50| ... | ... | @@ -246,64 +246,69 @@ template <class T> |
| 246 | 246 | |
| 247 | 247 | */ |
| 248 | 248 | |
| 249 | #include <__config> | |
| 250 | ||
| 251 | #include <__utility/declval.h> | |
| 252 | #include <__utility/forward.h> | |
| 253 | #include <__utility/move.h> | |
| 254 | #include <__utility/pair.h> | |
| 255 | #include <__utility/piecewise_construct.h> | |
| 256 | #include <__utility/rel_ops.h> | |
| 257 | #include <__utility/swap.h> | |
| 258 | ||
| 259 | #if _LIBCPP_STD_VER >= 14 | |
| 260 | # include <__utility/exchange.h> | |
| 261 | # include <__utility/integer_sequence.h> | |
| 262 | #endif | |
| 263 | ||
| 264 | #if _LIBCPP_STD_VER >= 17 | |
| 265 | # include <__utility/as_const.h> | |
| 266 | # include <__utility/in_place.h> | |
| 267 | #endif | |
| 268 | ||
| 269 | #if _LIBCPP_STD_VER >= 20 | |
| 270 | # include <__utility/cmp.h> | |
| 271 | #endif | |
| 272 | ||
| 273 | #if _LIBCPP_STD_VER >= 23 | |
| 274 | # include <__utility/forward_like.h> | |
| 275 | # include <__utility/to_underlying.h> | |
| 276 | # include <__utility/unreachable.h> | |
| 277 | #endif | |
| 278 | ||
| 279 | #include <version> | |
| 249 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 250 | # include <__cxx03/utility> | |
| 251 | #else | |
| 252 | # include <__config> | |
| 253 | ||
| 254 | # include <__utility/declval.h> | |
| 255 | # include <__utility/forward.h> | |
| 256 | # include <__utility/move.h> | |
| 257 | # include <__utility/pair.h> | |
| 258 | # include <__utility/piecewise_construct.h> | |
| 259 | # include <__utility/rel_ops.h> | |
| 260 | # include <__utility/swap.h> | |
| 261 | ||
| 262 | # if _LIBCPP_STD_VER >= 14 | |
| 263 | # include <__utility/exchange.h> | |
| 264 | # include <__utility/integer_sequence.h> | |
| 265 | # endif | |
| 266 | ||
| 267 | # if _LIBCPP_STD_VER >= 17 | |
| 268 | # include <__utility/as_const.h> | |
| 269 | # include <__utility/in_place.h> | |
| 270 | # endif | |
| 271 | ||
| 272 | # if _LIBCPP_STD_VER >= 20 | |
| 273 | # include <__utility/cmp.h> | |
| 274 | # endif | |
| 275 | ||
| 276 | # if _LIBCPP_STD_VER >= 23 | |
| 277 | # include <__utility/forward_like.h> | |
| 278 | # include <__utility/to_underlying.h> | |
| 279 | # include <__utility/unreachable.h> | |
| 280 | # endif | |
| 281 | ||
| 282 | # include <version> | |
| 280 | 283 | |
| 281 | 284 | // standard-mandated includes |
| 282 | 285 | |
| 283 | 286 | // [utility.syn] |
| 284 | #include <compare> | |
| 285 | #include <initializer_list> | |
| 287 | # include <compare> | |
| 288 | # include <initializer_list> | |
| 286 | 289 | |
| 287 | 290 | // [tuple.creation] |
| 288 | 291 | |
| 289 | #include <__tuple/ignore.h> | |
| 292 | # include <__tuple/ignore.h> | |
| 290 | 293 | |
| 291 | 294 | // [tuple.helper] |
| 292 | #include <__tuple/tuple_element.h> | |
| 293 | #include <__tuple/tuple_size.h> | |
| 294 | ||
| 295 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 296 | # pragma GCC system_header | |
| 297 | #endif | |
| 298 | ||
| 299 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 300 | # include <limits> | |
| 301 | #endif | |
| 302 | ||
| 303 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 304 | # include <cstdlib> | |
| 305 | # include <iosfwd> | |
| 306 | # include <type_traits> | |
| 307 | #endif | |
| 295 | # include <__tuple/tuple_element.h> | |
| 296 | # include <__tuple/tuple_size.h> | |
| 297 | ||
| 298 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 299 | # pragma GCC system_header | |
| 300 | # endif | |
| 301 | ||
| 302 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 303 | # include <limits> | |
| 304 | # endif | |
| 305 | ||
| 306 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 307 | # include <cstddef> | |
| 308 | # include <cstdlib> | |
| 309 | # include <iosfwd> | |
| 310 | # include <type_traits> | |
| 311 | # endif | |
| 312 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 308 | 313 | |
| 309 | 314 | #endif // _LIBCPP_UTILITY |
lib/libcxx/include/valarray+114-105| ... | ... | @@ -343,39 +343,41 @@ template <class T> unspecified2 end(const valarray<T>& v); |
| 343 | 343 | |
| 344 | 344 | */ |
| 345 | 345 | |
| 346 | #include <__algorithm/copy.h> | |
| 347 | #include <__algorithm/count.h> | |
| 348 | #include <__algorithm/fill.h> | |
| 349 | #include <__algorithm/max_element.h> | |
| 350 | #include <__algorithm/min.h> | |
| 351 | #include <__algorithm/min_element.h> | |
| 352 | #include <__algorithm/unwrap_iter.h> | |
| 353 | #include <__assert> | |
| 354 | #include <__config> | |
| 355 | #include <__functional/operations.h> | |
| 356 | #include <__memory/addressof.h> | |
| 357 | #include <__memory/allocator.h> | |
| 358 | #include <__memory/uninitialized_algorithms.h> | |
| 359 | #include <__type_traits/decay.h> | |
| 360 | #include <__type_traits/remove_reference.h> | |
| 361 | #include <__utility/move.h> | |
| 362 | #include <__utility/swap.h> | |
| 363 | #include <cmath> | |
| 364 | #include <cstddef> | |
| 365 | #include <new> | |
| 366 | #include <version> | |
| 346 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 347 | # include <__cxx03/valarray> | |
| 348 | #else | |
| 349 | # include <__algorithm/copy.h> | |
| 350 | # include <__algorithm/count.h> | |
| 351 | # include <__algorithm/fill.h> | |
| 352 | # include <__algorithm/max_element.h> | |
| 353 | # include <__algorithm/min.h> | |
| 354 | # include <__algorithm/min_element.h> | |
| 355 | # include <__algorithm/unwrap_iter.h> | |
| 356 | # include <__assert> | |
| 357 | # include <__config> | |
| 358 | # include <__cstddef/ptrdiff_t.h> | |
| 359 | # include <__functional/operations.h> | |
| 360 | # include <__memory/addressof.h> | |
| 361 | # include <__memory/allocator.h> | |
| 362 | # include <__memory/uninitialized_algorithms.h> | |
| 363 | # include <__type_traits/decay.h> | |
| 364 | # include <__type_traits/remove_reference.h> | |
| 365 | # include <__utility/move.h> | |
| 366 | # include <__utility/swap.h> | |
| 367 | # include <cmath> | |
| 368 | # include <version> | |
| 367 | 369 | |
| 368 | 370 | // standard-mandated includes |
| 369 | 371 | |
| 370 | 372 | // [valarray.syn] |
| 371 | #include <initializer_list> | |
| 373 | # include <initializer_list> | |
| 372 | 374 | |
| 373 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 374 | # pragma GCC system_header | |
| 375 | #endif | |
| 375 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 376 | # pragma GCC system_header | |
| 377 | # endif | |
| 376 | 378 | |
| 377 | 379 | _LIBCPP_PUSH_MACROS |
| 378 | #include <__undef_macros> | |
| 380 | # include <__undef_macros> | |
| 379 | 381 | |
| 380 | 382 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 381 | 383 | |
| ... | ... | @@ -397,13 +399,13 @@ public: |
| 397 | 399 | _LIBCPP_HIDE_FROM_ABI size_t size() const { return __size_; } |
| 398 | 400 | _LIBCPP_HIDE_FROM_ABI size_t stride() const { return __stride_; } |
| 399 | 401 | |
| 400 | #if _LIBCPP_STD_VER >= 20 | |
| 402 | # if _LIBCPP_STD_VER >= 20 | |
| 401 | 403 | |
| 402 | 404 | _LIBCPP_HIDE_FROM_ABI friend bool operator==(const slice& __x, const slice& __y) { |
| 403 | 405 | return __x.start() == __y.start() && __x.size() == __y.size() && __x.stride() == __y.stride(); |
| 404 | 406 | } |
| 405 | 407 | |
| 406 | #endif | |
| 408 | # endif | |
| 407 | 409 | }; |
| 408 | 410 | |
| 409 | 411 | template <class _Tp> |
| ... | ... | @@ -794,10 +796,10 @@ public: |
| 794 | 796 | _LIBCPP_HIDE_FROM_ABI valarray(const value_type& __x, size_t __n); |
| 795 | 797 | valarray(const value_type* __p, size_t __n); |
| 796 | 798 | valarray(const valarray& __v); |
| 797 | #ifndef _LIBCPP_CXX03_LANG | |
| 799 | # ifndef _LIBCPP_CXX03_LANG | |
| 798 | 800 | _LIBCPP_HIDE_FROM_ABI valarray(valarray&& __v) _NOEXCEPT; |
| 799 | 801 | valarray(initializer_list<value_type> __il); |
| 800 | #endif // _LIBCPP_CXX03_LANG | |
| 802 | # endif // _LIBCPP_CXX03_LANG | |
| 801 | 803 | valarray(const slice_array<value_type>& __sa); |
| 802 | 804 | valarray(const gslice_array<value_type>& __ga); |
| 803 | 805 | valarray(const mask_array<value_type>& __ma); |
| ... | ... | @@ -806,10 +808,10 @@ public: |
| 806 | 808 | |
| 807 | 809 | // assignment: |
| 808 | 810 | valarray& operator=(const valarray& __v); |
| 809 | #ifndef _LIBCPP_CXX03_LANG | |
| 811 | # ifndef _LIBCPP_CXX03_LANG | |
| 810 | 812 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(valarray&& __v) _NOEXCEPT; |
| 811 | 813 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(initializer_list<value_type>); |
| 812 | #endif // _LIBCPP_CXX03_LANG | |
| 814 | # endif // _LIBCPP_CXX03_LANG | |
| 813 | 815 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const value_type& __x); |
| 814 | 816 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const slice_array<value_type>& __sa); |
| 815 | 817 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const gslice_array<value_type>& __ga); |
| ... | ... | @@ -819,31 +821,37 @@ public: |
| 819 | 821 | _LIBCPP_HIDE_FROM_ABI valarray& operator=(const __val_expr<_ValExpr>& __v); |
| 820 | 822 | |
| 821 | 823 | // element access: |
| 822 | _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const { return __begin_[__i]; } | |
| 824 | _LIBCPP_HIDE_FROM_ABI const value_type& operator[](size_t __i) const { | |
| 825 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds"); | |
| 826 | return __begin_[__i]; | |
| 827 | } | |
| 823 | 828 | |
| 824 | _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) { return __begin_[__i]; } | |
| 829 | _LIBCPP_HIDE_FROM_ABI value_type& operator[](size_t __i) { | |
| 830 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "valarray::operator[] index out of bounds"); | |
| 831 | return __begin_[__i]; | |
| 832 | } | |
| 825 | 833 | |
| 826 | 834 | // subset operations: |
| 827 | 835 | _LIBCPP_HIDE_FROM_ABI __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const; |
| 828 | 836 | _LIBCPP_HIDE_FROM_ABI slice_array<value_type> operator[](slice __s); |
| 829 | 837 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const; |
| 830 | 838 | _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](const gslice& __gs); |
| 831 | #ifndef _LIBCPP_CXX03_LANG | |
| 839 | # ifndef _LIBCPP_CXX03_LANG | |
| 832 | 840 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const; |
| 833 | 841 | _LIBCPP_HIDE_FROM_ABI gslice_array<value_type> operator[](gslice&& __gs); |
| 834 | #endif // _LIBCPP_CXX03_LANG | |
| 842 | # endif // _LIBCPP_CXX03_LANG | |
| 835 | 843 | _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const; |
| 836 | 844 | _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](const valarray<bool>& __vb); |
| 837 | #ifndef _LIBCPP_CXX03_LANG | |
| 845 | # ifndef _LIBCPP_CXX03_LANG | |
| 838 | 846 | _LIBCPP_HIDE_FROM_ABI __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const; |
| 839 | 847 | _LIBCPP_HIDE_FROM_ABI mask_array<value_type> operator[](valarray<bool>&& __vb); |
| 840 | #endif // _LIBCPP_CXX03_LANG | |
| 848 | # endif // _LIBCPP_CXX03_LANG | |
| 841 | 849 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const; |
| 842 | 850 | _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](const valarray<size_t>& __vs); |
| 843 | #ifndef _LIBCPP_CXX03_LANG | |
| 851 | # ifndef _LIBCPP_CXX03_LANG | |
| 844 | 852 | _LIBCPP_HIDE_FROM_ABI __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const; |
| 845 | 853 | _LIBCPP_HIDE_FROM_ABI indirect_array<value_type> operator[](valarray<size_t>&& __vs); |
| 846 | #endif // _LIBCPP_CXX03_LANG | |
| 854 | # endif // _LIBCPP_CXX03_LANG | |
| 847 | 855 | |
| 848 | 856 | // unary operators: |
| 849 | 857 | _LIBCPP_HIDE_FROM_ABI __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const; |
| ... | ... | @@ -942,10 +950,10 @@ private: |
| 942 | 950 | valarray& __assign_range(const value_type* __f, const value_type* __l); |
| 943 | 951 | }; |
| 944 | 952 | |
| 945 | #if _LIBCPP_STD_VER >= 17 | |
| 953 | # if _LIBCPP_STD_VER >= 17 | |
| 946 | 954 | template <class _Tp, size_t _Size> |
| 947 | 955 | valarray(const _Tp (&)[_Size], size_t) -> valarray<_Tp>; |
| 948 | #endif | |
| 956 | # endif | |
| 949 | 957 | |
| 950 | 958 | template <class _Expr, |
| 951 | 959 | __enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0> |
| ... | ... | @@ -1221,7 +1229,7 @@ public: |
| 1221 | 1229 | __init(__start); |
| 1222 | 1230 | } |
| 1223 | 1231 | |
| 1224 | #ifndef _LIBCPP_CXX03_LANG | |
| 1232 | # ifndef _LIBCPP_CXX03_LANG | |
| 1225 | 1233 | |
| 1226 | 1234 | _LIBCPP_HIDE_FROM_ABI gslice(size_t __start, const valarray<size_t>& __size, valarray<size_t>&& __stride) |
| 1227 | 1235 | : __size_(__size), __stride_(std::move(__stride)) { |
| ... | ... | @@ -1238,7 +1246,7 @@ public: |
| 1238 | 1246 | __init(__start); |
| 1239 | 1247 | } |
| 1240 | 1248 | |
| 1241 | #endif // _LIBCPP_CXX03_LANG | |
| 1249 | # endif // _LIBCPP_CXX03_LANG | |
| 1242 | 1250 | |
| 1243 | 1251 | _LIBCPP_HIDE_FROM_ABI size_t start() const { return __1d_.size() ? __1d_[0] : 0; } |
| 1244 | 1252 | |
| ... | ... | @@ -1318,10 +1326,10 @@ private: |
| 1318 | 1326 | gslice_array(const gslice& __gs, const valarray<value_type>& __v) |
| 1319 | 1327 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {} |
| 1320 | 1328 | |
| 1321 | #ifndef _LIBCPP_CXX03_LANG | |
| 1329 | # ifndef _LIBCPP_CXX03_LANG | |
| 1322 | 1330 | gslice_array(gslice&& __gs, const valarray<value_type>& __v) |
| 1323 | 1331 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__gs.__1d_)) {} |
| 1324 | #endif // _LIBCPP_CXX03_LANG | |
| 1332 | # endif // _LIBCPP_CXX03_LANG | |
| 1325 | 1333 | |
| 1326 | 1334 | template <class> |
| 1327 | 1335 | friend class valarray; |
| ... | ... | @@ -1708,12 +1716,12 @@ private: |
| 1708 | 1716 | _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v) |
| 1709 | 1717 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {} |
| 1710 | 1718 | |
| 1711 | #ifndef _LIBCPP_CXX03_LANG | |
| 1719 | # ifndef _LIBCPP_CXX03_LANG | |
| 1712 | 1720 | |
| 1713 | 1721 | _LIBCPP_HIDE_FROM_ABI indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v) |
| 1714 | 1722 | : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(std::move(__ia)) {} |
| 1715 | 1723 | |
| 1716 | #endif // _LIBCPP_CXX03_LANG | |
| 1724 | # endif // _LIBCPP_CXX03_LANG | |
| 1717 | 1725 | |
| 1718 | 1726 | template <class> |
| 1719 | 1727 | friend class valarray; |
| ... | ... | @@ -1837,12 +1845,12 @@ private: |
| 1837 | 1845 | |
| 1838 | 1846 | _LIBCPP_HIDE_FROM_ABI __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) : __expr_(__e), __1d_(__ia) {} |
| 1839 | 1847 | |
| 1840 | #ifndef _LIBCPP_CXX03_LANG | |
| 1848 | # ifndef _LIBCPP_CXX03_LANG | |
| 1841 | 1849 | |
| 1842 | 1850 | _LIBCPP_HIDE_FROM_ABI __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e) |
| 1843 | 1851 | : __expr_(__e), __1d_(std::move(__ia)) {} |
| 1844 | 1852 | |
| 1845 | #endif // _LIBCPP_CXX03_LANG | |
| 1853 | # endif // _LIBCPP_CXX03_LANG | |
| 1846 | 1854 | |
| 1847 | 1855 | public: |
| 1848 | 1856 | _LIBCPP_HIDE_FROM_ABI __result_type operator[](size_t __i) const { return __expr_[__1d_[__i]]; } |
| ... | ... | @@ -1984,17 +1992,17 @@ template <class _Tp> |
| 1984 | 1992 | inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) { |
| 1985 | 1993 | if (__n) { |
| 1986 | 1994 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 1987 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1995 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1988 | 1996 | try { |
| 1989 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1997 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1990 | 1998 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
| 1991 | 1999 | ::new ((void*)__end_) value_type(); |
| 1992 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2000 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1993 | 2001 | } catch (...) { |
| 1994 | 2002 | __clear(__n); |
| 1995 | 2003 | throw; |
| 1996 | 2004 | } |
| 1997 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2005 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 1998 | 2006 | } |
| 1999 | 2007 | } |
| 2000 | 2008 | |
| ... | ... | @@ -2007,17 +2015,17 @@ template <class _Tp> |
| 2007 | 2015 | valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) { |
| 2008 | 2016 | if (__n) { |
| 2009 | 2017 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2010 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2018 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2011 | 2019 | try { |
| 2012 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2020 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2013 | 2021 | for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) |
| 2014 | 2022 | ::new ((void*)__end_) value_type(*__p); |
| 2015 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2023 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2016 | 2024 | } catch (...) { |
| 2017 | 2025 | __clear(__n); |
| 2018 | 2026 | throw; |
| 2019 | 2027 | } |
| 2020 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2028 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2021 | 2029 | } |
| 2022 | 2030 | } |
| 2023 | 2031 | |
| ... | ... | @@ -2025,21 +2033,21 @@ template <class _Tp> |
| 2025 | 2033 | valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) { |
| 2026 | 2034 | if (__v.size()) { |
| 2027 | 2035 | __begin_ = __end_ = allocator<value_type>().allocate(__v.size()); |
| 2028 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2036 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2029 | 2037 | try { |
| 2030 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2038 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2031 | 2039 | for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) |
| 2032 | 2040 | ::new ((void*)__end_) value_type(*__p); |
| 2033 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2041 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2034 | 2042 | } catch (...) { |
| 2035 | 2043 | __clear(__v.size()); |
| 2036 | 2044 | throw; |
| 2037 | 2045 | } |
| 2038 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2046 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2039 | 2047 | } |
| 2040 | 2048 | } |
| 2041 | 2049 | |
| 2042 | #ifndef _LIBCPP_CXX03_LANG | |
| 2050 | # ifndef _LIBCPP_CXX03_LANG | |
| 2043 | 2051 | |
| 2044 | 2052 | template <class _Tp> |
| 2045 | 2053 | inline valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT : __begin_(__v.__begin_), __end_(__v.__end_) { |
| ... | ... | @@ -2051,40 +2059,40 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il) : __begin_(nullptr), |
| 2051 | 2059 | const size_t __n = __il.size(); |
| 2052 | 2060 | if (__n) { |
| 2053 | 2061 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2054 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2062 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2055 | 2063 | try { |
| 2056 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2064 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2057 | 2065 | size_t __n_left = __n; |
| 2058 | 2066 | for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) |
| 2059 | 2067 | ::new ((void*)__end_) value_type(*__p); |
| 2060 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2068 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2061 | 2069 | } catch (...) { |
| 2062 | 2070 | __clear(__n); |
| 2063 | 2071 | throw; |
| 2064 | 2072 | } |
| 2065 | # endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2073 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2066 | 2074 | } |
| 2067 | 2075 | } |
| 2068 | 2076 | |
| 2069 | #endif // _LIBCPP_CXX03_LANG | |
| 2077 | # endif // _LIBCPP_CXX03_LANG | |
| 2070 | 2078 | |
| 2071 | 2079 | template <class _Tp> |
| 2072 | 2080 | valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(nullptr), __end_(nullptr) { |
| 2073 | 2081 | const size_t __n = __sa.__size_; |
| 2074 | 2082 | if (__n) { |
| 2075 | 2083 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2076 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2084 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2077 | 2085 | try { |
| 2078 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2086 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2079 | 2087 | size_t __n_left = __n; |
| 2080 | 2088 | for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) |
| 2081 | 2089 | ::new ((void*)__end_) value_type(*__p); |
| 2082 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2090 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2083 | 2091 | } catch (...) { |
| 2084 | 2092 | __clear(__n); |
| 2085 | 2093 | throw; |
| 2086 | 2094 | } |
| 2087 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2095 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2088 | 2096 | } |
| 2089 | 2097 | } |
| 2090 | 2098 | |
| ... | ... | @@ -2093,19 +2101,19 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(nullptr |
| 2093 | 2101 | const size_t __n = __ga.__1d_.size(); |
| 2094 | 2102 | if (__n) { |
| 2095 | 2103 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2096 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2104 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2097 | 2105 | try { |
| 2098 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2106 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2099 | 2107 | typedef const size_t* _Ip; |
| 2100 | 2108 | const value_type* __s = __ga.__vp_; |
| 2101 | 2109 | for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_) |
| 2102 | 2110 | ::new ((void*)__end_) value_type(__s[*__i]); |
| 2103 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2111 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2104 | 2112 | } catch (...) { |
| 2105 | 2113 | __clear(__n); |
| 2106 | 2114 | throw; |
| 2107 | 2115 | } |
| 2108 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2116 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2109 | 2117 | } |
| 2110 | 2118 | } |
| 2111 | 2119 | |
| ... | ... | @@ -2114,19 +2122,19 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(nullptr), |
| 2114 | 2122 | const size_t __n = __ma.__1d_.size(); |
| 2115 | 2123 | if (__n) { |
| 2116 | 2124 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2117 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2125 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2118 | 2126 | try { |
| 2119 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2127 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2120 | 2128 | typedef const size_t* _Ip; |
| 2121 | 2129 | const value_type* __s = __ma.__vp_; |
| 2122 | 2130 | for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_) |
| 2123 | 2131 | ::new ((void*)__end_) value_type(__s[*__i]); |
| 2124 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2132 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2125 | 2133 | } catch (...) { |
| 2126 | 2134 | __clear(__n); |
| 2127 | 2135 | throw; |
| 2128 | 2136 | } |
| 2129 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2137 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2130 | 2138 | } |
| 2131 | 2139 | } |
| 2132 | 2140 | |
| ... | ... | @@ -2135,19 +2143,19 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(nullp |
| 2135 | 2143 | const size_t __n = __ia.__1d_.size(); |
| 2136 | 2144 | if (__n) { |
| 2137 | 2145 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2138 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2146 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2139 | 2147 | try { |
| 2140 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2148 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2141 | 2149 | typedef const size_t* _Ip; |
| 2142 | 2150 | const value_type* __s = __ia.__vp_; |
| 2143 | 2151 | for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_) |
| 2144 | 2152 | ::new ((void*)__end_) value_type(__s[*__i]); |
| 2145 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2153 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2146 | 2154 | } catch (...) { |
| 2147 | 2155 | __clear(__n); |
| 2148 | 2156 | throw; |
| 2149 | 2157 | } |
| 2150 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2158 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2151 | 2159 | } |
| 2152 | 2160 | } |
| 2153 | 2161 | |
| ... | ... | @@ -2177,7 +2185,7 @@ valarray<_Tp>& valarray<_Tp>::operator=(const valarray& __v) { |
| 2177 | 2185 | return *this; |
| 2178 | 2186 | } |
| 2179 | 2187 | |
| 2180 | #ifndef _LIBCPP_CXX03_LANG | |
| 2188 | # ifndef _LIBCPP_CXX03_LANG | |
| 2181 | 2189 | |
| 2182 | 2190 | template <class _Tp> |
| 2183 | 2191 | inline valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT { |
| ... | ... | @@ -2194,7 +2202,7 @@ inline valarray<_Tp>& valarray<_Tp>::operator=(initializer_list<value_type> __il |
| 2194 | 2202 | return __assign_range(__il.begin(), __il.end()); |
| 2195 | 2203 | } |
| 2196 | 2204 | |
| 2197 | #endif // _LIBCPP_CXX03_LANG | |
| 2205 | # endif // _LIBCPP_CXX03_LANG | |
| 2198 | 2206 | |
| 2199 | 2207 | template <class _Tp> |
| 2200 | 2208 | inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) { |
| ... | ... | @@ -2273,7 +2281,7 @@ inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) { |
| 2273 | 2281 | return gslice_array<value_type>(__gs, *this); |
| 2274 | 2282 | } |
| 2275 | 2283 | |
| 2276 | #ifndef _LIBCPP_CXX03_LANG | |
| 2284 | # ifndef _LIBCPP_CXX03_LANG | |
| 2277 | 2285 | |
| 2278 | 2286 | template <class _Tp> |
| 2279 | 2287 | inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](gslice&& __gs) const { |
| ... | ... | @@ -2285,7 +2293,7 @@ inline gslice_array<_Tp> valarray<_Tp>::operator[](gslice&& __gs) { |
| 2285 | 2293 | return gslice_array<value_type>(std::move(__gs), *this); |
| 2286 | 2294 | } |
| 2287 | 2295 | |
| 2288 | #endif // _LIBCPP_CXX03_LANG | |
| 2296 | # endif // _LIBCPP_CXX03_LANG | |
| 2289 | 2297 | |
| 2290 | 2298 | template <class _Tp> |
| 2291 | 2299 | inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](const valarray<bool>& __vb) const { |
| ... | ... | @@ -2297,7 +2305,7 @@ inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray<bool>& __vb) { |
| 2297 | 2305 | return mask_array<value_type>(__vb, *this); |
| 2298 | 2306 | } |
| 2299 | 2307 | |
| 2300 | #ifndef _LIBCPP_CXX03_LANG | |
| 2308 | # ifndef _LIBCPP_CXX03_LANG | |
| 2301 | 2309 | |
| 2302 | 2310 | template <class _Tp> |
| 2303 | 2311 | inline __val_expr<__mask_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<bool>&& __vb) const { |
| ... | ... | @@ -2309,7 +2317,7 @@ inline mask_array<_Tp> valarray<_Tp>::operator[](valarray<bool>&& __vb) { |
| 2309 | 2317 | return mask_array<value_type>(std::move(__vb), *this); |
| 2310 | 2318 | } |
| 2311 | 2319 | |
| 2312 | #endif // _LIBCPP_CXX03_LANG | |
| 2320 | # endif // _LIBCPP_CXX03_LANG | |
| 2313 | 2321 | |
| 2314 | 2322 | template <class _Tp> |
| 2315 | 2323 | inline __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| ... | ... | @@ -2322,7 +2330,7 @@ inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray<size_t>& __v |
| 2322 | 2330 | return indirect_array<value_type>(__vs, *this); |
| 2323 | 2331 | } |
| 2324 | 2332 | |
| 2325 | #ifndef _LIBCPP_CXX03_LANG | |
| 2333 | # ifndef _LIBCPP_CXX03_LANG | |
| 2326 | 2334 | |
| 2327 | 2335 | template <class _Tp> |
| 2328 | 2336 | inline __val_expr<__indirect_expr<const valarray<_Tp>&> > valarray<_Tp>::operator[](valarray<size_t>&& __vs) const { |
| ... | ... | @@ -2334,7 +2342,7 @@ inline indirect_array<_Tp> valarray<_Tp>::operator[](valarray<size_t>&& __vs) { |
| 2334 | 2342 | return indirect_array<value_type>(std::move(__vs), *this); |
| 2335 | 2343 | } |
| 2336 | 2344 | |
| 2337 | #endif // _LIBCPP_CXX03_LANG | |
| 2345 | # endif // _LIBCPP_CXX03_LANG | |
| 2338 | 2346 | |
| 2339 | 2347 | template <class _Tp> |
| 2340 | 2348 | inline __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > valarray<_Tp>::operator+() const { |
| ... | ... | @@ -2636,17 +2644,17 @@ void valarray<_Tp>::resize(size_t __n, value_type __x) { |
| 2636 | 2644 | __clear(size()); |
| 2637 | 2645 | if (__n) { |
| 2638 | 2646 | __begin_ = __end_ = allocator<value_type>().allocate(__n); |
| 2639 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2647 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2640 | 2648 | try { |
| 2641 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2649 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2642 | 2650 | for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) |
| 2643 | 2651 | ::new ((void*)__end_) value_type(__x); |
| 2644 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2652 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 2645 | 2653 | } catch (...) { |
| 2646 | 2654 | __clear(__n); |
| 2647 | 2655 | throw; |
| 2648 | 2656 | } |
| 2649 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2657 | # endif // _LIBCPP_HAS_EXCEPTIONS | |
| 2650 | 2658 | } |
| 2651 | 2659 | } |
| 2652 | 2660 | |
| ... | ... | @@ -3351,14 +3359,15 @@ _LIBCPP_END_NAMESPACE_STD |
| 3351 | 3359 | |
| 3352 | 3360 | _LIBCPP_POP_MACROS |
| 3353 | 3361 | |
| 3354 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 3355 | # include <algorithm> | |
| 3356 | # include <concepts> | |
| 3357 | # include <cstdlib> | |
| 3358 | # include <cstring> | |
| 3359 | # include <functional> | |
| 3360 | # include <stdexcept> | |
| 3361 | # include <type_traits> | |
| 3362 | #endif | |
| 3362 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 3363 | # include <algorithm> | |
| 3364 | # include <concepts> | |
| 3365 | # include <cstdlib> | |
| 3366 | # include <cstring> | |
| 3367 | # include <functional> | |
| 3368 | # include <stdexcept> | |
| 3369 | # include <type_traits> | |
| 3370 | # endif | |
| 3371 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 3363 | 3372 | |
| 3364 | 3373 | #endif // _LIBCPP_VALARRAY |
lib/libcxx/include/variant+215-223| ... | ... | @@ -212,66 +212,76 @@ namespace std { |
| 212 | 212 | |
| 213 | 213 | */ |
| 214 | 214 | |
| 215 | #include <__compare/common_comparison_category.h> | |
| 216 | #include <__compare/compare_three_way_result.h> | |
| 217 | #include <__compare/three_way_comparable.h> | |
| 218 | #include <__config> | |
| 219 | #include <__exception/exception.h> | |
| 220 | #include <__functional/hash.h> | |
| 221 | #include <__functional/invoke.h> | |
| 222 | #include <__functional/operations.h> | |
| 223 | #include <__functional/unary_function.h> | |
| 224 | #include <__memory/addressof.h> | |
| 225 | #include <__memory/construct_at.h> | |
| 226 | #include <__tuple/find_index.h> | |
| 227 | #include <__tuple/sfinae_helpers.h> | |
| 228 | #include <__type_traits/add_const.h> | |
| 229 | #include <__type_traits/add_cv.h> | |
| 230 | #include <__type_traits/add_pointer.h> | |
| 231 | #include <__type_traits/add_volatile.h> | |
| 232 | #include <__type_traits/common_type.h> | |
| 233 | #include <__type_traits/conjunction.h> | |
| 234 | #include <__type_traits/dependent_type.h> | |
| 235 | #include <__type_traits/is_array.h> | |
| 236 | #include <__type_traits/is_constructible.h> | |
| 237 | #include <__type_traits/is_destructible.h> | |
| 238 | #include <__type_traits/is_nothrow_assignable.h> | |
| 239 | #include <__type_traits/is_nothrow_constructible.h> | |
| 240 | #include <__type_traits/is_reference.h> | |
| 241 | #include <__type_traits/is_trivially_assignable.h> | |
| 242 | #include <__type_traits/is_trivially_constructible.h> | |
| 243 | #include <__type_traits/is_trivially_destructible.h> | |
| 244 | #include <__type_traits/is_trivially_relocatable.h> | |
| 245 | #include <__type_traits/is_void.h> | |
| 246 | #include <__type_traits/remove_const.h> | |
| 247 | #include <__type_traits/remove_cvref.h> | |
| 248 | #include <__type_traits/type_identity.h> | |
| 249 | #include <__type_traits/void_t.h> | |
| 250 | #include <__utility/declval.h> | |
| 251 | #include <__utility/forward.h> | |
| 252 | #include <__utility/forward_like.h> | |
| 253 | #include <__utility/in_place.h> | |
| 254 | #include <__utility/integer_sequence.h> | |
| 255 | #include <__utility/move.h> | |
| 256 | #include <__utility/swap.h> | |
| 257 | #include <__variant/monostate.h> | |
| 258 | #include <__verbose_abort> | |
| 259 | #include <initializer_list> | |
| 260 | #include <limits> | |
| 261 | #include <new> | |
| 262 | #include <version> | |
| 215 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 216 | # include <__cxx03/variant> | |
| 217 | #else | |
| 218 | # include <__compare/common_comparison_category.h> | |
| 219 | # include <__compare/compare_three_way_result.h> | |
| 220 | # include <__compare/ordering.h> | |
| 221 | # include <__compare/three_way_comparable.h> | |
| 222 | # include <__config> | |
| 223 | # include <__exception/exception.h> | |
| 224 | # include <__functional/hash.h> | |
| 225 | # include <__functional/operations.h> | |
| 226 | # include <__functional/unary_function.h> | |
| 227 | # include <__fwd/variant.h> | |
| 228 | # include <__memory/addressof.h> | |
| 229 | # include <__memory/construct_at.h> | |
| 230 | # include <__tuple/find_index.h> | |
| 231 | # include <__tuple/sfinae_helpers.h> | |
| 232 | # include <__type_traits/add_cv_quals.h> | |
| 233 | # include <__type_traits/add_pointer.h> | |
| 234 | # include <__type_traits/common_type.h> | |
| 235 | # include <__type_traits/conditional.h> | |
| 236 | # include <__type_traits/conjunction.h> | |
| 237 | # include <__type_traits/decay.h> | |
| 238 | # include <__type_traits/dependent_type.h> | |
| 239 | # include <__type_traits/enable_if.h> | |
| 240 | # include <__type_traits/invoke.h> | |
| 241 | # include <__type_traits/is_array.h> | |
| 242 | # include <__type_traits/is_assignable.h> | |
| 243 | # include <__type_traits/is_constructible.h> | |
| 244 | # include <__type_traits/is_convertible.h> | |
| 245 | # include <__type_traits/is_destructible.h> | |
| 246 | # include <__type_traits/is_nothrow_assignable.h> | |
| 247 | # include <__type_traits/is_nothrow_constructible.h> | |
| 248 | # include <__type_traits/is_reference.h> | |
| 249 | # include <__type_traits/is_same.h> | |
| 250 | # include <__type_traits/is_swappable.h> | |
| 251 | # include <__type_traits/is_trivially_assignable.h> | |
| 252 | # include <__type_traits/is_trivially_constructible.h> | |
| 253 | # include <__type_traits/is_trivially_destructible.h> | |
| 254 | # include <__type_traits/is_trivially_relocatable.h> | |
| 255 | # include <__type_traits/is_void.h> | |
| 256 | # include <__type_traits/remove_const.h> | |
| 257 | # include <__type_traits/remove_cvref.h> | |
| 258 | # include <__type_traits/remove_reference.h> | |
| 259 | # include <__type_traits/type_identity.h> | |
| 260 | # include <__type_traits/void_t.h> | |
| 261 | # include <__utility/declval.h> | |
| 262 | # include <__utility/forward.h> | |
| 263 | # include <__utility/forward_like.h> | |
| 264 | # include <__utility/in_place.h> | |
| 265 | # include <__utility/integer_sequence.h> | |
| 266 | # include <__utility/move.h> | |
| 267 | # include <__utility/swap.h> | |
| 268 | # include <__variant/monostate.h> | |
| 269 | # include <__verbose_abort> | |
| 270 | # include <initializer_list> | |
| 271 | # include <limits> | |
| 272 | # include <version> | |
| 263 | 273 | |
| 264 | 274 | // standard-mandated includes |
| 265 | 275 | |
| 266 | 276 | // [variant.syn] |
| 267 | #include <compare> | |
| 277 | # include <compare> | |
| 268 | 278 | |
| 269 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 270 | # pragma GCC system_header | |
| 271 | #endif | |
| 279 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 280 | # pragma GCC system_header | |
| 281 | # endif | |
| 272 | 282 | |
| 273 | 283 | _LIBCPP_PUSH_MACROS |
| 274 | #include <__undef_macros> | |
| 284 | # include <__undef_macros> | |
| 275 | 285 | |
| 276 | 286 | namespace std { // explicitly not using versioning namespace |
| 277 | 287 | |
| ... | ... | @@ -284,7 +294,7 @@ public: |
| 284 | 294 | |
| 285 | 295 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 286 | 296 | |
| 287 | #if _LIBCPP_STD_VER >= 17 | |
| 297 | # if _LIBCPP_STD_VER >= 17 | |
| 288 | 298 | |
| 289 | 299 | // Light N-dimensional array of function pointers. Used in place of std::array to avoid |
| 290 | 300 | // adding a dependency. |
| ... | ... | @@ -296,24 +306,16 @@ struct __farray { |
| 296 | 306 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; } |
| 297 | 307 | }; |
| 298 | 308 | |
| 299 | _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void | |
| 309 | [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void | |
| 300 | 310 | __throw_bad_variant_access() { |
| 301 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 311 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 302 | 312 | throw bad_variant_access(); |
| 303 | # else | |
| 313 | # else | |
| 304 | 314 | _LIBCPP_VERBOSE_ABORT("bad_variant_access was thrown in -fno-exceptions mode"); |
| 305 | # endif | |
| 315 | # endif | |
| 306 | 316 | } |
| 307 | 317 | |
| 308 | template <class... _Types> | |
| 309 | class _LIBCPP_TEMPLATE_VIS variant; | |
| 310 | ||
| 311 | template <class _Tp> | |
| 312 | struct _LIBCPP_TEMPLATE_VIS variant_size; | |
| 313 | ||
| 314 | template <class _Tp> | |
| 315 | inline constexpr size_t variant_size_v = variant_size<_Tp>::value; | |
| 316 | ||
| 318 | // variant_size | |
| 317 | 319 | template <class _Tp> |
| 318 | 320 | struct _LIBCPP_TEMPLATE_VIS variant_size<const _Tp> : variant_size<_Tp> {}; |
| 319 | 321 | |
| ... | ... | @@ -326,12 +328,7 @@ struct _LIBCPP_TEMPLATE_VIS variant_size<const volatile _Tp> : variant_size<_Tp> |
| 326 | 328 | template <class... _Types> |
| 327 | 329 | struct _LIBCPP_TEMPLATE_VIS variant_size<variant<_Types...>> : integral_constant<size_t, sizeof...(_Types)> {}; |
| 328 | 330 | |
| 329 | template <size_t _Ip, class _Tp> | |
| 330 | struct _LIBCPP_TEMPLATE_VIS variant_alternative; | |
| 331 | ||
| 332 | template <size_t _Ip, class _Tp> | |
| 333 | using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type; | |
| 334 | ||
| 331 | // variant_alternative | |
| 335 | 332 | template <size_t _Ip, class _Tp> |
| 336 | 333 | struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const _Tp> : add_const<variant_alternative_t<_Ip, _Tp>> {}; |
| 337 | 334 | |
| ... | ... | @@ -347,29 +344,24 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> { |
| 347 | 344 | using type = __type_pack_element<_Ip, _Types...>; |
| 348 | 345 | }; |
| 349 | 346 | |
| 350 | inline constexpr size_t variant_npos = static_cast<size_t>(-1); | |
| 351 | ||
| 352 | 347 | template <size_t _NumAlternatives> |
| 353 | 348 | _LIBCPP_HIDE_FROM_ABI constexpr auto __choose_index_type() { |
| 354 | # ifdef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | |
| 349 | # ifdef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | |
| 355 | 350 | if constexpr (_NumAlternatives < numeric_limits<unsigned char>::max()) |
| 356 | 351 | return static_cast<unsigned char>(0); |
| 357 | 352 | else if constexpr (_NumAlternatives < numeric_limits<unsigned short>::max()) |
| 358 | 353 | return static_cast<unsigned short>(0); |
| 359 | 354 | else |
| 360 | # endif // _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | |
| 355 | # endif // _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | |
| 361 | 356 | return static_cast<unsigned int>(0); |
| 362 | 357 | } |
| 363 | 358 | |
| 364 | 359 | template <size_t _NumAlts> |
| 365 | using __variant_index_t = decltype(std::__choose_index_type<_NumAlts>()); | |
| 360 | using __variant_index_t _LIBCPP_NODEBUG = decltype(std::__choose_index_type<_NumAlts>()); | |
| 366 | 361 | |
| 367 | 362 | template <class _IndexType> |
| 368 | 363 | constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1); |
| 369 | 364 | |
| 370 | template <class... _Types> | |
| 371 | class _LIBCPP_TEMPLATE_VIS variant; | |
| 372 | ||
| 373 | 365 | template <class... _Types> |
| 374 | 366 | _LIBCPP_HIDE_FROM_ABI constexpr variant<_Types...>& __as_variant(variant<_Types...>& __vs) noexcept { |
| 375 | 367 | return __vs; |
| ... | ... | @@ -605,12 +597,12 @@ struct __variant { |
| 605 | 597 | return __visit_alt(__make_value_visitor(std::forward<_Visitor>(__visitor)), std::forward<_Vs>(__vs)...); |
| 606 | 598 | } |
| 607 | 599 | |
| 608 | # if _LIBCPP_STD_VER >= 20 | |
| 600 | # if _LIBCPP_STD_VER >= 20 | |
| 609 | 601 | template <class _Rp, class _Visitor, class... _Vs> |
| 610 | 602 | _LIBCPP_HIDE_FROM_ABI static constexpr _Rp __visit_value(_Visitor&& __visitor, _Vs&&... __vs) { |
| 611 | 603 | return __visit_alt(__make_value_visitor<_Rp>(std::forward<_Visitor>(__visitor)), std::forward<_Vs>(__vs)...); |
| 612 | 604 | } |
| 613 | # endif | |
| 605 | # endif | |
| 614 | 606 | |
| 615 | 607 | private: |
| 616 | 608 | template <class _Visitor, class... _Values> |
| ... | ... | @@ -628,7 +620,7 @@ private: |
| 628 | 620 | _Visitor&& __visitor; |
| 629 | 621 | }; |
| 630 | 622 | |
| 631 | # if _LIBCPP_STD_VER >= 20 | |
| 623 | # if _LIBCPP_STD_VER >= 20 | |
| 632 | 624 | template <class _Rp, class _Visitor> |
| 633 | 625 | struct __value_visitor_return_type { |
| 634 | 626 | template <class... _Alts> |
| ... | ... | @@ -643,31 +635,31 @@ private: |
| 643 | 635 | |
| 644 | 636 | _Visitor&& __visitor; |
| 645 | 637 | }; |
| 646 | # endif | |
| 638 | # endif | |
| 647 | 639 | |
| 648 | 640 | template <class _Visitor> |
| 649 | 641 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __make_value_visitor(_Visitor&& __visitor) { |
| 650 | 642 | return __value_visitor<_Visitor>{std::forward<_Visitor>(__visitor)}; |
| 651 | 643 | } |
| 652 | 644 | |
| 653 | # if _LIBCPP_STD_VER >= 20 | |
| 645 | # if _LIBCPP_STD_VER >= 20 | |
| 654 | 646 | template <class _Rp, class _Visitor> |
| 655 | 647 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __make_value_visitor(_Visitor&& __visitor) { |
| 656 | 648 | return __value_visitor_return_type<_Rp, _Visitor>{std::forward<_Visitor>(__visitor)}; |
| 657 | 649 | } |
| 658 | # endif | |
| 650 | # endif | |
| 659 | 651 | }; |
| 660 | 652 | |
| 661 | 653 | } // namespace __visitation |
| 662 | 654 | |
| 663 | 655 | // Adding semi-colons in macro expansions helps clang-format to do a better job. |
| 664 | 656 | // This macro is used to avoid compilation errors due to "stray" semi-colons. |
| 665 | # define _LIBCPP_EAT_SEMICOLON static_assert(true, "") | |
| 657 | # define _LIBCPP_EAT_SEMICOLON static_assert(true, "") | |
| 666 | 658 | |
| 667 | 659 | template <size_t _Index, class _Tp> |
| 668 | 660 | struct _LIBCPP_TEMPLATE_VIS __alt { |
| 669 | using __value_type = _Tp; | |
| 670 | static constexpr size_t __index = _Index; | |
| 661 | using __value_type _LIBCPP_NODEBUG = _Tp; | |
| 662 | static constexpr size_t __index = _Index; | |
| 671 | 663 | |
| 672 | 664 | template <class... _Args> |
| 673 | 665 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __alt(in_place_t, _Args&&... __args) |
| ... | ... | @@ -682,33 +674,33 @@ union _LIBCPP_TEMPLATE_VIS __union; |
| 682 | 674 | template <_Trait _DestructibleTrait, size_t _Index> |
| 683 | 675 | union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {}; |
| 684 | 676 | |
| 685 | # define _LIBCPP_VARIANT_UNION(destructible_trait, destructor_definition) \ | |
| 686 | template <size_t _Index, class _Tp, class... _Types> \ | |
| 687 | union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, _Index, _Tp, _Types...> { \ | |
| 688 | public: \ | |
| 689 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \ | |
| 677 | # define _LIBCPP_VARIANT_UNION(destructible_trait, destructor_definition) \ | |
| 678 | template <size_t _Index, class _Tp, class... _Types> \ | |
| 679 | union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, _Index, _Tp, _Types...> { \ | |
| 680 | public: \ | |
| 681 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \ | |
| 690 | 682 | \ |
| 691 | template <class... _Args> \ | |
| 692 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<0>, _Args&&... __args) \ | |
| 693 | : __head(in_place, std::forward<_Args>(__args)...) {} \ | |
| 683 | template <class... _Args> \ | |
| 684 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<0>, _Args&&... __args) \ | |
| 685 | : __head(in_place, std::forward<_Args>(__args)...) {} \ | |
| 694 | 686 | \ |
| 695 | template <size_t _Ip, class... _Args> \ | |
| 696 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \ | |
| 697 | : __tail(in_place_index<_Ip - 1>, std::forward<_Args>(__args)...) {} \ | |
| 687 | template <size_t _Ip, class... _Args> \ | |
| 688 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \ | |
| 689 | : __tail(in_place_index<_Ip - 1>, std::forward<_Args>(__args)...) {} \ | |
| 698 | 690 | \ |
| 699 | _LIBCPP_HIDE_FROM_ABI __union(const __union&) = default; \ | |
| 700 | _LIBCPP_HIDE_FROM_ABI __union(__union&&) = default; \ | |
| 701 | _LIBCPP_HIDE_FROM_ABI __union& operator=(const __union&) = default; \ | |
| 702 | _LIBCPP_HIDE_FROM_ABI __union& operator=(__union&&) = default; \ | |
| 703 | destructor_definition; \ | |
| 691 | _LIBCPP_HIDE_FROM_ABI __union(const __union&) = default; \ | |
| 692 | _LIBCPP_HIDE_FROM_ABI __union(__union&&) = default; \ | |
| 693 | _LIBCPP_HIDE_FROM_ABI __union& operator=(const __union&) = default; \ | |
| 694 | _LIBCPP_HIDE_FROM_ABI __union& operator=(__union&&) = default; \ | |
| 695 | destructor_definition; \ | |
| 704 | 696 | \ |
| 705 | private: \ | |
| 706 | char __dummy; \ | |
| 707 | __alt<_Index, _Tp> __head; \ | |
| 708 | __union<destructible_trait, _Index + 1, _Types...> __tail; \ | |
| 697 | private: \ | |
| 698 | char __dummy; \ | |
| 699 | __alt<_Index, _Tp> __head; \ | |
| 700 | __union<destructible_trait, _Index + 1, _Types...> __tail; \ | |
| 709 | 701 | \ |
| 710 | friend struct __access::__union; \ | |
| 711 | } | |
| 702 | friend struct __access::__union; \ | |
| 703 | } | |
| 712 | 704 | |
| 713 | 705 | _LIBCPP_VARIANT_UNION(_Trait::_TriviallyAvailable, |
| 714 | 706 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() = default); |
| ... | ... | @@ -716,12 +708,12 @@ _LIBCPP_VARIANT_UNION( |
| 716 | 708 | _Trait::_Available, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() {} _LIBCPP_EAT_SEMICOLON); |
| 717 | 709 | _LIBCPP_VARIANT_UNION(_Trait::_Unavailable, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() = delete); |
| 718 | 710 | |
| 719 | # undef _LIBCPP_VARIANT_UNION | |
| 711 | # undef _LIBCPP_VARIANT_UNION | |
| 720 | 712 | |
| 721 | 713 | template <_Trait _DestructibleTrait, class... _Types> |
| 722 | 714 | class _LIBCPP_TEMPLATE_VIS __base { |
| 723 | 715 | public: |
| 724 | using __index_t = __variant_index_t<sizeof...(_Types)>; | |
| 716 | using __index_t _LIBCPP_NODEBUG = __variant_index_t<sizeof...(_Types)>; | |
| 725 | 717 | |
| 726 | 718 | _LIBCPP_HIDE_FROM_ABI explicit constexpr __base(__valueless_t __tag) noexcept |
| 727 | 719 | : __data(__tag), __index(__variant_npos<__index_t>) {} |
| ... | ... | @@ -757,25 +749,25 @@ protected: |
| 757 | 749 | template <class _Traits, _Trait = _Traits::__destructible_trait> |
| 758 | 750 | class _LIBCPP_TEMPLATE_VIS __dtor; |
| 759 | 751 | |
| 760 | # define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor_definition, destroy) \ | |
| 761 | template <class... _Types> \ | |
| 762 | class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, destructible_trait> \ | |
| 763 | : public __base<destructible_trait, _Types...> { \ | |
| 764 | using __base_type = __base<destructible_trait, _Types...>; \ | |
| 765 | using __index_t = typename __base_type::__index_t; \ | |
| 752 | # define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor_definition, destroy) \ | |
| 753 | template <class... _Types> \ | |
| 754 | class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, destructible_trait> \ | |
| 755 | : public __base<destructible_trait, _Types...> { \ | |
| 756 | using __base_type _LIBCPP_NODEBUG = __base<destructible_trait, _Types...>; \ | |
| 757 | using __index_t _LIBCPP_NODEBUG = typename __base_type::__index_t; \ | |
| 766 | 758 | \ |
| 767 | public: \ | |
| 768 | using __base_type::__base_type; \ | |
| 769 | using __base_type::operator=; \ | |
| 770 | _LIBCPP_HIDE_FROM_ABI __dtor(const __dtor&) = default; \ | |
| 771 | _LIBCPP_HIDE_FROM_ABI __dtor(__dtor&&) = default; \ | |
| 772 | _LIBCPP_HIDE_FROM_ABI __dtor& operator=(const __dtor&) = default; \ | |
| 773 | _LIBCPP_HIDE_FROM_ABI __dtor& operator=(__dtor&&) = default; \ | |
| 774 | destructor_definition; \ | |
| 759 | public: \ | |
| 760 | using __base_type::__base_type; \ | |
| 761 | using __base_type::operator=; \ | |
| 762 | _LIBCPP_HIDE_FROM_ABI __dtor(const __dtor&) = default; \ | |
| 763 | _LIBCPP_HIDE_FROM_ABI __dtor(__dtor&&) = default; \ | |
| 764 | _LIBCPP_HIDE_FROM_ABI __dtor& operator=(const __dtor&) = default; \ | |
| 765 | _LIBCPP_HIDE_FROM_ABI __dtor& operator=(__dtor&&) = default; \ | |
| 766 | destructor_definition; \ | |
| 775 | 767 | \ |
| 776 | protected: \ | |
| 777 | destroy; \ | |
| 778 | } | |
| 768 | protected: \ | |
| 769 | destroy; \ | |
| 770 | } | |
| 779 | 771 | |
| 780 | 772 | _LIBCPP_VARIANT_DESTRUCTOR( |
| 781 | 773 | _Trait::_TriviallyAvailable, |
| ... | ... | @@ -803,11 +795,11 @@ _LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable, |
| 803 | 795 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__dtor() = delete, |
| 804 | 796 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy() noexcept = delete); |
| 805 | 797 | |
| 806 | # undef _LIBCPP_VARIANT_DESTRUCTOR | |
| 798 | # undef _LIBCPP_VARIANT_DESTRUCTOR | |
| 807 | 799 | |
| 808 | 800 | template <class _Traits> |
| 809 | 801 | class _LIBCPP_TEMPLATE_VIS __ctor : public __dtor<_Traits> { |
| 810 | using __base_type = __dtor<_Traits>; | |
| 802 | using __base_type _LIBCPP_NODEBUG = __dtor<_Traits>; | |
| 811 | 803 | |
| 812 | 804 | public: |
| 813 | 805 | using __base_type::__base_type; |
| ... | ... | @@ -835,22 +827,22 @@ protected: |
| 835 | 827 | template <class _Traits, _Trait = _Traits::__move_constructible_trait> |
| 836 | 828 | class _LIBCPP_TEMPLATE_VIS __move_constructor; |
| 837 | 829 | |
| 838 | # define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor_definition) \ | |
| 839 | template <class... _Types> \ | |
| 840 | class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, move_constructible_trait> \ | |
| 841 | : public __ctor<__traits<_Types...>> { \ | |
| 842 | using __base_type = __ctor<__traits<_Types...>>; \ | |
| 830 | # define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor_definition) \ | |
| 831 | template <class... _Types> \ | |
| 832 | class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, move_constructible_trait> \ | |
| 833 | : public __ctor<__traits<_Types...>> { \ | |
| 834 | using __base_type _LIBCPP_NODEBUG = __ctor<__traits<_Types...>>; \ | |
| 843 | 835 | \ |
| 844 | public: \ | |
| 845 | using __base_type::__base_type; \ | |
| 846 | using __base_type::operator=; \ | |
| 836 | public: \ | |
| 837 | using __base_type::__base_type; \ | |
| 838 | using __base_type::operator=; \ | |
| 847 | 839 | \ |
| 848 | _LIBCPP_HIDE_FROM_ABI __move_constructor(const __move_constructor&) = default; \ | |
| 849 | _LIBCPP_HIDE_FROM_ABI ~__move_constructor() = default; \ | |
| 850 | _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(const __move_constructor&) = default; \ | |
| 851 | _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(__move_constructor&&) = default; \ | |
| 852 | move_constructor_definition; \ | |
| 853 | } | |
| 840 | _LIBCPP_HIDE_FROM_ABI __move_constructor(const __move_constructor&) = default; \ | |
| 841 | _LIBCPP_HIDE_FROM_ABI ~__move_constructor() = default; \ | |
| 842 | _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(const __move_constructor&) = default; \ | |
| 843 | _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(__move_constructor&&) = default; \ | |
| 844 | move_constructor_definition; \ | |
| 845 | } | |
| 854 | 846 | |
| 855 | 847 | _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( |
| 856 | 848 | _Trait::_TriviallyAvailable, |
| ... | ... | @@ -868,27 +860,27 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR( |
| 868 | 860 | _Trait::_Unavailable, |
| 869 | 861 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&&) = delete); |
| 870 | 862 | |
| 871 | # undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR | |
| 863 | # undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR | |
| 872 | 864 | |
| 873 | 865 | template <class _Traits, _Trait = _Traits::__copy_constructible_trait> |
| 874 | 866 | class _LIBCPP_TEMPLATE_VIS __copy_constructor; |
| 875 | 867 | |
| 876 | # define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor_definition) \ | |
| 877 | template <class... _Types> \ | |
| 878 | class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, copy_constructible_trait> \ | |
| 879 | : public __move_constructor<__traits<_Types...>> { \ | |
| 880 | using __base_type = __move_constructor<__traits<_Types...>>; \ | |
| 868 | # define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor_definition) \ | |
| 869 | template <class... _Types> \ | |
| 870 | class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, copy_constructible_trait> \ | |
| 871 | : public __move_constructor<__traits<_Types...>> { \ | |
| 872 | using __base_type _LIBCPP_NODEBUG = __move_constructor<__traits<_Types...>>; \ | |
| 881 | 873 | \ |
| 882 | public: \ | |
| 883 | using __base_type::__base_type; \ | |
| 884 | using __base_type::operator=; \ | |
| 874 | public: \ | |
| 875 | using __base_type::__base_type; \ | |
| 876 | using __base_type::operator=; \ | |
| 885 | 877 | \ |
| 886 | _LIBCPP_HIDE_FROM_ABI __copy_constructor(__copy_constructor&&) = default; \ | |
| 887 | _LIBCPP_HIDE_FROM_ABI ~__copy_constructor() = default; \ | |
| 888 | _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(const __copy_constructor&) = default; \ | |
| 889 | _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(__copy_constructor&&) = default; \ | |
| 890 | copy_constructor_definition; \ | |
| 891 | } | |
| 878 | _LIBCPP_HIDE_FROM_ABI __copy_constructor(__copy_constructor&&) = default; \ | |
| 879 | _LIBCPP_HIDE_FROM_ABI ~__copy_constructor() = default; \ | |
| 880 | _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(const __copy_constructor&) = default; \ | |
| 881 | _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(__copy_constructor&&) = default; \ | |
| 882 | copy_constructor_definition; \ | |
| 883 | } | |
| 892 | 884 | |
| 893 | 885 | _LIBCPP_VARIANT_COPY_CONSTRUCTOR( |
| 894 | 886 | _Trait::_TriviallyAvailable, |
| ... | ... | @@ -903,11 +895,11 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR( |
| 903 | 895 | _Trait::_Unavailable, |
| 904 | 896 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor&) = delete); |
| 905 | 897 | |
| 906 | # undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR | |
| 898 | # undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR | |
| 907 | 899 | |
| 908 | 900 | template <class _Traits> |
| 909 | 901 | class _LIBCPP_TEMPLATE_VIS __assignment : public __copy_constructor<_Traits> { |
| 910 | using __base_type = __copy_constructor<_Traits>; | |
| 902 | using __base_type _LIBCPP_NODEBUG = __copy_constructor<_Traits>; | |
| 911 | 903 | |
| 912 | 904 | public: |
| 913 | 905 | using __base_type::__base_type; |
| ... | ... | @@ -962,22 +954,22 @@ protected: |
| 962 | 954 | template <class _Traits, _Trait = _Traits::__move_assignable_trait> |
| 963 | 955 | class _LIBCPP_TEMPLATE_VIS __move_assignment; |
| 964 | 956 | |
| 965 | # define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment_definition) \ | |
| 966 | template <class... _Types> \ | |
| 967 | class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, move_assignable_trait> \ | |
| 968 | : public __assignment<__traits<_Types...>> { \ | |
| 969 | using __base_type = __assignment<__traits<_Types...>>; \ | |
| 957 | # define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment_definition) \ | |
| 958 | template <class... _Types> \ | |
| 959 | class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, move_assignable_trait> \ | |
| 960 | : public __assignment<__traits<_Types...>> { \ | |
| 961 | using __base_type _LIBCPP_NODEBUG = __assignment<__traits<_Types...>>; \ | |
| 970 | 962 | \ |
| 971 | public: \ | |
| 972 | using __base_type::__base_type; \ | |
| 973 | using __base_type::operator=; \ | |
| 963 | public: \ | |
| 964 | using __base_type::__base_type; \ | |
| 965 | using __base_type::operator=; \ | |
| 974 | 966 | \ |
| 975 | _LIBCPP_HIDE_FROM_ABI __move_assignment(const __move_assignment&) = default; \ | |
| 976 | _LIBCPP_HIDE_FROM_ABI __move_assignment(__move_assignment&&) = default; \ | |
| 977 | _LIBCPP_HIDE_FROM_ABI ~__move_assignment() = default; \ | |
| 978 | _LIBCPP_HIDE_FROM_ABI __move_assignment& operator=(const __move_assignment&) = default; \ | |
| 979 | move_assignment_definition; \ | |
| 980 | } | |
| 967 | _LIBCPP_HIDE_FROM_ABI __move_assignment(const __move_assignment&) = default; \ | |
| 968 | _LIBCPP_HIDE_FROM_ABI __move_assignment(__move_assignment&&) = default; \ | |
| 969 | _LIBCPP_HIDE_FROM_ABI ~__move_assignment() = default; \ | |
| 970 | _LIBCPP_HIDE_FROM_ABI __move_assignment& operator=(const __move_assignment&) = default; \ | |
| 971 | move_assignment_definition; \ | |
| 972 | } | |
| 981 | 973 | |
| 982 | 974 | _LIBCPP_VARIANT_MOVE_ASSIGNMENT(_Trait::_TriviallyAvailable, |
| 983 | 975 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& operator=( |
| ... | ... | @@ -996,27 +988,27 @@ _LIBCPP_VARIANT_MOVE_ASSIGNMENT( |
| 996 | 988 | _Trait::_Unavailable, |
| 997 | 989 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& operator=(__move_assignment&&) = delete); |
| 998 | 990 | |
| 999 | # undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT | |
| 991 | # undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT | |
| 1000 | 992 | |
| 1001 | 993 | template <class _Traits, _Trait = _Traits::__copy_assignable_trait> |
| 1002 | 994 | class _LIBCPP_TEMPLATE_VIS __copy_assignment; |
| 1003 | 995 | |
| 1004 | # define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment_definition) \ | |
| 1005 | template <class... _Types> \ | |
| 1006 | class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, copy_assignable_trait> \ | |
| 1007 | : public __move_assignment<__traits<_Types...>> { \ | |
| 1008 | using __base_type = __move_assignment<__traits<_Types...>>; \ | |
| 996 | # define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment_definition) \ | |
| 997 | template <class... _Types> \ | |
| 998 | class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, copy_assignable_trait> \ | |
| 999 | : public __move_assignment<__traits<_Types...>> { \ | |
| 1000 | using __base_type _LIBCPP_NODEBUG = __move_assignment<__traits<_Types...>>; \ | |
| 1009 | 1001 | \ |
| 1010 | public: \ | |
| 1011 | using __base_type::__base_type; \ | |
| 1012 | using __base_type::operator=; \ | |
| 1002 | public: \ | |
| 1003 | using __base_type::__base_type; \ | |
| 1004 | using __base_type::operator=; \ | |
| 1013 | 1005 | \ |
| 1014 | _LIBCPP_HIDE_FROM_ABI __copy_assignment(const __copy_assignment&) = default; \ | |
| 1015 | _LIBCPP_HIDE_FROM_ABI __copy_assignment(__copy_assignment&&) = default; \ | |
| 1016 | _LIBCPP_HIDE_FROM_ABI ~__copy_assignment() = default; \ | |
| 1017 | _LIBCPP_HIDE_FROM_ABI __copy_assignment& operator=(__copy_assignment&&) = default; \ | |
| 1018 | copy_assignment_definition; \ | |
| 1019 | } | |
| 1006 | _LIBCPP_HIDE_FROM_ABI __copy_assignment(const __copy_assignment&) = default; \ | |
| 1007 | _LIBCPP_HIDE_FROM_ABI __copy_assignment(__copy_assignment&&) = default; \ | |
| 1008 | _LIBCPP_HIDE_FROM_ABI ~__copy_assignment() = default; \ | |
| 1009 | _LIBCPP_HIDE_FROM_ABI __copy_assignment& operator=(__copy_assignment&&) = default; \ | |
| 1010 | copy_assignment_definition; \ | |
| 1011 | } | |
| 1020 | 1012 | |
| 1021 | 1013 | _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_TriviallyAvailable, |
| 1022 | 1014 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& operator=( |
| ... | ... | @@ -1034,11 +1026,11 @@ _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable, |
| 1034 | 1026 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& operator=( |
| 1035 | 1027 | const __copy_assignment&) = delete); |
| 1036 | 1028 | |
| 1037 | # undef _LIBCPP_VARIANT_COPY_ASSIGNMENT | |
| 1029 | # undef _LIBCPP_VARIANT_COPY_ASSIGNMENT | |
| 1038 | 1030 | |
| 1039 | 1031 | template <class... _Types> |
| 1040 | 1032 | class _LIBCPP_TEMPLATE_VIS __impl : public __copy_assignment<__traits<_Types...>> { |
| 1041 | using __base_type = __copy_assignment<__traits<_Types...>>; | |
| 1033 | using __base_type _LIBCPP_NODEBUG = __copy_assignment<__traits<_Types...>>; | |
| 1042 | 1034 | |
| 1043 | 1035 | public: |
| 1044 | 1036 | using __base_type::__base_type; // get in_place_index_t constructor & friends |
| ... | ... | @@ -1071,7 +1063,7 @@ public: |
| 1071 | 1063 | std::swap(__lhs, __rhs); |
| 1072 | 1064 | } |
| 1073 | 1065 | __impl __tmp(std::move(*__rhs)); |
| 1074 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1066 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 1075 | 1067 | if constexpr (__all<is_nothrow_move_constructible_v<_Types>...>::value) { |
| 1076 | 1068 | this->__generic_construct(*__rhs, std::move(*__lhs)); |
| 1077 | 1069 | } else { |
| ... | ... | @@ -1087,11 +1079,11 @@ public: |
| 1087 | 1079 | throw; |
| 1088 | 1080 | } |
| 1089 | 1081 | } |
| 1090 | # else | |
| 1082 | # else | |
| 1091 | 1083 | // this isn't consolidated with the `if constexpr` branch above due to |
| 1092 | 1084 | // `throw` being ill-formed with exceptions disabled even when discarded. |
| 1093 | 1085 | this->__generic_construct(*__rhs, std::move(*__lhs)); |
| 1094 | # endif | |
| 1086 | # endif | |
| 1095 | 1087 | this->__generic_construct(*__lhs, std::move(__tmp)); |
| 1096 | 1088 | } |
| 1097 | 1089 | } |
| ... | ... | @@ -1105,7 +1097,7 @@ private: |
| 1105 | 1097 | |
| 1106 | 1098 | struct __no_narrowing_check { |
| 1107 | 1099 | template <class _Dest, class _Source> |
| 1108 | using _Apply = __type_identity<_Dest>; | |
| 1100 | using _Apply _LIBCPP_NODEBUG = __type_identity<_Dest>; | |
| 1109 | 1101 | }; |
| 1110 | 1102 | |
| 1111 | 1103 | struct __narrowing_check { |
| ... | ... | @@ -1146,7 +1138,7 @@ using _MakeOverloads _LIBCPP_NODEBUG = |
| 1146 | 1138 | typename __make_overloads_imp< __make_indices_imp<sizeof...(_Types), 0> >::template _Apply<_Types...>; |
| 1147 | 1139 | |
| 1148 | 1140 | template <class _Tp, class... _Types> |
| 1149 | using __best_match_t = typename invoke_result_t<_MakeOverloads<_Types...>, _Tp, _Tp>::type; | |
| 1141 | using __best_match_t _LIBCPP_NODEBUG = typename invoke_result_t<_MakeOverloads<_Types...>, _Tp, _Tp>::type; | |
| 1150 | 1142 | |
| 1151 | 1143 | } // namespace __variant_detail |
| 1152 | 1144 | |
| ... | ... | @@ -1154,17 +1146,17 @@ template <class _Visitor, class... _Vs, typename = void_t<decltype(std::__as_var |
| 1154 | 1146 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr decltype(auto) |
| 1155 | 1147 | visit(_Visitor&& __visitor, _Vs&&... __vs); |
| 1156 | 1148 | |
| 1157 | # if _LIBCPP_STD_VER >= 20 | |
| 1149 | # if _LIBCPP_STD_VER >= 20 | |
| 1158 | 1150 | template <class _Rp, |
| 1159 | 1151 | class _Visitor, |
| 1160 | 1152 | class... _Vs, |
| 1161 | 1153 | typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>> |
| 1162 | 1154 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp |
| 1163 | 1155 | visit(_Visitor&& __visitor, _Vs&&... __vs); |
| 1164 | # endif | |
| 1156 | # endif | |
| 1165 | 1157 | |
| 1166 | 1158 | template <class... _Types> |
| 1167 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES variant | |
| 1159 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIONS variant | |
| 1168 | 1160 | : private __sfinae_ctor_base< __all<is_copy_constructible_v<_Types>...>::value, |
| 1169 | 1161 | __all<is_move_constructible_v<_Types>...>::value>, |
| 1170 | 1162 | private __sfinae_assign_base< |
| ... | ... | @@ -1178,10 +1170,10 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES variant |
| 1178 | 1170 | |
| 1179 | 1171 | static_assert(__all<!is_void_v<_Types>...>::value, "variant can not have a void type as an alternative."); |
| 1180 | 1172 | |
| 1181 | using __first_type = variant_alternative_t<0, variant>; | |
| 1173 | using __first_type _LIBCPP_NODEBUG = variant_alternative_t<0, variant>; | |
| 1182 | 1174 | |
| 1183 | 1175 | public: |
| 1184 | using __trivially_relocatable = | |
| 1176 | using __trivially_relocatable _LIBCPP_NODEBUG = | |
| 1185 | 1177 | conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>; |
| 1186 | 1178 | |
| 1187 | 1179 | template <bool _Dummy = true, |
| ... | ... | @@ -1309,7 +1301,7 @@ public: |
| 1309 | 1301 | __impl_.__swap(__that.__impl_); |
| 1310 | 1302 | } |
| 1311 | 1303 | |
| 1312 | # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) | |
| 1304 | # if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER | |
| 1313 | 1305 | // Helper class to implement [variant.visit]/10 |
| 1314 | 1306 | // Constraints: The call to visit does not use an explicit template-argument-list |
| 1315 | 1307 | // that begins with a type template-argument. |
| ... | ... | @@ -1319,16 +1311,14 @@ public: |
| 1319 | 1311 | |
| 1320 | 1312 | template <__variant_visit_barrier_tag = __variant_visit_barrier_tag{}, class _Self, class _Visitor> |
| 1321 | 1313 | _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(this _Self&& __self, _Visitor&& __visitor) { |
| 1322 | using _VariantT = _OverrideRef<_Self&&, _CopyConst<remove_reference_t<_Self>, variant>>; | |
| 1323 | return std::visit(std::forward<_Visitor>(__visitor), (_VariantT)__self); | |
| 1314 | return std::visit(std::forward<_Visitor>(__visitor), std::__forward_as<_Self, variant>(__self)); | |
| 1324 | 1315 | } |
| 1325 | 1316 | |
| 1326 | 1317 | template <class _Rp, class _Self, class _Visitor> |
| 1327 | 1318 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp visit(this _Self&& __self, _Visitor&& __visitor) { |
| 1328 | using _VariantT = _OverrideRef<_Self&&, _CopyConst<remove_reference_t<_Self>, variant>>; | |
| 1329 | return std::visit<_Rp>(std::forward<_Visitor>(__visitor), (_VariantT)__self); | |
| 1319 | return std::visit<_Rp>(std::forward<_Visitor>(__visitor), std::__forward_as<_Self, variant>(__self)); | |
| 1330 | 1320 | } |
| 1331 | # endif | |
| 1321 | # endif | |
| 1332 | 1322 | |
| 1333 | 1323 | private: |
| 1334 | 1324 | __variant_detail::__impl<_Types...> __impl_; |
| ... | ... | @@ -1472,7 +1462,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const variant<_Types...>& __lhs, |
| 1472 | 1462 | return __variant::__visit_value_at(__lhs.index(), __convert_to_bool<equal_to<>>{}, __lhs, __rhs); |
| 1473 | 1463 | } |
| 1474 | 1464 | |
| 1475 | # if _LIBCPP_STD_VER >= 20 | |
| 1465 | # if _LIBCPP_STD_VER >= 20 | |
| 1476 | 1466 | |
| 1477 | 1467 | template <class... _Types> |
| 1478 | 1468 | requires(three_way_comparable<_Types> && ...) |
| ... | ... | @@ -1492,7 +1482,7 @@ operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { |
| 1492 | 1482 | return __variant::__visit_value_at(__lhs.index(), __three_way, __lhs, __rhs); |
| 1493 | 1483 | } |
| 1494 | 1484 | |
| 1495 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1485 | # endif // _LIBCPP_STD_VER >= 20 | |
| 1496 | 1486 | |
| 1497 | 1487 | template <class... _Types> |
| 1498 | 1488 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { |
| ... | ... | @@ -1576,7 +1566,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) { |
| 1576 | 1566 | return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...); |
| 1577 | 1567 | } |
| 1578 | 1568 | |
| 1579 | # if _LIBCPP_STD_VER >= 20 | |
| 1569 | # if _LIBCPP_STD_VER >= 20 | |
| 1580 | 1570 | template < class _Rp, class _Visitor, class... _Vs, typename> |
| 1581 | 1571 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp |
| 1582 | 1572 | visit(_Visitor&& __visitor, _Vs&&... __vs) { |
| ... | ... | @@ -1584,7 +1574,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) { |
| 1584 | 1574 | std::__throw_if_valueless(std::forward<_Vs>(__vs)...); |
| 1585 | 1575 | return __variant::__visit_value<_Rp>(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...); |
| 1586 | 1576 | } |
| 1587 | # endif | |
| 1577 | # endif | |
| 1588 | 1578 | |
| 1589 | 1579 | template <class... _Types> |
| 1590 | 1580 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto |
| ... | ... | @@ -1633,18 +1623,20 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto&& __unchecked_get(variant<_Types...>& __v) |
| 1633 | 1623 | return std::__unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v); |
| 1634 | 1624 | } |
| 1635 | 1625 | |
| 1636 | #endif // _LIBCPP_STD_VER >= 17 | |
| 1626 | # endif // _LIBCPP_STD_VER >= 17 | |
| 1637 | 1627 | |
| 1638 | 1628 | _LIBCPP_END_NAMESPACE_STD |
| 1639 | 1629 | |
| 1640 | 1630 | _LIBCPP_POP_MACROS |
| 1641 | 1631 | |
| 1642 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1643 | # include <exception> | |
| 1644 | # include <tuple> | |
| 1645 | # include <type_traits> | |
| 1646 | # include <typeinfo> | |
| 1647 | # include <utility> | |
| 1648 | #endif | |
| 1632 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 1633 | # include <cstddef> | |
| 1634 | # include <exception> | |
| 1635 | # include <tuple> | |
| 1636 | # include <type_traits> | |
| 1637 | # include <typeinfo> | |
| 1638 | # include <utility> | |
| 1639 | # endif | |
| 1640 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 1649 | 1641 | |
| 1650 | 1642 | #endif // _LIBCPP_VARIANT |
lib/libcxx/include/vector+54-2711| ... | ... | @@ -170,7 +170,7 @@ public: |
| 170 | 170 | |
| 171 | 171 | vector() |
| 172 | 172 | noexcept(is_nothrow_default_constructible<allocator_type>::value); |
| 173 | explicit vector(const allocator_type&); | |
| 173 | explicit vector(const allocator_type&) noexcept; | |
| 174 | 174 | explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14 |
| 175 | 175 | vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); |
| 176 | 176 | template <class InputIterator> |
| ... | ... | @@ -178,8 +178,7 @@ public: |
| 178 | 178 | template<container-compatible-range<bool> R> |
| 179 | 179 | constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator()); |
| 180 | 180 | vector(const vector& x); |
| 181 | vector(vector&& x) | |
| 182 | noexcept(is_nothrow_move_constructible<allocator_type>::value); | |
| 181 | vector(vector&& x) noexcept; | |
| 183 | 182 | vector(initializer_list<value_type> il); |
| 184 | 183 | vector(initializer_list<value_type> il, const allocator_type& a); |
| 185 | 184 | ~vector(); |
| ... | ... | @@ -305,2727 +304,71 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++ |
| 305 | 304 | |
| 306 | 305 | // clang-format on |
| 307 | 306 | |
| 308 | #include <__algorithm/copy.h> | |
| 309 | #include <__algorithm/equal.h> | |
| 310 | #include <__algorithm/fill_n.h> | |
| 311 | #include <__algorithm/iterator_operations.h> | |
| 312 | #include <__algorithm/lexicographical_compare.h> | |
| 313 | #include <__algorithm/lexicographical_compare_three_way.h> | |
| 314 | #include <__algorithm/remove.h> | |
| 315 | #include <__algorithm/remove_if.h> | |
| 316 | #include <__algorithm/rotate.h> | |
| 317 | #include <__algorithm/unwrap_iter.h> | |
| 318 | #include <__assert> | |
| 319 | #include <__bit_reference> | |
| 320 | #include <__concepts/same_as.h> | |
| 321 | #include <__config> | |
| 322 | #include <__debug_utils/sanitizers.h> | |
| 323 | #include <__format/enable_insertable.h> | |
| 324 | #include <__format/formatter.h> | |
| 325 | #include <__format/formatter_bool.h> | |
| 326 | #include <__functional/hash.h> | |
| 327 | #include <__functional/unary_function.h> | |
| 328 | #include <__fwd/vector.h> | |
| 329 | #include <__iterator/advance.h> | |
| 330 | #include <__iterator/bounded_iter.h> | |
| 331 | #include <__iterator/distance.h> | |
| 332 | #include <__iterator/iterator_traits.h> | |
| 333 | #include <__iterator/reverse_iterator.h> | |
| 334 | #include <__iterator/wrap_iter.h> | |
| 335 | #include <__memory/addressof.h> | |
| 336 | #include <__memory/allocate_at_least.h> | |
| 337 | #include <__memory/allocator_traits.h> | |
| 338 | #include <__memory/pointer_traits.h> | |
| 339 | #include <__memory/swap_allocator.h> | |
| 340 | #include <__memory/temp_value.h> | |
| 341 | #include <__memory/uninitialized_algorithms.h> | |
| 342 | #include <__memory_resource/polymorphic_allocator.h> | |
| 343 | #include <__ranges/access.h> | |
| 344 | #include <__ranges/concepts.h> | |
| 345 | #include <__ranges/container_compatible_range.h> | |
| 346 | #include <__ranges/from_range.h> | |
| 347 | #include <__ranges/size.h> | |
| 348 | #include <__split_buffer> | |
| 349 | #include <__type_traits/is_allocator.h> | |
| 350 | #include <__type_traits/is_constructible.h> | |
| 351 | #include <__type_traits/is_nothrow_assignable.h> | |
| 352 | #include <__type_traits/noexcept_move_assign_container.h> | |
| 353 | #include <__type_traits/type_identity.h> | |
| 354 | #include <__utility/exception_guard.h> | |
| 355 | #include <__utility/forward.h> | |
| 356 | #include <__utility/is_pointer_in_range.h> | |
| 357 | #include <__utility/move.h> | |
| 358 | #include <__utility/pair.h> | |
| 359 | #include <__utility/swap.h> | |
| 360 | #include <climits> | |
| 361 | #include <cstring> | |
| 362 | #include <limits> | |
| 363 | #include <stdexcept> | |
| 364 | #include <version> | |
| 365 | ||
| 366 | // standard-mandated includes | |
| 367 | ||
| 368 | // [iterator.range] | |
| 369 | #include <__iterator/access.h> | |
| 370 | #include <__iterator/data.h> | |
| 371 | #include <__iterator/empty.h> | |
| 372 | #include <__iterator/reverse_access.h> | |
| 373 | #include <__iterator/size.h> | |
| 374 | ||
| 375 | // [vector.syn] | |
| 376 | #include <compare> | |
| 377 | #include <initializer_list> | |
| 378 | ||
| 379 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 380 | # pragma GCC system_header | |
| 381 | #endif | |
| 382 | ||
| 383 | _LIBCPP_PUSH_MACROS | |
| 384 | #include <__undef_macros> | |
| 385 | ||
| 386 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 387 | ||
| 388 | template <class _Tp, class _Allocator /* = allocator<_Tp> */> | |
| 389 | class _LIBCPP_TEMPLATE_VIS vector { | |
| 390 | private: | |
| 391 | typedef allocator<_Tp> __default_allocator_type; | |
| 392 | ||
| 393 | public: | |
| 394 | typedef vector __self; | |
| 395 | typedef _Tp value_type; | |
| 396 | typedef _Allocator allocator_type; | |
| 397 | typedef allocator_traits<allocator_type> __alloc_traits; | |
| 398 | typedef value_type& reference; | |
| 399 | typedef const value_type& const_reference; | |
| 400 | typedef typename __alloc_traits::size_type size_type; | |
| 401 | typedef typename __alloc_traits::difference_type difference_type; | |
| 402 | typedef typename __alloc_traits::pointer pointer; | |
| 403 | typedef typename __alloc_traits::const_pointer const_pointer; | |
| 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 | |
| 411 | typedef __wrap_iter<pointer> iterator; | |
| 412 | typedef __wrap_iter<const_pointer> const_iterator; | |
| 413 | #endif | |
| 414 | typedef std::reverse_iterator<iterator> reverse_iterator; | |
| 415 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 416 | ||
| 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, | |
| 428 | "Allocator::value_type must be same type as value_type"); | |
| 429 | ||
| 430 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector() | |
| 431 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) {} | |
| 432 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a) | |
| 433 | #if _LIBCPP_STD_VER <= 14 | |
| 434 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) | |
| 435 | #else | |
| 436 | _NOEXCEPT | |
| 437 | #endif | |
| 438 | : __end_cap_(nullptr, __a) { | |
| 439 | } | |
| 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 | ||
| 450 | #if _LIBCPP_STD_VER >= 14 | |
| 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 | } | |
| 460 | #endif | |
| 461 | ||
| 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> | |
| 472 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 473 | vector(size_type __n, const value_type& __x, const allocator_type& __a) | |
| 474 | : __end_cap_(nullptr, __a) { | |
| 475 | if (__n > 0) { | |
| 476 | __vallocate(__n); | |
| 477 | __construct_at_end(__n, __x); | |
| 478 | } | |
| 479 | } | |
| 480 | ||
| 481 | template <class _InputIterator, | |
| 482 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 483 | is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, | |
| 484 | int> = 0> | |
| 485 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_InputIterator __first, _InputIterator __last); | |
| 486 | template <class _InputIterator, | |
| 487 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 488 | is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, | |
| 489 | int> = 0> | |
| 490 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 491 | vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a); | |
| 492 | ||
| 493 | template < | |
| 494 | class _ForwardIterator, | |
| 495 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 496 | is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 497 | int> = 0> | |
| 498 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(_ForwardIterator __first, _ForwardIterator __last); | |
| 499 | ||
| 500 | template < | |
| 501 | class _ForwardIterator, | |
| 502 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 503 | is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 504 | int> = 0> | |
| 505 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 506 | vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a); | |
| 507 | ||
| 508 | #if _LIBCPP_STD_VER >= 23 | |
| 509 | template <_ContainerCompatibleRange<_Tp> _Range> | |
| 510 | _LIBCPP_HIDE_FROM_ABI constexpr vector( | |
| 511 | from_range_t, _Range&& __range, const allocator_type& __alloc = allocator_type()) | |
| 512 | : __end_cap_(nullptr, __alloc) { | |
| 513 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 514 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 515 | __init_with_size(ranges::begin(__range), ranges::end(__range), __n); | |
| 516 | ||
| 517 | } else { | |
| 518 | __init_with_sentinel(ranges::begin(__range), ranges::end(__range)); | |
| 519 | } | |
| 520 | } | |
| 521 | #endif | |
| 522 | ||
| 523 | private: | |
| 524 | class __destroy_vector { | |
| 525 | public: | |
| 526 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {} | |
| 527 | ||
| 528 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() { | |
| 529 | if (__vec_.__begin_ != nullptr) { | |
| 530 | __vec_.__clear(); | |
| 531 | __vec_.__annotate_delete(); | |
| 532 | __alloc_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.capacity()); | |
| 533 | } | |
| 534 | } | |
| 535 | ||
| 536 | private: | |
| 537 | vector& __vec_; | |
| 538 | }; | |
| 539 | ||
| 540 | public: | |
| 541 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector (*this)(); } | |
| 542 | ||
| 543 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x); | |
| 544 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 545 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a); | |
| 546 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(const vector& __x); | |
| 547 | ||
| 548 | #ifndef _LIBCPP_CXX03_LANG | |
| 549 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(initializer_list<value_type> __il); | |
| 550 | ||
| 551 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 552 | vector(initializer_list<value_type> __il, const allocator_type& __a); | |
| 553 | ||
| 554 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(initializer_list<value_type> __il) { | |
| 555 | assign(__il.begin(), __il.end()); | |
| 556 | return *this; | |
| 557 | } | |
| 558 | #endif // !_LIBCPP_CXX03_LANG | |
| 559 | ||
| 560 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(vector&& __x) | |
| 561 | #if _LIBCPP_STD_VER >= 17 | |
| 562 | noexcept; | |
| 563 | #else | |
| 564 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | |
| 565 | #endif | |
| 566 | ||
| 567 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 568 | vector(vector&& __x, const __type_identity_t<allocator_type>& __a); | |
| 569 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(vector&& __x) | |
| 570 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value); | |
| 571 | ||
| 572 | template <class _InputIterator, | |
| 573 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 574 | is_constructible<value_type, typename iterator_traits<_InputIterator>::reference>::value, | |
| 575 | int> = 0> | |
| 576 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_InputIterator __first, _InputIterator __last); | |
| 577 | template < | |
| 578 | class _ForwardIterator, | |
| 579 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 580 | is_constructible<value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 581 | int> = 0> | |
| 582 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(_ForwardIterator __first, _ForwardIterator __last); | |
| 583 | ||
| 584 | #if _LIBCPP_STD_VER >= 23 | |
| 585 | template <_ContainerCompatibleRange<_Tp> _Range> | |
| 586 | _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) { | |
| 587 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 588 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 589 | __assign_with_size(ranges::begin(__range), ranges::end(__range), __n); | |
| 590 | ||
| 591 | } else { | |
| 592 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); | |
| 593 | } | |
| 594 | } | |
| 595 | #endif | |
| 596 | ||
| 597 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const_reference __u); | |
| 598 | ||
| 599 | #ifndef _LIBCPP_CXX03_LANG | |
| 600 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { | |
| 601 | assign(__il.begin(), __il.end()); | |
| 602 | } | |
| 603 | #endif | |
| 604 | ||
| 605 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { | |
| 606 | return this->__alloc(); | |
| 607 | } | |
| 608 | ||
| 609 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT; | |
| 610 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT; | |
| 611 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT; | |
| 612 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT; | |
| 613 | ||
| 614 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { | |
| 615 | return reverse_iterator(end()); | |
| 616 | } | |
| 617 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { | |
| 618 | return const_reverse_iterator(end()); | |
| 619 | } | |
| 620 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { | |
| 621 | return reverse_iterator(begin()); | |
| 622 | } | |
| 623 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { | |
| 624 | return const_reverse_iterator(begin()); | |
| 625 | } | |
| 626 | ||
| 627 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } | |
| 628 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } | |
| 629 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { | |
| 630 | return rbegin(); | |
| 631 | } | |
| 632 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | |
| 633 | ||
| 634 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { | |
| 635 | return static_cast<size_type>(this->__end_ - this->__begin_); | |
| 636 | } | |
| 637 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT { | |
| 638 | return static_cast<size_type>(__end_cap() - this->__begin_); | |
| 639 | } | |
| 640 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { | |
| 641 | return this->__begin_ == this->__end_; | |
| 642 | } | |
| 643 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT; | |
| 644 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n); | |
| 645 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT; | |
| 646 | ||
| 647 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT; | |
| 648 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT; | |
| 649 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n); | |
| 650 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const; | |
| 651 | ||
| 652 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT { | |
| 653 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector"); | |
| 654 | return *this->__begin_; | |
| 655 | } | |
| 656 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT { | |
| 657 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector"); | |
| 658 | return *this->__begin_; | |
| 659 | } | |
| 660 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT { | |
| 661 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector"); | |
| 662 | return *(this->__end_ - 1); | |
| 663 | } | |
| 664 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { | |
| 665 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector"); | |
| 666 | return *(this->__end_ - 1); | |
| 667 | } | |
| 668 | ||
| 669 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT { | |
| 670 | return std::__to_address(this->__begin_); | |
| 671 | } | |
| 672 | ||
| 673 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT { | |
| 674 | return std::__to_address(this->__begin_); | |
| 675 | } | |
| 676 | ||
| 677 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(const_reference __x); | |
| 678 | ||
| 679 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x); | |
| 680 | ||
| 681 | template <class... _Args> | |
| 682 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI | |
| 683 | #if _LIBCPP_STD_VER >= 17 | |
| 684 | reference | |
| 685 | emplace_back(_Args&&... __args); | |
| 686 | #else | |
| 687 | void | |
| 688 | emplace_back(_Args&&... __args); | |
| 689 | #endif | |
| 690 | ||
| 691 | #if _LIBCPP_STD_VER >= 23 | |
| 692 | template <_ContainerCompatibleRange<_Tp> _Range> | |
| 693 | _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) { | |
| 694 | insert_range(end(), std::forward<_Range>(__range)); | |
| 695 | } | |
| 696 | #endif | |
| 697 | ||
| 698 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back(); | |
| 699 | ||
| 700 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x); | |
| 701 | ||
| 702 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x); | |
| 703 | template <class... _Args> | |
| 704 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args); | |
| 705 | ||
| 706 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 707 | insert(const_iterator __position, size_type __n, const_reference __x); | |
| 708 | ||
| 709 | template <class _InputIterator, | |
| 710 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 711 | is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value, | |
| 712 | int> = 0> | |
| 713 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 714 | insert(const_iterator __position, _InputIterator __first, _InputIterator __last); | |
| 715 | ||
| 716 | #if _LIBCPP_STD_VER >= 23 | |
| 717 | template <_ContainerCompatibleRange<_Tp> _Range> | |
| 718 | _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) { | |
| 719 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 720 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 721 | return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n); | |
| 722 | ||
| 723 | } else { | |
| 724 | return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); | |
| 725 | } | |
| 726 | } | |
| 727 | #endif | |
| 728 | ||
| 729 | template < | |
| 730 | class _ForwardIterator, | |
| 731 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 732 | is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 733 | int> = 0> | |
| 734 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 735 | insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); | |
| 736 | ||
| 737 | #ifndef _LIBCPP_CXX03_LANG | |
| 738 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 739 | insert(const_iterator __position, initializer_list<value_type> __il) { | |
| 740 | return insert(__position, __il.begin(), __il.end()); | |
| 741 | } | |
| 742 | #endif | |
| 743 | ||
| 744 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position); | |
| 745 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last); | |
| 746 | ||
| 747 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { | |
| 748 | size_type __old_size = size(); | |
| 749 | __clear(); | |
| 750 | __annotate_shrink(__old_size); | |
| 751 | } | |
| 752 | ||
| 753 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz); | |
| 754 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void resize(size_type __sz, const_reference __x); | |
| 755 | ||
| 756 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(vector&) | |
| 757 | #if _LIBCPP_STD_VER >= 14 | |
| 758 | _NOEXCEPT; | |
| 759 | #else | |
| 760 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); | |
| 761 | #endif | |
| 762 | ||
| 763 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const; | |
| 764 | ||
| 765 | private: | |
| 766 | pointer __begin_ = nullptr; | |
| 767 | pointer __end_ = nullptr; | |
| 768 | __compressed_pair<pointer, allocator_type> __end_cap_ = | |
| 769 | __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag()); | |
| 770 | ||
| 771 | // Allocate space for __n objects | |
| 772 | // throws length_error if __n > max_size() | |
| 773 | // throws (probably bad_alloc) if memory run out | |
| 774 | // Precondition: __begin_ == __end_ == __end_cap() == 0 | |
| 775 | // Precondition: __n > 0 | |
| 776 | // Postcondition: capacity() >= __n | |
| 777 | // Postcondition: size() == 0 | |
| 778 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { | |
| 779 | if (__n > max_size()) | |
| 780 | __throw_length_error(); | |
| 781 | auto __allocation = std::__allocate_at_least(__alloc(), __n); | |
| 782 | __begin_ = __allocation.ptr; | |
| 783 | __end_ = __allocation.ptr; | |
| 784 | __end_cap() = __begin_ + __allocation.count; | |
| 785 | __annotate_new(0); | |
| 786 | } | |
| 787 | ||
| 788 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vdeallocate() _NOEXCEPT; | |
| 789 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __recommend(size_type __new_size) const; | |
| 790 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n); | |
| 791 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x); | |
| 792 | ||
| 793 | template <class _InputIterator, class _Sentinel> | |
| 794 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 795 | __init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) { | |
| 796 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 797 | ||
| 798 | if (__n > 0) { | |
| 799 | __vallocate(__n); | |
| 800 | __construct_at_end(__first, __last, __n); | |
| 801 | } | |
| 802 | ||
| 803 | __guard.__complete(); | |
| 804 | } | |
| 805 | ||
| 806 | template <class _InputIterator, class _Sentinel> | |
| 807 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 808 | __init_with_sentinel(_InputIterator __first, _Sentinel __last) { | |
| 809 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 810 | ||
| 811 | for (; __first != __last; ++__first) | |
| 812 | emplace_back(*__first); | |
| 813 | ||
| 814 | __guard.__complete(); | |
| 815 | } | |
| 816 | ||
| 817 | template <class _Iterator, class _Sentinel> | |
| 818 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last); | |
| 819 | ||
| 820 | template <class _ForwardIterator, class _Sentinel> | |
| 821 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 822 | __assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __n); | |
| 823 | ||
| 824 | template <class _InputIterator, class _Sentinel> | |
| 825 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 826 | __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last); | |
| 827 | ||
| 828 | template <class _Iterator, class _Sentinel> | |
| 829 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 830 | __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n); | |
| 831 | ||
| 832 | template <class _InputIterator, class _Sentinel> | |
| 833 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 834 | __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n); | |
| 835 | ||
| 836 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n); | |
| 837 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x); | |
| 838 | ||
| 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 | |
| 855 | return iterator(__p); | |
| 856 | #endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | |
| 857 | } | |
| 858 | ||
| 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 | |
| 867 | return const_iterator(__p); | |
| 868 | #endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR | |
| 869 | } | |
| 870 | ||
| 871 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 872 | __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); | |
| 873 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer | |
| 874 | __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p); | |
| 875 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 876 | __move_range(pointer __from_s, pointer __from_e, pointer __to); | |
| 877 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type) | |
| 878 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | |
| 879 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, false_type) | |
| 880 | _NOEXCEPT_(__alloc_traits::is_always_equal::value); | |
| 881 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last) _NOEXCEPT { | |
| 882 | size_type __old_size = size(); | |
| 883 | __base_destruct_at_end(__new_last); | |
| 884 | __annotate_shrink(__old_size); | |
| 885 | } | |
| 886 | ||
| 887 | template <class _Up> | |
| 888 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __push_back_slow_path(_Up&& __x); | |
| 889 | ||
| 890 | template <class... _Args> | |
| 891 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI inline pointer __emplace_back_slow_path(_Args&&... __args); | |
| 892 | ||
| 893 | // The following functions are no-ops outside of AddressSanitizer mode. | |
| 894 | // We call annotations for every allocator, unless explicitly disabled. | |
| 895 | // | |
| 896 | // To disable annotations for a particular allocator, change value of | |
| 897 | // __asan_annotate_container_with_allocator to false. | |
| 898 | // For more details, see the "Using libc++" documentation page or | |
| 899 | // the documentation for __sanitizer_annotate_contiguous_container. | |
| 900 | ||
| 901 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 902 | __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const { | |
| 903 | std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity(), __old_mid, __new_mid); | |
| 904 | } | |
| 905 | ||
| 906 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { | |
| 907 | (void)__current_size; | |
| 908 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 909 | __annotate_contiguous_container(data() + capacity(), data() + __current_size); | |
| 910 | #endif | |
| 911 | } | |
| 912 | ||
| 913 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT { | |
| 914 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 915 | __annotate_contiguous_container(data() + size(), data() + capacity()); | |
| 916 | #endif | |
| 917 | } | |
| 918 | ||
| 919 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT { | |
| 920 | (void)__n; | |
| 921 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 922 | __annotate_contiguous_container(data() + size(), data() + size() + __n); | |
| 923 | #endif | |
| 924 | } | |
| 925 | ||
| 926 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT { | |
| 927 | (void)__old_size; | |
| 928 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 929 | __annotate_contiguous_container(data() + __old_size, data() + size()); | |
| 930 | #endif | |
| 931 | } | |
| 932 | ||
| 933 | struct _ConstructTransaction { | |
| 934 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n) | |
| 935 | : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { | |
| 936 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 937 | __v_.__annotate_increase(__n); | |
| 938 | #endif | |
| 939 | } | |
| 940 | ||
| 941 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { | |
| 942 | __v_.__end_ = __pos_; | |
| 943 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 944 | if (__pos_ != __new_end_) { | |
| 945 | __v_.__annotate_shrink(__new_end_ - __v_.__begin_); | |
| 946 | } | |
| 947 | #endif | |
| 948 | } | |
| 949 | ||
| 950 | vector& __v_; | |
| 951 | pointer __pos_; | |
| 952 | const_pointer const __new_end_; | |
| 953 | ||
| 954 | _ConstructTransaction(_ConstructTransaction const&) = delete; | |
| 955 | _ConstructTransaction& operator=(_ConstructTransaction const&) = delete; | |
| 956 | }; | |
| 957 | ||
| 958 | template <class... _Args> | |
| 959 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_one_at_end(_Args&&... __args) { | |
| 960 | _ConstructTransaction __tx(*this, 1); | |
| 961 | __alloc_traits::construct(this->__alloc(), std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...); | |
| 962 | ++__tx.__pos_; | |
| 963 | } | |
| 964 | ||
| 965 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { | |
| 966 | return this->__end_cap_.second(); | |
| 967 | } | |
| 968 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { | |
| 969 | return this->__end_cap_.second(); | |
| 970 | } | |
| 971 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT { | |
| 972 | return this->__end_cap_.first(); | |
| 973 | } | |
| 974 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT { | |
| 975 | return this->__end_cap_.first(); | |
| 976 | } | |
| 977 | ||
| 978 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __clear() _NOEXCEPT { | |
| 979 | __base_destruct_at_end(this->__begin_); | |
| 980 | } | |
| 981 | ||
| 982 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT { | |
| 983 | pointer __soon_to_be_end = this->__end_; | |
| 984 | while (__new_last != __soon_to_be_end) | |
| 985 | __alloc_traits::destroy(__alloc(), std::__to_address(--__soon_to_be_end)); | |
| 986 | this->__end_ = __new_last; | |
| 987 | } | |
| 988 | ||
| 989 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c) { | |
| 990 | __copy_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_copy_assignment::value>()); | |
| 991 | } | |
| 992 | ||
| 993 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c) | |
| 994 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_move_assignment::value || | |
| 995 | is_nothrow_move_assignable<allocator_type>::value) { | |
| 996 | __move_assign_alloc(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); | |
| 997 | } | |
| 998 | ||
| 999 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("vector"); } | |
| 1000 | ||
| 1001 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("vector"); } | |
| 1002 | ||
| 1003 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c, true_type) { | |
| 1004 | if (__alloc() != __c.__alloc()) { | |
| 1005 | __clear(); | |
| 1006 | __annotate_delete(); | |
| 1007 | __alloc_traits::deallocate(__alloc(), this->__begin_, capacity()); | |
| 1008 | this->__begin_ = this->__end_ = __end_cap() = nullptr; | |
| 1009 | } | |
| 1010 | __alloc() = __c.__alloc(); | |
| 1011 | } | |
| 1012 | ||
| 1013 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector&, false_type) {} | |
| 1014 | ||
| 1015 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c, true_type) | |
| 1016 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | |
| 1017 | __alloc() = std::move(__c.__alloc()); | |
| 1018 | } | |
| 1019 | ||
| 1020 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector&, false_type) _NOEXCEPT {} | |
| 1021 | }; | |
| 1022 | ||
| 1023 | #if _LIBCPP_STD_VER >= 17 | |
| 1024 | template <class _InputIterator, | |
| 1025 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, | |
| 1026 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | |
| 1027 | class = enable_if_t<__is_allocator<_Alloc>::value> > | |
| 1028 | vector(_InputIterator, _InputIterator) -> vector<__iter_value_type<_InputIterator>, _Alloc>; | |
| 1029 | ||
| 1030 | template <class _InputIterator, | |
| 1031 | class _Alloc, | |
| 1032 | class = enable_if_t<__has_input_iterator_category<_InputIterator>::value>, | |
| 1033 | class = enable_if_t<__is_allocator<_Alloc>::value> > | |
| 1034 | vector(_InputIterator, _InputIterator, _Alloc) -> vector<__iter_value_type<_InputIterator>, _Alloc>; | |
| 1035 | #endif | |
| 1036 | ||
| 1037 | #if _LIBCPP_STD_VER >= 23 | |
| 1038 | template <ranges::input_range _Range, | |
| 1039 | class _Alloc = allocator<ranges::range_value_t<_Range>>, | |
| 1040 | class = enable_if_t<__is_allocator<_Alloc>::value> > | |
| 1041 | vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>; | |
| 1042 | #endif | |
| 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. | |
| 1047 | template <class _Tp, class _Allocator> | |
| 1048 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 1049 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) { | |
| 1050 | __annotate_delete(); | |
| 1051 | auto __new_begin = __v.__begin_ - (__end_ - __begin_); | |
| 1052 | std::__uninitialized_allocator_relocate( | |
| 1053 | __alloc(), std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin)); | |
| 1054 | __v.__begin_ = __new_begin; | |
| 1055 | __end_ = __begin_; // All the objects have been destroyed by relocating them. | |
| 1056 | std::swap(this->__begin_, __v.__begin_); | |
| 1057 | std::swap(this->__end_, __v.__end_); | |
| 1058 | std::swap(this->__end_cap(), __v.__end_cap()); | |
| 1059 | __v.__first_ = __v.__begin_; | |
| 1060 | __annotate_new(size()); | |
| 1061 | } | |
| 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. | |
| 1067 | template <class _Tp, class _Allocator> | |
| 1068 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer | |
| 1069 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) { | |
| 1070 | __annotate_delete(); | |
| 1071 | pointer __ret = __v.__begin_; | |
| 1072 | ||
| 1073 | // Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_) | |
| 1074 | // in case something in [__begin_, __p) throws. | |
| 1075 | std::__uninitialized_allocator_relocate( | |
| 1076 | __alloc(), std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.__end_)); | |
| 1077 | __v.__end_ += (__end_ - __p); | |
| 1078 | __end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them. | |
| 1079 | auto __new_begin = __v.__begin_ - (__p - __begin_); | |
| 1080 | ||
| 1081 | std::__uninitialized_allocator_relocate( | |
| 1082 | __alloc(), std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin)); | |
| 1083 | __v.__begin_ = __new_begin; | |
| 1084 | __end_ = __begin_; // All the objects have been destroyed by relocating them. | |
| 1085 | ||
| 1086 | std::swap(this->__begin_, __v.__begin_); | |
| 1087 | std::swap(this->__end_, __v.__end_); | |
| 1088 | std::swap(this->__end_cap(), __v.__end_cap()); | |
| 1089 | __v.__first_ = __v.__begin_; | |
| 1090 | __annotate_new(size()); | |
| 1091 | return __ret; | |
| 1092 | } | |
| 1093 | ||
| 1094 | template <class _Tp, class _Allocator> | |
| 1095 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT { | |
| 1096 | if (this->__begin_ != nullptr) { | |
| 1097 | clear(); | |
| 1098 | __annotate_delete(); | |
| 1099 | __alloc_traits::deallocate(this->__alloc(), this->__begin_, capacity()); | |
| 1100 | this->__begin_ = this->__end_ = this->__end_cap() = nullptr; | |
| 1101 | } | |
| 1102 | } | |
| 1103 | ||
| 1104 | template <class _Tp, class _Allocator> | |
| 1105 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::size_type | |
| 1106 | vector<_Tp, _Allocator>::max_size() const _NOEXCEPT { | |
| 1107 | return std::min<size_type>(__alloc_traits::max_size(this->__alloc()), numeric_limits<difference_type>::max()); | |
| 1108 | } | |
| 1109 | ||
| 1110 | // Precondition: __new_size > capacity() | |
| 1111 | template <class _Tp, class _Allocator> | |
| 1112 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type | |
| 1113 | vector<_Tp, _Allocator>::__recommend(size_type __new_size) const { | |
| 1114 | const size_type __ms = max_size(); | |
| 1115 | if (__new_size > __ms) | |
| 1116 | this->__throw_length_error(); | |
| 1117 | const size_type __cap = capacity(); | |
| 1118 | if (__cap >= __ms / 2) | |
| 1119 | return __ms; | |
| 1120 | return std::max<size_type>(2 * __cap, __new_size); | |
| 1121 | } | |
| 1122 | ||
| 1123 | // Default constructs __n objects starting at __end_ | |
| 1124 | // throws if construction throws | |
| 1125 | // Precondition: __n > 0 | |
| 1126 | // Precondition: size() + __n <= capacity() | |
| 1127 | // Postcondition: size() == size() + __n | |
| 1128 | template <class _Tp, class _Allocator> | |
| 1129 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__construct_at_end(size_type __n) { | |
| 1130 | _ConstructTransaction __tx(*this, __n); | |
| 1131 | const_pointer __new_end = __tx.__new_end_; | |
| 1132 | for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) { | |
| 1133 | __alloc_traits::construct(this->__alloc(), std::__to_address(__pos)); | |
| 1134 | } | |
| 1135 | } | |
| 1136 | ||
| 1137 | // Copy constructs __n objects starting at __end_ from __x | |
| 1138 | // throws if construction throws | |
| 1139 | // Precondition: __n > 0 | |
| 1140 | // Precondition: size() + __n <= capacity() | |
| 1141 | // Postcondition: size() == old size() + __n | |
| 1142 | // Postcondition: [i] == __x for all i in [size() - __n, __n) | |
| 1143 | template <class _Tp, class _Allocator> | |
| 1144 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void | |
| 1145 | vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { | |
| 1146 | _ConstructTransaction __tx(*this, __n); | |
| 1147 | const_pointer __new_end = __tx.__new_end_; | |
| 1148 | for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) { | |
| 1149 | __alloc_traits::construct(this->__alloc(), std::__to_address(__pos), __x); | |
| 1150 | } | |
| 1151 | } | |
| 1152 | ||
| 1153 | template <class _Tp, class _Allocator> | |
| 1154 | template <class _InputIterator, class _Sentinel> | |
| 1155 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 1156 | vector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) { | |
| 1157 | _ConstructTransaction __tx(*this, __n); | |
| 1158 | __tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_); | |
| 1159 | } | |
| 1160 | ||
| 1161 | // Default constructs __n objects starting at __end_ | |
| 1162 | // throws if construction throws | |
| 1163 | // Postcondition: size() == size() + __n | |
| 1164 | // Exception safety: strong. | |
| 1165 | template <class _Tp, class _Allocator> | |
| 1166 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n) { | |
| 1167 | if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) | |
| 1168 | this->__construct_at_end(__n); | |
| 1169 | else { | |
| 1170 | allocator_type& __a = this->__alloc(); | |
| 1171 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a); | |
| 1172 | __v.__construct_at_end(__n); | |
| 1173 | __swap_out_circular_buffer(__v); | |
| 1174 | } | |
| 1175 | } | |
| 1176 | ||
| 1177 | // Default constructs __n objects starting at __end_ | |
| 1178 | // throws if construction throws | |
| 1179 | // Postcondition: size() == size() + __n | |
| 1180 | // Exception safety: strong. | |
| 1181 | template <class _Tp, class _Allocator> | |
| 1182 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) { | |
| 1183 | if (static_cast<size_type>(this->__end_cap() - this->__end_) >= __n) | |
| 1184 | this->__construct_at_end(__n, __x); | |
| 1185 | else { | |
| 1186 | allocator_type& __a = this->__alloc(); | |
| 1187 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), size(), __a); | |
| 1188 | __v.__construct_at_end(__n, __x); | |
| 1189 | __swap_out_circular_buffer(__v); | |
| 1190 | } | |
| 1191 | } | |
| 1192 | ||
| 1193 | template <class _Tp, class _Allocator> | |
| 1194 | template <class _InputIterator, | |
| 1195 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 1196 | is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value, | |
| 1197 | int> > | |
| 1198 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last) { | |
| 1199 | __init_with_sentinel(__first, __last); | |
| 1200 | } | |
| 1201 | ||
| 1202 | template <class _Tp, class _Allocator> | |
| 1203 | template <class _InputIterator, | |
| 1204 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 1205 | is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value, | |
| 1206 | int> > | |
| 1207 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 1208 | vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a) | |
| 1209 | : __end_cap_(nullptr, __a) { | |
| 1210 | __init_with_sentinel(__first, __last); | |
| 1211 | } | |
| 1212 | ||
| 1213 | template <class _Tp, class _Allocator> | |
| 1214 | template <class _ForwardIterator, | |
| 1215 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 1216 | is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 1217 | int> > | |
| 1218 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last) { | |
| 1219 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | |
| 1220 | __init_with_size(__first, __last, __n); | |
| 1221 | } | |
| 1222 | ||
| 1223 | template <class _Tp, class _Allocator> | |
| 1224 | template <class _ForwardIterator, | |
| 1225 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 1226 | is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 1227 | int> > | |
| 1228 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 1229 | vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a) | |
| 1230 | : __end_cap_(nullptr, __a) { | |
| 1231 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | |
| 1232 | __init_with_size(__first, __last, __n); | |
| 1233 | } | |
| 1234 | ||
| 1235 | template <class _Tp, class _Allocator> | |
| 1236 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(const vector& __x) | |
| 1237 | : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc())) { | |
| 1238 | __init_with_size(__x.__begin_, __x.__end_, __x.size()); | |
| 1239 | } | |
| 1240 | ||
| 1241 | template <class _Tp, class _Allocator> | |
| 1242 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 1243 | vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | |
| 1244 | : __end_cap_(nullptr, __a) { | |
| 1245 | __init_with_size(__x.__begin_, __x.__end_, __x.size()); | |
| 1246 | } | |
| 1247 | ||
| 1248 | template <class _Tp, class _Allocator> | |
| 1249 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>::vector(vector&& __x) | |
| 1250 | #if _LIBCPP_STD_VER >= 17 | |
| 1251 | noexcept | |
| 1252 | #else | |
| 1253 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | |
| 1254 | #endif | |
| 1255 | : __end_cap_(nullptr, std::move(__x.__alloc())) { | |
| 1256 | this->__begin_ = __x.__begin_; | |
| 1257 | this->__end_ = __x.__end_; | |
| 1258 | this->__end_cap() = __x.__end_cap(); | |
| 1259 | __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; | |
| 1260 | } | |
| 1261 | ||
| 1262 | template <class _Tp, class _Allocator> | |
| 1263 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI | |
| 1264 | vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a) | |
| 1265 | : __end_cap_(nullptr, __a) { | |
| 1266 | if (__a == __x.__alloc()) { | |
| 1267 | this->__begin_ = __x.__begin_; | |
| 1268 | this->__end_ = __x.__end_; | |
| 1269 | this->__end_cap() = __x.__end_cap(); | |
| 1270 | __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; | |
| 1271 | } else { | |
| 1272 | typedef move_iterator<iterator> _Ip; | |
| 1273 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 1274 | assign(_Ip(__x.begin()), _Ip(__x.end())); | |
| 1275 | __guard.__complete(); | |
| 1276 | } | |
| 1277 | } | |
| 1278 | ||
| 1279 | #ifndef _LIBCPP_CXX03_LANG | |
| 1280 | ||
| 1281 | template <class _Tp, class _Allocator> | |
| 1282 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI | |
| 1283 | vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) { | |
| 1284 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 1285 | if (__il.size() > 0) { | |
| 1286 | __vallocate(__il.size()); | |
| 1287 | __construct_at_end(__il.begin(), __il.end(), __il.size()); | |
| 1288 | } | |
| 1289 | __guard.__complete(); | |
| 1290 | } | |
| 1291 | ||
| 1292 | template <class _Tp, class _Allocator> | |
| 1293 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI | |
| 1294 | vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) | |
| 1295 | : __end_cap_(nullptr, __a) { | |
| 1296 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 1297 | if (__il.size() > 0) { | |
| 1298 | __vallocate(__il.size()); | |
| 1299 | __construct_at_end(__il.begin(), __il.end(), __il.size()); | |
| 1300 | } | |
| 1301 | __guard.__complete(); | |
| 1302 | } | |
| 1303 | ||
| 1304 | #endif // _LIBCPP_CXX03_LANG | |
| 1305 | ||
| 1306 | template <class _Tp, class _Allocator> | |
| 1307 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>& | |
| 1308 | vector<_Tp, _Allocator>::operator=(vector&& __x) | |
| 1309 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { | |
| 1310 | __move_assign(__x, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); | |
| 1311 | return *this; | |
| 1312 | } | |
| 1313 | ||
| 1314 | template <class _Tp, class _Allocator> | |
| 1315 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) | |
| 1316 | _NOEXCEPT_(__alloc_traits::is_always_equal::value) { | |
| 1317 | if (__alloc() != __c.__alloc()) { | |
| 1318 | typedef move_iterator<iterator> _Ip; | |
| 1319 | assign(_Ip(__c.begin()), _Ip(__c.end())); | |
| 1320 | } else | |
| 1321 | __move_assign(__c, true_type()); | |
| 1322 | } | |
| 1323 | ||
| 1324 | template <class _Tp, class _Allocator> | |
| 1325 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) | |
| 1326 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | |
| 1327 | __vdeallocate(); | |
| 1328 | __move_assign_alloc(__c); // this can throw | |
| 1329 | this->__begin_ = __c.__begin_; | |
| 1330 | this->__end_ = __c.__end_; | |
| 1331 | this->__end_cap() = __c.__end_cap(); | |
| 1332 | __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; | |
| 1333 | } | |
| 1334 | ||
| 1335 | template <class _Tp, class _Allocator> | |
| 1336 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>& | |
| 1337 | vector<_Tp, _Allocator>::operator=(const vector& __x) { | |
| 1338 | if (this != std::addressof(__x)) { | |
| 1339 | __copy_assign_alloc(__x); | |
| 1340 | assign(__x.__begin_, __x.__end_); | |
| 1341 | } | |
| 1342 | return *this; | |
| 1343 | } | |
| 1344 | ||
| 1345 | template <class _Tp, class _Allocator> | |
| 1346 | template <class _InputIterator, | |
| 1347 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 1348 | is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value, | |
| 1349 | int> > | |
| 1350 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { | |
| 1351 | __assign_with_sentinel(__first, __last); | |
| 1352 | } | |
| 1353 | ||
| 1354 | template <class _Tp, class _Allocator> | |
| 1355 | template <class _Iterator, class _Sentinel> | |
| 1356 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 1357 | vector<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) { | |
| 1358 | clear(); | |
| 1359 | for (; __first != __last; ++__first) | |
| 1360 | emplace_back(*__first); | |
| 1361 | } | |
| 1362 | ||
| 1363 | template <class _Tp, class _Allocator> | |
| 1364 | template <class _ForwardIterator, | |
| 1365 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 1366 | is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 1367 | int> > | |
| 1368 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) { | |
| 1369 | __assign_with_size(__first, __last, std::distance(__first, __last)); | |
| 1370 | } | |
| 1371 | ||
| 1372 | template <class _Tp, class _Allocator> | |
| 1373 | template <class _ForwardIterator, class _Sentinel> | |
| 1374 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 1375 | vector<_Tp, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __n) { | |
| 1376 | size_type __new_size = static_cast<size_type>(__n); | |
| 1377 | if (__new_size <= capacity()) { | |
| 1378 | if (__new_size > size()) { | |
| 1379 | _ForwardIterator __mid = std::next(__first, size()); | |
| 1380 | std::copy(__first, __mid, this->__begin_); | |
| 1381 | __construct_at_end(__mid, __last, __new_size - size()); | |
| 1382 | } else { | |
| 1383 | pointer __m = std::__copy<_ClassicAlgPolicy>(__first, __last, this->__begin_).second; | |
| 1384 | this->__destruct_at_end(__m); | |
| 1385 | } | |
| 1386 | } else { | |
| 1387 | __vdeallocate(); | |
| 1388 | __vallocate(__recommend(__new_size)); | |
| 1389 | __construct_at_end(__first, __last, __new_size); | |
| 1390 | } | |
| 1391 | } | |
| 1392 | ||
| 1393 | template <class _Tp, class _Allocator> | |
| 1394 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) { | |
| 1395 | if (__n <= capacity()) { | |
| 1396 | size_type __s = size(); | |
| 1397 | std::fill_n(this->__begin_, std::min(__n, __s), __u); | |
| 1398 | if (__n > __s) | |
| 1399 | __construct_at_end(__n - __s, __u); | |
| 1400 | else | |
| 1401 | this->__destruct_at_end(this->__begin_ + __n); | |
| 1402 | } else { | |
| 1403 | __vdeallocate(); | |
| 1404 | __vallocate(__recommend(static_cast<size_type>(__n))); | |
| 1405 | __construct_at_end(__n, __u); | |
| 1406 | } | |
| 1407 | } | |
| 1408 | ||
| 1409 | template <class _Tp, class _Allocator> | |
| 1410 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator | |
| 1411 | vector<_Tp, _Allocator>::begin() _NOEXCEPT { | |
| 1412 | return __make_iter(this->__begin_); | |
| 1413 | } | |
| 1414 | ||
| 1415 | template <class _Tp, class _Allocator> | |
| 1416 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_iterator | |
| 1417 | vector<_Tp, _Allocator>::begin() const _NOEXCEPT { | |
| 1418 | return __make_iter(this->__begin_); | |
| 1419 | } | |
| 1420 | ||
| 1421 | template <class _Tp, class _Allocator> | |
| 1422 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator | |
| 1423 | vector<_Tp, _Allocator>::end() _NOEXCEPT { | |
| 1424 | return __make_iter(this->__end_); | |
| 1425 | } | |
| 1426 | ||
| 1427 | template <class _Tp, class _Allocator> | |
| 1428 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_iterator | |
| 1429 | vector<_Tp, _Allocator>::end() const _NOEXCEPT { | |
| 1430 | return __make_iter(this->__end_); | |
| 1431 | } | |
| 1432 | ||
| 1433 | template <class _Tp, class _Allocator> | |
| 1434 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::reference | |
| 1435 | vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT { | |
| 1436 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds"); | |
| 1437 | return this->__begin_[__n]; | |
| 1438 | } | |
| 1439 | ||
| 1440 | template <class _Tp, class _Allocator> | |
| 1441 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::const_reference | |
| 1442 | vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT { | |
| 1443 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds"); | |
| 1444 | return this->__begin_[__n]; | |
| 1445 | } | |
| 1446 | ||
| 1447 | template <class _Tp, class _Allocator> | |
| 1448 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::at(size_type __n) { | |
| 1449 | if (__n >= size()) | |
| 1450 | this->__throw_out_of_range(); | |
| 1451 | return this->__begin_[__n]; | |
| 1452 | } | |
| 1453 | ||
| 1454 | template <class _Tp, class _Allocator> | |
| 1455 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::const_reference | |
| 1456 | vector<_Tp, _Allocator>::at(size_type __n) const { | |
| 1457 | if (__n >= size()) | |
| 1458 | this->__throw_out_of_range(); | |
| 1459 | return this->__begin_[__n]; | |
| 1460 | } | |
| 1461 | ||
| 1462 | template <class _Tp, class _Allocator> | |
| 1463 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __n) { | |
| 1464 | if (__n > capacity()) { | |
| 1465 | if (__n > max_size()) | |
| 1466 | this->__throw_length_error(); | |
| 1467 | allocator_type& __a = this->__alloc(); | |
| 1468 | __split_buffer<value_type, allocator_type&> __v(__n, size(), __a); | |
| 1469 | __swap_out_circular_buffer(__v); | |
| 1470 | } | |
| 1471 | } | |
| 1472 | ||
| 1473 | template <class _Tp, class _Allocator> | |
| 1474 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { | |
| 1475 | if (capacity() > size()) { | |
| 1476 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1477 | try { | |
| 1478 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1479 | allocator_type& __a = this->__alloc(); | |
| 1480 | __split_buffer<value_type, allocator_type&> __v(size(), size(), __a); | |
| 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); | |
| 1486 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1487 | } catch (...) { | |
| 1488 | } | |
| 1489 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1490 | } | |
| 1491 | } | |
| 1492 | ||
| 1493 | template <class _Tp, class _Allocator> | |
| 1494 | template <class _Up> | |
| 1495 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer | |
| 1496 | vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) { | |
| 1497 | allocator_type& __a = this->__alloc(); | |
| 1498 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); | |
| 1499 | // __v.push_back(std::forward<_Up>(__x)); | |
| 1500 | __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Up>(__x)); | |
| 1501 | __v.__end_++; | |
| 1502 | __swap_out_circular_buffer(__v); | |
| 1503 | return this->__end_; | |
| 1504 | } | |
| 1505 | ||
| 1506 | template <class _Tp, class _Allocator> | |
| 1507 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void | |
| 1508 | vector<_Tp, _Allocator>::push_back(const_reference __x) { | |
| 1509 | pointer __end = this->__end_; | |
| 1510 | if (__end < this->__end_cap()) { | |
| 1511 | __construct_one_at_end(__x); | |
| 1512 | ++__end; | |
| 1513 | } else { | |
| 1514 | __end = __push_back_slow_path(__x); | |
| 1515 | } | |
| 1516 | this->__end_ = __end; | |
| 1517 | } | |
| 1518 | ||
| 1519 | template <class _Tp, class _Allocator> | |
| 1520 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void vector<_Tp, _Allocator>::push_back(value_type&& __x) { | |
| 1521 | pointer __end = this->__end_; | |
| 1522 | if (__end < this->__end_cap()) { | |
| 1523 | __construct_one_at_end(std::move(__x)); | |
| 1524 | ++__end; | |
| 1525 | } else { | |
| 1526 | __end = __push_back_slow_path(std::move(__x)); | |
| 1527 | } | |
| 1528 | this->__end_ = __end; | |
| 1529 | } | |
| 1530 | ||
| 1531 | template <class _Tp, class _Allocator> | |
| 1532 | template <class... _Args> | |
| 1533 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer | |
| 1534 | vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) { | |
| 1535 | allocator_type& __a = this->__alloc(); | |
| 1536 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); | |
| 1537 | // __v.emplace_back(std::forward<_Args>(__args)...); | |
| 1538 | __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Args>(__args)...); | |
| 1539 | __v.__end_++; | |
| 1540 | __swap_out_circular_buffer(__v); | |
| 1541 | return this->__end_; | |
| 1542 | } | |
| 1543 | ||
| 1544 | template <class _Tp, class _Allocator> | |
| 1545 | template <class... _Args> | |
| 1546 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline | |
| 1547 | #if _LIBCPP_STD_VER >= 17 | |
| 1548 | typename vector<_Tp, _Allocator>::reference | |
| 307 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 308 | # include <__cxx03/vector> | |
| 1549 | 309 | #else |
| 1550 | void | |
| 1551 | #endif | |
| 1552 | vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { | |
| 1553 | pointer __end = this->__end_; | |
| 1554 | if (__end < this->__end_cap()) { | |
| 1555 | __construct_one_at_end(std::forward<_Args>(__args)...); | |
| 1556 | ++__end; | |
| 1557 | } else { | |
| 1558 | __end = __emplace_back_slow_path(std::forward<_Args>(__args)...); | |
| 1559 | } | |
| 1560 | this->__end_ = __end; | |
| 1561 | #if _LIBCPP_STD_VER >= 17 | |
| 1562 | return *(__end - 1); | |
| 1563 | #endif | |
| 1564 | } | |
| 1565 | ||
| 1566 | template <class _Tp, class _Allocator> | |
| 1567 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline void vector<_Tp, _Allocator>::pop_back() { | |
| 1568 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector::pop_back called on an empty vector"); | |
| 1569 | this->__destruct_at_end(this->__end_ - 1); | |
| 1570 | } | |
| 1571 | ||
| 1572 | template <class _Tp, class _Allocator> | |
| 1573 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator | |
| 1574 | vector<_Tp, _Allocator>::erase(const_iterator __position) { | |
| 1575 | _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS( | |
| 1576 | __position != end(), "vector::erase(iterator) called with a non-dereferenceable iterator"); | |
| 1577 | difference_type __ps = __position - cbegin(); | |
| 1578 | pointer __p = this->__begin_ + __ps; | |
| 1579 | this->__destruct_at_end(std::move(__p + 1, this->__end_, __p)); | |
| 1580 | return __make_iter(__p); | |
| 1581 | } | |
| 1582 | ||
| 1583 | template <class _Tp, class _Allocator> | |
| 1584 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1585 | vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) { | |
| 1586 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "vector::erase(first, last) called with invalid range"); | |
| 1587 | pointer __p = this->__begin_ + (__first - begin()); | |
| 1588 | if (__first != __last) { | |
| 1589 | this->__destruct_at_end(std::move(__p + (__last - __first), this->__end_, __p)); | |
| 1590 | } | |
| 1591 | return __make_iter(__p); | |
| 1592 | } | |
| 1593 | ||
| 1594 | template <class _Tp, class _Allocator> | |
| 1595 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 1596 | vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) { | |
| 1597 | pointer __old_last = this->__end_; | |
| 1598 | difference_type __n = __old_last - __to; | |
| 1599 | { | |
| 1600 | pointer __i = __from_s + __n; | |
| 1601 | _ConstructTransaction __tx(*this, __from_e - __i); | |
| 1602 | for (pointer __pos = __tx.__pos_; __i < __from_e; ++__i, (void)++__pos, __tx.__pos_ = __pos) { | |
| 1603 | __alloc_traits::construct(this->__alloc(), std::__to_address(__pos), std::move(*__i)); | |
| 1604 | } | |
| 1605 | } | |
| 1606 | std::move_backward(__from_s, __from_s + __n, __old_last); | |
| 1607 | } | |
| 1608 | ||
| 1609 | template <class _Tp, class _Allocator> | |
| 1610 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1611 | vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) { | |
| 1612 | pointer __p = this->__begin_ + (__position - begin()); | |
| 1613 | if (this->__end_ < this->__end_cap()) { | |
| 1614 | if (__p == this->__end_) { | |
| 1615 | __construct_one_at_end(__x); | |
| 1616 | } else { | |
| 1617 | __move_range(__p, this->__end_, __p + 1); | |
| 1618 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); | |
| 1619 | if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x))) | |
| 1620 | ++__xr; | |
| 1621 | *__p = *__xr; | |
| 1622 | } | |
| 1623 | } else { | |
| 1624 | allocator_type& __a = this->__alloc(); | |
| 1625 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); | |
| 1626 | __v.push_back(__x); | |
| 1627 | __p = __swap_out_circular_buffer(__v, __p); | |
| 1628 | } | |
| 1629 | return __make_iter(__p); | |
| 1630 | } | |
| 1631 | ||
| 1632 | template <class _Tp, class _Allocator> | |
| 1633 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1634 | vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { | |
| 1635 | pointer __p = this->__begin_ + (__position - begin()); | |
| 1636 | if (this->__end_ < this->__end_cap()) { | |
| 1637 | if (__p == this->__end_) { | |
| 1638 | __construct_one_at_end(std::move(__x)); | |
| 1639 | } else { | |
| 1640 | __move_range(__p, this->__end_, __p + 1); | |
| 1641 | *__p = std::move(__x); | |
| 1642 | } | |
| 1643 | } else { | |
| 1644 | allocator_type& __a = this->__alloc(); | |
| 1645 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); | |
| 1646 | __v.push_back(std::move(__x)); | |
| 1647 | __p = __swap_out_circular_buffer(__v, __p); | |
| 1648 | } | |
| 1649 | return __make_iter(__p); | |
| 1650 | } | |
| 1651 | ||
| 1652 | template <class _Tp, class _Allocator> | |
| 1653 | template <class... _Args> | |
| 1654 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1655 | vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { | |
| 1656 | pointer __p = this->__begin_ + (__position - begin()); | |
| 1657 | if (this->__end_ < this->__end_cap()) { | |
| 1658 | if (__p == this->__end_) { | |
| 1659 | __construct_one_at_end(std::forward<_Args>(__args)...); | |
| 1660 | } else { | |
| 1661 | __temp_value<value_type, _Allocator> __tmp(this->__alloc(), std::forward<_Args>(__args)...); | |
| 1662 | __move_range(__p, this->__end_, __p + 1); | |
| 1663 | *__p = std::move(__tmp.get()); | |
| 1664 | } | |
| 1665 | } else { | |
| 1666 | allocator_type& __a = this->__alloc(); | |
| 1667 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), __p - this->__begin_, __a); | |
| 1668 | __v.emplace_back(std::forward<_Args>(__args)...); | |
| 1669 | __p = __swap_out_circular_buffer(__v, __p); | |
| 1670 | } | |
| 1671 | return __make_iter(__p); | |
| 1672 | } | |
| 1673 | ||
| 1674 | template <class _Tp, class _Allocator> | |
| 1675 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1676 | vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) { | |
| 1677 | pointer __p = this->__begin_ + (__position - begin()); | |
| 1678 | if (__n > 0) { | |
| 1679 | // We can't compare unrelated pointers inside constant expressions | |
| 1680 | if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_)) { | |
| 1681 | size_type __old_n = __n; | |
| 1682 | pointer __old_last = this->__end_; | |
| 1683 | if (__n > static_cast<size_type>(this->__end_ - __p)) { | |
| 1684 | size_type __cx = __n - (this->__end_ - __p); | |
| 1685 | __construct_at_end(__cx, __x); | |
| 1686 | __n -= __cx; | |
| 1687 | } | |
| 1688 | if (__n > 0) { | |
| 1689 | __move_range(__p, __old_last, __p + __old_n); | |
| 1690 | const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x); | |
| 1691 | if (__p <= __xr && __xr < this->__end_) | |
| 1692 | __xr += __old_n; | |
| 1693 | std::fill_n(__p, __n, *__xr); | |
| 1694 | } | |
| 1695 | } else { | |
| 1696 | allocator_type& __a = this->__alloc(); | |
| 1697 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a); | |
| 1698 | __v.__construct_at_end(__n, __x); | |
| 1699 | __p = __swap_out_circular_buffer(__v, __p); | |
| 1700 | } | |
| 1701 | } | |
| 1702 | return __make_iter(__p); | |
| 1703 | } | |
| 1704 | template <class _Tp, class _Allocator> | |
| 1705 | template <class _InputIterator, | |
| 1706 | __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value && | |
| 1707 | is_constructible<_Tp, typename iterator_traits<_InputIterator>::reference>::value, | |
| 1708 | int> > | |
| 1709 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1710 | vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { | |
| 1711 | return __insert_with_sentinel(__position, __first, __last); | |
| 1712 | } | |
| 1713 | ||
| 1714 | template <class _Tp, class _Allocator> | |
| 1715 | template <class _InputIterator, class _Sentinel> | |
| 1716 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator | |
| 1717 | vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) { | |
| 1718 | difference_type __off = __position - begin(); | |
| 1719 | pointer __p = this->__begin_ + __off; | |
| 1720 | allocator_type& __a = this->__alloc(); | |
| 1721 | pointer __old_last = this->__end_; | |
| 1722 | for (; this->__end_ != this->__end_cap() && __first != __last; ++__first) { | |
| 1723 | __construct_one_at_end(*__first); | |
| 1724 | } | |
| 1725 | __split_buffer<value_type, allocator_type&> __v(__a); | |
| 1726 | if (__first != __last) { | |
| 1727 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1728 | try { | |
| 1729 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1730 | __v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last)); | |
| 1731 | difference_type __old_size = __old_last - this->__begin_; | |
| 1732 | difference_type __old_p = __p - this->__begin_; | |
| 1733 | reserve(__recommend(size() + __v.size())); | |
| 1734 | __p = this->__begin_ + __old_p; | |
| 1735 | __old_last = this->__begin_ + __old_size; | |
| 1736 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1737 | } catch (...) { | |
| 1738 | erase(__make_iter(__old_last), end()); | |
| 1739 | throw; | |
| 1740 | } | |
| 1741 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 1742 | } | |
| 1743 | __p = std::rotate(__p, __old_last, this->__end_); | |
| 1744 | insert(__make_iter(__p), std::make_move_iterator(__v.begin()), std::make_move_iterator(__v.end())); | |
| 1745 | return begin() + __off; | |
| 1746 | } | |
| 1747 | ||
| 1748 | template <class _Tp, class _Allocator> | |
| 1749 | template <class _ForwardIterator, | |
| 1750 | __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value && | |
| 1751 | is_constructible<_Tp, typename iterator_traits<_ForwardIterator>::reference>::value, | |
| 1752 | int> > | |
| 1753 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator | |
| 1754 | vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) { | |
| 1755 | return __insert_with_size(__position, __first, __last, std::distance(__first, __last)); | |
| 1756 | } | |
| 1757 | ||
| 1758 | template <class _Tp, class _Allocator> | |
| 1759 | template <class _Iterator, class _Sentinel> | |
| 1760 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator | |
| 1761 | vector<_Tp, _Allocator>::__insert_with_size( | |
| 1762 | const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n) { | |
| 1763 | auto __insertion_size = __n; | |
| 1764 | pointer __p = this->__begin_ + (__position - begin()); | |
| 1765 | if (__n > 0) { | |
| 1766 | if (__n <= this->__end_cap() - this->__end_) { | |
| 1767 | size_type __old_n = __n; | |
| 1768 | pointer __old_last = this->__end_; | |
| 1769 | _Iterator __m = std::next(__first, __n); | |
| 1770 | difference_type __dx = this->__end_ - __p; | |
| 1771 | if (__n > __dx) { | |
| 1772 | __m = __first; | |
| 1773 | difference_type __diff = this->__end_ - __p; | |
| 1774 | std::advance(__m, __diff); | |
| 1775 | __construct_at_end(__m, __last, __n - __diff); | |
| 1776 | __n = __dx; | |
| 1777 | } | |
| 1778 | if (__n > 0) { | |
| 1779 | __move_range(__p, __old_last, __p + __old_n); | |
| 1780 | std::copy(__first, __m, __p); | |
| 1781 | } | |
| 1782 | } else { | |
| 1783 | allocator_type& __a = this->__alloc(); | |
| 1784 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, __a); | |
| 1785 | __v.__construct_at_end_with_size(__first, __insertion_size); | |
| 1786 | __p = __swap_out_circular_buffer(__v, __p); | |
| 1787 | } | |
| 1788 | } | |
| 1789 | return __make_iter(__p); | |
| 1790 | } | |
| 1791 | ||
| 1792 | template <class _Tp, class _Allocator> | |
| 1793 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz) { | |
| 1794 | size_type __cs = size(); | |
| 1795 | if (__cs < __sz) | |
| 1796 | this->__append(__sz - __cs); | |
| 1797 | else if (__cs > __sz) | |
| 1798 | this->__destruct_at_end(this->__begin_ + __sz); | |
| 1799 | } | |
| 1800 | ||
| 1801 | template <class _Tp, class _Allocator> | |
| 1802 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) { | |
| 1803 | size_type __cs = size(); | |
| 1804 | if (__cs < __sz) | |
| 1805 | this->__append(__sz - __cs, __x); | |
| 1806 | else if (__cs > __sz) | |
| 1807 | this->__destruct_at_end(this->__begin_ + __sz); | |
| 1808 | } | |
| 1809 | ||
| 1810 | template <class _Tp, class _Allocator> | |
| 1811 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x) | |
| 1812 | #if _LIBCPP_STD_VER >= 14 | |
| 1813 | _NOEXCEPT | |
| 1814 | #else | |
| 1815 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) | |
| 1816 | #endif | |
| 1817 | { | |
| 1818 | _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( | |
| 1819 | __alloc_traits::propagate_on_container_swap::value || this->__alloc() == __x.__alloc(), | |
| 1820 | "vector::swap: Either propagate_on_container_swap must be true" | |
| 1821 | " or the allocators must compare equal"); | |
| 1822 | std::swap(this->__begin_, __x.__begin_); | |
| 1823 | std::swap(this->__end_, __x.__end_); | |
| 1824 | std::swap(this->__end_cap(), __x.__end_cap()); | |
| 1825 | std::__swap_allocator( | |
| 1826 | this->__alloc(), __x.__alloc(), integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>()); | |
| 1827 | } | |
| 1828 | ||
| 1829 | template <class _Tp, class _Allocator> | |
| 1830 | _LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<_Tp, _Allocator>::__invariants() const { | |
| 1831 | if (this->__begin_ == nullptr) { | |
| 1832 | if (this->__end_ != nullptr || this->__end_cap() != nullptr) | |
| 1833 | return false; | |
| 1834 | } else { | |
| 1835 | if (this->__begin_ > this->__end_) | |
| 1836 | return false; | |
| 1837 | if (this->__begin_ == this->__end_cap()) | |
| 1838 | return false; | |
| 1839 | if (this->__end_ > this->__end_cap()) | |
| 1840 | return false; | |
| 1841 | } | |
| 1842 | return true; | |
| 1843 | } | |
| 1844 | ||
| 1845 | // vector<bool> | |
| 1846 | ||
| 1847 | template <class _Allocator> | |
| 1848 | class vector<bool, _Allocator>; | |
| 1849 | ||
| 1850 | template <class _Allocator> | |
| 1851 | struct hash<vector<bool, _Allocator> >; | |
| 1852 | ||
| 1853 | template <class _Allocator> | |
| 1854 | struct __has_storage_type<vector<bool, _Allocator> > { | |
| 1855 | static const bool value = true; | |
| 1856 | }; | |
| 310 | # include <__config> | |
| 1857 | 311 | |
| 1858 | template <class _Allocator> | |
| 1859 | class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> { | |
| 1860 | public: | |
| 1861 | typedef vector __self; | |
| 1862 | typedef bool value_type; | |
| 1863 | typedef _Allocator allocator_type; | |
| 1864 | typedef allocator_traits<allocator_type> __alloc_traits; | |
| 1865 | typedef typename __alloc_traits::size_type size_type; | |
| 1866 | typedef typename __alloc_traits::difference_type difference_type; | |
| 1867 | typedef size_type __storage_type; | |
| 1868 | typedef __bit_iterator<vector, false> pointer; | |
| 1869 | typedef __bit_iterator<vector, true> const_pointer; | |
| 1870 | typedef pointer iterator; | |
| 1871 | typedef const_pointer const_iterator; | |
| 1872 | typedef std::reverse_iterator<iterator> reverse_iterator; | |
| 1873 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 1874 | ||
| 1875 | private: | |
| 1876 | typedef __rebind_alloc<__alloc_traits, __storage_type> __storage_allocator; | |
| 1877 | typedef allocator_traits<__storage_allocator> __storage_traits; | |
| 1878 | typedef typename __storage_traits::pointer __storage_pointer; | |
| 1879 | typedef typename __storage_traits::const_pointer __const_storage_pointer; | |
| 1880 | ||
| 1881 | __storage_pointer __begin_; | |
| 1882 | size_type __size_; | |
| 1883 | __compressed_pair<size_type, __storage_allocator> __cap_alloc_; | |
| 312 | # include <__vector/comparison.h> | |
| 313 | # include <__vector/swap.h> | |
| 314 | # include <__vector/vector.h> | |
| 315 | # include <__vector/vector_bool.h> | |
| 1884 | 316 | |
| 1885 | public: | |
| 1886 | typedef __bit_reference<vector> reference; | |
| 1887 | #ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | |
| 1888 | using const_reference = bool; | |
| 1889 | #else | |
| 1890 | typedef __bit_const_reference<vector> const_reference; | |
| 1891 | #endif | |
| 1892 | ||
| 1893 | private: | |
| 1894 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type& __cap() _NOEXCEPT { return __cap_alloc_.first(); } | |
| 1895 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const size_type& __cap() const _NOEXCEPT { | |
| 1896 | return __cap_alloc_.first(); | |
| 1897 | } | |
| 1898 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __storage_allocator& __alloc() _NOEXCEPT { | |
| 1899 | return __cap_alloc_.second(); | |
| 1900 | } | |
| 1901 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const __storage_allocator& __alloc() const _NOEXCEPT { | |
| 1902 | return __cap_alloc_.second(); | |
| 1903 | } | |
| 1904 | ||
| 1905 | static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); | |
| 1906 | ||
| 1907 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type | |
| 1908 | __internal_cap_to_external(size_type __n) _NOEXCEPT { | |
| 1909 | return __n * __bits_per_word; | |
| 1910 | } | |
| 1911 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type | |
| 1912 | __external_cap_to_internal(size_type __n) _NOEXCEPT { | |
| 1913 | return (__n - 1) / __bits_per_word + 1; | |
| 1914 | } | |
| 317 | # if _LIBCPP_STD_VER >= 17 | |
| 318 | # include <__vector/pmr.h> | |
| 319 | # endif | |
| 1915 | 320 | |
| 1916 | public: | |
| 1917 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector() | |
| 1918 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); | |
| 321 | # if _LIBCPP_STD_VER >= 20 | |
| 322 | # include <__vector/erase.h> | |
| 323 | # endif | |
| 1919 | 324 | |
| 1920 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(const allocator_type& __a) | |
| 1921 | #if _LIBCPP_STD_VER <= 14 | |
| 1922 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); | |
| 1923 | #else | |
| 1924 | _NOEXCEPT; | |
| 1925 | #endif | |
| 325 | # if _LIBCPP_STD_VER >= 23 | |
| 326 | # include <__vector/vector_bool_formatter.h> | |
| 327 | # endif | |
| 1926 | 328 | |
| 1927 | private: | |
| 1928 | class __destroy_vector { | |
| 1929 | public: | |
| 1930 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {} | |
| 329 | # include <version> | |
| 1931 | 330 | |
| 1932 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() { | |
| 1933 | if (__vec_.__begin_ != nullptr) | |
| 1934 | __storage_traits::deallocate(__vec_.__alloc(), __vec_.__begin_, __vec_.__cap()); | |
| 1935 | } | |
| 331 | // standard-mandated includes | |
| 1936 | 332 | |
| 1937 | private: | |
| 1938 | vector& __vec_; | |
| 1939 | }; | |
| 333 | // [iterator.range] | |
| 334 | # include <__iterator/access.h> | |
| 335 | # include <__iterator/data.h> | |
| 336 | # include <__iterator/empty.h> | |
| 337 | # include <__iterator/reverse_access.h> | |
| 338 | # include <__iterator/size.h> | |
| 1940 | 339 | |
| 1941 | public: | |
| 1942 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector() { __destroy_vector (*this)(); } | |
| 1943 | ||
| 1944 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n); | |
| 1945 | #if _LIBCPP_STD_VER >= 14 | |
| 1946 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n, const allocator_type& __a); | |
| 1947 | #endif | |
| 1948 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v); | |
| 1949 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 1950 | vector(size_type __n, const value_type& __v, const allocator_type& __a); | |
| 1951 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | |
| 1952 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last); | |
| 1953 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | |
| 1954 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 1955 | vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a); | |
| 1956 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | |
| 1957 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last); | |
| 1958 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | |
| 1959 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 1960 | vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a); | |
| 1961 | ||
| 1962 | #if _LIBCPP_STD_VER >= 23 | |
| 1963 | template <_ContainerCompatibleRange<bool> _Range> | |
| 1964 | _LIBCPP_HIDE_FROM_ABI constexpr vector(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type()) | |
| 1965 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { | |
| 1966 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 1967 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 1968 | __init_with_size(ranges::begin(__range), ranges::end(__range), __n); | |
| 1969 | ||
| 1970 | } else { | |
| 1971 | __init_with_sentinel(ranges::begin(__range), ranges::end(__range)); | |
| 1972 | } | |
| 1973 | } | |
| 1974 | #endif | |
| 1975 | ||
| 1976 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v); | |
| 1977 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(const vector& __v, const allocator_type& __a); | |
| 1978 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(const vector& __v); | |
| 1979 | ||
| 1980 | #ifndef _LIBCPP_CXX03_LANG | |
| 1981 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(initializer_list<value_type> __il); | |
| 1982 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 1983 | vector(initializer_list<value_type> __il, const allocator_type& __a); | |
| 1984 | ||
| 1985 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(initializer_list<value_type> __il) { | |
| 1986 | assign(__il.begin(), __il.end()); | |
| 1987 | return *this; | |
| 1988 | } | |
| 1989 | ||
| 1990 | #endif // !_LIBCPP_CXX03_LANG | |
| 1991 | ||
| 1992 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(vector&& __v) | |
| 1993 | #if _LIBCPP_STD_VER >= 17 | |
| 1994 | noexcept; | |
| 1995 | #else | |
| 1996 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); | |
| 1997 | #endif | |
| 1998 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 1999 | vector(vector&& __v, const __type_identity_t<allocator_type>& __a); | |
| 2000 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(vector&& __v) | |
| 2001 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value); | |
| 2002 | ||
| 2003 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | |
| 2004 | void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last); | |
| 2005 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | |
| 2006 | void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_ForwardIterator __first, _ForwardIterator __last); | |
| 2007 | ||
| 2008 | #if _LIBCPP_STD_VER >= 23 | |
| 2009 | template <_ContainerCompatibleRange<bool> _Range> | |
| 2010 | _LIBCPP_HIDE_FROM_ABI constexpr void assign_range(_Range&& __range) { | |
| 2011 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 2012 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 2013 | __assign_with_size(ranges::begin(__range), ranges::end(__range), __n); | |
| 2014 | ||
| 2015 | } else { | |
| 2016 | __assign_with_sentinel(ranges::begin(__range), ranges::end(__range)); | |
| 2017 | } | |
| 2018 | } | |
| 2019 | #endif | |
| 2020 | ||
| 2021 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(size_type __n, const value_type& __x); | |
| 2022 | ||
| 2023 | #ifndef _LIBCPP_CXX03_LANG | |
| 2024 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void assign(initializer_list<value_type> __il) { | |
| 2025 | assign(__il.begin(), __il.end()); | |
| 2026 | } | |
| 2027 | #endif | |
| 2028 | ||
| 2029 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT { | |
| 2030 | return allocator_type(this->__alloc()); | |
| 2031 | } | |
| 2032 | ||
| 2033 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT; | |
| 2034 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type capacity() const _NOEXCEPT { | |
| 2035 | return __internal_cap_to_external(__cap()); | |
| 2036 | } | |
| 2037 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { return __size_; } | |
| 2038 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT { | |
| 2039 | return __size_ == 0; | |
| 2040 | } | |
| 2041 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n); | |
| 2042 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT; | |
| 2043 | ||
| 2044 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT { return __make_iter(0); } | |
| 2045 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator begin() const _NOEXCEPT { return __make_iter(0); } | |
| 2046 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _NOEXCEPT { return __make_iter(__size_); } | |
| 2047 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT { | |
| 2048 | return __make_iter(__size_); | |
| 2049 | } | |
| 2050 | ||
| 2051 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rbegin() _NOEXCEPT { | |
| 2052 | return reverse_iterator(end()); | |
| 2053 | } | |
| 2054 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rbegin() const _NOEXCEPT { | |
| 2055 | return const_reverse_iterator(end()); | |
| 2056 | } | |
| 2057 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reverse_iterator rend() _NOEXCEPT { | |
| 2058 | return reverse_iterator(begin()); | |
| 2059 | } | |
| 2060 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator rend() const _NOEXCEPT { | |
| 2061 | return const_reverse_iterator(begin()); | |
| 2062 | } | |
| 2063 | ||
| 2064 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cbegin() const _NOEXCEPT { return __make_iter(0); } | |
| 2065 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator cend() const _NOEXCEPT { | |
| 2066 | return __make_iter(__size_); | |
| 2067 | } | |
| 2068 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crbegin() const _NOEXCEPT { | |
| 2069 | return rbegin(); | |
| 2070 | } | |
| 2071 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reverse_iterator crend() const _NOEXCEPT { return rend(); } | |
| 2072 | ||
| 2073 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](size_type __n) { return __make_ref(__n); } | |
| 2074 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference operator[](size_type __n) const { | |
| 2075 | return __make_ref(__n); | |
| 2076 | } | |
| 2077 | _LIBCPP_HIDE_FROM_ABI reference at(size_type __n); | |
| 2078 | _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const; | |
| 2079 | ||
| 2080 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference front() { return __make_ref(0); } | |
| 2081 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference front() const { return __make_ref(0); } | |
| 2082 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference back() { return __make_ref(__size_ - 1); } | |
| 2083 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference back() const { return __make_ref(__size_ - 1); } | |
| 2084 | ||
| 2085 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void push_back(const value_type& __x); | |
| 2086 | #if _LIBCPP_STD_VER >= 14 | |
| 2087 | template <class... _Args> | |
| 2088 | # if _LIBCPP_STD_VER >= 17 | |
| 2089 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference emplace_back(_Args&&... __args) | |
| 2090 | # else | |
| 2091 | _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args) | |
| 2092 | # endif | |
| 2093 | { | |
| 2094 | push_back(value_type(std::forward<_Args>(__args)...)); | |
| 2095 | # if _LIBCPP_STD_VER >= 17 | |
| 2096 | return this->back(); | |
| 2097 | # endif | |
| 2098 | } | |
| 2099 | #endif | |
| 2100 | ||
| 2101 | #if _LIBCPP_STD_VER >= 23 | |
| 2102 | template <_ContainerCompatibleRange<bool> _Range> | |
| 2103 | _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) { | |
| 2104 | insert_range(end(), std::forward<_Range>(__range)); | |
| 2105 | } | |
| 2106 | #endif | |
| 2107 | ||
| 2108 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void pop_back() { --__size_; } | |
| 2109 | ||
| 2110 | #if _LIBCPP_STD_VER >= 14 | |
| 2111 | template <class... _Args> | |
| 2112 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator emplace(const_iterator __position, _Args&&... __args) { | |
| 2113 | return insert(__position, value_type(std::forward<_Args>(__args)...)); | |
| 2114 | } | |
| 2115 | #endif | |
| 2116 | ||
| 2117 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, const value_type& __x); | |
| 2118 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator | |
| 2119 | insert(const_iterator __position, size_type __n, const value_type& __x); | |
| 2120 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> | |
| 2121 | iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 2122 | insert(const_iterator __position, _InputIterator __first, _InputIterator __last); | |
| 2123 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> | |
| 2124 | iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 2125 | insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); | |
| 2126 | ||
| 2127 | #if _LIBCPP_STD_VER >= 23 | |
| 2128 | template <_ContainerCompatibleRange<bool> _Range> | |
| 2129 | _LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) { | |
| 2130 | if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) { | |
| 2131 | auto __n = static_cast<size_type>(ranges::distance(__range)); | |
| 2132 | return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n); | |
| 2133 | ||
| 2134 | } else { | |
| 2135 | return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range)); | |
| 2136 | } | |
| 2137 | } | |
| 2138 | #endif | |
| 2139 | ||
| 2140 | #ifndef _LIBCPP_CXX03_LANG | |
| 2141 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator | |
| 2142 | insert(const_iterator __position, initializer_list<value_type> __il) { | |
| 2143 | return insert(__position, __il.begin(), __il.end()); | |
| 2144 | } | |
| 2145 | #endif | |
| 2146 | ||
| 2147 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __position); | |
| 2148 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator erase(const_iterator __first, const_iterator __last); | |
| 2149 | ||
| 2150 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT { __size_ = 0; } | |
| 2151 | ||
| 2152 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(vector&) | |
| 2153 | #if _LIBCPP_STD_VER >= 14 | |
| 2154 | _NOEXCEPT; | |
| 2155 | #else | |
| 2156 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>); | |
| 2157 | #endif | |
| 2158 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT { | |
| 2159 | std::swap(__x, __y); | |
| 2160 | } | |
| 2161 | ||
| 2162 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __sz, value_type __x = false); | |
| 2163 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT; | |
| 2164 | ||
| 2165 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const; | |
| 2166 | ||
| 2167 | private: | |
| 2168 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { std::__throw_length_error("vector"); } | |
| 2169 | ||
| 2170 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("vector"); } | |
| 2171 | ||
| 2172 | template <class _InputIterator, class _Sentinel> | |
| 2173 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 2174 | __init_with_size(_InputIterator __first, _Sentinel __last, size_type __n) { | |
| 2175 | auto __guard = std::__make_exception_guard(__destroy_vector(*this)); | |
| 2176 | ||
| 2177 | if (__n > 0) { | |
| 2178 | __vallocate(__n); | |
| 2179 | __construct_at_end(std::move(__first), std::move(__last), __n); | |
| 2180 | } | |
| 2181 | ||
| 2182 | __guard.__complete(); | |
| 2183 | } | |
| 2184 | ||
| 2185 | template <class _InputIterator, class _Sentinel> | |
| 2186 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 2187 | __init_with_sentinel(_InputIterator __first, _Sentinel __last) { | |
| 2188 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2189 | try { | |
| 2190 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2191 | for (; __first != __last; ++__first) | |
| 2192 | push_back(*__first); | |
| 2193 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2194 | } catch (...) { | |
| 2195 | if (__begin_ != nullptr) | |
| 2196 | __storage_traits::deallocate(__alloc(), __begin_, __cap()); | |
| 2197 | throw; | |
| 2198 | } | |
| 2199 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2200 | } | |
| 2201 | ||
| 2202 | template <class _Iterator, class _Sentinel> | |
| 2203 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last); | |
| 2204 | ||
| 2205 | template <class _ForwardIterator, class _Sentinel> | |
| 2206 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 2207 | __assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __ns); | |
| 2208 | ||
| 2209 | template <class _InputIterator, class _Sentinel> | |
| 2210 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 2211 | __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last); | |
| 2212 | ||
| 2213 | template <class _Iterator, class _Sentinel> | |
| 2214 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator | |
| 2215 | __insert_with_size(const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n); | |
| 2216 | ||
| 2217 | // Allocate space for __n objects | |
| 2218 | // throws length_error if __n > max_size() | |
| 2219 | // throws (probably bad_alloc) if memory run out | |
| 2220 | // Precondition: __begin_ == __end_ == __cap() == 0 | |
| 2221 | // Precondition: __n > 0 | |
| 2222 | // Postcondition: capacity() >= __n | |
| 2223 | // Postcondition: size() == 0 | |
| 2224 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) { | |
| 2225 | if (__n > max_size()) | |
| 2226 | __throw_length_error(); | |
| 2227 | auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n)); | |
| 2228 | __begin_ = __allocation.ptr; | |
| 2229 | __size_ = 0; | |
| 2230 | __cap() = __allocation.count; | |
| 2231 | if (__libcpp_is_constant_evaluated()) { | |
| 2232 | for (size_type __i = 0; __i != __cap(); ++__i) | |
| 2233 | std::__construct_at(std::__to_address(__begin_) + __i); | |
| 2234 | } | |
| 2235 | } | |
| 2236 | ||
| 2237 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vdeallocate() _NOEXCEPT; | |
| 2238 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type __align_it(size_type __new_size) _NOEXCEPT { | |
| 2239 | return (__new_size + (__bits_per_word - 1)) & ~((size_type)__bits_per_word - 1); | |
| 2240 | } | |
| 2241 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __new_size) const; | |
| 2242 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct_at_end(size_type __n, bool __x); | |
| 2243 | template <class _InputIterator, class _Sentinel> | |
| 2244 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 2245 | __construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n); | |
| 2246 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append(size_type __n, const_reference __x); | |
| 2247 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference __make_ref(size_type __pos) _NOEXCEPT { | |
| 2248 | return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word); | |
| 2249 | } | |
| 2250 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_reference __make_ref(size_type __pos) const _NOEXCEPT { | |
| 2251 | return __bit_const_reference<vector>( | |
| 2252 | __begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word); | |
| 2253 | } | |
| 2254 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iter(size_type __pos) _NOEXCEPT { | |
| 2255 | return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word)); | |
| 2256 | } | |
| 2257 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_iter(size_type __pos) const _NOEXCEPT { | |
| 2258 | return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word)); | |
| 2259 | } | |
| 2260 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT { | |
| 2261 | return begin() + (__p - cbegin()); | |
| 2262 | } | |
| 2263 | ||
| 2264 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector& __v) { | |
| 2265 | __copy_assign_alloc( | |
| 2266 | __v, integral_constant<bool, __storage_traits::propagate_on_container_copy_assignment::value>()); | |
| 2267 | } | |
| 2268 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector& __c, true_type) { | |
| 2269 | if (__alloc() != __c.__alloc()) | |
| 2270 | __vdeallocate(); | |
| 2271 | __alloc() = __c.__alloc(); | |
| 2272 | } | |
| 2273 | ||
| 2274 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __copy_assign_alloc(const vector&, false_type) {} | |
| 2275 | ||
| 2276 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, false_type); | |
| 2277 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(vector& __c, true_type) | |
| 2278 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); | |
| 2279 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector& __c) | |
| 2280 | _NOEXCEPT_(!__storage_traits::propagate_on_container_move_assignment::value || | |
| 2281 | is_nothrow_move_assignable<allocator_type>::value) { | |
| 2282 | __move_assign_alloc( | |
| 2283 | __c, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>()); | |
| 2284 | } | |
| 2285 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector& __c, true_type) | |
| 2286 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | |
| 2287 | __alloc() = std::move(__c.__alloc()); | |
| 2288 | } | |
| 2289 | ||
| 2290 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector&, false_type) _NOEXCEPT {} | |
| 2291 | ||
| 2292 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t __hash_code() const _NOEXCEPT; | |
| 2293 | ||
| 2294 | friend class __bit_reference<vector>; | |
| 2295 | friend class __bit_const_reference<vector>; | |
| 2296 | friend class __bit_iterator<vector, false>; | |
| 2297 | friend class __bit_iterator<vector, true>; | |
| 2298 | friend struct __bit_array<vector>; | |
| 2299 | friend struct _LIBCPP_TEMPLATE_VIS hash<vector>; | |
| 2300 | }; | |
| 340 | // [vector.syn] | |
| 341 | # include <compare> | |
| 342 | # include <initializer_list> | |
| 2301 | 343 | |
| 2302 | template <class _Allocator> | |
| 2303 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT { | |
| 2304 | if (this->__begin_ != nullptr) { | |
| 2305 | __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap()); | |
| 2306 | this->__begin_ = nullptr; | |
| 2307 | this->__size_ = this->__cap() = 0; | |
| 2308 | } | |
| 2309 | } | |
| 2310 | ||
| 2311 | template <class _Allocator> | |
| 2312 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type | |
| 2313 | vector<bool, _Allocator>::max_size() const _NOEXCEPT { | |
| 2314 | size_type __amax = __storage_traits::max_size(__alloc()); | |
| 2315 | size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always | |
| 2316 | if (__nmax / __bits_per_word <= __amax) | |
| 2317 | return __nmax; | |
| 2318 | return __internal_cap_to_external(__amax); | |
| 2319 | } | |
| 2320 | ||
| 2321 | // Precondition: __new_size > capacity() | |
| 2322 | template <class _Allocator> | |
| 2323 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type | |
| 2324 | vector<bool, _Allocator>::__recommend(size_type __new_size) const { | |
| 2325 | const size_type __ms = max_size(); | |
| 2326 | if (__new_size > __ms) | |
| 2327 | this->__throw_length_error(); | |
| 2328 | const size_type __cap = capacity(); | |
| 2329 | if (__cap >= __ms / 2) | |
| 2330 | return __ms; | |
| 2331 | return std::max(2 * __cap, __align_it(__new_size)); | |
| 2332 | } | |
| 2333 | ||
| 2334 | // Default constructs __n objects starting at __end_ | |
| 2335 | // Precondition: __n > 0 | |
| 2336 | // Precondition: size() + __n <= capacity() | |
| 2337 | // Postcondition: size() == size() + __n | |
| 2338 | template <class _Allocator> | |
| 2339 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 2340 | vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) { | |
| 2341 | size_type __old_size = this->__size_; | |
| 2342 | this->__size_ += __n; | |
| 2343 | if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) { | |
| 2344 | if (this->__size_ <= __bits_per_word) | |
| 2345 | this->__begin_[0] = __storage_type(0); | |
| 2346 | else | |
| 2347 | this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); | |
| 2348 | } | |
| 2349 | std::fill_n(__make_iter(__old_size), __n, __x); | |
| 2350 | } | |
| 2351 | ||
| 2352 | template <class _Allocator> | |
| 2353 | template <class _InputIterator, class _Sentinel> | |
| 2354 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void | |
| 2355 | vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) { | |
| 2356 | size_type __old_size = this->__size_; | |
| 2357 | this->__size_ += __n; | |
| 2358 | if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) { | |
| 2359 | if (this->__size_ <= __bits_per_word) | |
| 2360 | this->__begin_[0] = __storage_type(0); | |
| 2361 | else | |
| 2362 | this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0); | |
| 2363 | } | |
| 2364 | std::__copy<_ClassicAlgPolicy>(__first, __last, __make_iter(__old_size)); | |
| 2365 | } | |
| 2366 | ||
| 2367 | template <class _Allocator> | |
| 2368 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector() | |
| 2369 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | |
| 2370 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) {} | |
| 2371 | ||
| 2372 | template <class _Allocator> | |
| 2373 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const allocator_type& __a) | |
| 2374 | #if _LIBCPP_STD_VER <= 14 | |
| 2375 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) | |
| 2376 | #else | |
| 2377 | _NOEXCEPT | |
| 2378 | #endif | |
| 2379 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { | |
| 2380 | } | |
| 2381 | ||
| 2382 | template <class _Allocator> | |
| 2383 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n) | |
| 2384 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) { | |
| 2385 | if (__n > 0) { | |
| 2386 | __vallocate(__n); | |
| 2387 | __construct_at_end(__n, false); | |
| 2388 | } | |
| 2389 | } | |
| 2390 | ||
| 2391 | #if _LIBCPP_STD_VER >= 14 | |
| 2392 | template <class _Allocator> | |
| 2393 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) | |
| 2394 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { | |
| 2395 | if (__n > 0) { | |
| 2396 | __vallocate(__n); | |
| 2397 | __construct_at_end(__n, false); | |
| 2398 | } | |
| 2399 | } | |
| 2400 | #endif | |
| 2401 | ||
| 2402 | template <class _Allocator> | |
| 2403 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x) | |
| 2404 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) { | |
| 2405 | if (__n > 0) { | |
| 2406 | __vallocate(__n); | |
| 2407 | __construct_at_end(__n, __x); | |
| 2408 | } | |
| 2409 | } | |
| 2410 | ||
| 2411 | template <class _Allocator> | |
| 2412 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 2413 | vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) | |
| 2414 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { | |
| 2415 | if (__n > 0) { | |
| 2416 | __vallocate(__n); | |
| 2417 | __construct_at_end(__n, __x); | |
| 2418 | } | |
| 2419 | } | |
| 2420 | ||
| 2421 | template <class _Allocator> | |
| 2422 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > | |
| 2423 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last) | |
| 2424 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) { | |
| 2425 | __init_with_sentinel(__first, __last); | |
| 2426 | } | |
| 2427 | ||
| 2428 | template <class _Allocator> | |
| 2429 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > | |
| 2430 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 2431 | vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a) | |
| 2432 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { | |
| 2433 | __init_with_sentinel(__first, __last); | |
| 2434 | } | |
| 2435 | ||
| 2436 | template <class _Allocator> | |
| 2437 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | |
| 2438 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last) | |
| 2439 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) { | |
| 2440 | auto __n = static_cast<size_type>(std::distance(__first, __last)); | |
| 2441 | __init_with_size(__first, __last, __n); | |
| 2442 | } | |
| 2443 | ||
| 2444 | template <class _Allocator> | |
| 2445 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | |
| 2446 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 2447 | vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a) | |
| 2448 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { | |
| 2449 | auto __n = static_cast<size_type>(std::distance(__first, __last)); | |
| 2450 | __init_with_size(__first, __last, __n); | |
| 2451 | } | |
| 2452 | ||
| 2453 | #ifndef _LIBCPP_CXX03_LANG | |
| 2454 | ||
| 2455 | template <class _Allocator> | |
| 2456 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(initializer_list<value_type> __il) | |
| 2457 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) { | |
| 2458 | size_type __n = static_cast<size_type>(__il.size()); | |
| 2459 | if (__n > 0) { | |
| 2460 | __vallocate(__n); | |
| 2461 | __construct_at_end(__il.begin(), __il.end(), __n); | |
| 2462 | } | |
| 2463 | } | |
| 2464 | ||
| 2465 | template <class _Allocator> | |
| 2466 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 2467 | vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) | |
| 2468 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) { | |
| 2469 | size_type __n = static_cast<size_type>(__il.size()); | |
| 2470 | if (__n > 0) { | |
| 2471 | __vallocate(__n); | |
| 2472 | __construct_at_end(__il.begin(), __il.end(), __n); | |
| 2473 | } | |
| 2474 | } | |
| 2475 | ||
| 2476 | #endif // _LIBCPP_CXX03_LANG | |
| 2477 | ||
| 2478 | template <class _Allocator> | |
| 2479 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v) | |
| 2480 | : __begin_(nullptr), | |
| 2481 | __size_(0), | |
| 2482 | __cap_alloc_(0, __storage_traits::select_on_container_copy_construction(__v.__alloc())) { | |
| 2483 | if (__v.size() > 0) { | |
| 2484 | __vallocate(__v.size()); | |
| 2485 | __construct_at_end(__v.begin(), __v.end(), __v.size()); | |
| 2486 | } | |
| 2487 | } | |
| 2488 | ||
| 2489 | template <class _Allocator> | |
| 2490 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a) | |
| 2491 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) { | |
| 2492 | if (__v.size() > 0) { | |
| 2493 | __vallocate(__v.size()); | |
| 2494 | __construct_at_end(__v.begin(), __v.end(), __v.size()); | |
| 2495 | } | |
| 2496 | } | |
| 2497 | ||
| 2498 | template <class _Allocator> | |
| 2499 | _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& vector<bool, _Allocator>::operator=(const vector& __v) { | |
| 2500 | if (this != std::addressof(__v)) { | |
| 2501 | __copy_assign_alloc(__v); | |
| 2502 | if (__v.__size_) { | |
| 2503 | if (__v.__size_ > capacity()) { | |
| 2504 | __vdeallocate(); | |
| 2505 | __vallocate(__v.__size_); | |
| 2506 | } | |
| 2507 | std::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_); | |
| 2508 | } | |
| 2509 | __size_ = __v.__size_; | |
| 2510 | } | |
| 2511 | return *this; | |
| 2512 | } | |
| 2513 | ||
| 2514 | template <class _Allocator> | |
| 2515 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(vector&& __v) | |
| 2516 | #if _LIBCPP_STD_VER >= 17 | |
| 2517 | _NOEXCEPT | |
| 2518 | #else | |
| 2519 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) | |
| 2520 | #endif | |
| 2521 | : __begin_(__v.__begin_), | |
| 2522 | __size_(__v.__size_), | |
| 2523 | __cap_alloc_(std::move(__v.__cap_alloc_)) { | |
| 2524 | __v.__begin_ = nullptr; | |
| 2525 | __v.__size_ = 0; | |
| 2526 | __v.__cap() = 0; | |
| 2527 | } | |
| 2528 | ||
| 2529 | template <class _Allocator> | |
| 2530 | _LIBCPP_CONSTEXPR_SINCE_CXX20 | |
| 2531 | vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a) | |
| 2532 | : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) { | |
| 2533 | if (__a == allocator_type(__v.__alloc())) { | |
| 2534 | this->__begin_ = __v.__begin_; | |
| 2535 | this->__size_ = __v.__size_; | |
| 2536 | this->__cap() = __v.__cap(); | |
| 2537 | __v.__begin_ = nullptr; | |
| 2538 | __v.__cap() = __v.__size_ = 0; | |
| 2539 | } else if (__v.size() > 0) { | |
| 2540 | __vallocate(__v.size()); | |
| 2541 | __construct_at_end(__v.begin(), __v.end(), __v.size()); | |
| 2542 | } | |
| 2543 | } | |
| 2544 | ||
| 2545 | template <class _Allocator> | |
| 2546 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& | |
| 2547 | vector<bool, _Allocator>::operator=(vector&& __v) | |
| 2548 | _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) { | |
| 2549 | __move_assign(__v, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>()); | |
| 2550 | return *this; | |
| 2551 | } | |
| 2552 | ||
| 2553 | template <class _Allocator> | |
| 2554 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vector& __c, false_type) { | |
| 2555 | if (__alloc() != __c.__alloc()) | |
| 2556 | assign(__c.begin(), __c.end()); | |
| 2557 | else | |
| 2558 | __move_assign(__c, true_type()); | |
| 2559 | } | |
| 2560 | ||
| 2561 | template <class _Allocator> | |
| 2562 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vector& __c, true_type) | |
| 2563 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) { | |
| 2564 | __vdeallocate(); | |
| 2565 | __move_assign_alloc(__c); | |
| 2566 | this->__begin_ = __c.__begin_; | |
| 2567 | this->__size_ = __c.__size_; | |
| 2568 | this->__cap() = __c.__cap(); | |
| 2569 | __c.__begin_ = nullptr; | |
| 2570 | __c.__cap() = __c.__size_ = 0; | |
| 2571 | } | |
| 2572 | ||
| 2573 | template <class _Allocator> | |
| 2574 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) { | |
| 2575 | __size_ = 0; | |
| 2576 | if (__n > 0) { | |
| 2577 | size_type __c = capacity(); | |
| 2578 | if (__n <= __c) | |
| 2579 | __size_ = __n; | |
| 2580 | else { | |
| 2581 | vector __v(get_allocator()); | |
| 2582 | __v.reserve(__recommend(__n)); | |
| 2583 | __v.__size_ = __n; | |
| 2584 | swap(__v); | |
| 2585 | } | |
| 2586 | std::fill_n(begin(), __n, __x); | |
| 2587 | } | |
| 2588 | } | |
| 2589 | ||
| 2590 | template <class _Allocator> | |
| 2591 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > | |
| 2592 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { | |
| 2593 | __assign_with_sentinel(__first, __last); | |
| 2594 | } | |
| 2595 | ||
| 2596 | template <class _Allocator> | |
| 2597 | template <class _Iterator, class _Sentinel> | |
| 2598 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 2599 | vector<bool, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) { | |
| 2600 | clear(); | |
| 2601 | for (; __first != __last; ++__first) | |
| 2602 | push_back(*__first); | |
| 2603 | } | |
| 2604 | ||
| 2605 | template <class _Allocator> | |
| 2606 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | |
| 2607 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) { | |
| 2608 | __assign_with_size(__first, __last, std::distance(__first, __last)); | |
| 2609 | } | |
| 2610 | ||
| 2611 | template <class _Allocator> | |
| 2612 | template <class _ForwardIterator, class _Sentinel> | |
| 2613 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void | |
| 2614 | vector<bool, _Allocator>::__assign_with_size(_ForwardIterator __first, _Sentinel __last, difference_type __ns) { | |
| 2615 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__ns >= 0, "invalid range specified"); | |
| 2616 | ||
| 2617 | clear(); | |
| 2618 | ||
| 2619 | const size_t __n = static_cast<size_type>(__ns); | |
| 2620 | if (__n) { | |
| 2621 | if (__n > capacity()) { | |
| 2622 | __vdeallocate(); | |
| 2623 | __vallocate(__n); | |
| 2624 | } | |
| 2625 | __construct_at_end(__first, __last, __n); | |
| 2626 | } | |
| 2627 | } | |
| 2628 | ||
| 2629 | template <class _Allocator> | |
| 2630 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::reserve(size_type __n) { | |
| 2631 | if (__n > capacity()) { | |
| 2632 | if (__n > max_size()) | |
| 2633 | this->__throw_length_error(); | |
| 2634 | vector __v(this->get_allocator()); | |
| 2635 | __v.__vallocate(__n); | |
| 2636 | __v.__construct_at_end(this->begin(), this->end(), this->size()); | |
| 2637 | swap(__v); | |
| 2638 | } | |
| 2639 | } | |
| 2640 | ||
| 2641 | template <class _Allocator> | |
| 2642 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT { | |
| 2643 | if (__external_cap_to_internal(size()) > __cap()) { | |
| 2644 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2645 | try { | |
| 2646 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2647 | vector(*this, allocator_type(__alloc())).swap(*this); | |
| 2648 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2649 | } catch (...) { | |
| 2650 | } | |
| 2651 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2652 | } | |
| 2653 | } | |
| 2654 | ||
| 2655 | template <class _Allocator> | |
| 2656 | typename vector<bool, _Allocator>::reference vector<bool, _Allocator>::at(size_type __n) { | |
| 2657 | if (__n >= size()) | |
| 2658 | this->__throw_out_of_range(); | |
| 2659 | return (*this)[__n]; | |
| 2660 | } | |
| 2661 | ||
| 2662 | template <class _Allocator> | |
| 2663 | typename vector<bool, _Allocator>::const_reference vector<bool, _Allocator>::at(size_type __n) const { | |
| 2664 | if (__n >= size()) | |
| 2665 | this->__throw_out_of_range(); | |
| 2666 | return (*this)[__n]; | |
| 2667 | } | |
| 2668 | ||
| 2669 | template <class _Allocator> | |
| 2670 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::push_back(const value_type& __x) { | |
| 2671 | if (this->__size_ == this->capacity()) | |
| 2672 | reserve(__recommend(this->__size_ + 1)); | |
| 2673 | ++this->__size_; | |
| 2674 | back() = __x; | |
| 2675 | } | |
| 2676 | ||
| 2677 | template <class _Allocator> | |
| 2678 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 2679 | vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x) { | |
| 2680 | iterator __r; | |
| 2681 | if (size() < capacity()) { | |
| 2682 | const_iterator __old_end = end(); | |
| 2683 | ++__size_; | |
| 2684 | std::copy_backward(__position, __old_end, end()); | |
| 2685 | __r = __const_iterator_cast(__position); | |
| 2686 | } else { | |
| 2687 | vector __v(get_allocator()); | |
| 2688 | __v.reserve(__recommend(__size_ + 1)); | |
| 2689 | __v.__size_ = __size_ + 1; | |
| 2690 | __r = std::copy(cbegin(), __position, __v.begin()); | |
| 2691 | std::copy_backward(__position, cend(), __v.end()); | |
| 2692 | swap(__v); | |
| 2693 | } | |
| 2694 | *__r = __x; | |
| 2695 | return __r; | |
| 2696 | } | |
| 2697 | ||
| 2698 | template <class _Allocator> | |
| 2699 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 2700 | vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x) { | |
| 2701 | iterator __r; | |
| 2702 | size_type __c = capacity(); | |
| 2703 | if (__n <= __c && size() <= __c - __n) { | |
| 2704 | const_iterator __old_end = end(); | |
| 2705 | __size_ += __n; | |
| 2706 | std::copy_backward(__position, __old_end, end()); | |
| 2707 | __r = __const_iterator_cast(__position); | |
| 2708 | } else { | |
| 2709 | vector __v(get_allocator()); | |
| 2710 | __v.reserve(__recommend(__size_ + __n)); | |
| 2711 | __v.__size_ = __size_ + __n; | |
| 2712 | __r = std::copy(cbegin(), __position, __v.begin()); | |
| 2713 | std::copy_backward(__position, cend(), __v.end()); | |
| 2714 | swap(__v); | |
| 2715 | } | |
| 2716 | std::fill_n(__r, __n, __x); | |
| 2717 | return __r; | |
| 2718 | } | |
| 2719 | ||
| 2720 | template <class _Allocator> | |
| 2721 | template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > | |
| 2722 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 2723 | vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { | |
| 2724 | return __insert_with_sentinel(__position, __first, __last); | |
| 2725 | } | |
| 2726 | ||
| 2727 | template <class _Allocator> | |
| 2728 | template <class _InputIterator, class _Sentinel> | |
| 2729 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<bool, _Allocator>::iterator | |
| 2730 | vector<bool, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) { | |
| 2731 | difference_type __off = __position - begin(); | |
| 2732 | iterator __p = __const_iterator_cast(__position); | |
| 2733 | iterator __old_end = end(); | |
| 2734 | for (; size() != capacity() && __first != __last; ++__first) { | |
| 2735 | ++this->__size_; | |
| 2736 | back() = *__first; | |
| 2737 | } | |
| 2738 | vector __v(get_allocator()); | |
| 2739 | if (__first != __last) { | |
| 2740 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2741 | try { | |
| 2742 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2743 | __v.__assign_with_sentinel(std::move(__first), std::move(__last)); | |
| 2744 | difference_type __old_size = static_cast<difference_type>(__old_end - begin()); | |
| 2745 | difference_type __old_p = __p - begin(); | |
| 2746 | reserve(__recommend(size() + __v.size())); | |
| 2747 | __p = begin() + __old_p; | |
| 2748 | __old_end = begin() + __old_size; | |
| 2749 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2750 | } catch (...) { | |
| 2751 | erase(__old_end, end()); | |
| 2752 | throw; | |
| 2753 | } | |
| 2754 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 2755 | } | |
| 2756 | __p = std::rotate(__p, __old_end, end()); | |
| 2757 | insert(__p, __v.begin(), __v.end()); | |
| 2758 | return begin() + __off; | |
| 2759 | } | |
| 2760 | ||
| 2761 | template <class _Allocator> | |
| 2762 | template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > | |
| 2763 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 2764 | vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) { | |
| 2765 | return __insert_with_size(__position, __first, __last, std::distance(__first, __last)); | |
| 2766 | } | |
| 2767 | ||
| 2768 | template <class _Allocator> | |
| 2769 | template <class _ForwardIterator, class _Sentinel> | |
| 2770 | _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<bool, _Allocator>::iterator | |
| 2771 | vector<bool, _Allocator>::__insert_with_size( | |
| 2772 | const_iterator __position, _ForwardIterator __first, _Sentinel __last, difference_type __n_signed) { | |
| 2773 | _LIBCPP_ASSERT_VALID_INPUT_RANGE(__n_signed >= 0, "invalid range specified"); | |
| 2774 | const size_type __n = static_cast<size_type>(__n_signed); | |
| 2775 | iterator __r; | |
| 2776 | size_type __c = capacity(); | |
| 2777 | if (__n <= __c && size() <= __c - __n) { | |
| 2778 | const_iterator __old_end = end(); | |
| 2779 | __size_ += __n; | |
| 2780 | std::copy_backward(__position, __old_end, end()); | |
| 2781 | __r = __const_iterator_cast(__position); | |
| 2782 | } else { | |
| 2783 | vector __v(get_allocator()); | |
| 2784 | __v.reserve(__recommend(__size_ + __n)); | |
| 2785 | __v.__size_ = __size_ + __n; | |
| 2786 | __r = std::copy(cbegin(), __position, __v.begin()); | |
| 2787 | std::copy_backward(__position, cend(), __v.end()); | |
| 2788 | swap(__v); | |
| 2789 | } | |
| 2790 | std::__copy<_ClassicAlgPolicy>(__first, __last, __r); | |
| 2791 | return __r; | |
| 2792 | } | |
| 2793 | ||
| 2794 | template <class _Allocator> | |
| 2795 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 2796 | vector<bool, _Allocator>::erase(const_iterator __position) { | |
| 2797 | iterator __r = __const_iterator_cast(__position); | |
| 2798 | std::copy(__position + 1, this->cend(), __r); | |
| 2799 | --__size_; | |
| 2800 | return __r; | |
| 2801 | } | |
| 2802 | ||
| 2803 | template <class _Allocator> | |
| 2804 | _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::iterator | |
| 2805 | vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) { | |
| 2806 | iterator __r = __const_iterator_cast(__first); | |
| 2807 | difference_type __d = __last - __first; | |
| 2808 | std::copy(__last, this->cend(), __r); | |
| 2809 | __size_ -= __d; | |
| 2810 | return __r; | |
| 2811 | } | |
| 2812 | ||
| 2813 | template <class _Allocator> | |
| 2814 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x) | |
| 2815 | #if _LIBCPP_STD_VER >= 14 | |
| 2816 | _NOEXCEPT | |
| 2817 | #else | |
| 2818 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>) | |
| 2819 | #endif | |
| 2820 | { | |
| 2821 | std::swap(this->__begin_, __x.__begin_); | |
| 2822 | std::swap(this->__size_, __x.__size_); | |
| 2823 | std::swap(this->__cap(), __x.__cap()); | |
| 2824 | std::__swap_allocator( | |
| 2825 | this->__alloc(), __x.__alloc(), integral_constant<bool, __alloc_traits::propagate_on_container_swap::value>()); | |
| 2826 | } | |
| 2827 | ||
| 2828 | template <class _Allocator> | |
| 2829 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::resize(size_type __sz, value_type __x) { | |
| 2830 | size_type __cs = size(); | |
| 2831 | if (__cs < __sz) { | |
| 2832 | iterator __r; | |
| 2833 | size_type __c = capacity(); | |
| 2834 | size_type __n = __sz - __cs; | |
| 2835 | if (__n <= __c && __cs <= __c - __n) { | |
| 2836 | __r = end(); | |
| 2837 | __size_ += __n; | |
| 2838 | } else { | |
| 2839 | vector __v(get_allocator()); | |
| 2840 | __v.reserve(__recommend(__size_ + __n)); | |
| 2841 | __v.__size_ = __size_ + __n; | |
| 2842 | __r = std::copy(cbegin(), cend(), __v.begin()); | |
| 2843 | swap(__v); | |
| 2844 | } | |
| 2845 | std::fill_n(__r, __n, __x); | |
| 2846 | } else | |
| 2847 | __size_ = __sz; | |
| 2848 | } | |
| 2849 | ||
| 2850 | template <class _Allocator> | |
| 2851 | _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::flip() _NOEXCEPT { | |
| 2852 | // do middle whole words | |
| 2853 | size_type __n = __size_; | |
| 2854 | __storage_pointer __p = __begin_; | |
| 2855 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) | |
| 2856 | *__p = ~*__p; | |
| 2857 | // do last partial word | |
| 2858 | if (__n > 0) { | |
| 2859 | __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | |
| 2860 | __storage_type __b = *__p & __m; | |
| 2861 | *__p &= ~__m; | |
| 2862 | *__p |= ~__b & __m; | |
| 2863 | } | |
| 2864 | } | |
| 2865 | ||
| 2866 | template <class _Allocator> | |
| 2867 | _LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<bool, _Allocator>::__invariants() const { | |
| 2868 | if (this->__begin_ == nullptr) { | |
| 2869 | if (this->__size_ != 0 || this->__cap() != 0) | |
| 2870 | return false; | |
| 2871 | } else { | |
| 2872 | if (this->__cap() == 0) | |
| 2873 | return false; | |
| 2874 | if (this->__size_ > this->capacity()) | |
| 2875 | return false; | |
| 2876 | } | |
| 2877 | return true; | |
| 2878 | } | |
| 2879 | ||
| 2880 | template <class _Allocator> | |
| 2881 | _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() const _NOEXCEPT { | |
| 2882 | size_t __h = 0; | |
| 2883 | // do middle whole words | |
| 2884 | size_type __n = __size_; | |
| 2885 | __storage_pointer __p = __begin_; | |
| 2886 | for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word) | |
| 2887 | __h ^= *__p; | |
| 2888 | // do last partial word | |
| 2889 | if (__n > 0) { | |
| 2890 | const __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); | |
| 2891 | __h ^= *__p & __m; | |
| 2892 | } | |
| 2893 | return __h; | |
| 2894 | } | |
| 2895 | ||
| 2896 | template <class _Allocator> | |
| 2897 | struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > | |
| 2898 | : public __unary_function<vector<bool, _Allocator>, size_t> { | |
| 2899 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t | |
| 2900 | operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT { | |
| 2901 | return __vec.__hash_code(); | |
| 2902 | } | |
| 2903 | }; | |
| 344 | // [vector.syn], [unord.hash] | |
| 345 | # include <__functional/hash.h> | |
| 2904 | 346 | |
| 2905 | template <class _Tp, class _Allocator> | |
| 2906 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI bool | |
| 2907 | operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 2908 | const typename vector<_Tp, _Allocator>::size_type __sz = __x.size(); | |
| 2909 | return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin()); | |
| 2910 | } | |
| 2911 | ||
| 2912 | #if _LIBCPP_STD_VER <= 17 | |
| 2913 | ||
| 2914 | template <class _Tp, class _Allocator> | |
| 2915 | inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 2916 | return !(__x == __y); | |
| 2917 | } | |
| 2918 | ||
| 2919 | template <class _Tp, class _Allocator> | |
| 2920 | inline _LIBCPP_HIDE_FROM_ABI bool operator<(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 2921 | return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); | |
| 2922 | } | |
| 2923 | ||
| 2924 | template <class _Tp, class _Allocator> | |
| 2925 | inline _LIBCPP_HIDE_FROM_ABI bool operator>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 2926 | return __y < __x; | |
| 2927 | } | |
| 2928 | ||
| 2929 | template <class _Tp, class _Allocator> | |
| 2930 | inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 2931 | return !(__x < __y); | |
| 2932 | } | |
| 2933 | ||
| 2934 | template <class _Tp, class _Allocator> | |
| 2935 | inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 2936 | return !(__y < __x); | |
| 2937 | } | |
| 2938 | ||
| 2939 | #else // _LIBCPP_STD_VER <= 17 | |
| 2940 | ||
| 2941 | template <class _Tp, class _Allocator> | |
| 2942 | _LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp> | |
| 2943 | operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { | |
| 2944 | return std::lexicographical_compare_three_way( | |
| 2945 | __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way); | |
| 2946 | } | |
| 2947 | ||
| 2948 | #endif // _LIBCPP_STD_VER <= 17 | |
| 2949 | ||
| 2950 | template <class _Tp, class _Allocator> | |
| 2951 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI void | |
| 2952 | swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { | |
| 2953 | __x.swap(__y); | |
| 2954 | } | |
| 2955 | ||
| 2956 | #if _LIBCPP_STD_VER >= 20 | |
| 2957 | template <class _Tp, class _Allocator, class _Up> | |
| 2958 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type | |
| 2959 | erase(vector<_Tp, _Allocator>& __c, const _Up& __v) { | |
| 2960 | auto __old_size = __c.size(); | |
| 2961 | __c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end()); | |
| 2962 | return __old_size - __c.size(); | |
| 2963 | } | |
| 2964 | ||
| 2965 | template <class _Tp, class _Allocator, class _Predicate> | |
| 2966 | _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::size_type | |
| 2967 | erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) { | |
| 2968 | auto __old_size = __c.size(); | |
| 2969 | __c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end()); | |
| 2970 | return __old_size - __c.size(); | |
| 2971 | } | |
| 2972 | ||
| 2973 | template <> | |
| 2974 | inline constexpr bool __format::__enable_insertable<vector<char>> = true; | |
| 2975 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2976 | template <> | |
| 2977 | inline constexpr bool __format::__enable_insertable<vector<wchar_t>> = true; | |
| 347 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 348 | # pragma GCC system_header | |
| 2978 | 349 | # endif |
| 2979 | 350 | |
| 2980 | #endif // _LIBCPP_STD_VER >= 20 | |
| 2981 | ||
| 2982 | #if _LIBCPP_STD_VER >= 23 | |
| 2983 | template <class _Tp, class _CharT> | |
| 2984 | // Since is-vector-bool-reference is only used once it's inlined here. | |
| 2985 | requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>> | |
| 2986 | struct _LIBCPP_TEMPLATE_VIS formatter<_Tp, _CharT> { | |
| 2987 | private: | |
| 2988 | formatter<bool, _CharT> __underlying_; | |
| 2989 | ||
| 2990 | public: | |
| 2991 | template <class _ParseContext> | |
| 2992 | _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) { | |
| 2993 | return __underlying_.parse(__ctx); | |
| 2994 | } | |
| 2995 | ||
| 2996 | template <class _FormatContext> | |
| 2997 | _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(const _Tp& __ref, _FormatContext& __ctx) const { | |
| 2998 | return __underlying_.format(__ref, __ctx); | |
| 2999 | } | |
| 3000 | }; | |
| 3001 | #endif // _LIBCPP_STD_VER >= 23 | |
| 3002 | ||
| 3003 | _LIBCPP_END_NAMESPACE_STD | |
| 3004 | ||
| 3005 | #if _LIBCPP_STD_VER >= 17 | |
| 3006 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 3007 | namespace pmr { | |
| 3008 | template <class _ValueT> | |
| 3009 | using vector _LIBCPP_AVAILABILITY_PMR = std::vector<_ValueT, polymorphic_allocator<_ValueT>>; | |
| 3010 | } // namespace pmr | |
| 3011 | _LIBCPP_END_NAMESPACE_STD | |
| 3012 | #endif | |
| 3013 | ||
| 3014 | _LIBCPP_POP_MACROS | |
| 3015 | ||
| 3016 | #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 3017 | # include <algorithm> | |
| 3018 | # include <atomic> | |
| 3019 | # include <concepts> | |
| 3020 | # include <cstdlib> | |
| 3021 | # include <iosfwd> | |
| 3022 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 3023 | # include <locale> | |
| 351 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 | |
| 352 | # include <algorithm> | |
| 353 | # include <array> | |
| 354 | # include <atomic> | |
| 355 | # include <cctype> | |
| 356 | # include <cerrno> | |
| 357 | # include <clocale> | |
| 358 | # include <concepts> | |
| 359 | # include <cstdint> | |
| 360 | # include <cstdlib> | |
| 361 | # include <iosfwd> | |
| 362 | # if _LIBCPP_HAS_LOCALIZATION | |
| 363 | # include <locale> | |
| 364 | # endif | |
| 365 | # include <string> | |
| 366 | # include <string_view> | |
| 367 | # include <tuple> | |
| 368 | # include <type_traits> | |
| 369 | # include <typeinfo> | |
| 370 | # include <utility> | |
| 3024 | 371 | # endif |
| 3025 | # include <tuple> | |
| 3026 | # include <type_traits> | |
| 3027 | # include <typeinfo> | |
| 3028 | # include <utility> | |
| 3029 | #endif | |
| 372 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 3030 | 373 | |
| 3031 | 374 | #endif // _LIBCPP_VECTOR |
lib/libcxx/include/version+62-26| ... | ... | @@ -101,6 +101,8 @@ __cpp_lib_execution 201902L <execution> |
| 101 | 101 | 201603L // C++17 |
| 102 | 102 | __cpp_lib_expected 202211L <expected> |
| 103 | 103 | __cpp_lib_filesystem 201703L <filesystem> |
| 104 | __cpp_lib_flat_map 202207L <flat_map> | |
| 105 | __cpp_lib_flat_set 202207L <flat_set> | |
| 104 | 106 | __cpp_lib_format 202110L <format> |
| 105 | 107 | __cpp_lib_format_path 202403L <filesystem> |
| 106 | 108 | __cpp_lib_format_ranges 202207L <format> |
| ... | ... | @@ -138,6 +140,7 @@ __cpp_lib_ios_noreplace 202207L <ios> |
| 138 | 140 | __cpp_lib_is_aggregate 201703L <type_traits> |
| 139 | 141 | __cpp_lib_is_constant_evaluated 201811L <type_traits> |
| 140 | 142 | __cpp_lib_is_final 201402L <type_traits> |
| 143 | __cpp_lib_is_implicit_lifetime 202302L <type_traits> | |
| 141 | 144 | __cpp_lib_is_invocable 201703L <type_traits> |
| 142 | 145 | __cpp_lib_is_layout_compatible 201907L <type_traits> |
| 143 | 146 | __cpp_lib_is_nothrow_convertible 201806L <type_traits> |
| ... | ... | @@ -170,9 +173,11 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque> |
| 170 | 173 | <iterator> <list> <map> |
| 171 | 174 | <regex> <set> <string> |
| 172 | 175 | <unordered_map> <unordered_set> <vector> |
| 173 | __cpp_lib_not_fn 201603L <functional> | |
| 176 | __cpp_lib_not_fn 202306L <functional> | |
| 177 | 201603L // C++17 | |
| 174 | 178 | __cpp_lib_null_iterators 201304L <iterator> |
| 175 | 179 | __cpp_lib_optional 202110L <optional> |
| 180 | 202106L // C++20 | |
| 176 | 181 | 201606L // C++17 |
| 177 | 182 | __cpp_lib_optional_range_support 202406L <optional> |
| 178 | 183 | __cpp_lib_out_ptr 202311L <memory> |
| ... | ... | @@ -182,8 +187,9 @@ __cpp_lib_philox_engine 202406L <random> |
| 182 | 187 | __cpp_lib_polymorphic_allocator 201902L <memory_resource> |
| 183 | 188 | __cpp_lib_print 202207L <ostream> <print> |
| 184 | 189 | __cpp_lib_quoted_string_io 201304L <iomanip> |
| 185 | __cpp_lib_ranges 202207L <algorithm> <functional> <iterator> | |
| 190 | __cpp_lib_ranges 202406L <algorithm> <functional> <iterator> | |
| 186 | 191 | <memory> <ranges> |
| 192 | 202110L // C++20 | |
| 187 | 193 | __cpp_lib_ranges_as_const 202207L <ranges> |
| 188 | 194 | __cpp_lib_ranges_as_rvalue 202207L <ranges> |
| 189 | 195 | __cpp_lib_ranges_chunk 202202L <ranges> |
| ... | ... | @@ -259,16 +265,21 @@ __cpp_lib_uncaught_exceptions 201411L <exception> |
| 259 | 265 | __cpp_lib_unordered_map_try_emplace 201411L <unordered_map> |
| 260 | 266 | __cpp_lib_unreachable 202202L <utility> |
| 261 | 267 | __cpp_lib_unwrap_ref 201811L <functional> |
| 262 | __cpp_lib_variant 202102L <variant> | |
| 268 | __cpp_lib_variant 202306L <variant> | |
| 269 | 202106L // C++20 | |
| 270 | 202102L // C++17 | |
| 263 | 271 | __cpp_lib_void_t 201411L <type_traits> |
| 264 | 272 | |
| 265 | 273 | */ |
| 266 | 274 | |
| 267 | #include <__config> | |
| 275 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 276 | # include <__cxx03/version> | |
| 277 | #else | |
| 278 | # include <__config> | |
| 268 | 279 | |
| 269 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 270 | # pragma GCC system_header | |
| 271 | #endif | |
| 280 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 281 | # pragma GCC system_header | |
| 282 | # endif | |
| 272 | 283 | |
| 273 | 284 | // clang-format off |
| 274 | 285 | |
| ... | ... | @@ -284,12 +295,12 @@ __cpp_lib_void_t 201411L <type_traits> |
| 284 | 295 | # define __cpp_lib_make_reverse_iterator 201402L |
| 285 | 296 | # define __cpp_lib_make_unique 201304L |
| 286 | 297 | # define __cpp_lib_null_iterators 201304L |
| 287 | # if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 298 | # if _LIBCPP_HAS_LOCALIZATION | |
| 288 | 299 | # define __cpp_lib_quoted_string_io 201304L |
| 289 | 300 | # endif |
| 290 | 301 | # define __cpp_lib_result_of_sfinae 201210L |
| 291 | 302 | # define __cpp_lib_robust_nonmodifying_seq_ops 201304L |
| 292 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 303 | # if _LIBCPP_HAS_THREADS | |
| 293 | 304 | # define __cpp_lib_shared_timed_mutex 201402L |
| 294 | 305 | # endif |
| 295 | 306 | # define __cpp_lib_string_udls 201304L |
| ... | ... | @@ -314,7 +325,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 314 | 325 | # define __cpp_lib_clamp 201603L |
| 315 | 326 | # define __cpp_lib_enable_shared_from_this 201603L |
| 316 | 327 | // # define __cpp_lib_execution 201603L |
| 317 | # if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY | |
| 328 | # if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY | |
| 318 | 329 | # define __cpp_lib_filesystem 201703L |
| 319 | 330 | # endif |
| 320 | 331 | # define __cpp_lib_gcd_lcm 201606L |
| ... | ... | @@ -343,10 +354,10 @@ __cpp_lib_void_t 201411L <type_traits> |
| 343 | 354 | // # define __cpp_lib_parallel_algorithm 201603L |
| 344 | 355 | # define __cpp_lib_raw_memory_algorithms 201606L |
| 345 | 356 | # define __cpp_lib_sample 201603L |
| 346 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 357 | # if _LIBCPP_HAS_THREADS | |
| 347 | 358 | # define __cpp_lib_scoped_lock 201703L |
| 348 | 359 | # endif |
| 349 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 360 | # if _LIBCPP_HAS_THREADS | |
| 350 | 361 | # define __cpp_lib_shared_mutex 201505L |
| 351 | 362 | # endif |
| 352 | 363 | # define __cpp_lib_shared_ptr_arrays 201611L |
| ... | ... | @@ -367,7 +378,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 367 | 378 | # define __cpp_lib_array_constexpr 201811L |
| 368 | 379 | # define __cpp_lib_assume_aligned 201811L |
| 369 | 380 | # define __cpp_lib_atomic_flag_test 201907L |
| 370 | // # define __cpp_lib_atomic_float 201711L | |
| 381 | # define __cpp_lib_atomic_float 201711L | |
| 371 | 382 | # define __cpp_lib_atomic_lock_free_type_aliases 201907L |
| 372 | 383 | # define __cpp_lib_atomic_ref 201806L |
| 373 | 384 | // # define __cpp_lib_atomic_shared_ptr 201711L |
| ... | ... | @@ -375,14 +386,14 @@ __cpp_lib_void_t 201411L <type_traits> |
| 375 | 386 | # if _LIBCPP_AVAILABILITY_HAS_SYNC |
| 376 | 387 | # define __cpp_lib_atomic_wait 201907L |
| 377 | 388 | # endif |
| 378 | # if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC | |
| 389 | # if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC | |
| 379 | 390 | # define __cpp_lib_barrier 201907L |
| 380 | 391 | # endif |
| 381 | 392 | # define __cpp_lib_bind_front 201907L |
| 382 | 393 | # define __cpp_lib_bit_cast 201806L |
| 383 | 394 | # define __cpp_lib_bitops 201907L |
| 384 | 395 | # define __cpp_lib_bounded_array_traits 201902L |
| 385 | # if !defined(_LIBCPP_HAS_NO_CHAR8_T) | |
| 396 | # if _LIBCPP_HAS_CHAR8_T | |
| 386 | 397 | # define __cpp_lib_char8_t 201907L |
| 387 | 398 | # endif |
| 388 | 399 | # define __cpp_lib_concepts 202002L |
| ... | ... | @@ -406,7 +417,9 @@ __cpp_lib_void_t 201411L <type_traits> |
| 406 | 417 | # define __cpp_lib_erase_if 202002L |
| 407 | 418 | # undef __cpp_lib_execution |
| 408 | 419 | // # define __cpp_lib_execution 201902L |
| 409 | # define __cpp_lib_format 202110L | |
| 420 | # if _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT | |
| 421 | # define __cpp_lib_format 202110L | |
| 422 | # endif | |
| 410 | 423 | # define __cpp_lib_format_uchar 202311L |
| 411 | 424 | # define __cpp_lib_generic_unordered_lookup 201811L |
| 412 | 425 | # define __cpp_lib_int_pow2 202002L |
| ... | ... | @@ -416,34 +429,36 @@ __cpp_lib_void_t 201411L <type_traits> |
| 416 | 429 | // # define __cpp_lib_is_layout_compatible 201907L |
| 417 | 430 | # define __cpp_lib_is_nothrow_convertible 201806L |
| 418 | 431 | // # define __cpp_lib_is_pointer_interconvertible 201907L |
| 419 | # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && _LIBCPP_AVAILABILITY_HAS_SYNC | |
| 432 | # if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC | |
| 420 | 433 | # define __cpp_lib_jthread 201911L |
| 421 | 434 | # endif |
| 422 | # if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC | |
| 435 | # if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC | |
| 423 | 436 | # define __cpp_lib_latch 201907L |
| 424 | 437 | # endif |
| 425 | 438 | # define __cpp_lib_list_remove_return_type 201806L |
| 426 | 439 | # define __cpp_lib_math_constants 201907L |
| 427 | 440 | # define __cpp_lib_move_iterator_concept 202207L |
| 441 | # undef __cpp_lib_optional | |
| 442 | # define __cpp_lib_optional 202106L | |
| 428 | 443 | # if _LIBCPP_AVAILABILITY_HAS_PMR |
| 429 | 444 | # define __cpp_lib_polymorphic_allocator 201902L |
| 430 | 445 | # endif |
| 431 | # define __cpp_lib_ranges 202207L | |
| 446 | # define __cpp_lib_ranges 202110L | |
| 432 | 447 | # define __cpp_lib_remove_cvref 201711L |
| 433 | # if !defined(_LIBCPP_HAS_NO_THREADS) && _LIBCPP_AVAILABILITY_HAS_SYNC | |
| 448 | # if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_SYNC | |
| 434 | 449 | # define __cpp_lib_semaphore 201907L |
| 435 | 450 | # endif |
| 436 | 451 | # undef __cpp_lib_shared_ptr_arrays |
| 437 | 452 | # define __cpp_lib_shared_ptr_arrays 201707L |
| 438 | 453 | # define __cpp_lib_shift 201806L |
| 439 | // # define __cpp_lib_smart_ptr_for_overwrite 202002L | |
| 454 | # define __cpp_lib_smart_ptr_for_overwrite 202002L | |
| 440 | 455 | # define __cpp_lib_source_location 201907L |
| 441 | 456 | # define __cpp_lib_span 202002L |
| 442 | 457 | # define __cpp_lib_ssize 201902L |
| 443 | 458 | # define __cpp_lib_starts_ends_with 201711L |
| 444 | 459 | # undef __cpp_lib_string_view |
| 445 | 460 | # define __cpp_lib_string_view 201803L |
| 446 | # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM) | |
| 461 | # if _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM | |
| 447 | 462 | # define __cpp_lib_syncbuf 201803L |
| 448 | 463 | # endif |
| 449 | 464 | # define __cpp_lib_three_way_comparison 201907L |
| ... | ... | @@ -451,6 +466,8 @@ __cpp_lib_void_t 201411L <type_traits> |
| 451 | 466 | # define __cpp_lib_to_array 201907L |
| 452 | 467 | # define __cpp_lib_type_identity 201806L |
| 453 | 468 | # define __cpp_lib_unwrap_ref 201811L |
| 469 | # undef __cpp_lib_variant | |
| 470 | # define __cpp_lib_variant 202106L | |
| 454 | 471 | #endif |
| 455 | 472 | |
| 456 | 473 | #if _LIBCPP_STD_VER >= 23 |
| ... | ... | @@ -467,11 +484,16 @@ __cpp_lib_void_t 201411L <type_traits> |
| 467 | 484 | # define __cpp_lib_constexpr_typeinfo 202106L |
| 468 | 485 | # define __cpp_lib_containers_ranges 202202L |
| 469 | 486 | # define __cpp_lib_expected 202211L |
| 487 | # define __cpp_lib_flat_map 202207L | |
| 488 | // # define __cpp_lib_flat_set 202207L | |
| 470 | 489 | # define __cpp_lib_format_ranges 202207L |
| 471 | 490 | // # define __cpp_lib_formatters 202302L |
| 472 | 491 | # define __cpp_lib_forward_like 202207L |
| 473 | 492 | # define __cpp_lib_invoke_r 202106L |
| 474 | 493 | # define __cpp_lib_ios_noreplace 202207L |
| 494 | # if __has_builtin(__builtin_is_implicit_lifetime) | |
| 495 | # define __cpp_lib_is_implicit_lifetime 202302L | |
| 496 | # endif | |
| 475 | 497 | # define __cpp_lib_is_scoped_enum 202011L |
| 476 | 498 | # define __cpp_lib_mdspan 202207L |
| 477 | 499 | # define __cpp_lib_modules 202207L |
| ... | ... | @@ -479,7 +501,11 @@ __cpp_lib_void_t 201411L <type_traits> |
| 479 | 501 | # undef __cpp_lib_optional |
| 480 | 502 | # define __cpp_lib_optional 202110L |
| 481 | 503 | # define __cpp_lib_out_ptr 202106L |
| 482 | # define __cpp_lib_print 202207L | |
| 504 | # if _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT | |
| 505 | # define __cpp_lib_print 202207L | |
| 506 | # endif | |
| 507 | # undef __cpp_lib_ranges | |
| 508 | # define __cpp_lib_ranges 202406L | |
| 483 | 509 | // # define __cpp_lib_ranges_as_const 202207L |
| 484 | 510 | # define __cpp_lib_ranges_as_rvalue 202207L |
| 485 | 511 | // # define __cpp_lib_ranges_chunk 202202L |
| ... | ... | @@ -510,7 +536,9 @@ __cpp_lib_void_t 201411L <type_traits> |
| 510 | 536 | # undef __cpp_lib_bind_front |
| 511 | 537 | # define __cpp_lib_bind_front 202306L |
| 512 | 538 | # define __cpp_lib_bitset 202306L |
| 513 | // # define __cpp_lib_constexpr_new 202406L | |
| 539 | # if !defined(_LIBCPP_ABI_VCRUNTIME) | |
| 540 | # define __cpp_lib_constexpr_new 202406L | |
| 541 | # endif | |
| 514 | 542 | // # define __cpp_lib_constrained_equality 202403L |
| 515 | 543 | // # define __cpp_lib_copyable_function 202306L |
| 516 | 544 | // # define __cpp_lib_debugging 202311L |
| ... | ... | @@ -524,18 +552,22 @@ __cpp_lib_void_t 201411L <type_traits> |
| 524 | 552 | // # define __cpp_lib_freestanding_optional 202311L |
| 525 | 553 | // # define __cpp_lib_freestanding_string_view 202311L |
| 526 | 554 | // # define __cpp_lib_freestanding_variant 202311L |
| 527 | # if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 555 | # if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION | |
| 528 | 556 | # define __cpp_lib_fstream_native_handle 202306L |
| 529 | 557 | # endif |
| 530 | 558 | // # define __cpp_lib_function_ref 202306L |
| 531 | 559 | // # define __cpp_lib_generate_random 202403L |
| 532 | 560 | // # define __cpp_lib_hazard_pointer 202306L |
| 533 | 561 | // # define __cpp_lib_inplace_vector 202406L |
| 534 | // # define __cpp_lib_is_virtual_base_of 202406L | |
| 562 | # if __has_builtin(__builtin_is_virtual_base_of) | |
| 563 | # define __cpp_lib_is_virtual_base_of 202406L | |
| 564 | # endif | |
| 535 | 565 | // # define __cpp_lib_is_within_lifetime 202306L |
| 536 | 566 | // # define __cpp_lib_linalg 202311L |
| 537 | 567 | # undef __cpp_lib_mdspan |
| 538 | 568 | # define __cpp_lib_mdspan 202406L |
| 569 | # undef __cpp_lib_not_fn | |
| 570 | # define __cpp_lib_not_fn 202306L | |
| 539 | 571 | // # define __cpp_lib_optional_range_support 202406L |
| 540 | 572 | # undef __cpp_lib_out_ptr |
| 541 | 573 | # define __cpp_lib_out_ptr 202311L |
| ... | ... | @@ -559,8 +591,12 @@ __cpp_lib_void_t 201411L <type_traits> |
| 559 | 591 | // # define __cpp_lib_to_string 202306L |
| 560 | 592 | # undef __cpp_lib_tuple_like |
| 561 | 593 | // # define __cpp_lib_tuple_like 202311L |
| 594 | # undef __cpp_lib_variant | |
| 595 | # define __cpp_lib_variant 202306L | |
| 562 | 596 | #endif |
| 563 | 597 | |
| 598 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 599 | ||
| 564 | 600 | // clang-format on |
| 565 | 601 | |
| 566 | 602 | #endif // _LIBCPP_VERSIONH |
lib/libcxx/include/wchar.h+30-34| ... | ... | @@ -7,17 +7,6 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #if defined(__need_wint_t) || defined(__need_mbstate_t) | |
| 11 | ||
| 12 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 13 | # pragma GCC system_header | |
| 14 | # endif | |
| 15 | ||
| 16 | # include_next <wchar.h> | |
| 17 | ||
| 18 | #elif !defined(_LIBCPP_WCHAR_H) | |
| 19 | # define _LIBCPP_WCHAR_H | |
| 20 | ||
| 21 | 10 | /* |
| 22 | 11 | wchar.h synopsis |
| 23 | 12 | |
| ... | ... | @@ -105,13 +94,10 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, |
| 105 | 94 | |
| 106 | 95 | */ |
| 107 | 96 | |
| 97 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 98 | # include <__cxx03/wchar.h> | |
| 99 | #else | |
| 108 | 100 | # include <__config> |
| 109 | # include <stddef.h> | |
| 110 | ||
| 111 | # if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 112 | # error \ | |
| 113 | "The <wchar.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled" | |
| 114 | # endif | |
| 115 | 101 | |
| 116 | 102 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 117 | 103 | # pragma GCC system_header |
| ... | ... | @@ -119,30 +105,38 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, |
| 119 | 105 | |
| 120 | 106 | // We define this here to support older versions of glibc <wchar.h> that do |
| 121 | 107 | // not define this for clang. |
| 122 | # ifdef __cplusplus | |
| 108 | # if defined(__cplusplus) && !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO) | |
| 123 | 109 | # define __CORRECT_ISO_CPP_WCHAR_H_PROTO |
| 124 | 110 | # endif |
| 125 | 111 | |
| 112 | // The inclusion of the system's <wchar.h> is intentionally done once outside of any include | |
| 113 | // guards because some code expects to be able to include the underlying system header multiple | |
| 114 | // times to get different definitions based on the macros that are set before inclusion. | |
| 126 | 115 | # if __has_include_next(<wchar.h>) |
| 127 | 116 | # include_next <wchar.h> |
| 128 | # else | |
| 129 | # include <__mbstate_t.h> // make sure we have mbstate_t regardless of the existence of <wchar.h> | |
| 130 | 117 | # endif |
| 131 | 118 | |
| 119 | # ifndef _LIBCPP_WCHAR_H | |
| 120 | # define _LIBCPP_WCHAR_H | |
| 121 | ||
| 122 | # include <__mbstate_t.h> // provide mbstate_t | |
| 123 | # include <stddef.h> // provide size_t | |
| 124 | ||
| 132 | 125 | // Determine whether we have const-correct overloads for wcschr and friends. |
| 133 | # if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_) | |
| 134 | # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 | |
| 135 | # elif defined(__GLIBC_PREREQ) | |
| 136 | # if __GLIBC_PREREQ(2, 10) | |
| 126 | # if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_) | |
| 137 | 127 | # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 |
| 128 | # elif defined(__GLIBC_PREREQ) | |
| 129 | # if __GLIBC_PREREQ(2, 10) | |
| 130 | # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 | |
| 131 | # endif | |
| 132 | # elif defined(_LIBCPP_MSVCRT) | |
| 133 | # if defined(_CRT_CONST_CORRECT_OVERLOADS) | |
| 134 | # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 | |
| 135 | # endif | |
| 138 | 136 | # endif |
| 139 | # elif defined(_LIBCPP_MSVCRT) | |
| 140 | # if defined(_CRT_CONST_CORRECT_OVERLOADS) | |
| 141 | # define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 | |
| 142 | # endif | |
| 143 | # endif | |
| 144 | 137 | |
| 145 | # if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) | |
| 138 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 139 | # if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD) | |
| 146 | 140 | extern "C++" { |
| 147 | 141 | inline _LIBCPP_HIDE_FROM_ABI wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) { |
| 148 | 142 | return (wchar_t*)wcschr(__s, __c); |
| ... | ... | @@ -197,15 +191,17 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD wchar_t* wmemchr(wchar_t |
| 197 | 191 | return __libcpp_wmemchr(__s, __c, __n); |
| 198 | 192 | } |
| 199 | 193 | } |
| 200 | # endif | |
| 194 | # endif | |
| 201 | 195 | |
| 202 | # if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__)) | |
| 196 | # if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__)) | |
| 203 | 197 | extern "C" { |
| 204 | 198 | size_t mbsnrtowcs( |
| 205 | 199 | wchar_t* __restrict __dst, const char** __restrict __src, size_t __nmc, size_t __len, mbstate_t* __restrict __ps); |
| 206 | 200 | size_t wcsnrtombs( |
| 207 | 201 | char* __restrict __dst, const wchar_t** __restrict __src, size_t __nwc, size_t __len, mbstate_t* __restrict __ps); |
| 208 | 202 | } // extern "C" |
| 209 | # endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__) | |
| 203 | # endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__) | |
| 204 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 205 | # endif // _LIBCPP_WCHAR_H | |
| 210 | 206 | |
| 211 | #endif // _LIBCPP_WCHAR_H | |
| 207 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
lib/libcxx/include/wctype.h+35-36| ... | ... | @@ -44,16 +44,14 @@ wctrans_t wctrans(const char* property); |
| 44 | 44 | |
| 45 | 45 | */ |
| 46 | 46 | |
| 47 | #include <__config> | |
| 47 | #if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 48 | # include <__cxx03/wctype.h> | |
| 49 | #else | |
| 50 | # include <__config> | |
| 48 | 51 | |
| 49 | #if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 50 | # error \ | |
| 51 | "The <wctype.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled" | |
| 52 | #endif | |
| 53 | ||
| 54 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 55 | # pragma GCC system_header | |
| 56 | #endif | |
| 52 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 53 | # pragma GCC system_header | |
| 54 | # endif | |
| 57 | 55 | |
| 58 | 56 | // TODO: |
| 59 | 57 | // In the future, we should unconditionally include_next <wctype.h> here and instead |
| ... | ... | @@ -64,32 +62,33 @@ wctrans_t wctrans(const char* property); |
| 64 | 62 | // nothing (with using_if_exists), and if we include another header that defines one |
| 65 | 63 | // of these declarations (e.g. <wchar.h>), the second `using ::wint_t` with using_if_exists |
| 66 | 64 | // will fail because it does not refer to the same declaration. |
| 67 | #if __has_include_next(<wctype.h>) | |
| 68 | # include_next <wctype.h> | |
| 69 | # define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H | |
| 70 | #endif | |
| 71 | ||
| 72 | #ifdef __cplusplus | |
| 73 | ||
| 74 | # undef iswalnum | |
| 75 | # undef iswalpha | |
| 76 | # undef iswblank | |
| 77 | # undef iswcntrl | |
| 78 | # undef iswdigit | |
| 79 | # undef iswgraph | |
| 80 | # undef iswlower | |
| 81 | # undef iswprint | |
| 82 | # undef iswpunct | |
| 83 | # undef iswspace | |
| 84 | # undef iswupper | |
| 85 | # undef iswxdigit | |
| 86 | # undef iswctype | |
| 87 | # undef wctype | |
| 88 | # undef towlower | |
| 89 | # undef towupper | |
| 90 | # undef towctrans | |
| 91 | # undef wctrans | |
| 92 | ||
| 93 | #endif // __cplusplus | |
| 65 | # if __has_include_next(<wctype.h>) | |
| 66 | # include_next <wctype.h> | |
| 67 | # define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H | |
| 68 | # endif | |
| 69 | ||
| 70 | # ifdef __cplusplus | |
| 71 | ||
| 72 | # undef iswalnum | |
| 73 | # undef iswalpha | |
| 74 | # undef iswblank | |
| 75 | # undef iswcntrl | |
| 76 | # undef iswdigit | |
| 77 | # undef iswgraph | |
| 78 | # undef iswlower | |
| 79 | # undef iswprint | |
| 80 | # undef iswpunct | |
| 81 | # undef iswspace | |
| 82 | # undef iswupper | |
| 83 | # undef iswxdigit | |
| 84 | # undef iswctype | |
| 85 | # undef wctype | |
| 86 | # undef towlower | |
| 87 | # undef towupper | |
| 88 | # undef towctrans | |
| 89 | # undef wctrans | |
| 90 | ||
| 91 | # endif // __cplusplus | |
| 92 | #endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) | |
| 94 | 93 | |
| 95 | 94 | #endif // _LIBCPP_WCTYPE_H |
lib/libcxx/libc/hdr/errno_macros.h created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | //===-- Definition of macros from errno.h ---------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_HDR_ERRNO_MACROS_H | |
| 10 | #define LLVM_LIBC_HDR_ERRNO_MACROS_H | |
| 11 | ||
| 12 | #ifdef LIBC_FULL_BUILD | |
| 13 | ||
| 14 | #ifdef __linux__ | |
| 15 | #include <linux/errno.h> | |
| 16 | ||
| 17 | #include "include/llvm-libc-macros/error-number-macros.h" | |
| 18 | #else // __linux__ | |
| 19 | #include "include/llvm-libc-macros/generic-error-number-macros.h" | |
| 20 | #endif | |
| 21 | ||
| 22 | #else // Overlay mode | |
| 23 | ||
| 24 | #include <errno.h> | |
| 25 | ||
| 26 | #endif // LLVM_LIBC_FULL_BUILD | |
| 27 | ||
| 28 | #endif // LLVM_LIBC_HDR_ERRNO_MACROS_H |
lib/libcxx/libc/hdr/fenv_macros.h created+61| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | //===-- Definition of macros from fenv.h ----------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_HDR_FENV_MACROS_H | |
| 10 | #define LLVM_LIBC_HDR_FENV_MACROS_H | |
| 11 | ||
| 12 | #ifdef LIBC_FULL_BUILD | |
| 13 | ||
| 14 | #include "include/llvm-libc-macros/fenv-macros.h" | |
| 15 | ||
| 16 | #else // Overlay mode | |
| 17 | ||
| 18 | #include <fenv.h> | |
| 19 | ||
| 20 | // In some environment, FE_ALL_EXCEPT is set to 0 and the remaining exceptions | |
| 21 | // FE_* are missing. | |
| 22 | #ifndef FE_DIVBYZERO | |
| 23 | #define FE_DIVBYZERO 0 | |
| 24 | #endif // FE_DIVBYZERO | |
| 25 | ||
| 26 | #ifndef FE_INEXACT | |
| 27 | #define FE_INEXACT 0 | |
| 28 | #endif // FE_INEXACT | |
| 29 | ||
| 30 | #ifndef FE_INVALID | |
| 31 | #define FE_INVALID 0 | |
| 32 | #endif // FE_INVALID | |
| 33 | ||
| 34 | #ifndef FE_OVERFLOW | |
| 35 | #define FE_OVERFLOW 0 | |
| 36 | #endif // FE_OVERFLOW | |
| 37 | ||
| 38 | #ifndef FE_UNDERFLOW | |
| 39 | #define FE_UNDERFLOW 0 | |
| 40 | #endif // FE_UNDERFLOW | |
| 41 | ||
| 42 | // Rounding mode macros might be missing. | |
| 43 | #ifndef FE_DOWNWARD | |
| 44 | #define FE_DOWNWARD 0x400 | |
| 45 | #endif // FE_DOWNWARD | |
| 46 | ||
| 47 | #ifndef FE_TONEAREST | |
| 48 | #define FE_TONEAREST 0 | |
| 49 | #endif // FE_TONEAREST | |
| 50 | ||
| 51 | #ifndef FE_TOWARDZERO | |
| 52 | #define FE_TOWARDZERO 0xC00 | |
| 53 | #endif // FE_TOWARDZERO | |
| 54 | ||
| 55 | #ifndef FE_UPWARD | |
| 56 | #define FE_UPWARD 0x800 | |
| 57 | #endif // FE_UPWARD | |
| 58 | ||
| 59 | #endif // LLVM_LIBC_FULL_BUILD | |
| 60 | ||
| 61 | #endif // LLVM_LIBC_HDR_FENV_MACROS_H |
lib/libcxx/libc/hdr/float_macros.h created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | //===-- Definition of macros from math.h ----------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_HDR_FLOAT_MACROS_H | |
| 10 | #define LLVM_LIBC_HDR_FLOAT_MACROS_H | |
| 11 | ||
| 12 | #ifdef LIBC_FULL_BUILD | |
| 13 | ||
| 14 | #include "include/llvm-libc-macros/float-macros.h" | |
| 15 | ||
| 16 | #else // Overlay mode | |
| 17 | ||
| 18 | #include <float.h> | |
| 19 | ||
| 20 | #endif // LLVM_LIBC_FULL_BUILD | |
| 21 | ||
| 22 | #endif // LLVM_LIBC_HDR_FLOAT_MACROS_H |
lib/libcxx/libc/hdr/limits_macros.h created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | //===-- Definition of macros from limits.h --------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_HDR_LIMITS_MACROS_H | |
| 10 | #define LLVM_LIBC_HDR_LIMITS_MACROS_H | |
| 11 | ||
| 12 | #ifdef LIBC_FULL_BUILD | |
| 13 | ||
| 14 | #include "include/llvm-libc-macros/limits-macros.h" | |
| 15 | ||
| 16 | #else // Overlay mode | |
| 17 | ||
| 18 | #include <limits.h> | |
| 19 | ||
| 20 | #endif // LLVM_LIBC_FULL_BUILD | |
| 21 | ||
| 22 | #endif // LLVM_LIBC_HDR_LIMITS_MACROS_H |
lib/libcxx/libc/include/llvm-libc-macros/float-macros.h created+178| ... | ... | @@ -0,0 +1,178 @@ |
| 1 | //===-- Definition of macros from float.h ---------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_MACROS_FLOAT_MACROS_H | |
| 10 | #define LLVM_LIBC_MACROS_FLOAT_MACROS_H | |
| 11 | ||
| 12 | #ifndef FLT_RADIX | |
| 13 | #define FLT_RADIX __FLT_RADIX__ | |
| 14 | #endif // FLT_RADIX | |
| 15 | ||
| 16 | #ifndef FLT_EVAL_METHOD | |
| 17 | #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ | |
| 18 | #endif // FLT_EVAL_METHOD | |
| 19 | ||
| 20 | #ifndef FLT_ROUNDS | |
| 21 | #if __has_builtin(__builtin_flt_rounds) | |
| 22 | #define FLT_ROUNDS __builtin_flt_rounds() | |
| 23 | #else | |
| 24 | #define FLT_ROUNDS 1 | |
| 25 | #endif | |
| 26 | #endif // FLT_ROUNDS | |
| 27 | ||
| 28 | #ifndef FLT_DECIMAL_DIG | |
| 29 | #define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__ | |
| 30 | #endif // FLT_DECIMAL_DIG | |
| 31 | ||
| 32 | #ifndef DBL_DECIMAL_DIG | |
| 33 | #define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__ | |
| 34 | #endif // DBL_DECIMAL_DIG | |
| 35 | ||
| 36 | #ifndef LDBL_DECIMAL_DIG | |
| 37 | #define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ | |
| 38 | #endif // LDBL_DECIMAL_DIG | |
| 39 | ||
| 40 | #ifndef DECIMAL_DIG | |
| 41 | #define DECIMAL_DIG __DECIMAL_DIG__ | |
| 42 | #endif // DECIMAL_DIG | |
| 43 | ||
| 44 | #ifndef FLT_DIG | |
| 45 | #define FLT_DIG __FLT_DIG__ | |
| 46 | #endif // FLT_DIG | |
| 47 | ||
| 48 | #ifndef DBL_DIG | |
| 49 | #define DBL_DIG __DBL_DIG__ | |
| 50 | #endif // DBL_DIG | |
| 51 | ||
| 52 | #ifndef LDBL_DIG | |
| 53 | #define LDBL_DIG __LDBL_DIG__ | |
| 54 | #endif // LDBL_DIG | |
| 55 | ||
| 56 | #ifndef FLT_MANT_DIG | |
| 57 | #define FLT_MANT_DIG __FLT_MANT_DIG__ | |
| 58 | #endif // FLT_MANT_DIG | |
| 59 | ||
| 60 | #ifndef DBL_MANT_DIG | |
| 61 | #define DBL_MANT_DIG __DBL_MANT_DIG__ | |
| 62 | #endif // DBL_MANT_DIG | |
| 63 | ||
| 64 | #ifndef LDBL_MANT_DIG | |
| 65 | #define LDBL_MANT_DIG __LDBL_MANT_DIG__ | |
| 66 | #endif // LDBL_MANT_DIG | |
| 67 | ||
| 68 | #ifndef FLT_MIN | |
| 69 | #define FLT_MIN __FLT_MIN__ | |
| 70 | #endif // FLT_MIN | |
| 71 | ||
| 72 | #ifndef DBL_MIN | |
| 73 | #define DBL_MIN __DBL_MIN__ | |
| 74 | #endif // DBL_MIN | |
| 75 | ||
| 76 | #ifndef LDBL_MIN | |
| 77 | #define LDBL_MIN __LDBL_MIN__ | |
| 78 | #endif // LDBL_MIN | |
| 79 | ||
| 80 | #ifndef FLT_MAX | |
| 81 | #define FLT_MAX __FLT_MAX__ | |
| 82 | #endif // FLT_MAX | |
| 83 | ||
| 84 | #ifndef DBL_MAX | |
| 85 | #define DBL_MAX __DBL_MAX__ | |
| 86 | #endif // DBL_MAX | |
| 87 | ||
| 88 | #ifndef LDBL_MAX | |
| 89 | #define LDBL_MAX __LDBL_MAX__ | |
| 90 | #endif // LDBL_MAX | |
| 91 | ||
| 92 | #ifndef FLT_TRUE_MIN | |
| 93 | #define FLT_TRUE_MIN __FLT_DENORM_MIN__ | |
| 94 | #endif // FLT_TRUE_MIN | |
| 95 | ||
| 96 | #ifndef DBL_TRUE_MIN | |
| 97 | #define DBL_TRUE_MIN __DBL_DENORM_MIN__ | |
| 98 | #endif // DBL_TRUE_MIN | |
| 99 | ||
| 100 | #ifndef LDBL_TRUE_MIN | |
| 101 | #define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ | |
| 102 | #endif // LDBL_TRUE_MIN | |
| 103 | ||
| 104 | #ifndef FLT_EPSILON | |
| 105 | #define FLT_EPSILON __FLT_EPSILON__ | |
| 106 | #endif // FLT_EPSILON | |
| 107 | ||
| 108 | #ifndef DBL_EPSILON | |
| 109 | #define DBL_EPSILON __DBL_EPSILON__ | |
| 110 | #endif // DBL_EPSILON | |
| 111 | ||
| 112 | #ifndef LDBL_EPSILON | |
| 113 | #define LDBL_EPSILON __LDBL_EPSILON__ | |
| 114 | #endif // LDBL_EPSILON | |
| 115 | ||
| 116 | #ifndef FLT_MIN_EXP | |
| 117 | #define FLT_MIN_EXP __FLT_MIN_EXP__ | |
| 118 | #endif // FLT_MIN_EXP | |
| 119 | ||
| 120 | #ifndef DBL_MIN_EXP | |
| 121 | #define DBL_MIN_EXP __DBL_MIN_EXP__ | |
| 122 | #endif // DBL_MIN_EXP | |
| 123 | ||
| 124 | #ifndef LDBL_MIN_EXP | |
| 125 | #define LDBL_MIN_EXP __LDBL_MIN_EXP__ | |
| 126 | #endif // LDBL_MIN_EXP | |
| 127 | ||
| 128 | #ifndef FLT_MIN_10_EXP | |
| 129 | #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__ | |
| 130 | #endif // FLT_MIN_10_EXP | |
| 131 | ||
| 132 | #ifndef DBL_MIN_10_EXP | |
| 133 | #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__ | |
| 134 | #endif // DBL_MIN_10_EXP | |
| 135 | ||
| 136 | #ifndef LDBL_MIN_10_EXP | |
| 137 | #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ | |
| 138 | #endif // LDBL_MIN_10_EXP | |
| 139 | ||
| 140 | #ifndef FLT_MAX_EXP | |
| 141 | #define FLT_MAX_EXP __FLT_MAX_EXP__ | |
| 142 | #endif // FLT_MAX_EXP | |
| 143 | ||
| 144 | #ifndef DBL_MAX_EXP | |
| 145 | #define DBL_MAX_EXP __DBL_MAX_EXP__ | |
| 146 | #endif // DBL_MAX_EXP | |
| 147 | ||
| 148 | #ifndef LDBL_MAX_EXP | |
| 149 | #define LDBL_MAX_EXP __LDBL_MAX_EXP__ | |
| 150 | #endif // LDBL_MAX_EXP | |
| 151 | ||
| 152 | #ifndef FLT_MAX_10_EXP | |
| 153 | #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__ | |
| 154 | #endif // FLT_MAX_10_EXP | |
| 155 | ||
| 156 | #ifndef DBL_MAX_10_EXP | |
| 157 | #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__ | |
| 158 | #endif // DBL_MAX_10_EXP | |
| 159 | ||
| 160 | #ifndef LDBL_MAX_10_EXP | |
| 161 | #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ | |
| 162 | #endif // LDBL_MAX_10_EXP | |
| 163 | ||
| 164 | #ifndef FLT_HAS_SUBNORM | |
| 165 | #define FLT_HAS_SUBNORM __FLT_HAS_DENORM__ | |
| 166 | #endif // FLT_HAS_SUBNORM | |
| 167 | ||
| 168 | #ifndef DBL_HAS_SUBNORM | |
| 169 | #define DBL_HAS_SUBNORM __DBL_HAS_DENORM__ | |
| 170 | #endif // DBL_HAS_SUBNORM | |
| 171 | ||
| 172 | #ifndef LDBL_HAS_SUBNORM | |
| 173 | #define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__ | |
| 174 | #endif // LDBL_HAS_SUBNORM | |
| 175 | ||
| 176 | // TODO: Add FLT16 and FLT128 constants. | |
| 177 | ||
| 178 | #endif // LLVM_LIBC_MACROS_FLOAT_MACROS_H |
lib/libcxx/libc/include/llvm-libc-macros/float16-macros.h created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | //===-- Detection of _Float16 compiler builtin type -----------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_MACROS_FLOAT16_MACROS_H | |
| 10 | #define LLVM_LIBC_MACROS_FLOAT16_MACROS_H | |
| 11 | ||
| 12 | #include "../llvm-libc-types/float128.h" | |
| 13 | ||
| 14 | #if defined(__FLT16_MANT_DIG__) && \ | |
| 15 | (!defined(__GNUC__) || __GNUC__ >= 13 || defined(__clang__)) && \ | |
| 16 | !defined(__arm__) && !defined(_M_ARM) && !defined(__riscv) && \ | |
| 17 | !defined(_WIN32) | |
| 18 | #define LIBC_TYPES_HAS_FLOAT16 | |
| 19 | ||
| 20 | // TODO: This would no longer be required if HdrGen let us guard function | |
| 21 | // declarations with multiple macros. | |
| 22 | #ifdef LIBC_TYPES_HAS_FLOAT128 | |
| 23 | #define LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128 | |
| 24 | #endif // LIBC_TYPES_HAS_FLOAT128 | |
| 25 | #endif | |
| 26 | ||
| 27 | #endif // LLVM_LIBC_MACROS_FLOAT16_MACROS_H |
lib/libcxx/libc/include/llvm-libc-macros/stdfix-macros.h created+328| ... | ... | @@ -0,0 +1,328 @@ |
| 1 | //===-- Definitions from stdfix.h -----------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_MACROS_STDFIX_MACROS_H | |
| 10 | #define LLVM_LIBC_MACROS_STDFIX_MACROS_H | |
| 11 | ||
| 12 | #ifdef __FRACT_FBIT__ | |
| 13 | // _Fract and _Accum types are available | |
| 14 | #define LIBC_COMPILER_HAS_FIXED_POINT | |
| 15 | #endif // __FRACT_FBIT__ | |
| 16 | ||
| 17 | #ifdef LIBC_COMPILER_HAS_FIXED_POINT | |
| 18 | ||
| 19 | #define fract _Fract | |
| 20 | #define accum _Accum | |
| 21 | #define sat _Sat | |
| 22 | ||
| 23 | // Default values: from ISO/IEC TR 18037:2008 standard - Annex A.3 - Typical | |
| 24 | // desktop processor. | |
| 25 | ||
| 26 | #ifdef __SFRACT_FBIT__ | |
| 27 | #define SFRACT_FBIT __SFRACT_FBIT__ | |
| 28 | #else | |
| 29 | #define SFRACT_FBIT 7 | |
| 30 | #endif // SFRACT_FBIT | |
| 31 | ||
| 32 | #ifdef __SFRACT_MIN__ | |
| 33 | #define SFRACT_MIN __SFRACT_MIN__ | |
| 34 | #else | |
| 35 | #define SFRACT_MIN (-0.5HR - 0.5HR) | |
| 36 | #endif // SFRACT_MIN | |
| 37 | ||
| 38 | #ifdef __SFRACT_MAX__ | |
| 39 | #define SFRACT_MAX __SFRACT_MAX__ | |
| 40 | #else | |
| 41 | #define SFRACT_MAX 0x1.FCp-1HR | |
| 42 | #endif // SFRACT_MAX | |
| 43 | ||
| 44 | #ifdef __SFRACT_EPSILON__ | |
| 45 | #define SFRACT_EPSILON __SFRACT_EPSILON__ | |
| 46 | #else | |
| 47 | #define SFRACT_EPSILON 0x1.0p-7HR | |
| 48 | #endif // SFRACT_EPSILON | |
| 49 | ||
| 50 | #ifdef __USFRACT_FBIT__ | |
| 51 | #define USFRACT_FBIT __USFRACT_FBIT__ | |
| 52 | #else | |
| 53 | #define USFRACT_FBIT 8 | |
| 54 | #endif // USFRACT_FBIT | |
| 55 | ||
| 56 | #define USFRACT_MIN 0.0UHR | |
| 57 | ||
| 58 | #ifdef __USFRACT_MAX__ | |
| 59 | #define USFRACT_MAX __USFRACT_MAX__ | |
| 60 | #else | |
| 61 | #define USFRACT_MAX 0x1.FEp-1UHR | |
| 62 | #endif // USFRACT_MAX | |
| 63 | ||
| 64 | #ifdef __USFRACT_EPSILON__ | |
| 65 | #define USFRACT_EPSILON __USFRACT_EPSILON__ | |
| 66 | #else | |
| 67 | #define USFRACT_EPSILON 0x1.0p-8UHR | |
| 68 | #endif // USFRACT_EPSILON | |
| 69 | ||
| 70 | #ifdef __FRACT_FBIT__ | |
| 71 | #define FRACT_FBIT __FRACT_FBIT__ | |
| 72 | #else | |
| 73 | #define FRACT_FBIT 15 | |
| 74 | #endif // FRACT_FBIT | |
| 75 | ||
| 76 | #ifdef __FRACT_MIN__ | |
| 77 | #define FRACT_MIN __FRACT_MIN__ | |
| 78 | #else | |
| 79 | #define FRACT_MIN (-0.5R - 0.5R) | |
| 80 | #endif // FRACT_MIN | |
| 81 | ||
| 82 | #ifdef __FRACT_MAX__ | |
| 83 | #define FRACT_MAX __FRACT_MAX__ | |
| 84 | #else | |
| 85 | #define FRACT_MAX 0x1.FFFCp-1R | |
| 86 | #endif // FRACT_MAX | |
| 87 | ||
| 88 | #ifdef __FRACT_EPSILON__ | |
| 89 | #define FRACT_EPSILON __FRACT_EPSILON__ | |
| 90 | #else | |
| 91 | #define FRACT_EPSILON 0x1.0p-15R | |
| 92 | #endif // FRACT_EPSILON | |
| 93 | ||
| 94 | #ifdef __UFRACT_FBIT__ | |
| 95 | #define UFRACT_FBIT __UFRACT_FBIT__ | |
| 96 | #else | |
| 97 | #define UFRACT_FBIT 16 | |
| 98 | #endif // UFRACT_FBIT | |
| 99 | ||
| 100 | #define UFRACT_MIN 0.0UR | |
| 101 | ||
| 102 | #ifdef __UFRACT_MAX__ | |
| 103 | #define UFRACT_MAX __UFRACT_MAX__ | |
| 104 | #else | |
| 105 | #define UFRACT_MAX 0x1.FFFEp-1UR | |
| 106 | #endif // UFRACT_MAX | |
| 107 | ||
| 108 | #ifdef __UFRACT_EPSILON__ | |
| 109 | #define UFRACT_EPSILON __UFRACT_EPSILON__ | |
| 110 | #else | |
| 111 | #define UFRACT_EPSILON 0x1.0p-16UR | |
| 112 | #endif // UFRACT_EPSILON | |
| 113 | ||
| 114 | #ifdef __LFRACT_FBIT__ | |
| 115 | #define LFRACT_FBIT __LFRACT_FBIT__ | |
| 116 | #else | |
| 117 | #define LFRACT_FBIT 31 | |
| 118 | #endif // LFRACT_FBIT | |
| 119 | ||
| 120 | #ifdef __LFRACT_MIN__ | |
| 121 | #define LFRACT_MIN __LFRACT_MIN__ | |
| 122 | #else | |
| 123 | #define LFRACT_MIN (-0.5LR - 0.5LR) | |
| 124 | #endif // LFRACT_MIN | |
| 125 | ||
| 126 | #ifdef __LFRACT_MAX__ | |
| 127 | #define LFRACT_MAX __LFRACT_MAX__ | |
| 128 | #else | |
| 129 | #define LFRACT_MAX 0x1.FFFFFFFCp-1LR | |
| 130 | #endif // LFRACT_MAX | |
| 131 | ||
| 132 | #ifdef __LFRACT_EPSILON__ | |
| 133 | #define LFRACT_EPSILON __LFRACT_EPSILON__ | |
| 134 | #else | |
| 135 | #define LFRACT_EPSILON 0x1.0p-31LR | |
| 136 | #endif // LFRACT_EPSILON | |
| 137 | ||
| 138 | #ifdef __ULFRACT_FBIT__ | |
| 139 | #define ULFRACT_FBIT __ULFRACT_FBIT__ | |
| 140 | #else | |
| 141 | #define ULFRACT_FBIT 32 | |
| 142 | #endif // ULFRACT_FBIT | |
| 143 | ||
| 144 | #define ULFRACT_MIN 0.0ULR | |
| 145 | ||
| 146 | #ifdef __ULFRACT_MAX__ | |
| 147 | #define ULFRACT_MAX __ULFRACT_MAX__ | |
| 148 | #else | |
| 149 | #define ULFRACT_MAX 0x1.FFFFFFFEp-1ULR | |
| 150 | #endif // ULFRACT_MAX | |
| 151 | ||
| 152 | #ifdef __ULFRACT_EPSILON__ | |
| 153 | #define ULFRACT_EPSILON __ULFRACT_EPSILON__ | |
| 154 | #else | |
| 155 | #define ULFRACT_EPSILON 0x1.0p-32ULR | |
| 156 | #endif // ULFRACT_EPSILON | |
| 157 | ||
| 158 | #ifdef __SACCUM_FBIT__ | |
| 159 | #define SACCUM_FBIT __SACCUM_FBIT__ | |
| 160 | #else | |
| 161 | #define SACCUM_FBIT 7 | |
| 162 | #endif // SACCUM_FBIT | |
| 163 | ||
| 164 | #ifdef __SACCUM_IBIT__ | |
| 165 | #define SACCUM_IBIT __SACCUM_IBIT__ | |
| 166 | #else | |
| 167 | #define SACCUM_IBIT 8 | |
| 168 | #endif // SACCUM_IBIT | |
| 169 | ||
| 170 | #ifdef __SACCUM_MIN__ | |
| 171 | #define SACCUM_MIN __SACCUM_MIN__ | |
| 172 | #else | |
| 173 | #define SACCUM_MIN (-0x1.0p+7HK - 0x1.0p+7HK) | |
| 174 | #endif // SACCUM_MIN | |
| 175 | ||
| 176 | #ifdef __SACCUM_MAX__ | |
| 177 | #define SACCUM_MAX __SACCUM_MAX__ | |
| 178 | #else | |
| 179 | #define SACCUM_MAX 0x1.FFFCp+7HK | |
| 180 | #endif // SACCUM_MAX | |
| 181 | ||
| 182 | #ifdef __SACCUM_EPSILON__ | |
| 183 | #define SACCUM_EPSILON __SACCUM_EPSILON__ | |
| 184 | #else | |
| 185 | #define SACCUM_EPSILON 0x1.0p-7HK | |
| 186 | #endif // SACCUM_EPSILON | |
| 187 | ||
| 188 | #ifdef __USACCUM_FBIT__ | |
| 189 | #define USACCUM_FBIT __USACCUM_FBIT__ | |
| 190 | #else | |
| 191 | #define USACCUM_FBIT 8 | |
| 192 | #endif // USACCUM_FBIT | |
| 193 | ||
| 194 | #ifdef __USACCUM_IBIT__ | |
| 195 | #define USACCUM_IBIT __USACCUM_IBIT__ | |
| 196 | #else | |
| 197 | #define USACCUM_IBIT 8 | |
| 198 | #endif // USACCUM_IBIT | |
| 199 | ||
| 200 | #define USACCUM_MIN 0.0UHK | |
| 201 | ||
| 202 | #ifdef __USACCUM_MAX__ | |
| 203 | #define USACCUM_MAX __USACCUM_MAX__ | |
| 204 | #else | |
| 205 | #define USACCUM_MAX 0x1.FFFEp+7UHK | |
| 206 | #endif // USACCUM_MAX | |
| 207 | ||
| 208 | #ifdef __USACCUM_EPSILON__ | |
| 209 | #define USACCUM_EPSILON __USACCUM_EPSILON__ | |
| 210 | #else | |
| 211 | #define USACCUM_EPSILON 0x1.0p-8UHK | |
| 212 | #endif // USACCUM_EPSILON | |
| 213 | ||
| 214 | #ifdef __ACCUM_FBIT__ | |
| 215 | #define ACCUM_FBIT __ACCUM_FBIT__ | |
| 216 | #else | |
| 217 | #define ACCUM_FBIT 15 | |
| 218 | #endif // ACCUM_FBIT | |
| 219 | ||
| 220 | #ifdef __ACCUM_IBIT__ | |
| 221 | #define ACCUM_IBIT __ACCUM_IBIT__ | |
| 222 | #else | |
| 223 | #define ACCUM_IBIT 16 | |
| 224 | #endif // ACCUM_IBIT | |
| 225 | ||
| 226 | #ifdef __ACCUM_MIN__ | |
| 227 | #define ACCUM_MIN __ACCUM_MIN__ | |
| 228 | #else | |
| 229 | #define ACCUM_MIN (-0x1.0p+15K - 0x1.0p+15K) | |
| 230 | #endif // ACCUM_MIN | |
| 231 | ||
| 232 | #ifdef __ACCUM_MAX__ | |
| 233 | #define ACCUM_MAX __ACCUM_MAX__ | |
| 234 | #else | |
| 235 | #define ACCUM_MAX 0x1.FFFFFFFCp+15K | |
| 236 | #endif // ACCUM_MAX | |
| 237 | ||
| 238 | #ifdef __ACCUM_EPSILON__ | |
| 239 | #define ACCUM_EPSILON __ACCUM_EPSILON__ | |
| 240 | #else | |
| 241 | #define ACCUM_EPSILON 0x1.0p-15K | |
| 242 | #endif // ACCUM_EPSILON | |
| 243 | ||
| 244 | #ifdef __UACCUM_FBIT__ | |
| 245 | #define UACCUM_FBIT __UACCUM_FBIT__ | |
| 246 | #else | |
| 247 | #define UACCUM_FBIT 16 | |
| 248 | #endif // UACCUM_FBIT | |
| 249 | ||
| 250 | #ifdef __UACCUM_IBIT__ | |
| 251 | #define UACCUM_IBIT __UACCUM_IBIT__ | |
| 252 | #else | |
| 253 | #define UACCUM_IBIT 16 | |
| 254 | #endif // UACCUM_IBIT | |
| 255 | ||
| 256 | #define UACCUM_MIN 0.0UK | |
| 257 | ||
| 258 | #ifdef __UACCUM_MAX__ | |
| 259 | #define UACCUM_MAX __UACCUM_MAX__ | |
| 260 | #else | |
| 261 | #define UACCUM_MAX 0x1.FFFFFFFEp+15UK | |
| 262 | #endif // UACCUM_MAX | |
| 263 | ||
| 264 | #ifdef __UACCUM_EPSILON__ | |
| 265 | #define UACCUM_EPSILON __UACCUM_EPSILON__ | |
| 266 | #else | |
| 267 | #define UACCUM_EPSILON 0x1.0p-16UK | |
| 268 | #endif // UACCUM_EPSILON | |
| 269 | ||
| 270 | #ifdef __LACCUM_FBIT__ | |
| 271 | #define LACCUM_FBIT __LACCUM_FBIT__ | |
| 272 | #else | |
| 273 | #define LACCUM_FBIT 31 | |
| 274 | #endif // LACCUM_FBIT | |
| 275 | ||
| 276 | #ifdef __LACCUM_IBIT__ | |
| 277 | #define LACCUM_IBIT __LACCUM_IBIT__ | |
| 278 | #else | |
| 279 | #define LACCUM_IBIT 32 | |
| 280 | #endif // LACCUM_IBIT | |
| 281 | ||
| 282 | #ifdef __LACCUM_MIN__ | |
| 283 | #define LACCUM_MIN __LACCUM_MIN__ | |
| 284 | #else | |
| 285 | #define LACCUM_MIN (-0x1.0p+31LK - 0x1.0p+31LK) | |
| 286 | #endif // LACCUM_MIN | |
| 287 | ||
| 288 | #ifdef __LACCUM_MAX__ | |
| 289 | #define LACCUM_MAX __LACCUM_MAX__ | |
| 290 | #else | |
| 291 | #define LACCUM_MAX 0x1.FFFFFFFFFFFFFFFCp+31LK | |
| 292 | #endif // LACCUM_MAX | |
| 293 | ||
| 294 | #ifdef __LACCUM_EPSILON__ | |
| 295 | #define LACCUM_EPSILON __LACCUM_EPSILON__ | |
| 296 | #else | |
| 297 | #define LACCUM_EPSILON 0x1.0p-31LK | |
| 298 | #endif // LACCUM_EPSILON | |
| 299 | ||
| 300 | #ifdef __ULACCUM_FBIT__ | |
| 301 | #define ULACCUM_FBIT __ULACCUM_FBIT__ | |
| 302 | #else | |
| 303 | #define ULACCUM_FBIT 32 | |
| 304 | #endif // ULACCUM_FBIT | |
| 305 | ||
| 306 | #ifdef __ULACCUM_IBIT__ | |
| 307 | #define ULACCUM_IBIT __ULACCUM_IBIT__ | |
| 308 | #else | |
| 309 | #define ULACCUM_IBIT 32 | |
| 310 | #endif // ULACCUM_IBIT | |
| 311 | ||
| 312 | #define ULACCUM_MIN 0.0ULK | |
| 313 | ||
| 314 | #ifdef __ULACCUM_MAX__ | |
| 315 | #define ULACCUM_MAX __ULACCUM_MAX__ | |
| 316 | #else | |
| 317 | #define ULACCUM_MAX 0x1.FFFFFFFFFFFFFFFEp+31ULK | |
| 318 | #endif // ULACCUM_MAX | |
| 319 | ||
| 320 | #ifdef __ULACCUM_EPSILON__ | |
| 321 | #define ULACCUM_EPSILON __ULACCUM_EPSILON__ | |
| 322 | #else | |
| 323 | #define ULACCUM_EPSILON 0x1.0p-32ULK | |
| 324 | #endif // ULACCUM_EPSILON | |
| 325 | ||
| 326 | #endif // LIBC_COMPILER_HAS_FIXED_POINT | |
| 327 | ||
| 328 | #endif // LLVM_LIBC_MACROS_STDFIX_MACROS_H |
lib/libcxx/libc/include/llvm-libc-types/cfloat128.h created+44| ... | ... | @@ -0,0 +1,44 @@ |
| 1 | //===-- Definition of cfloat128 type --------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_TYPES_CFLOAT128_H | |
| 10 | #define LLVM_LIBC_TYPES_CFLOAT128_H | |
| 11 | ||
| 12 | #include "../llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG | |
| 13 | ||
| 14 | // Currently, the complex variant of C23 `_Float128` type is only defined as a | |
| 15 | // built-in type in GCC 7 or later, for C and in GCC 13 or later, for C++. For | |
| 16 | // clang, the complex variant of `__float128` is defined instead, and only on | |
| 17 | // x86-64 targets for clang 11 or later. | |
| 18 | // | |
| 19 | // TODO: Update the complex variant of C23 `_Float128` type detection again when | |
| 20 | // clang supports it. | |
| 21 | #ifdef __clang__ | |
| 22 | #if (__clang_major__ >= 11) && \ | |
| 23 | (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)) | |
| 24 | // Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__ | |
| 25 | // macro to notify the availability of __float128 type: | |
| 26 | // https://reviews.llvm.org/D15120 | |
| 27 | #define LIBC_TYPES_HAS_CFLOAT128 | |
| 28 | typedef _Complex __float128 cfloat128; | |
| 29 | #endif | |
| 30 | #elif defined(__GNUC__) | |
| 31 | #if (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && \ | |
| 32 | (__GNUC__ >= 13 || (!defined(__cplusplus))) | |
| 33 | #define LIBC_TYPES_HAS_CFLOAT128 | |
| 34 | typedef _Complex _Float128 cfloat128; | |
| 35 | #endif | |
| 36 | #endif | |
| 37 | ||
| 38 | #if !defined(LIBC_TYPES_HAS_CFLOAT128) && (LDBL_MANT_DIG == 113) | |
| 39 | #define LIBC_TYPES_HAS_CFLOAT128 | |
| 40 | #define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE | |
| 41 | typedef _Complex long double cfloat128; | |
| 42 | #endif | |
| 43 | ||
| 44 | #endif // LLVM_LIBC_TYPES_CFLOAT128_H |
lib/libcxx/libc/include/llvm-libc-types/cfloat16.h created+21| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | //===-- Definition of cfloat16 type ---------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_TYPES_CFLOAT16_H | |
| 10 | #define LLVM_LIBC_TYPES_CFLOAT16_H | |
| 11 | ||
| 12 | #if defined(__FLT16_MANT_DIG__) && \ | |
| 13 | (!defined(__GNUC__) || __GNUC__ >= 13 || \ | |
| 14 | (defined(__clang__) && __clang_major__ >= 14)) && \ | |
| 15 | !defined(__arm__) && !defined(_M_ARM) && !defined(__riscv) && \ | |
| 16 | !defined(_WIN32) | |
| 17 | #define LIBC_TYPES_HAS_CFLOAT16 | |
| 18 | typedef _Complex _Float16 cfloat16; | |
| 19 | #endif | |
| 20 | ||
| 21 | #endif // LLVM_LIBC_TYPES_CFLOAT16_H |
lib/libcxx/libc/include/llvm-libc-types/float128.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===-- Definition of float128 type ---------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_TYPES_FLOAT128_H | |
| 10 | #define LLVM_LIBC_TYPES_FLOAT128_H | |
| 11 | ||
| 12 | #include "../llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG | |
| 13 | ||
| 14 | // Currently, C23 `_Float128` type is only defined as a built-in type in GCC 7 | |
| 15 | // or later, and only for C. For C++, or for clang, `__float128` is defined | |
| 16 | // instead, and only on x86-64 targets. | |
| 17 | // | |
| 18 | // TODO: Update C23 `_Float128` type detection again when clang supports it. | |
| 19 | // https://github.com/llvm/llvm-project/issues/80195 | |
| 20 | #if defined(__STDC_IEC_60559_BFP__) && !defined(__clang__) && \ | |
| 21 | !defined(__cplusplus) | |
| 22 | #define LIBC_TYPES_HAS_FLOAT128 | |
| 23 | typedef _Float128 float128; | |
| 24 | #elif defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) | |
| 25 | // Use __float128 type. gcc and clang sometime use __SIZEOF_FLOAT128__ to | |
| 26 | // notify the availability of __float128. | |
| 27 | // clang also uses __FLOAT128__ macro to notify the availability of __float128 | |
| 28 | // type: https://reviews.llvm.org/D15120 | |
| 29 | #define LIBC_TYPES_HAS_FLOAT128 | |
| 30 | typedef __float128 float128; | |
| 31 | #elif (LDBL_MANT_DIG == 113) | |
| 32 | #define LIBC_TYPES_HAS_FLOAT128 | |
| 33 | typedef long double float128; | |
| 34 | #endif | |
| 35 | ||
| 36 | #endif // LLVM_LIBC_TYPES_FLOAT128_H |
lib/libcxx/libc/shared/fp_bits.h created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | //===-- Floating point number utils -----------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SHARED_FP_BITS_H | |
| 10 | #define LLVM_LIBC_SHARED_FP_BITS_H | |
| 11 | ||
| 12 | #include "src/__support/FPUtil/FPBits.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace shared { | |
| 16 | ||
| 17 | using fputil::FPBits; | |
| 18 | ||
| 19 | } // namespace shared | |
| 20 | } // namespace LIBC_NAMESPACE_DECL | |
| 21 | ||
| 22 | #endif // LLVM_LIBC_SHARED_FP_BITS_H |
lib/libcxx/libc/shared/str_to_float.h created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | //===-- String to float conversion utils ------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SHARED_STR_TO_FLOAT_H | |
| 10 | #define LLVM_LIBC_SHARED_STR_TO_FLOAT_H | |
| 11 | ||
| 12 | #include "src/__support/str_to_float.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace shared { | |
| 16 | ||
| 17 | using internal::ExpandedFloat; | |
| 18 | using internal::FloatConvertReturn; | |
| 19 | using internal::RoundDirection; | |
| 20 | ||
| 21 | using internal::binary_exp_to_float; | |
| 22 | using internal::decimal_exp_to_float; | |
| 23 | ||
| 24 | } // namespace shared | |
| 25 | } // namespace LIBC_NAMESPACE_DECL | |
| 26 | ||
| 27 | #endif // LLVM_LIBC_SHARED_STR_TO_FLOAT_H |
lib/libcxx/libc/shared/str_to_integer.h created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | //===-- String to int conversion utils --------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SHARED_STR_TO_INTEGER_H | |
| 10 | #define LLVM_LIBC_SHARED_STR_TO_INTEGER_H | |
| 11 | ||
| 12 | #include "src/__support/str_to_integer.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace shared { | |
| 16 | ||
| 17 | using LIBC_NAMESPACE::StrToNumResult; | |
| 18 | ||
| 19 | using internal::strtointeger; | |
| 20 | ||
| 21 | } // namespace shared | |
| 22 | } // namespace LIBC_NAMESPACE_DECL | |
| 23 | ||
| 24 | #endif // LLVM_LIBC_SHARED_STR_TO_INTEGER_H |
lib/libcxx/libc/src/__support/CPP/array.h created+80| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | //===-- A self contained equivalent of std::array ---------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_ARRAY_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_ARRAY_H | |
| 11 | ||
| 12 | #include "src/__support/CPP/iterator.h" // reverse_iterator | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | #include <stddef.h> // For size_t. | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | template <class T, size_t N> struct array { | |
| 21 | static_assert(N != 0, | |
| 22 | "Cannot create a LIBC_NAMESPACE::cpp::array of size 0."); | |
| 23 | ||
| 24 | T Data[N]; | |
| 25 | using value_type = T; | |
| 26 | using iterator = T *; | |
| 27 | using const_iterator = const T *; | |
| 28 | using reverse_iterator = cpp::reverse_iterator<iterator>; | |
| 29 | using const_reverse_iterator = cpp::reverse_iterator<const_iterator>; | |
| 30 | ||
| 31 | LIBC_INLINE constexpr T *data() { return Data; } | |
| 32 | LIBC_INLINE constexpr const T *data() const { return Data; } | |
| 33 | ||
| 34 | LIBC_INLINE constexpr T &front() { return Data[0]; } | |
| 35 | LIBC_INLINE constexpr const T &front() const { return Data[0]; } | |
| 36 | ||
| 37 | LIBC_INLINE constexpr T &back() { return Data[N - 1]; } | |
| 38 | LIBC_INLINE constexpr const T &back() const { return Data[N - 1]; } | |
| 39 | ||
| 40 | LIBC_INLINE constexpr T &operator[](size_t Index) { return Data[Index]; } | |
| 41 | ||
| 42 | LIBC_INLINE constexpr const T &operator[](size_t Index) const { | |
| 43 | return Data[Index]; | |
| 44 | } | |
| 45 | ||
| 46 | LIBC_INLINE constexpr size_t size() const { return N; } | |
| 47 | ||
| 48 | LIBC_INLINE constexpr bool empty() const { return N == 0; } | |
| 49 | ||
| 50 | LIBC_INLINE constexpr iterator begin() { return Data; } | |
| 51 | LIBC_INLINE constexpr const_iterator begin() const { return Data; } | |
| 52 | LIBC_INLINE constexpr const_iterator cbegin() const { return begin(); } | |
| 53 | ||
| 54 | LIBC_INLINE constexpr iterator end() { return Data + N; } | |
| 55 | LIBC_INLINE constexpr const_iterator end() const { return Data + N; } | |
| 56 | LIBC_INLINE constexpr const_iterator cend() const { return end(); } | |
| 57 | ||
| 58 | LIBC_INLINE constexpr reverse_iterator rbegin() { | |
| 59 | return reverse_iterator{end()}; | |
| 60 | } | |
| 61 | LIBC_INLINE constexpr const_reverse_iterator rbegin() const { | |
| 62 | return const_reverse_iterator{end()}; | |
| 63 | } | |
| 64 | LIBC_INLINE constexpr const_reverse_iterator crbegin() const { | |
| 65 | return rbegin(); | |
| 66 | } | |
| 67 | ||
| 68 | LIBC_INLINE constexpr reverse_iterator rend() { | |
| 69 | return reverse_iterator{begin()}; | |
| 70 | } | |
| 71 | LIBC_INLINE constexpr const_reverse_iterator rend() const { | |
| 72 | return const_reverse_iterator{begin()}; | |
| 73 | } | |
| 74 | LIBC_INLINE constexpr const_reverse_iterator crend() const { return rend(); } | |
| 75 | }; | |
| 76 | ||
| 77 | } // namespace cpp | |
| 78 | } // namespace LIBC_NAMESPACE_DECL | |
| 79 | ||
| 80 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_ARRAY_H |
lib/libcxx/libc/src/__support/CPP/bit.h created+298| ... | ... | @@ -0,0 +1,298 @@ |
| 1 | //===-- Implementation of the C++20 bit header -----------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | // This is inspired by LLVM ADT/bit.h header. | |
| 9 | // Some functions are missing, we can add them as needed (popcount, byteswap). | |
| 10 | ||
| 11 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H | |
| 12 | #define LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H | |
| 13 | ||
| 14 | #include "src/__support/CPP/limits.h" // numeric_limits | |
| 15 | #include "src/__support/CPP/type_traits.h" | |
| 16 | #include "src/__support/macros/attributes.h" | |
| 17 | #include "src/__support/macros/config.h" | |
| 18 | #include "src/__support/macros/sanitizer.h" | |
| 19 | ||
| 20 | #include <stdint.h> | |
| 21 | ||
| 22 | namespace LIBC_NAMESPACE_DECL { | |
| 23 | namespace cpp { | |
| 24 | ||
| 25 | #if __has_builtin(__builtin_memcpy_inline) | |
| 26 | #define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE | |
| 27 | #endif | |
| 28 | ||
| 29 | // This implementation of bit_cast requires trivially-constructible To, to avoid | |
| 30 | // UB in the implementation. | |
| 31 | template <typename To, typename From> | |
| 32 | LIBC_INLINE constexpr cpp::enable_if_t< | |
| 33 | (sizeof(To) == sizeof(From)) && | |
| 34 | cpp::is_trivially_constructible<To>::value && | |
| 35 | cpp::is_trivially_copyable<To>::value && | |
| 36 | cpp::is_trivially_copyable<From>::value, | |
| 37 | To> | |
| 38 | bit_cast(const From &from) { | |
| 39 | MSAN_UNPOISON(&from, sizeof(From)); | |
| 40 | #if __has_builtin(__builtin_bit_cast) | |
| 41 | return __builtin_bit_cast(To, from); | |
| 42 | #else | |
| 43 | To to; | |
| 44 | char *dst = reinterpret_cast<char *>(&to); | |
| 45 | const char *src = reinterpret_cast<const char *>(&from); | |
| 46 | #if __has_builtin(__builtin_memcpy_inline) | |
| 47 | __builtin_memcpy_inline(dst, src, sizeof(To)); | |
| 48 | #else | |
| 49 | for (unsigned i = 0; i < sizeof(To); ++i) | |
| 50 | dst[i] = src[i]; | |
| 51 | #endif // __has_builtin(__builtin_memcpy_inline) | |
| 52 | return to; | |
| 53 | #endif // __has_builtin(__builtin_bit_cast) | |
| 54 | } | |
| 55 | ||
| 56 | template <typename T> | |
| 57 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, | |
| 58 | bool> | |
| 59 | has_single_bit(T value) { | |
| 60 | return (value != 0) && ((value & (value - 1)) == 0); | |
| 61 | } | |
| 62 | ||
| 63 | // A temporary macro to add template function specialization when compiler | |
| 64 | // builtin is available. | |
| 65 | #define ADD_SPECIALIZATION(NAME, TYPE, BUILTIN) \ | |
| 66 | template <> [[nodiscard]] LIBC_INLINE constexpr int NAME<TYPE>(TYPE value) { \ | |
| 67 | static_assert(cpp::is_unsigned_v<TYPE>); \ | |
| 68 | return value == 0 ? cpp::numeric_limits<TYPE>::digits : BUILTIN(value); \ | |
| 69 | } | |
| 70 | ||
| 71 | /// Count number of 0's from the least significant bit to the most | |
| 72 | /// stopping at the first 1. | |
| 73 | /// | |
| 74 | /// Only unsigned integral types are allowed. | |
| 75 | /// | |
| 76 | /// Returns cpp::numeric_limits<T>::digits on an input of 0. | |
| 77 | // clang-19+, gcc-14+ | |
| 78 | #if __has_builtin(__builtin_ctzg) | |
| 79 | template <typename T> | |
| 80 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 81 | countr_zero(T value) { | |
| 82 | return __builtin_ctzg(value, cpp::numeric_limits<T>::digits); | |
| 83 | } | |
| 84 | #else | |
| 85 | template <typename T> | |
| 86 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 87 | countr_zero(T value) { | |
| 88 | if (!value) | |
| 89 | return cpp::numeric_limits<T>::digits; | |
| 90 | if (value & 0x1) | |
| 91 | return 0; | |
| 92 | // Bisection method. | |
| 93 | unsigned zero_bits = 0; | |
| 94 | unsigned shift = cpp::numeric_limits<T>::digits >> 1; | |
| 95 | T mask = cpp::numeric_limits<T>::max() >> shift; | |
| 96 | while (shift) { | |
| 97 | if ((value & mask) == 0) { | |
| 98 | value >>= shift; | |
| 99 | zero_bits |= shift; | |
| 100 | } | |
| 101 | shift >>= 1; | |
| 102 | mask >>= shift; | |
| 103 | } | |
| 104 | return zero_bits; | |
| 105 | } | |
| 106 | #if __has_builtin(__builtin_ctzs) | |
| 107 | ADD_SPECIALIZATION(countr_zero, unsigned short, __builtin_ctzs) | |
| 108 | #endif | |
| 109 | ADD_SPECIALIZATION(countr_zero, unsigned int, __builtin_ctz) | |
| 110 | ADD_SPECIALIZATION(countr_zero, unsigned long, __builtin_ctzl) | |
| 111 | ADD_SPECIALIZATION(countr_zero, unsigned long long, __builtin_ctzll) | |
| 112 | #endif // __has_builtin(__builtin_ctzg) | |
| 113 | ||
| 114 | /// Count number of 0's from the most significant bit to the least | |
| 115 | /// stopping at the first 1. | |
| 116 | /// | |
| 117 | /// Only unsigned integral types are allowed. | |
| 118 | /// | |
| 119 | /// Returns cpp::numeric_limits<T>::digits on an input of 0. | |
| 120 | // clang-19+, gcc-14+ | |
| 121 | #if __has_builtin(__builtin_clzg) | |
| 122 | template <typename T> | |
| 123 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 124 | countl_zero(T value) { | |
| 125 | return __builtin_clzg(value, cpp::numeric_limits<T>::digits); | |
| 126 | } | |
| 127 | #else | |
| 128 | template <typename T> | |
| 129 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 130 | countl_zero(T value) { | |
| 131 | if (!value) | |
| 132 | return cpp::numeric_limits<T>::digits; | |
| 133 | // Bisection method. | |
| 134 | unsigned zero_bits = 0; | |
| 135 | for (unsigned shift = cpp::numeric_limits<T>::digits >> 1; shift; | |
| 136 | shift >>= 1) { | |
| 137 | T tmp = value >> shift; | |
| 138 | if (tmp) | |
| 139 | value = tmp; | |
| 140 | else | |
| 141 | zero_bits |= shift; | |
| 142 | } | |
| 143 | return zero_bits; | |
| 144 | } | |
| 145 | #if __has_builtin(__builtin_clzs) | |
| 146 | ADD_SPECIALIZATION(countl_zero, unsigned short, __builtin_clzs) | |
| 147 | #endif | |
| 148 | ADD_SPECIALIZATION(countl_zero, unsigned int, __builtin_clz) | |
| 149 | ADD_SPECIALIZATION(countl_zero, unsigned long, __builtin_clzl) | |
| 150 | ADD_SPECIALIZATION(countl_zero, unsigned long long, __builtin_clzll) | |
| 151 | #endif // __has_builtin(__builtin_clzg) | |
| 152 | ||
| 153 | #undef ADD_SPECIALIZATION | |
| 154 | ||
| 155 | /// Count the number of ones from the most significant bit to the first | |
| 156 | /// zero bit. | |
| 157 | /// | |
| 158 | /// Ex. countl_one(0xFF0FFF00) == 8. | |
| 159 | /// Only unsigned integral types are allowed. | |
| 160 | /// | |
| 161 | /// Returns cpp::numeric_limits<T>::digits on an input of all ones. | |
| 162 | template <typename T> | |
| 163 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 164 | countl_one(T value) { | |
| 165 | return cpp::countl_zero<T>(~value); | |
| 166 | } | |
| 167 | ||
| 168 | /// Count the number of ones from the least significant bit to the first | |
| 169 | /// zero bit. | |
| 170 | /// | |
| 171 | /// Ex. countr_one(0x00FF00FF) == 8. | |
| 172 | /// Only unsigned integral types are allowed. | |
| 173 | /// | |
| 174 | /// Returns cpp::numeric_limits<T>::digits on an input of all ones. | |
| 175 | template <typename T> | |
| 176 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 177 | countr_one(T value) { | |
| 178 | return cpp::countr_zero<T>(~value); | |
| 179 | } | |
| 180 | ||
| 181 | /// Returns the number of bits needed to represent value if value is nonzero. | |
| 182 | /// Returns 0 otherwise. | |
| 183 | /// | |
| 184 | /// Ex. bit_width(5) == 3. | |
| 185 | template <typename T> | |
| 186 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 187 | bit_width(T value) { | |
| 188 | return cpp::numeric_limits<T>::digits - cpp::countl_zero(value); | |
| 189 | } | |
| 190 | ||
| 191 | /// Returns the largest integral power of two no greater than value if value is | |
| 192 | /// nonzero. Returns 0 otherwise. | |
| 193 | /// | |
| 194 | /// Ex. bit_floor(5) == 4. | |
| 195 | template <typename T> | |
| 196 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 197 | bit_floor(T value) { | |
| 198 | if (!value) | |
| 199 | return 0; | |
| 200 | return static_cast<T>(T(1) << (cpp::bit_width(value) - 1)); | |
| 201 | } | |
| 202 | ||
| 203 | /// Returns the smallest integral power of two no smaller than value if value is | |
| 204 | /// nonzero. Returns 1 otherwise. | |
| 205 | /// | |
| 206 | /// Ex. bit_ceil(5) == 8. | |
| 207 | /// | |
| 208 | /// The return value is undefined if the input is larger than the largest power | |
| 209 | /// of two representable in T. | |
| 210 | template <typename T> | |
| 211 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 212 | bit_ceil(T value) { | |
| 213 | if (value < 2) | |
| 214 | return 1; | |
| 215 | return static_cast<T>(T(1) << cpp::bit_width(value - 1U)); | |
| 216 | } | |
| 217 | ||
| 218 | // Rotate algorithms make use of "Safe, Efficient, and Portable Rotate in C/C++" | |
| 219 | // from https://blog.regehr.org/archives/1063. | |
| 220 | ||
| 221 | // Forward-declare rotr so that rotl can use it. | |
| 222 | template <typename T> | |
| 223 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 224 | rotr(T value, int rotate); | |
| 225 | ||
| 226 | template <typename T> | |
| 227 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 228 | rotl(T value, int rotate) { | |
| 229 | constexpr unsigned N = cpp::numeric_limits<T>::digits; | |
| 230 | rotate = rotate % N; | |
| 231 | if (!rotate) | |
| 232 | return value; | |
| 233 | if (rotate < 0) | |
| 234 | return cpp::rotr<T>(value, -rotate); | |
| 235 | return (value << rotate) | (value >> (N - rotate)); | |
| 236 | } | |
| 237 | ||
| 238 | template <typename T> | |
| 239 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 240 | rotr(T value, int rotate) { | |
| 241 | constexpr unsigned N = cpp::numeric_limits<T>::digits; | |
| 242 | rotate = rotate % N; | |
| 243 | if (!rotate) | |
| 244 | return value; | |
| 245 | if (rotate < 0) | |
| 246 | return cpp::rotl<T>(value, -rotate); | |
| 247 | return (value >> rotate) | (value << (N - rotate)); | |
| 248 | } | |
| 249 | ||
| 250 | // TODO: Do we need this function at all? How is it different from | |
| 251 | // 'static_cast'? | |
| 252 | template <class To, class From> | |
| 253 | LIBC_INLINE constexpr To bit_or_static_cast(const From &from) { | |
| 254 | if constexpr (sizeof(To) == sizeof(From)) { | |
| 255 | return bit_cast<To>(from); | |
| 256 | } else { | |
| 257 | return static_cast<To>(from); | |
| 258 | } | |
| 259 | } | |
| 260 | ||
| 261 | /// Count number of 1's aka population count or Hamming weight. | |
| 262 | /// | |
| 263 | /// Only unsigned integral types are allowed. | |
| 264 | // clang-19+, gcc-14+ | |
| 265 | #if __has_builtin(__builtin_popcountg) | |
| 266 | template <typename T> | |
| 267 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 268 | popcount(T value) { | |
| 269 | return __builtin_popcountg(value); | |
| 270 | } | |
| 271 | #else // !__has_builtin(__builtin_popcountg) | |
| 272 | template <typename T> | |
| 273 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 274 | popcount(T value) { | |
| 275 | int count = 0; | |
| 276 | while (value) { | |
| 277 | value &= value - 1; | |
| 278 | ++count; | |
| 279 | } | |
| 280 | return count; | |
| 281 | } | |
| 282 | #define ADD_SPECIALIZATION(TYPE, BUILTIN) \ | |
| 283 | template <> \ | |
| 284 | [[nodiscard]] LIBC_INLINE constexpr int popcount<TYPE>(TYPE value) { \ | |
| 285 | return BUILTIN(value); \ | |
| 286 | } | |
| 287 | ADD_SPECIALIZATION(unsigned char, __builtin_popcount) | |
| 288 | ADD_SPECIALIZATION(unsigned short, __builtin_popcount) | |
| 289 | ADD_SPECIALIZATION(unsigned, __builtin_popcount) | |
| 290 | ADD_SPECIALIZATION(unsigned long, __builtin_popcountl) | |
| 291 | ADD_SPECIALIZATION(unsigned long long, __builtin_popcountll) | |
| 292 | #endif // __builtin_popcountg | |
| 293 | #undef ADD_SPECIALIZATION | |
| 294 | ||
| 295 | } // namespace cpp | |
| 296 | } // namespace LIBC_NAMESPACE_DECL | |
| 297 | ||
| 298 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H |
lib/libcxx/libc/src/__support/CPP/iterator.h created+99| ... | ... | @@ -0,0 +1,99 @@ |
| 1 | //===-- Standalone implementation of iterator -------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_ITERATOR_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_ITERATOR_H | |
| 11 | ||
| 12 | #include "src/__support/CPP/type_traits/enable_if.h" | |
| 13 | #include "src/__support/CPP/type_traits/is_convertible.h" | |
| 14 | #include "src/__support/CPP/type_traits/is_same.h" | |
| 15 | #include "src/__support/macros/attributes.h" | |
| 16 | #include "src/__support/macros/config.h" | |
| 17 | ||
| 18 | namespace LIBC_NAMESPACE_DECL { | |
| 19 | namespace cpp { | |
| 20 | ||
| 21 | template <typename T> struct iterator_traits; | |
| 22 | template <typename T> struct iterator_traits<T *> { | |
| 23 | using reference = T &; | |
| 24 | using value_type = T; | |
| 25 | }; | |
| 26 | ||
| 27 | template <typename Iter> class reverse_iterator { | |
| 28 | Iter current; | |
| 29 | ||
| 30 | public: | |
| 31 | using reference = typename iterator_traits<Iter>::reference; | |
| 32 | using value_type = typename iterator_traits<Iter>::value_type; | |
| 33 | using iterator_type = Iter; | |
| 34 | ||
| 35 | LIBC_INLINE reverse_iterator() : current() {} | |
| 36 | LIBC_INLINE constexpr explicit reverse_iterator(Iter it) : current(it) {} | |
| 37 | ||
| 38 | template <typename Other, | |
| 39 | cpp::enable_if_t<!cpp::is_same_v<Iter, Other> && | |
| 40 | cpp::is_convertible_v<const Other &, Iter>, | |
| 41 | int> = 0> | |
| 42 | LIBC_INLINE constexpr explicit reverse_iterator(const Other &it) | |
| 43 | : current(it) {} | |
| 44 | ||
| 45 | LIBC_INLINE friend constexpr bool operator==(const reverse_iterator &lhs, | |
| 46 | const reverse_iterator &rhs) { | |
| 47 | return lhs.base() == rhs.base(); | |
| 48 | } | |
| 49 | ||
| 50 | LIBC_INLINE friend constexpr bool operator!=(const reverse_iterator &lhs, | |
| 51 | const reverse_iterator &rhs) { | |
| 52 | return lhs.base() != rhs.base(); | |
| 53 | } | |
| 54 | ||
| 55 | LIBC_INLINE friend constexpr bool operator<(const reverse_iterator &lhs, | |
| 56 | const reverse_iterator &rhs) { | |
| 57 | return lhs.base() > rhs.base(); | |
| 58 | } | |
| 59 | ||
| 60 | LIBC_INLINE friend constexpr bool operator<=(const reverse_iterator &lhs, | |
| 61 | const reverse_iterator &rhs) { | |
| 62 | return lhs.base() >= rhs.base(); | |
| 63 | } | |
| 64 | ||
| 65 | LIBC_INLINE friend constexpr bool operator>(const reverse_iterator &lhs, | |
| 66 | const reverse_iterator &rhs) { | |
| 67 | return lhs.base() < rhs.base(); | |
| 68 | } | |
| 69 | ||
| 70 | LIBC_INLINE friend constexpr bool operator>=(const reverse_iterator &lhs, | |
| 71 | const reverse_iterator &rhs) { | |
| 72 | return lhs.base() <= rhs.base(); | |
| 73 | } | |
| 74 | ||
| 75 | LIBC_INLINE constexpr iterator_type base() const { return current; } | |
| 76 | ||
| 77 | LIBC_INLINE constexpr reference operator*() const { | |
| 78 | Iter tmp = current; | |
| 79 | return *--tmp; | |
| 80 | } | |
| 81 | LIBC_INLINE constexpr reverse_iterator operator--() { | |
| 82 | ++current; | |
| 83 | return *this; | |
| 84 | } | |
| 85 | LIBC_INLINE constexpr reverse_iterator &operator++() { | |
| 86 | --current; | |
| 87 | return *this; | |
| 88 | } | |
| 89 | LIBC_INLINE constexpr reverse_iterator operator++(int) { | |
| 90 | reverse_iterator tmp(*this); | |
| 91 | --current; | |
| 92 | return tmp; | |
| 93 | } | |
| 94 | }; | |
| 95 | ||
| 96 | } // namespace cpp | |
| 97 | } // namespace LIBC_NAMESPACE_DECL | |
| 98 | ||
| 99 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_ITERATOR_H |
lib/libcxx/libc/src/__support/CPP/limits.h created+92| ... | ... | @@ -0,0 +1,92 @@ |
| 1 | //===-- A self contained equivalent of std::limits --------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_LIMITS_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_LIMITS_H | |
| 11 | ||
| 12 | #include "hdr/limits_macros.h" // CHAR_BIT | |
| 13 | #include "src/__support/CPP/type_traits/is_integral.h" | |
| 14 | #include "src/__support/CPP/type_traits/is_signed.h" | |
| 15 | #include "src/__support/macros/attributes.h" // LIBC_INLINE | |
| 16 | #include "src/__support/macros/config.h" | |
| 17 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128 | |
| 18 | ||
| 19 | namespace LIBC_NAMESPACE_DECL { | |
| 20 | namespace cpp { | |
| 21 | ||
| 22 | namespace internal { | |
| 23 | ||
| 24 | template <typename T, T min_value, T max_value> struct integer_impl { | |
| 25 | static_assert(cpp::is_integral_v<T>); | |
| 26 | LIBC_INLINE static constexpr T max() { return max_value; } | |
| 27 | LIBC_INLINE static constexpr T min() { return min_value; } | |
| 28 | LIBC_INLINE_VAR static constexpr int digits = | |
| 29 | CHAR_BIT * sizeof(T) - cpp::is_signed_v<T>; | |
| 30 | }; | |
| 31 | ||
| 32 | } // namespace internal | |
| 33 | ||
| 34 | template <class T> struct numeric_limits {}; | |
| 35 | ||
| 36 | // TODO: Add numeric_limits specializations as needed for new types. | |
| 37 | template <> | |
| 38 | struct numeric_limits<short> | |
| 39 | : public internal::integer_impl<short, SHRT_MIN, SHRT_MAX> {}; | |
| 40 | ||
| 41 | template <> | |
| 42 | struct numeric_limits<unsigned short> | |
| 43 | : public internal::integer_impl<unsigned short, 0, USHRT_MAX> {}; | |
| 44 | ||
| 45 | template <> | |
| 46 | struct numeric_limits<int> | |
| 47 | : public internal::integer_impl<int, INT_MIN, INT_MAX> {}; | |
| 48 | ||
| 49 | template <> | |
| 50 | struct numeric_limits<unsigned int> | |
| 51 | : public internal::integer_impl<unsigned int, 0, UINT_MAX> {}; | |
| 52 | ||
| 53 | template <> | |
| 54 | struct numeric_limits<long> | |
| 55 | : public internal::integer_impl<long, LONG_MIN, LONG_MAX> {}; | |
| 56 | ||
| 57 | template <> | |
| 58 | struct numeric_limits<unsigned long> | |
| 59 | : public internal::integer_impl<unsigned long, 0, ULONG_MAX> {}; | |
| 60 | ||
| 61 | template <> | |
| 62 | struct numeric_limits<long long> | |
| 63 | : public internal::integer_impl<long long, LLONG_MIN, LLONG_MAX> {}; | |
| 64 | ||
| 65 | template <> | |
| 66 | struct numeric_limits<unsigned long long> | |
| 67 | : public internal::integer_impl<unsigned long long, 0, ULLONG_MAX> {}; | |
| 68 | ||
| 69 | template <> | |
| 70 | struct numeric_limits<char> | |
| 71 | : public internal::integer_impl<char, CHAR_MIN, CHAR_MAX> {}; | |
| 72 | ||
| 73 | template <> | |
| 74 | struct numeric_limits<signed char> | |
| 75 | : public internal::integer_impl<signed char, SCHAR_MIN, SCHAR_MAX> {}; | |
| 76 | ||
| 77 | template <> | |
| 78 | struct numeric_limits<unsigned char> | |
| 79 | : public internal::integer_impl<unsigned char, 0, UCHAR_MAX> {}; | |
| 80 | ||
| 81 | #ifdef LIBC_TYPES_HAS_INT128 | |
| 82 | // On platform where UInt128 resolves to __uint128_t, this specialization | |
| 83 | // provides the limits of UInt128. | |
| 84 | template <> | |
| 85 | struct numeric_limits<__uint128_t> | |
| 86 | : public internal::integer_impl<__uint128_t, 0, ~__uint128_t(0)> {}; | |
| 87 | #endif | |
| 88 | ||
| 89 | } // namespace cpp | |
| 90 | } // namespace LIBC_NAMESPACE_DECL | |
| 91 | ||
| 92 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_LIMITS_H |
lib/libcxx/libc/src/__support/CPP/optional.h created+139| ... | ... | @@ -0,0 +1,139 @@ |
| 1 | //===-- Standalone implementation of std::optional --------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_OPTIONAL_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_OPTIONAL_H | |
| 11 | ||
| 12 | #include "src/__support/CPP/type_traits.h" | |
| 13 | #include "src/__support/CPP/utility.h" | |
| 14 | #include "src/__support/macros/attributes.h" | |
| 15 | #include "src/__support/macros/config.h" | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // Trivial nullopt_t struct. | |
| 21 | struct nullopt_t { | |
| 22 | LIBC_INLINE constexpr explicit nullopt_t() = default; | |
| 23 | }; | |
| 24 | ||
| 25 | // nullopt that can be used and returned. | |
| 26 | LIBC_INLINE_VAR constexpr nullopt_t nullopt{}; | |
| 27 | ||
| 28 | // This is very simple implementation of the std::optional class. It makes | |
| 29 | // several assumptions that the underlying type is trivially constructible, | |
| 30 | // copyable, or movable. | |
| 31 | template <typename T> class optional { | |
| 32 | template <typename U, bool = !is_trivially_destructible<U>::value> | |
| 33 | struct OptionalStorage { | |
| 34 | union { | |
| 35 | char empty; | |
| 36 | U stored_value; | |
| 37 | }; | |
| 38 | ||
| 39 | bool in_use = false; | |
| 40 | ||
| 41 | LIBC_INLINE ~OptionalStorage() { reset(); } | |
| 42 | ||
| 43 | LIBC_INLINE constexpr OptionalStorage() : empty() {} | |
| 44 | ||
| 45 | template <typename... Args> | |
| 46 | LIBC_INLINE constexpr explicit OptionalStorage(in_place_t, Args &&...args) | |
| 47 | : stored_value(forward<Args>(args)...) {} | |
| 48 | ||
| 49 | LIBC_INLINE constexpr void reset() { | |
| 50 | if (in_use) | |
| 51 | stored_value.~U(); | |
| 52 | in_use = false; | |
| 53 | } | |
| 54 | }; | |
| 55 | ||
| 56 | // The only difference is that this type U doesn't have a nontrivial | |
| 57 | // destructor. | |
| 58 | template <typename U> struct OptionalStorage<U, false> { | |
| 59 | union { | |
| 60 | char empty; | |
| 61 | U stored_value; | |
| 62 | }; | |
| 63 | ||
| 64 | bool in_use = false; | |
| 65 | ||
| 66 | LIBC_INLINE constexpr OptionalStorage() : empty() {} | |
| 67 | ||
| 68 | template <typename... Args> | |
| 69 | LIBC_INLINE constexpr explicit OptionalStorage(in_place_t, Args &&...args) | |
| 70 | : stored_value(forward<Args>(args)...) {} | |
| 71 | ||
| 72 | LIBC_INLINE constexpr void reset() { in_use = false; } | |
| 73 | }; | |
| 74 | ||
| 75 | OptionalStorage<T> storage; | |
| 76 | ||
| 77 | public: | |
| 78 | LIBC_INLINE constexpr optional() = default; | |
| 79 | LIBC_INLINE constexpr optional(nullopt_t) {} | |
| 80 | ||
| 81 | LIBC_INLINE constexpr optional(const T &t) : storage(in_place, t) { | |
| 82 | storage.in_use = true; | |
| 83 | } | |
| 84 | LIBC_INLINE constexpr optional(const optional &) = default; | |
| 85 | ||
| 86 | LIBC_INLINE constexpr optional(T &&t) : storage(in_place, move(t)) { | |
| 87 | storage.in_use = true; | |
| 88 | } | |
| 89 | LIBC_INLINE constexpr optional(optional &&O) = default; | |
| 90 | ||
| 91 | template <typename... ArgTypes> | |
| 92 | LIBC_INLINE constexpr optional(in_place_t, ArgTypes &&...Args) | |
| 93 | : storage(in_place, forward<ArgTypes>(Args)...) { | |
| 94 | storage.in_use = true; | |
| 95 | } | |
| 96 | ||
| 97 | LIBC_INLINE constexpr optional &operator=(T &&t) { | |
| 98 | storage = move(t); | |
| 99 | return *this; | |
| 100 | } | |
| 101 | LIBC_INLINE constexpr optional &operator=(optional &&) = default; | |
| 102 | ||
| 103 | LIBC_INLINE constexpr optional &operator=(const T &t) { | |
| 104 | storage = t; | |
| 105 | return *this; | |
| 106 | } | |
| 107 | LIBC_INLINE constexpr optional &operator=(const optional &) = default; | |
| 108 | ||
| 109 | LIBC_INLINE constexpr void reset() { storage.reset(); } | |
| 110 | ||
| 111 | LIBC_INLINE constexpr const T &value() const & { | |
| 112 | return storage.stored_value; | |
| 113 | } | |
| 114 | ||
| 115 | LIBC_INLINE constexpr T &value() & { return storage.stored_value; } | |
| 116 | ||
| 117 | LIBC_INLINE constexpr explicit operator bool() const { | |
| 118 | return storage.in_use; | |
| 119 | } | |
| 120 | LIBC_INLINE constexpr bool has_value() const { return storage.in_use; } | |
| 121 | LIBC_INLINE constexpr const T *operator->() const { | |
| 122 | return &storage.stored_value; | |
| 123 | } | |
| 124 | LIBC_INLINE constexpr T *operator->() { return &storage.stored_value; } | |
| 125 | LIBC_INLINE constexpr const T &operator*() const & { | |
| 126 | return storage.stored_value; | |
| 127 | } | |
| 128 | LIBC_INLINE constexpr T &operator*() & { return storage.stored_value; } | |
| 129 | ||
| 130 | LIBC_INLINE constexpr T &&value() && { return move(storage.stored_value); } | |
| 131 | LIBC_INLINE constexpr T &&operator*() && { | |
| 132 | return move(storage.stored_value); | |
| 133 | } | |
| 134 | }; | |
| 135 | ||
| 136 | } // namespace cpp | |
| 137 | } // namespace LIBC_NAMESPACE_DECL | |
| 138 | ||
| 139 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_OPTIONAL_H |
lib/libcxx/libc/src/__support/CPP/string_view.h created+220| ... | ... | @@ -0,0 +1,220 @@ |
| 1 | //===-- Standalone implementation std::string_view --------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_STRING_VIEW_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_STRING_VIEW_H | |
| 11 | ||
| 12 | #include "src/__support/common.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | #include <stddef.h> | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // This is very simple alternate of the std::string_view class. There is no | |
| 21 | // bounds check performed in any of the methods. The callers are expected to | |
| 22 | // do the checks before invoking the methods. | |
| 23 | // | |
| 24 | // This class will be extended as needed in future. | |
| 25 | class string_view { | |
| 26 | private: | |
| 27 | const char *Data; | |
| 28 | size_t Len; | |
| 29 | ||
| 30 | LIBC_INLINE static size_t min(size_t A, size_t B) { return A <= B ? A : B; } | |
| 31 | ||
| 32 | LIBC_INLINE static int compareMemory(const char *Lhs, const char *Rhs, | |
| 33 | size_t Length) { | |
| 34 | for (size_t i = 0; i < Length; ++i) | |
| 35 | if (int Diff = (int)Lhs[i] - (int)Rhs[i]) | |
| 36 | return Diff; | |
| 37 | return 0; | |
| 38 | } | |
| 39 | ||
| 40 | LIBC_INLINE static constexpr size_t length(const char *Str) { | |
| 41 | for (const char *End = Str;; ++End) | |
| 42 | if (*End == '\0') | |
| 43 | return End - Str; | |
| 44 | } | |
| 45 | ||
| 46 | LIBC_INLINE bool equals(string_view Other) const { | |
| 47 | return (Len == Other.Len && | |
| 48 | compareMemory(Data, Other.Data, Other.Len) == 0); | |
| 49 | } | |
| 50 | ||
| 51 | public: | |
| 52 | using value_type = char; | |
| 53 | using size_type = size_t; | |
| 54 | using difference_type = ptrdiff_t; | |
| 55 | using pointer = char *; | |
| 56 | using const_pointer = const char *; | |
| 57 | using reference = char &; | |
| 58 | using const_reference = const char &; | |
| 59 | using const_iterator = char *; | |
| 60 | using iterator = const_iterator; | |
| 61 | ||
| 62 | // special value equal to the maximum value representable by the type | |
| 63 | // size_type. | |
| 64 | LIBC_INLINE_VAR static constexpr size_t npos = -1; | |
| 65 | ||
| 66 | LIBC_INLINE constexpr string_view() : Data(nullptr), Len(0) {} | |
| 67 | ||
| 68 | // Assumes Str is a null-terminated string. The length of the string does | |
| 69 | // not include the terminating null character. | |
| 70 | // Preconditions: [Str, Str + ​length(Str)) is a valid range. | |
| 71 | LIBC_INLINE constexpr string_view(const char *Str) | |
| 72 | : Data(Str), Len(length(Str)) {} | |
| 73 | ||
| 74 | // Preconditions: [Str, Str + N) is a valid range. | |
| 75 | LIBC_INLINE constexpr string_view(const char *Str, size_t N) | |
| 76 | : Data(Str), Len(N) {} | |
| 77 | ||
| 78 | LIBC_INLINE constexpr const char *data() const { return Data; } | |
| 79 | ||
| 80 | // Returns the size of the string_view. | |
| 81 | LIBC_INLINE constexpr size_t size() const { return Len; } | |
| 82 | ||
| 83 | // Returns whether the string_view is empty. | |
| 84 | LIBC_INLINE constexpr bool empty() const { return Len == 0; } | |
| 85 | ||
| 86 | // Returns an iterator to the first character of the view. | |
| 87 | LIBC_INLINE const char *begin() const { return Data; } | |
| 88 | ||
| 89 | // Returns an iterator to the character following the last character of the | |
| 90 | // view. | |
| 91 | LIBC_INLINE const char *end() const { return Data + Len; } | |
| 92 | ||
| 93 | // Returns a const reference to the character at specified location pos. | |
| 94 | // No bounds checking is performed: the behavior is undefined if pos >= | |
| 95 | // size(). | |
| 96 | LIBC_INLINE constexpr const char &operator[](size_t Index) const { | |
| 97 | return Data[Index]; | |
| 98 | } | |
| 99 | ||
| 100 | /// compare - Compare two strings; the result is -1, 0, or 1 if this string | |
| 101 | /// is lexicographically less than, equal to, or greater than the \p Other. | |
| 102 | LIBC_INLINE int compare(string_view Other) const { | |
| 103 | // Check the prefix for a mismatch. | |
| 104 | if (int Res = compareMemory(Data, Other.Data, min(Len, Other.Len))) | |
| 105 | return Res < 0 ? -1 : 1; | |
| 106 | // Otherwise the prefixes match, so we only need to check the lengths. | |
| 107 | if (Len == Other.Len) | |
| 108 | return 0; | |
| 109 | return Len < Other.Len ? -1 : 1; | |
| 110 | } | |
| 111 | ||
| 112 | LIBC_INLINE bool operator==(string_view Other) const { return equals(Other); } | |
| 113 | LIBC_INLINE bool operator!=(string_view Other) const { | |
| 114 | return !(*this == Other); | |
| 115 | } | |
| 116 | LIBC_INLINE bool operator<(string_view Other) const { | |
| 117 | return compare(Other) == -1; | |
| 118 | } | |
| 119 | LIBC_INLINE bool operator<=(string_view Other) const { | |
| 120 | return compare(Other) != 1; | |
| 121 | } | |
| 122 | LIBC_INLINE bool operator>(string_view Other) const { | |
| 123 | return compare(Other) == 1; | |
| 124 | } | |
| 125 | LIBC_INLINE bool operator>=(string_view Other) const { | |
| 126 | return compare(Other) != -1; | |
| 127 | } | |
| 128 | ||
| 129 | // Moves the start of the view forward by n characters. | |
| 130 | // The behavior is undefined if n > size(). | |
| 131 | LIBC_INLINE void remove_prefix(size_t N) { | |
| 132 | Len -= N; | |
| 133 | Data += N; | |
| 134 | } | |
| 135 | ||
| 136 | // Moves the end of the view back by n characters. | |
| 137 | // The behavior is undefined if n > size(). | |
| 138 | LIBC_INLINE void remove_suffix(size_t N) { Len -= N; } | |
| 139 | ||
| 140 | // Check if this string starts with the given Prefix. | |
| 141 | LIBC_INLINE bool starts_with(string_view Prefix) const { | |
| 142 | return Len >= Prefix.Len && | |
| 143 | compareMemory(Data, Prefix.Data, Prefix.Len) == 0; | |
| 144 | } | |
| 145 | ||
| 146 | // Check if this string starts with the given Prefix. | |
| 147 | LIBC_INLINE bool starts_with(const char Prefix) const { | |
| 148 | return !empty() && front() == Prefix; | |
| 149 | } | |
| 150 | ||
| 151 | // Check if this string ends with the given Prefix. | |
| 152 | LIBC_INLINE bool ends_with(const char Suffix) const { | |
| 153 | return !empty() && back() == Suffix; | |
| 154 | } | |
| 155 | ||
| 156 | // Check if this string ends with the given Suffix. | |
| 157 | LIBC_INLINE bool ends_with(string_view Suffix) const { | |
| 158 | return Len >= Suffix.Len && | |
| 159 | compareMemory(end() - Suffix.Len, Suffix.Data, Suffix.Len) == 0; | |
| 160 | } | |
| 161 | ||
| 162 | // Return a reference to the substring from [Start, Start + N). | |
| 163 | // | |
| 164 | // Start The index of the starting character in the substring; if the index is | |
| 165 | // npos or greater than the length of the string then the empty substring will | |
| 166 | // be returned. | |
| 167 | // | |
| 168 | // N The number of characters to included in the substring. If N exceeds the | |
| 169 | // number of characters remaining in the string, the string suffix (starting | |
| 170 | // with Start) will be returned. | |
| 171 | LIBC_INLINE string_view substr(size_t Start, size_t N = npos) const { | |
| 172 | Start = min(Start, Len); | |
| 173 | return string_view(Data + Start, min(N, Len - Start)); | |
| 174 | } | |
| 175 | ||
| 176 | // front - Get the first character in the string. | |
| 177 | LIBC_INLINE char front() const { return Data[0]; } | |
| 178 | ||
| 179 | // back - Get the last character in the string. | |
| 180 | LIBC_INLINE char back() const { return Data[Len - 1]; } | |
| 181 | ||
| 182 | // Finds the first occurence of c in this view, starting at position From. | |
| 183 | LIBC_INLINE constexpr size_t find_first_of(const char c, | |
| 184 | size_t From = 0) const { | |
| 185 | for (size_t Pos = From; Pos < size(); ++Pos) | |
| 186 | if ((*this)[Pos] == c) | |
| 187 | return Pos; | |
| 188 | return npos; | |
| 189 | } | |
| 190 | ||
| 191 | // Finds the last occurence of c in this view, ending at position End. | |
| 192 | LIBC_INLINE constexpr size_t find_last_of(const char c, | |
| 193 | size_t End = npos) const { | |
| 194 | End = End >= size() ? size() : End + 1; | |
| 195 | for (; End > 0; --End) | |
| 196 | if ((*this)[End - 1] == c) | |
| 197 | return End - 1; | |
| 198 | return npos; | |
| 199 | } | |
| 200 | ||
| 201 | // Finds the first character not equal to c in this view, starting at position | |
| 202 | // From. | |
| 203 | LIBC_INLINE constexpr size_t find_first_not_of(const char c, | |
| 204 | size_t From = 0) const { | |
| 205 | for (size_t Pos = From; Pos < size(); ++Pos) | |
| 206 | if ((*this)[Pos] != c) | |
| 207 | return Pos; | |
| 208 | return npos; | |
| 209 | } | |
| 210 | ||
| 211 | // Check if this view contains the given character. | |
| 212 | LIBC_INLINE constexpr bool contains(char c) const { | |
| 213 | return find_first_of(c) != npos; | |
| 214 | } | |
| 215 | }; | |
| 216 | ||
| 217 | } // namespace cpp | |
| 218 | } // namespace LIBC_NAMESPACE_DECL | |
| 219 | ||
| 220 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_STRING_VIEW_H |
lib/libcxx/libc/src/__support/CPP/type_traits.h created+70| ... | ... | @@ -0,0 +1,70 @@ |
| 1 | //===-- Self contained C++ type_traits --------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_H | |
| 11 | ||
| 12 | #include "src/__support/CPP/type_traits/add_lvalue_reference.h" | |
| 13 | #include "src/__support/CPP/type_traits/add_pointer.h" | |
| 14 | #include "src/__support/CPP/type_traits/add_rvalue_reference.h" | |
| 15 | #include "src/__support/CPP/type_traits/aligned_storage.h" | |
| 16 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 17 | #include "src/__support/CPP/type_traits/conditional.h" | |
| 18 | #include "src/__support/CPP/type_traits/decay.h" | |
| 19 | #include "src/__support/CPP/type_traits/enable_if.h" | |
| 20 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 21 | #include "src/__support/CPP/type_traits/has_unique_object_representations.h" | |
| 22 | #include "src/__support/CPP/type_traits/integral_constant.h" | |
| 23 | #include "src/__support/CPP/type_traits/invoke.h" | |
| 24 | #include "src/__support/CPP/type_traits/invoke_result.h" | |
| 25 | #include "src/__support/CPP/type_traits/is_arithmetic.h" | |
| 26 | #include "src/__support/CPP/type_traits/is_array.h" | |
| 27 | #include "src/__support/CPP/type_traits/is_base_of.h" | |
| 28 | #include "src/__support/CPP/type_traits/is_class.h" | |
| 29 | #include "src/__support/CPP/type_traits/is_complex.h" | |
| 30 | #include "src/__support/CPP/type_traits/is_const.h" | |
| 31 | #include "src/__support/CPP/type_traits/is_constant_evaluated.h" | |
| 32 | #include "src/__support/CPP/type_traits/is_convertible.h" | |
| 33 | #include "src/__support/CPP/type_traits/is_copy_assignable.h" | |
| 34 | #include "src/__support/CPP/type_traits/is_copy_constructible.h" | |
| 35 | #include "src/__support/CPP/type_traits/is_destructible.h" | |
| 36 | #include "src/__support/CPP/type_traits/is_enum.h" | |
| 37 | #include "src/__support/CPP/type_traits/is_fixed_point.h" | |
| 38 | #include "src/__support/CPP/type_traits/is_floating_point.h" | |
| 39 | #include "src/__support/CPP/type_traits/is_function.h" | |
| 40 | #include "src/__support/CPP/type_traits/is_integral.h" | |
| 41 | #include "src/__support/CPP/type_traits/is_lvalue_reference.h" | |
| 42 | #include "src/__support/CPP/type_traits/is_member_pointer.h" | |
| 43 | #include "src/__support/CPP/type_traits/is_move_assignable.h" | |
| 44 | #include "src/__support/CPP/type_traits/is_move_constructible.h" | |
| 45 | #include "src/__support/CPP/type_traits/is_null_pointer.h" | |
| 46 | #include "src/__support/CPP/type_traits/is_object.h" | |
| 47 | #include "src/__support/CPP/type_traits/is_pointer.h" | |
| 48 | #include "src/__support/CPP/type_traits/is_reference.h" | |
| 49 | #include "src/__support/CPP/type_traits/is_rvalue_reference.h" | |
| 50 | #include "src/__support/CPP/type_traits/is_same.h" | |
| 51 | #include "src/__support/CPP/type_traits/is_scalar.h" | |
| 52 | #include "src/__support/CPP/type_traits/is_signed.h" | |
| 53 | #include "src/__support/CPP/type_traits/is_trivially_constructible.h" | |
| 54 | #include "src/__support/CPP/type_traits/is_trivially_copyable.h" | |
| 55 | #include "src/__support/CPP/type_traits/is_trivially_destructible.h" | |
| 56 | #include "src/__support/CPP/type_traits/is_union.h" | |
| 57 | #include "src/__support/CPP/type_traits/is_unsigned.h" | |
| 58 | #include "src/__support/CPP/type_traits/is_void.h" | |
| 59 | #include "src/__support/CPP/type_traits/make_signed.h" | |
| 60 | #include "src/__support/CPP/type_traits/make_unsigned.h" | |
| 61 | #include "src/__support/CPP/type_traits/remove_all_extents.h" | |
| 62 | #include "src/__support/CPP/type_traits/remove_cv.h" | |
| 63 | #include "src/__support/CPP/type_traits/remove_cvref.h" | |
| 64 | #include "src/__support/CPP/type_traits/remove_extent.h" | |
| 65 | #include "src/__support/CPP/type_traits/remove_reference.h" | |
| 66 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 67 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 68 | #include "src/__support/CPP/type_traits/void_t.h" | |
| 69 | ||
| 70 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_H |
lib/libcxx/libc/src/__support/CPP/type_traits/add_lvalue_reference.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===-- add_lvalue_reference type_traits ------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // add_lvalue_reference | |
| 18 | namespace detail { | |
| 19 | template <class T> // Note that `cv void&` is a substitution failure | |
| 20 | auto try_add_lvalue_reference(int) -> cpp::type_identity<T &>; | |
| 21 | template <class T> // Handle T = cv void case | |
| 22 | auto try_add_lvalue_reference(...) -> cpp::type_identity<T>; | |
| 23 | } // namespace detail | |
| 24 | template <class T> | |
| 25 | struct add_lvalue_reference : decltype(detail::try_add_lvalue_reference<T>(0)) { | |
| 26 | }; | |
| 27 | template <class T> | |
| 28 | using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; | |
| 29 | ||
| 30 | } // namespace cpp | |
| 31 | } // namespace LIBC_NAMESPACE_DECL | |
| 32 | ||
| 33 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_LVALUE_REFERENCE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/add_pointer.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===-- add_pointer type_traits ---------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/remove_reference.h" | |
| 12 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // add_pointer | |
| 19 | namespace detail { | |
| 20 | template <class T> | |
| 21 | auto try_add_pointer(int) -> cpp::type_identity<cpp::remove_reference_t<T> *>; | |
| 22 | template <class T> auto try_add_pointer(...) -> cpp::type_identity<T>; | |
| 23 | } // namespace detail | |
| 24 | template <class T> | |
| 25 | struct add_pointer : decltype(detail::try_add_pointer<T>(0)) {}; | |
| 26 | template <class T> using add_pointer_t = typename add_pointer<T>::type; | |
| 27 | } // namespace cpp | |
| 28 | } // namespace LIBC_NAMESPACE_DECL | |
| 29 | ||
| 30 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_POINTER_H |
lib/libcxx/libc/src/__support/CPP/type_traits/add_rvalue_reference.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===-- add_rvalue_reference type_traits ------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // add_rvalue_reference | |
| 18 | namespace detail { | |
| 19 | template <class T> | |
| 20 | auto try_add_rvalue_reference(int) -> cpp::type_identity<T &&>; | |
| 21 | template <class T> auto try_add_rvalue_reference(...) -> cpp::type_identity<T>; | |
| 22 | } // namespace detail | |
| 23 | template <class T> | |
| 24 | struct add_rvalue_reference : decltype(detail::try_add_rvalue_reference<T>(0)) { | |
| 25 | }; | |
| 26 | template <class T> | |
| 27 | using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; | |
| 28 | ||
| 29 | } // namespace cpp | |
| 30 | } // namespace LIBC_NAMESPACE_DECL | |
| 31 | ||
| 32 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ADD_RVALUE_REFERENCE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/aligned_storage.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===-- aligned_storage type_traits --------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H | |
| 11 | ||
| 12 | #include "src/__support/macros/config.h" | |
| 13 | #include <stddef.h> // size_t | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | template <size_t Len, size_t Align> struct aligned_storage { | |
| 19 | struct type { | |
| 20 | alignas(Align) unsigned char data[Len]; | |
| 21 | }; | |
| 22 | }; | |
| 23 | ||
| 24 | template <size_t Len, size_t Align> | |
| 25 | using aligned_storage_t = typename aligned_storage<Len, Align>::type; | |
| 26 | ||
| 27 | } // namespace cpp | |
| 28 | } // namespace LIBC_NAMESPACE_DECL | |
| 29 | ||
| 30 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALIGNED_STORAGE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/always_false.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===-- convenient static_assert(false) helper ------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALWAYS_FALSE_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALWAYS_FALSE_H | |
| 11 | ||
| 12 | #include "src/__support/macros/attributes.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // This is technically not part of the standard but it come often enough that | |
| 19 | // it's convenient to have around. | |
| 20 | // | |
| 21 | // https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2593r0.html#valid-workaround | |
| 22 | // | |
| 23 | // This will be fixed in C++23 according to [CWG | |
| 24 | // 2518](https://cplusplus.github.io/CWG/issues/2518.html). | |
| 25 | ||
| 26 | // Usage `static_assert(cpp::always_false<T>, "error message");` | |
| 27 | template <typename...> LIBC_INLINE_VAR constexpr bool always_false = false; | |
| 28 | ||
| 29 | } // namespace cpp | |
| 30 | } // namespace LIBC_NAMESPACE_DECL | |
| 31 | ||
| 32 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ALWAYS_FALSE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/bool_constant.h created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | //===-- bool_constant type_traits -------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/integral_constant.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // bool_constant | |
| 18 | template <bool V> using bool_constant = cpp::integral_constant<bool, V>; | |
| 19 | ||
| 20 | } // namespace cpp | |
| 21 | } // namespace LIBC_NAMESPACE_DECL | |
| 22 | ||
| 23 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_BOOL_CONSTANT_H |
lib/libcxx/libc/src/__support/CPP/type_traits/conditional.h created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | //===-- conditional type_traits ---------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // conditional | |
| 18 | template <bool B, typename T, typename F> | |
| 19 | struct conditional : type_identity<T> {}; | |
| 20 | template <typename T, typename F> | |
| 21 | struct conditional<false, T, F> : type_identity<F> {}; | |
| 22 | template <bool B, typename T, typename F> | |
| 23 | using conditional_t = typename conditional<B, T, F>::type; | |
| 24 | ||
| 25 | } // namespace cpp | |
| 26 | } // namespace LIBC_NAMESPACE_DECL | |
| 27 | ||
| 28 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_CONDITIONAL_H |
lib/libcxx/libc/src/__support/CPP/type_traits/decay.h created+40| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | //===-- decay type_traits ---------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_DECAY_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_DECAY_H | |
| 10 | ||
| 11 | #include "src/__support/macros/attributes.h" | |
| 12 | ||
| 13 | #include "src/__support/CPP/type_traits/add_pointer.h" | |
| 14 | #include "src/__support/CPP/type_traits/conditional.h" | |
| 15 | #include "src/__support/CPP/type_traits/is_array.h" | |
| 16 | #include "src/__support/CPP/type_traits/is_function.h" | |
| 17 | #include "src/__support/CPP/type_traits/remove_cv.h" | |
| 18 | #include "src/__support/CPP/type_traits/remove_extent.h" | |
| 19 | #include "src/__support/CPP/type_traits/remove_reference.h" | |
| 20 | #include "src/__support/macros/config.h" | |
| 21 | ||
| 22 | namespace LIBC_NAMESPACE_DECL { | |
| 23 | namespace cpp { | |
| 24 | ||
| 25 | // decay | |
| 26 | template <class T> class decay { | |
| 27 | using U = cpp::remove_reference_t<T>; | |
| 28 | ||
| 29 | public: | |
| 30 | using type = conditional_t< | |
| 31 | cpp::is_array_v<U>, cpp::add_pointer_t<cpp::remove_extent_t<U>>, | |
| 32 | cpp::conditional_t<cpp::is_function_v<U>, cpp::add_pointer_t<U>, | |
| 33 | cpp::remove_cv_t<U>>>; | |
| 34 | }; | |
| 35 | template <class T> using decay_t = typename decay<T>::type; | |
| 36 | ||
| 37 | } // namespace cpp | |
| 38 | } // namespace LIBC_NAMESPACE_DECL | |
| 39 | ||
| 40 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_DECAY_H |
lib/libcxx/libc/src/__support/CPP/type_traits/enable_if.h created+26| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | //===-- enable_if type_traits -----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // enable_if | |
| 18 | template <bool B, typename T = void> struct enable_if; | |
| 19 | template <typename T> struct enable_if<true, T> : type_identity<T> {}; | |
| 20 | template <bool B, typename T = void> | |
| 21 | using enable_if_t = typename enable_if<B, T>::type; | |
| 22 | ||
| 23 | } // namespace cpp | |
| 24 | } // namespace LIBC_NAMESPACE_DECL | |
| 25 | ||
| 26 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_ENABLE_IF_H |
lib/libcxx/libc/src/__support/CPP/type_traits/false_type.h created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | //===-- false_type type_traits ----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // false_type | |
| 18 | using false_type = cpp::bool_constant<false>; | |
| 19 | ||
| 20 | } // namespace cpp | |
| 21 | } // namespace LIBC_NAMESPACE_DECL | |
| 22 | ||
| 23 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_FALSE_TYPE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/has_unique_object_representations.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===-- has_unique_object_representations type_traits ------------*- C++-*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/integral_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/remove_all_extents.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | template <class T> | |
| 19 | struct has_unique_object_representations | |
| 20 | : public integral_constant<bool, __has_unique_object_representations( | |
| 21 | remove_all_extents_t<T>)> {}; | |
| 22 | ||
| 23 | template <class T> | |
| 24 | LIBC_INLINE_VAR constexpr bool has_unique_object_representations_v = | |
| 25 | has_unique_object_representations<T>::value; | |
| 26 | ||
| 27 | } // namespace cpp | |
| 28 | } // namespace LIBC_NAMESPACE_DECL | |
| 29 | ||
| 30 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_H |
lib/libcxx/libc/src/__support/CPP/type_traits/integral_constant.h created+26| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | //===-- integral_constant type_traits ---------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H | |
| 10 | ||
| 11 | #include "src/__support/macros/attributes.h" // LIBC_INLINE_VAR | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // integral_constant | |
| 18 | template <typename T, T v> struct integral_constant { | |
| 19 | using value_type = T; | |
| 20 | LIBC_INLINE_VAR static constexpr T value = v; | |
| 21 | }; | |
| 22 | ||
| 23 | } // namespace cpp | |
| 24 | } // namespace LIBC_NAMESPACE_DECL | |
| 25 | ||
| 26 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INTEGRAL_CONSTANT_H |
lib/libcxx/libc/src/__support/CPP/type_traits/invoke.h created+67| ... | ... | @@ -0,0 +1,67 @@ |
| 1 | //===-- invoke type_traits --------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_H | |
| 11 | ||
| 12 | #include "src/__support/CPP/type_traits/always_false.h" | |
| 13 | #include "src/__support/CPP/type_traits/decay.h" | |
| 14 | #include "src/__support/CPP/type_traits/enable_if.h" | |
| 15 | #include "src/__support/CPP/type_traits/is_base_of.h" | |
| 16 | #include "src/__support/CPP/type_traits/is_pointer.h" | |
| 17 | #include "src/__support/CPP/type_traits/is_same.h" | |
| 18 | #include "src/__support/CPP/utility/forward.h" | |
| 19 | #include "src/__support/macros/attributes.h" // LIBC_INLINE | |
| 20 | #include "src/__support/macros/config.h" | |
| 21 | ||
| 22 | namespace LIBC_NAMESPACE_DECL { | |
| 23 | namespace cpp { | |
| 24 | ||
| 25 | namespace detail { | |
| 26 | ||
| 27 | // Catch all function and functor types. | |
| 28 | template <class FunctionPtrType> struct invoke_dispatcher { | |
| 29 | template <class T, class... Args, | |
| 30 | typename = cpp::enable_if_t< | |
| 31 | cpp::is_same_v<cpp::decay_t<T>, FunctionPtrType>>> | |
| 32 | LIBC_INLINE static decltype(auto) call(T &&fun, Args &&...args) { | |
| 33 | return cpp::forward<T>(fun)(cpp::forward<Args>(args)...); | |
| 34 | } | |
| 35 | }; | |
| 36 | ||
| 37 | // Catch pointer to member function types. | |
| 38 | template <class Class, class FunctionReturnType> | |
| 39 | struct invoke_dispatcher<FunctionReturnType Class::*> { | |
| 40 | using FunctionPtrType = FunctionReturnType Class::*; | |
| 41 | ||
| 42 | template <class T, class... Args, class DecayT = cpp::decay_t<T>> | |
| 43 | LIBC_INLINE static decltype(auto) call(FunctionPtrType fun, T &&t1, | |
| 44 | Args &&...args) { | |
| 45 | if constexpr (cpp::is_base_of_v<Class, DecayT>) { | |
| 46 | // T is a (possibly cv ref) type. | |
| 47 | return (cpp::forward<T>(t1).*fun)(cpp::forward<Args>(args)...); | |
| 48 | } else if constexpr (cpp::is_pointer_v<T>) { | |
| 49 | // T is a pointer type. | |
| 50 | return (*cpp::forward<T>(t1).*fun)(cpp::forward<Args>(args)...); | |
| 51 | } else { | |
| 52 | static_assert(cpp::always_false<T>); | |
| 53 | } | |
| 54 | } | |
| 55 | }; | |
| 56 | ||
| 57 | } // namespace detail | |
| 58 | template <class Function, class... Args> | |
| 59 | decltype(auto) invoke(Function &&fun, Args &&...args) { | |
| 60 | return detail::invoke_dispatcher<cpp::decay_t<Function>>::call( | |
| 61 | cpp::forward<Function>(fun), cpp::forward<Args>(args)...); | |
| 62 | } | |
| 63 | ||
| 64 | } // namespace cpp | |
| 65 | } // namespace LIBC_NAMESPACE_DECL | |
| 66 | ||
| 67 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/invoke_result.h created+29| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | //===-- invoke_result type_traits -------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_RESULT_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_RESULT_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/invoke.h" | |
| 12 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 13 | #include "src/__support/CPP/utility/declval.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | template <class F, class... Args> | |
| 20 | struct invoke_result : cpp::type_identity<decltype(cpp::invoke( | |
| 21 | cpp::declval<F>(), cpp::declval<Args>()...))> {}; | |
| 22 | ||
| 23 | template <class F, class... Args> | |
| 24 | using invoke_result_t = typename invoke_result<F, Args...>::type; | |
| 25 | ||
| 26 | } // namespace cpp | |
| 27 | } // namespace LIBC_NAMESPACE_DECL | |
| 28 | ||
| 29 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_INVOKE_RESULT_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_arithmetic.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===-- is_arithmetic type_traits -------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/is_floating_point.h" | |
| 13 | #include "src/__support/CPP/type_traits/is_integral.h" | |
| 14 | #include "src/__support/macros/attributes.h" | |
| 15 | #include "src/__support/macros/config.h" | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // is_arithmetic | |
| 21 | template <typename T> | |
| 22 | struct is_arithmetic : cpp::bool_constant<(cpp::is_integral_v<T> || | |
| 23 | cpp::is_floating_point_v<T>)> {}; | |
| 24 | template <typename T> | |
| 25 | LIBC_INLINE_VAR constexpr bool is_arithmetic_v = is_arithmetic<T>::value; | |
| 26 | ||
| 27 | } // namespace cpp | |
| 28 | } // namespace LIBC_NAMESPACE_DECL | |
| 29 | ||
| 30 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARITHMETIC_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_array.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===-- is_array type_traits ------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 12 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | #include <stddef.h> // For size_t | |
| 17 | ||
| 18 | namespace LIBC_NAMESPACE_DECL { | |
| 19 | namespace cpp { | |
| 20 | ||
| 21 | // is_array | |
| 22 | template <class T> struct is_array : false_type {}; | |
| 23 | template <class T> struct is_array<T[]> : true_type {}; | |
| 24 | template <class T, size_t N> struct is_array<T[N]> : true_type {}; | |
| 25 | template <class T> | |
| 26 | LIBC_INLINE_VAR constexpr bool is_array_v = is_array<T>::value; | |
| 27 | ||
| 28 | } // namespace cpp | |
| 29 | } // namespace LIBC_NAMESPACE_DECL | |
| 30 | ||
| 31 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ARRAY_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_base_of.h created+47| ... | ... | @@ -0,0 +1,47 @@ |
| 1 | //===-- is_base_of type_traits ----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/add_rvalue_reference.h" | |
| 12 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 13 | #include "src/__support/CPP/type_traits/is_class.h" | |
| 14 | #include "src/__support/CPP/type_traits/remove_all_extents.h" | |
| 15 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 16 | #include "src/__support/macros/attributes.h" | |
| 17 | #include "src/__support/macros/config.h" | |
| 18 | ||
| 19 | namespace LIBC_NAMESPACE_DECL { | |
| 20 | namespace cpp { | |
| 21 | ||
| 22 | // is_base_of | |
| 23 | namespace detail { | |
| 24 | template <typename B> cpp::true_type __test_ptr_conv(const volatile B *); | |
| 25 | template <typename> cpp::false_type __test_ptr_conv(const volatile void *); | |
| 26 | ||
| 27 | template <typename B, typename D> | |
| 28 | auto is_base_of(int) -> decltype(__test_ptr_conv<B>(static_cast<D *>(nullptr))); | |
| 29 | ||
| 30 | template <typename, typename> | |
| 31 | auto is_base_of(...) -> cpp::true_type; // private or ambiguous base | |
| 32 | ||
| 33 | } // namespace detail | |
| 34 | ||
| 35 | template <typename Base, typename Derived> | |
| 36 | struct is_base_of | |
| 37 | : cpp::bool_constant< | |
| 38 | cpp::is_class_v<Base> && | |
| 39 | cpp::is_class_v<Derived> &&decltype(detail::is_base_of<Base, Derived>( | |
| 40 | 0))::value> {}; | |
| 41 | template <typename Base, typename Derived> | |
| 42 | LIBC_INLINE_VAR constexpr bool is_base_of_v = is_base_of<Base, Derived>::value; | |
| 43 | ||
| 44 | } // namespace cpp | |
| 45 | } // namespace LIBC_NAMESPACE_DECL | |
| 46 | ||
| 47 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_BASE_OF_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_class.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===-- is_class type_traits ------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 13 | #include "src/__support/CPP/type_traits/is_union.h" | |
| 14 | #include "src/__support/macros/attributes.h" | |
| 15 | #include "src/__support/macros/config.h" | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // is_class | |
| 21 | namespace detail { | |
| 22 | template <class T> cpp::bool_constant<!cpp::is_union_v<T>> test(int T::*); | |
| 23 | template <class> cpp::false_type test(...); | |
| 24 | } // namespace detail | |
| 25 | template <class T> struct is_class : decltype(detail::test<T>(nullptr)) {}; | |
| 26 | template <typename T> | |
| 27 | LIBC_INLINE_VAR constexpr bool is_class_v = is_class<T>::value; | |
| 28 | ||
| 29 | } // namespace cpp | |
| 30 | } // namespace LIBC_NAMESPACE_DECL | |
| 31 | ||
| 32 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CLASS_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_complex.h created+53| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | //===-- is_complex type_traits ----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/is_same.h" | |
| 12 | #include "src/__support/CPP/type_traits/remove_cv.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | // LIBC_TYPES_HAS_CFLOAT16 && LIBC_TYPES_HAS_CFLOAT128 | |
| 16 | #include "src/__support/macros/properties/complex_types.h" | |
| 17 | ||
| 18 | namespace LIBC_NAMESPACE_DECL { | |
| 19 | namespace cpp { | |
| 20 | ||
| 21 | // is_complex | |
| 22 | template <typename T> struct is_complex { | |
| 23 | private: | |
| 24 | template <typename Head, typename... Args> | |
| 25 | LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() { | |
| 26 | return (... || is_same_v<remove_cv_t<Head>, Args>); | |
| 27 | } | |
| 28 | ||
| 29 | public: | |
| 30 | LIBC_INLINE_VAR static constexpr bool value = | |
| 31 | __is_unqualified_any_of<T, _Complex float, _Complex double, | |
| 32 | _Complex long double | |
| 33 | #ifdef LIBC_TYPES_HAS_CFLOAT16 | |
| 34 | , | |
| 35 | cfloat16 | |
| 36 | #endif | |
| 37 | #ifdef LIBC_TYPES_HAS_CFLOAT128 | |
| 38 | , | |
| 39 | cfloat128 | |
| 40 | #endif | |
| 41 | >(); | |
| 42 | }; | |
| 43 | template <typename T> | |
| 44 | LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex<T>::value; | |
| 45 | template <typename T1, typename T2> | |
| 46 | LIBC_INLINE_VAR constexpr bool is_complex_type_same() { | |
| 47 | return is_same_v<remove_cv_t<T1>, T2>; | |
| 48 | } | |
| 49 | ||
| 50 | } // namespace cpp | |
| 51 | } // namespace LIBC_NAMESPACE_DECL | |
| 52 | ||
| 53 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COMPLEX_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_const.h created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | //===-- is_const type_traits ------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 12 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // is_const | |
| 20 | template <class T> struct is_const : cpp::false_type {}; | |
| 21 | template <class T> struct is_const<const T> : cpp::true_type {}; | |
| 22 | template <class T> | |
| 23 | LIBC_INLINE_VAR constexpr bool is_const_v = is_const<T>::value; | |
| 24 | ||
| 25 | } // namespace cpp | |
| 26 | } // namespace LIBC_NAMESPACE_DECL | |
| 27 | ||
| 28 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONST_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_constant_evaluated.h created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | //===-- is_constant_evaluated type_traits -----------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTANT_EVALUATED_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTANT_EVALUATED_H | |
| 10 | ||
| 11 | #include "src/__support/macros/attributes.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | LIBC_INLINE constexpr bool is_constant_evaluated() { | |
| 18 | return __builtin_is_constant_evaluated(); | |
| 19 | } | |
| 20 | ||
| 21 | } // namespace cpp | |
| 22 | } // namespace LIBC_NAMESPACE_DECL | |
| 23 | ||
| 24 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONSTANT_EVALUATED_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_convertible.h created+48| ... | ... | @@ -0,0 +1,48 @@ |
| 1 | //===-- is_convertible type_traits ------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/is_void.h" | |
| 12 | #include "src/__support/CPP/utility/declval.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // is_convertible | |
| 20 | namespace detail { | |
| 21 | template <class T> | |
| 22 | auto test_returnable(int) | |
| 23 | -> decltype(void(static_cast<T (*)()>(nullptr)), cpp::true_type{}); | |
| 24 | template <class> auto test_returnable(...) -> cpp::false_type; | |
| 25 | ||
| 26 | template <class From, class To> | |
| 27 | auto test_implicitly_convertible(int) | |
| 28 | -> decltype(void(cpp::declval<void (&)(To)>()(cpp::declval<From>())), | |
| 29 | cpp::true_type{}); | |
| 30 | template <class, class> | |
| 31 | auto test_implicitly_convertible(...) -> cpp::false_type; | |
| 32 | } // namespace detail | |
| 33 | ||
| 34 | template <class From, class To> | |
| 35 | struct is_convertible | |
| 36 | : cpp::bool_constant< | |
| 37 | (decltype(detail::test_returnable<To>(0))::value && | |
| 38 | decltype(detail::test_implicitly_convertible<From, To>(0))::value) || | |
| 39 | (cpp::is_void_v<From> && cpp::is_void_v<To>)> {}; | |
| 40 | ||
| 41 | template <class From, class To> | |
| 42 | LIBC_INLINE_VAR constexpr bool is_convertible_v = | |
| 43 | is_convertible<From, To>::value; | |
| 44 | ||
| 45 | } // namespace cpp | |
| 46 | } // namespace LIBC_NAMESPACE_DECL | |
| 47 | ||
| 48 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_CONVERTIBLE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_copy_assignable.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===-- is_copy_assignable type_traits --------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_ASSIGNABLE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_ASSIGNABLE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/add_lvalue_reference.h" | |
| 12 | #include "src/__support/CPP/type_traits/integral_constant.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // is copy assignable | |
| 19 | template <class T> | |
| 20 | struct is_copy_assignable | |
| 21 | : public integral_constant< | |
| 22 | bool, __is_assignable(cpp::add_lvalue_reference_t<T>, | |
| 23 | cpp::add_lvalue_reference_t<const T>)> {}; | |
| 24 | ||
| 25 | template <class T> | |
| 26 | LIBC_INLINE_VAR constexpr bool is_copy_assignable_v = | |
| 27 | is_copy_assignable<T>::value; | |
| 28 | ||
| 29 | } // namespace cpp | |
| 30 | } // namespace LIBC_NAMESPACE_DECL | |
| 31 | ||
| 32 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_ASSIGNABLE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_copy_constructible.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===-- is_copy_constructible type_traits -----------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/add_lvalue_reference.h" | |
| 12 | #include "src/__support/CPP/type_traits/integral_constant.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // is copy constructible | |
| 19 | template <class T> | |
| 20 | struct is_copy_constructible | |
| 21 | : public integral_constant< | |
| 22 | bool, __is_constructible(T, cpp::add_lvalue_reference_t<const T>)> {}; | |
| 23 | ||
| 24 | template <class T> | |
| 25 | LIBC_INLINE_VAR constexpr bool is_copy_constructible_v = | |
| 26 | is_copy_constructible<T>::value; | |
| 27 | ||
| 28 | } // namespace cpp | |
| 29 | } // namespace LIBC_NAMESPACE_DECL | |
| 30 | ||
| 31 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_destructible.h created+68| ... | ... | @@ -0,0 +1,68 @@ |
| 1 | //===-- is_destructible type_traits -----------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 13 | #include "src/__support/CPP/type_traits/is_function.h" | |
| 14 | #include "src/__support/CPP/type_traits/is_reference.h" | |
| 15 | #include "src/__support/CPP/type_traits/remove_all_extents.h" | |
| 16 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 17 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 18 | #include "src/__support/macros/attributes.h" | |
| 19 | #include "src/__support/macros/config.h" | |
| 20 | ||
| 21 | namespace LIBC_NAMESPACE_DECL { | |
| 22 | namespace cpp { | |
| 23 | ||
| 24 | // is_destructible | |
| 25 | #if __has_builtin(__is_destructible) | |
| 26 | template <typename T> | |
| 27 | struct is_destructible : bool_constant<__is_destructible(T)> {}; | |
| 28 | #else | |
| 29 | // if it's a reference, return true | |
| 30 | // if it's a function, return false | |
| 31 | // if it's void, return false | |
| 32 | // if it's an array of unknown bound, return false | |
| 33 | // Otherwise, return "declval<T&>().~T()" is well-formed | |
| 34 | // where T is remove_all_extents<T>::type | |
| 35 | template <typename> struct __is_destructible_apply : cpp::type_identity<int> {}; | |
| 36 | template <typename T> struct __is_destructor_wellformed { | |
| 37 | template <typename T1> | |
| 38 | static cpp::true_type __test( | |
| 39 | typename __is_destructible_apply<decltype(declval<T1 &>().~T1())>::type); | |
| 40 | template <typename T1> static cpp::false_type __test(...); | |
| 41 | static const bool value = decltype(__test<T>(12))::value; | |
| 42 | }; | |
| 43 | template <typename T, bool> struct __destructible_imp; | |
| 44 | template <typename T> | |
| 45 | struct __destructible_imp<T, false> | |
| 46 | : public bool_constant< | |
| 47 | __is_destructor_wellformed<cpp::remove_all_extents_t<T>>::value> {}; | |
| 48 | template <typename T> | |
| 49 | struct __destructible_imp<T, true> : public cpp::true_type {}; | |
| 50 | template <typename T, bool> struct __destructible_false; | |
| 51 | template <typename T> | |
| 52 | struct __destructible_false<T, false> | |
| 53 | : public __destructible_imp<T, is_reference<T>::value> {}; | |
| 54 | template <typename T> | |
| 55 | struct __destructible_false<T, true> : public cpp::false_type {}; | |
| 56 | template <typename T> | |
| 57 | struct is_destructible : public __destructible_false<T, is_function<T>::value> { | |
| 58 | }; | |
| 59 | template <typename T> struct is_destructible<T[]> : public false_type {}; | |
| 60 | template <> struct is_destructible<void> : public false_type {}; | |
| 61 | #endif | |
| 62 | template <class T> | |
| 63 | LIBC_INLINE_VAR constexpr bool is_destructible_v = is_destructible<T>::value; | |
| 64 | ||
| 65 | } // namespace cpp | |
| 66 | } // namespace LIBC_NAMESPACE_DECL | |
| 67 | ||
| 68 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_DESTRUCTIBLE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_enum.h created+26| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | //===-- is_enum type_traits -------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/macros/attributes.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // is_enum | |
| 19 | template <typename T> struct is_enum : bool_constant<__is_enum(T)> {}; | |
| 20 | template <typename T> | |
| 21 | LIBC_INLINE_VAR constexpr bool is_enum_v = is_enum<T>::value; | |
| 22 | ||
| 23 | } // namespace cpp | |
| 24 | } // namespace LIBC_NAMESPACE_DECL | |
| 25 | ||
| 26 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_ENUM_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_fixed_point.h created+49| ... | ... | @@ -0,0 +1,49 @@ |
| 1 | //===-- is_fixed_point type_traits ------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FIXED_POINT_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FIXED_POINT_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/is_same.h" | |
| 12 | #include "src/__support/CPP/type_traits/remove_cv.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | ||
| 15 | #include "include/llvm-libc-macros/stdfix-macros.h" | |
| 16 | #include "src/__support/macros/config.h" | |
| 17 | ||
| 18 | namespace LIBC_NAMESPACE_DECL { | |
| 19 | namespace cpp { | |
| 20 | ||
| 21 | // is_fixed_point | |
| 22 | #ifdef LIBC_COMPILER_HAS_FIXED_POINT | |
| 23 | template <typename T> struct is_fixed_point { | |
| 24 | private: | |
| 25 | template <typename Head, typename... Args> | |
| 26 | LIBC_INLINE static constexpr bool __is_unqualified_any_of() { | |
| 27 | return (... || is_same_v<remove_cv_t<Head>, Args>); | |
| 28 | } | |
| 29 | ||
| 30 | public: | |
| 31 | LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of< | |
| 32 | T, short fract, fract, long fract, unsigned short fract, unsigned fract, | |
| 33 | unsigned long fract, short accum, accum, long accum, unsigned short accum, | |
| 34 | unsigned accum, unsigned long accum, short sat fract, sat fract, | |
| 35 | long sat fract, unsigned short sat fract, unsigned sat fract, | |
| 36 | unsigned long sat fract, short sat accum, sat accum, long sat accum, | |
| 37 | unsigned short sat accum, unsigned sat accum, unsigned long sat accum>(); | |
| 38 | }; | |
| 39 | #else | |
| 40 | template <typename T> struct is_fixed_point : false_type {}; | |
| 41 | #endif // LIBC_COMPILER_HAS_FIXED_POINT | |
| 42 | ||
| 43 | template <typename T> | |
| 44 | LIBC_INLINE_VAR constexpr bool is_fixed_point_v = is_fixed_point<T>::value; | |
| 45 | ||
| 46 | } // namespace cpp | |
| 47 | } // namespace LIBC_NAMESPACE_DECL | |
| 48 | ||
| 49 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FIXED_POINT_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_floating_point.h created+48| ... | ... | @@ -0,0 +1,48 @@ |
| 1 | //===-- is_floating_point type_traits ---------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/is_same.h" | |
| 12 | #include "src/__support/CPP/type_traits/remove_cv.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_FLOAT128 | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // is_floating_point | |
| 21 | template <typename T> struct is_floating_point { | |
| 22 | private: | |
| 23 | template <typename Head, typename... Args> | |
| 24 | LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() { | |
| 25 | return (... || is_same_v<remove_cv_t<Head>, Args>); | |
| 26 | } | |
| 27 | ||
| 28 | public: | |
| 29 | LIBC_INLINE_VAR static constexpr bool value = | |
| 30 | __is_unqualified_any_of<T, float, double, long double | |
| 31 | #ifdef LIBC_TYPES_HAS_FLOAT16 | |
| 32 | , | |
| 33 | float16 | |
| 34 | #endif | |
| 35 | #ifdef LIBC_TYPES_HAS_FLOAT128 | |
| 36 | , | |
| 37 | float128 | |
| 38 | #endif | |
| 39 | >(); | |
| 40 | }; | |
| 41 | template <typename T> | |
| 42 | LIBC_INLINE_VAR constexpr bool is_floating_point_v = | |
| 43 | is_floating_point<T>::value; | |
| 44 | ||
| 45 | } // namespace cpp | |
| 46 | } // namespace LIBC_NAMESPACE_DECL | |
| 47 | ||
| 48 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FLOATING_POINT_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_function.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | //===-- is_function type_traits ---------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/is_const.h" | |
| 13 | #include "src/__support/CPP/type_traits/is_reference.h" | |
| 14 | #include "src/__support/macros/attributes.h" | |
| 15 | #include "src/__support/macros/config.h" | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // is_function | |
| 21 | #if __has_builtin(__is_function) | |
| 22 | template <typename T> | |
| 23 | struct is_function : integral_constant<bool, __is_function(T)> {}; | |
| 24 | #else | |
| 25 | template <typename T> | |
| 26 | struct is_function | |
| 27 | : public bool_constant<!(is_reference_v<T> || is_const_v<const T>)> {}; | |
| 28 | #endif | |
| 29 | template <class T> | |
| 30 | LIBC_INLINE_VAR constexpr bool is_function_v = is_function<T>::value; | |
| 31 | ||
| 32 | } // namespace cpp | |
| 33 | } // namespace LIBC_NAMESPACE_DECL | |
| 34 | ||
| 35 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_FUNCTION_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_integral.h created+43| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | //===-- is_integral type_traits ---------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/is_same.h" | |
| 12 | #include "src/__support/CPP/type_traits/remove_cv.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128 | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // is_integral | |
| 21 | template <typename T> struct is_integral { | |
| 22 | private: | |
| 23 | template <typename Head, typename... Args> | |
| 24 | LIBC_INLINE_VAR static constexpr bool __is_unqualified_any_of() { | |
| 25 | return (... || is_same_v<remove_cv_t<Head>, Args>); | |
| 26 | } | |
| 27 | ||
| 28 | public: | |
| 29 | LIBC_INLINE_VAR static constexpr bool value = __is_unqualified_any_of< | |
| 30 | T, | |
| 31 | #ifdef LIBC_TYPES_HAS_INT128 | |
| 32 | __int128_t, __uint128_t, | |
| 33 | #endif | |
| 34 | char, signed char, unsigned char, short, unsigned short, int, | |
| 35 | unsigned int, long, unsigned long, long long, unsigned long long, bool>(); | |
| 36 | }; | |
| 37 | template <typename T> | |
| 38 | LIBC_INLINE_VAR constexpr bool is_integral_v = is_integral<T>::value; | |
| 39 | ||
| 40 | } // namespace cpp | |
| 41 | } // namespace LIBC_NAMESPACE_DECL | |
| 42 | ||
| 43 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_INTEGRAL_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_lvalue_reference.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | //===-- is_lvalue_reference type_traits -------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 13 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 14 | #include "src/__support/macros/attributes.h" | |
| 15 | #include "src/__support/macros/config.h" | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // is_lvalue_reference | |
| 21 | #if __has_builtin(__is_lvalue_reference) | |
| 22 | template <typename T> | |
| 23 | struct is_lvalue_reference : bool_constant<__is_lvalue_reference(T)> {}; | |
| 24 | #else | |
| 25 | template <typename T> struct is_lvalue_reference : public false_type {}; | |
| 26 | template <typename T> struct is_lvalue_reference<T &> : public true_type {}; | |
| 27 | #endif | |
| 28 | template <class T> | |
| 29 | LIBC_INLINE_VAR constexpr bool is_lvalue_reference_v = | |
| 30 | is_lvalue_reference<T>::value; | |
| 31 | ||
| 32 | } // namespace cpp | |
| 33 | } // namespace LIBC_NAMESPACE_DECL | |
| 34 | ||
| 35 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_LVALUE_REFERENCE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_member_pointer.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===-- is_member_pointer type_traits ---------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 12 | #include "src/__support/CPP/type_traits/remove_cv.h" | |
| 13 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 14 | #include "src/__support/macros/attributes.h" | |
| 15 | #include "src/__support/macros/config.h" | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // is_member_pointer | |
| 21 | template <class T> struct is_member_pointer_helper : cpp::false_type {}; | |
| 22 | template <class T, class U> | |
| 23 | struct is_member_pointer_helper<T U::*> : cpp::true_type {}; | |
| 24 | template <class T> | |
| 25 | struct is_member_pointer : is_member_pointer_helper<cpp::remove_cv_t<T>> {}; | |
| 26 | template <class T> | |
| 27 | LIBC_INLINE_VAR constexpr bool is_member_pointer_v = | |
| 28 | is_member_pointer<T>::value; | |
| 29 | ||
| 30 | } // namespace cpp | |
| 31 | } // namespace LIBC_NAMESPACE_DECL | |
| 32 | ||
| 33 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MEMBER_POINTER_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_move_assignable.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===-- is_move_assignable type_traits --------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/add_lvalue_reference.h" | |
| 12 | #include "src/__support/CPP/type_traits/add_rvalue_reference.h" | |
| 13 | #include "src/__support/CPP/type_traits/integral_constant.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // is move assignable | |
| 20 | template <class T> | |
| 21 | struct is_move_assignable | |
| 22 | : public integral_constant<bool, __is_assignable( | |
| 23 | cpp::add_lvalue_reference_t<T>, | |
| 24 | cpp::add_rvalue_reference_t<T>)> {}; | |
| 25 | ||
| 26 | template <class T> | |
| 27 | LIBC_INLINE_VAR constexpr bool is_move_assignable_v = | |
| 28 | is_move_assignable<T>::value; | |
| 29 | ||
| 30 | } // namespace cpp | |
| 31 | } // namespace LIBC_NAMESPACE_DECL | |
| 32 | ||
| 33 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_move_constructible.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===-- is_move_constructible type_traits ------------------------*- C++-*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/add_rvalue_reference.h" | |
| 12 | #include "src/__support/CPP/type_traits/integral_constant.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // is move constructible | |
| 19 | template <class T> | |
| 20 | struct is_move_constructible | |
| 21 | : public integral_constant<bool, __is_constructible( | |
| 22 | T, cpp::add_rvalue_reference_t<T>)> {}; | |
| 23 | ||
| 24 | template <class T> | |
| 25 | LIBC_INLINE_VAR constexpr bool is_move_constructible_v = | |
| 26 | is_move_constructible<T>::value; | |
| 27 | ||
| 28 | } // namespace cpp | |
| 29 | } // namespace LIBC_NAMESPACE_DECL | |
| 30 | ||
| 31 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_null_pointer.h created+29| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | //===-- is_null_pointer type_traits -----------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/is_same.h" | |
| 12 | #include "src/__support/CPP/type_traits/remove_cv.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // is_null_pointer | |
| 20 | using nullptr_t = decltype(nullptr); | |
| 21 | template <class T> | |
| 22 | struct is_null_pointer : cpp::is_same<cpp::nullptr_t, cpp::remove_cv_t<T>> {}; | |
| 23 | template <class T> | |
| 24 | LIBC_INLINE_VAR constexpr bool is_null_pointer_v = is_null_pointer<T>::value; | |
| 25 | ||
| 26 | } // namespace cpp | |
| 27 | } // namespace LIBC_NAMESPACE_DECL | |
| 28 | ||
| 29 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_NULL_POINTER_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_object.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===-- is_object type_traits -----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/is_array.h" | |
| 13 | #include "src/__support/CPP/type_traits/is_class.h" | |
| 14 | #include "src/__support/CPP/type_traits/is_scalar.h" | |
| 15 | #include "src/__support/CPP/type_traits/is_union.h" | |
| 16 | #include "src/__support/macros/attributes.h" | |
| 17 | #include "src/__support/macros/config.h" | |
| 18 | ||
| 19 | namespace LIBC_NAMESPACE_DECL { | |
| 20 | namespace cpp { | |
| 21 | ||
| 22 | // is_object | |
| 23 | template <class T> | |
| 24 | struct is_object | |
| 25 | : cpp::bool_constant<cpp::is_scalar_v<T> || cpp::is_array_v<T> || | |
| 26 | cpp::is_union_v<T> || cpp::is_class_v<T>> {}; | |
| 27 | template <class T> | |
| 28 | LIBC_INLINE_VAR constexpr bool is_object_v = is_object<T>::value; | |
| 29 | ||
| 30 | } // namespace cpp | |
| 31 | } // namespace LIBC_NAMESPACE_DECL | |
| 32 | ||
| 33 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_OBJECT_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_pointer.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===-- is_pointer type_traits ----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 12 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // is_pointer | |
| 20 | template <typename T> struct is_pointer : cpp::false_type {}; | |
| 21 | template <typename T> struct is_pointer<T *> : cpp::true_type {}; | |
| 22 | template <typename T> struct is_pointer<T *const> : cpp::true_type {}; | |
| 23 | template <typename T> struct is_pointer<T *volatile> : cpp::true_type {}; | |
| 24 | template <typename T> struct is_pointer<T *const volatile> : cpp::true_type {}; | |
| 25 | template <typename T> | |
| 26 | LIBC_INLINE_VAR constexpr bool is_pointer_v = is_pointer<T>::value; | |
| 27 | ||
| 28 | } // namespace cpp | |
| 29 | } // namespace LIBC_NAMESPACE_DECL | |
| 30 | ||
| 31 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_POINTER_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_reference.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===-- is_reference type_traits --------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 13 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 14 | #include "src/__support/macros/attributes.h" | |
| 15 | #include "src/__support/macros/config.h" | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // is_reference | |
| 21 | #if __has_builtin(__is_reference) | |
| 22 | template <typename T> struct is_reference : bool_constant<__is_reference(T)> {}; | |
| 23 | #else | |
| 24 | template <typename T> struct is_reference : public false_type {}; | |
| 25 | template <typename T> struct is_reference<T &> : public true_type {}; | |
| 26 | template <typename T> struct is_reference<T &&> : public true_type {}; | |
| 27 | #endif | |
| 28 | template <class T> | |
| 29 | LIBC_INLINE_VAR constexpr bool is_reference_v = is_reference<T>::value; | |
| 30 | ||
| 31 | } // namespace cpp | |
| 32 | } // namespace LIBC_NAMESPACE_DECL | |
| 33 | ||
| 34 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_REFERENCE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_rvalue_reference.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | //===-- is_rvalue_reference type_traits -------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 13 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 14 | #include "src/__support/macros/attributes.h" | |
| 15 | #include "src/__support/macros/config.h" | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace cpp { | |
| 19 | ||
| 20 | // is_rvalue_reference | |
| 21 | #if __has_builtin(__is_rvalue_reference) | |
| 22 | template <typename T> | |
| 23 | struct is_rvalue_reference : bool_constant<__is_rvalue_reference(T)> {}; | |
| 24 | #else | |
| 25 | template <typename T> struct is_rvalue_reference : public false_type {}; | |
| 26 | template <typename T> struct is_rvalue_reference<T &&> : public true_type {}; | |
| 27 | #endif | |
| 28 | template <class T> | |
| 29 | LIBC_INLINE_VAR constexpr bool is_rvalue_reference_v = | |
| 30 | is_rvalue_reference<T>::value; | |
| 31 | ||
| 32 | } // namespace cpp | |
| 33 | } // namespace LIBC_NAMESPACE_DECL | |
| 34 | ||
| 35 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_RVALUE_REFERENCE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_same.h created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | //===-- is_same type_traits -------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/false_type.h" | |
| 12 | #include "src/__support/CPP/type_traits/true_type.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // is_same | |
| 20 | template <typename T, typename U> struct is_same : cpp::false_type {}; | |
| 21 | template <typename T> struct is_same<T, T> : cpp::true_type {}; | |
| 22 | template <typename T, typename U> | |
| 23 | LIBC_INLINE_VAR constexpr bool is_same_v = is_same<T, U>::value; | |
| 24 | ||
| 25 | } // namespace cpp | |
| 26 | } // namespace LIBC_NAMESPACE_DECL | |
| 27 | ||
| 28 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SAME_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_scalar.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | //===-- is_scalar type_traits -----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SCALAR_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SCALAR_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/is_arithmetic.h" | |
| 13 | #include "src/__support/CPP/type_traits/is_enum.h" | |
| 14 | #include "src/__support/CPP/type_traits/is_member_pointer.h" | |
| 15 | #include "src/__support/CPP/type_traits/is_null_pointer.h" | |
| 16 | #include "src/__support/CPP/type_traits/is_pointer.h" | |
| 17 | #include "src/__support/macros/attributes.h" | |
| 18 | #include "src/__support/macros/config.h" | |
| 19 | ||
| 20 | namespace LIBC_NAMESPACE_DECL { | |
| 21 | namespace cpp { | |
| 22 | ||
| 23 | // is_scalar | |
| 24 | template <class T> | |
| 25 | struct is_scalar | |
| 26 | : cpp::bool_constant<cpp::is_arithmetic_v<T> || cpp::is_enum_v<T> || | |
| 27 | cpp::is_pointer_v<T> || cpp::is_member_pointer_v<T> || | |
| 28 | cpp::is_null_pointer_v<T>> {}; | |
| 29 | template <class T> | |
| 30 | LIBC_INLINE_VAR constexpr bool is_scalar_v = is_scalar<T>::value; | |
| 31 | ||
| 32 | } // namespace cpp | |
| 33 | } // namespace LIBC_NAMESPACE_DECL | |
| 34 | ||
| 35 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SCALAR_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_signed.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===-- is_signed type_traits -----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/is_arithmetic.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // is_signed | |
| 20 | template <typename T> | |
| 21 | struct is_signed : bool_constant<(is_arithmetic_v<T> && (T(-1) < T(0)))> { | |
| 22 | LIBC_INLINE constexpr operator bool() const { return is_signed::value; } | |
| 23 | LIBC_INLINE constexpr bool operator()() const { return is_signed::value; } | |
| 24 | }; | |
| 25 | template <typename T> | |
| 26 | LIBC_INLINE_VAR constexpr bool is_signed_v = is_signed<T>::value; | |
| 27 | ||
| 28 | } // namespace cpp | |
| 29 | } // namespace LIBC_NAMESPACE_DECL | |
| 30 | ||
| 31 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_SIGNED_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_trivially_constructible.h created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | //===-- is_trivially_constructible type_traits ------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/integral_constant.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // is_trivially_constructible | |
| 18 | template <class T, class... Args> | |
| 19 | struct is_trivially_constructible | |
| 20 | : integral_constant<bool, __is_trivially_constructible(T, Args...)> {}; | |
| 21 | ||
| 22 | } // namespace cpp | |
| 23 | } // namespace LIBC_NAMESPACE_DECL | |
| 24 | ||
| 25 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_trivially_copyable.h created+29| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | //===-- is_trivially_copyable type_traits -----------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/integral_constant.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // is_trivially_copyable | |
| 18 | template <class T> | |
| 19 | struct is_trivially_copyable | |
| 20 | : public integral_constant<bool, __is_trivially_copyable(T)> {}; | |
| 21 | ||
| 22 | template <class T> | |
| 23 | LIBC_INLINE_VAR constexpr bool is_trivially_copyable_v = | |
| 24 | is_trivially_copyable<T>::value; | |
| 25 | ||
| 26 | } // namespace cpp | |
| 27 | } // namespace LIBC_NAMESPACE_DECL | |
| 28 | ||
| 29 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_trivially_destructible.h created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | //===-- is_trivially_destructible type_traits -------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/is_destructible.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // is_trivially_destructible | |
| 20 | #if __has_builtin(__is_trivially_destructible) | |
| 21 | template <typename T> | |
| 22 | struct is_trivially_destructible | |
| 23 | : public bool_constant<__is_trivially_destructible(T)> {}; | |
| 24 | #else | |
| 25 | template <typename T> | |
| 26 | struct is_trivially_destructible | |
| 27 | : public bool_constant<cpp::is_destructible_v<T> &&__has_trivial_destructor( | |
| 28 | T)> {}; | |
| 29 | #endif // __has_builtin(__is_trivially_destructible) | |
| 30 | template <typename T> | |
| 31 | LIBC_INLINE_VAR constexpr bool is_trivially_destructible_v = | |
| 32 | is_trivially_destructible<T>::value; | |
| 33 | ||
| 34 | } // namespace cpp | |
| 35 | } // namespace LIBC_NAMESPACE_DECL | |
| 36 | ||
| 37 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_union.h created+26| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | //===-- is_union type_traits ------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/macros/attributes.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // is_union | |
| 19 | template <class T> struct is_union : bool_constant<__is_union(T)> {}; | |
| 20 | template <typename T> | |
| 21 | LIBC_INLINE_VAR constexpr bool is_union_v = is_union<T>::value; | |
| 22 | ||
| 23 | } // namespace cpp | |
| 24 | } // namespace LIBC_NAMESPACE_DECL | |
| 25 | ||
| 26 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNION_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_unsigned.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===-- is_unsigned type_traits ---------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/CPP/type_traits/is_arithmetic.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // is_unsigned | |
| 20 | template <typename T> | |
| 21 | struct is_unsigned : bool_constant<(is_arithmetic_v<T> && (T(-1) > T(0)))> { | |
| 22 | LIBC_INLINE constexpr operator bool() const { return is_unsigned::value; } | |
| 23 | LIBC_INLINE constexpr bool operator()() const { return is_unsigned::value; } | |
| 24 | }; | |
| 25 | template <typename T> | |
| 26 | LIBC_INLINE_VAR constexpr bool is_unsigned_v = is_unsigned<T>::value; | |
| 27 | ||
| 28 | } // namespace cpp | |
| 29 | } // namespace LIBC_NAMESPACE_DECL | |
| 30 | ||
| 31 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_UNSIGNED_H |
lib/libcxx/libc/src/__support/CPP/type_traits/is_void.h created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | //===-- is_void type_traits -------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/is_same.h" | |
| 12 | #include "src/__support/CPP/type_traits/remove_cv.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // is_void | |
| 20 | template <typename T> struct is_void : is_same<void, remove_cv_t<T>> {}; | |
| 21 | template <typename T> | |
| 22 | LIBC_INLINE_VAR constexpr bool is_void_v = is_void<T>::value; | |
| 23 | ||
| 24 | } // namespace cpp | |
| 25 | } // namespace LIBC_NAMESPACE_DECL | |
| 26 | ||
| 27 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_IS_VOID_H |
lib/libcxx/libc/src/__support/CPP/type_traits/make_signed.h created+41| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | //===-- make_signed type_traits ---------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128 | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // make_signed | |
| 19 | template <typename T> struct make_signed; | |
| 20 | template <> struct make_signed<char> : type_identity<char> {}; | |
| 21 | template <> struct make_signed<signed char> : type_identity<char> {}; | |
| 22 | template <> struct make_signed<short> : type_identity<short> {}; | |
| 23 | template <> struct make_signed<int> : type_identity<int> {}; | |
| 24 | template <> struct make_signed<long> : type_identity<long> {}; | |
| 25 | template <> struct make_signed<long long> : type_identity<long long> {}; | |
| 26 | template <> struct make_signed<unsigned char> : type_identity<char> {}; | |
| 27 | template <> struct make_signed<unsigned short> : type_identity<short> {}; | |
| 28 | template <> struct make_signed<unsigned int> : type_identity<int> {}; | |
| 29 | template <> struct make_signed<unsigned long> : type_identity<long> {}; | |
| 30 | template <> | |
| 31 | struct make_signed<unsigned long long> : type_identity<long long> {}; | |
| 32 | #ifdef LIBC_TYPES_HAS_INT128 | |
| 33 | template <> struct make_signed<__int128_t> : type_identity<__int128_t> {}; | |
| 34 | template <> struct make_signed<__uint128_t> : type_identity<__int128_t> {}; | |
| 35 | #endif | |
| 36 | template <typename T> using make_signed_t = typename make_signed<T>::type; | |
| 37 | ||
| 38 | } // namespace cpp | |
| 39 | } // namespace LIBC_NAMESPACE_DECL | |
| 40 | ||
| 41 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_SIGNED_H |
lib/libcxx/libc/src/__support/CPP/type_traits/make_unsigned.h created+46| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | //===-- make_unsigned type_traits -------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128 | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // make_unsigned | |
| 19 | ||
| 20 | template <typename T> struct make_unsigned; | |
| 21 | template <> struct make_unsigned<char> : type_identity<unsigned char> {}; | |
| 22 | template <> struct make_unsigned<signed char> : type_identity<unsigned char> {}; | |
| 23 | template <> struct make_unsigned<short> : type_identity<unsigned short> {}; | |
| 24 | template <> struct make_unsigned<int> : type_identity<unsigned int> {}; | |
| 25 | template <> struct make_unsigned<long> : type_identity<unsigned long> {}; | |
| 26 | template <> | |
| 27 | struct make_unsigned<long long> : type_identity<unsigned long long> {}; | |
| 28 | template <> | |
| 29 | struct make_unsigned<unsigned char> : type_identity<unsigned char> {}; | |
| 30 | template <> | |
| 31 | struct make_unsigned<unsigned short> : type_identity<unsigned short> {}; | |
| 32 | template <> struct make_unsigned<unsigned int> : type_identity<unsigned int> {}; | |
| 33 | template <> | |
| 34 | struct make_unsigned<unsigned long> : type_identity<unsigned long> {}; | |
| 35 | template <> | |
| 36 | struct make_unsigned<unsigned long long> : type_identity<unsigned long long> {}; | |
| 37 | #ifdef LIBC_TYPES_HAS_INT128 | |
| 38 | template <> struct make_unsigned<__int128_t> : type_identity<__uint128_t> {}; | |
| 39 | template <> struct make_unsigned<__uint128_t> : type_identity<__uint128_t> {}; | |
| 40 | #endif | |
| 41 | template <typename T> using make_unsigned_t = typename make_unsigned<T>::type; | |
| 42 | ||
| 43 | } // namespace cpp | |
| 44 | } // namespace LIBC_NAMESPACE_DECL | |
| 45 | ||
| 46 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_MAKE_UNSIGNED_H |
lib/libcxx/libc/src/__support/CPP/type_traits/remove_all_extents.h created+41| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | //===-- remove_all_extents type_traits --------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | #include <stddef.h> // size_t | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // remove_all_extents | |
| 20 | #if __has_builtin(__remove_all_extents) | |
| 21 | template <typename T> using remove_all_extents_t = __remove_all_extents(T); | |
| 22 | template <typename T> | |
| 23 | struct remove_all_extents : cpp::type_identity<remove_all_extents_t<T>> {}; | |
| 24 | #else | |
| 25 | template <typename T> struct remove_all_extents { | |
| 26 | using type = T; | |
| 27 | }; | |
| 28 | template <typename T> struct remove_all_extents<T[]> { | |
| 29 | using type = typename remove_all_extents<T>::type; | |
| 30 | }; | |
| 31 | template <typename T, size_t _Np> struct remove_all_extents<T[_Np]> { | |
| 32 | using type = typename remove_all_extents<T>::type; | |
| 33 | }; | |
| 34 | template <typename T> | |
| 35 | using remove_all_extents_t = typename remove_all_extents<T>::type; | |
| 36 | #endif | |
| 37 | ||
| 38 | } // namespace cpp | |
| 39 | } // namespace LIBC_NAMESPACE_DECL | |
| 40 | ||
| 41 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_ALL_EXTENTS_H |
lib/libcxx/libc/src/__support/CPP/type_traits/remove_cv.h created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | //===-- remove_cv type_traits -----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // remove_cv | |
| 18 | template <class T> struct remove_cv : cpp::type_identity<T> {}; | |
| 19 | template <class T> struct remove_cv<const T> : cpp::type_identity<T> {}; | |
| 20 | template <class T> struct remove_cv<volatile T> : cpp::type_identity<T> {}; | |
| 21 | template <class T> | |
| 22 | struct remove_cv<const volatile T> : cpp::type_identity<T> {}; | |
| 23 | template <class T> using remove_cv_t = typename remove_cv<T>::type; | |
| 24 | ||
| 25 | } // namespace cpp | |
| 26 | } // namespace LIBC_NAMESPACE_DECL | |
| 27 | ||
| 28 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CV_H |
lib/libcxx/libc/src/__support/CPP/type_traits/remove_cvref.h created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | //===-- remove_cvref type_traits --------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/remove_cv.h" | |
| 12 | #include "src/__support/CPP/type_traits/remove_reference.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // remove_cvref | |
| 19 | template <typename T> struct remove_cvref { | |
| 20 | using type = remove_cv_t<remove_reference_t<T>>; | |
| 21 | }; | |
| 22 | template <typename T> using remove_cvref_t = typename remove_cvref<T>::type; | |
| 23 | ||
| 24 | } // namespace cpp | |
| 25 | } // namespace LIBC_NAMESPACE_DECL | |
| 26 | ||
| 27 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_CVREF_H |
lib/libcxx/libc/src/__support/CPP/type_traits/remove_extent.h created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | //===-- remove_extent type_traits -------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | #include "stddef.h" // size_t | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // remove_extent | |
| 19 | template <class T> struct remove_extent : cpp::type_identity<T> {}; | |
| 20 | template <class T> struct remove_extent<T[]> : cpp::type_identity<T> {}; | |
| 21 | template <class T, size_t N> | |
| 22 | struct remove_extent<T[N]> : cpp::type_identity<T> {}; | |
| 23 | template <class T> using remove_extent_t = typename remove_extent<T>::type; | |
| 24 | ||
| 25 | } // namespace cpp | |
| 26 | } // namespace LIBC_NAMESPACE_DECL | |
| 27 | ||
| 28 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_EXTENT_H |
lib/libcxx/libc/src/__support/CPP/type_traits/remove_reference.h created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | //===-- remove_reference type_traits ----------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // remove_reference | |
| 18 | template <class T> struct remove_reference : cpp::type_identity<T> {}; | |
| 19 | template <class T> struct remove_reference<T &> : cpp::type_identity<T> {}; | |
| 20 | template <class T> struct remove_reference<T &&> : cpp::type_identity<T> {}; | |
| 21 | template <class T> | |
| 22 | using remove_reference_t = typename remove_reference<T>::type; | |
| 23 | ||
| 24 | } // namespace cpp | |
| 25 | } // namespace LIBC_NAMESPACE_DECL | |
| 26 | ||
| 27 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_REMOVE_REFERENCE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/true_type.h created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | //===-- true_type type_traits -----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/bool_constant.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // true_type | |
| 18 | using true_type = cpp::bool_constant<true>; | |
| 19 | ||
| 20 | } // namespace cpp | |
| 21 | } // namespace LIBC_NAMESPACE_DECL | |
| 22 | ||
| 23 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TRUE_TYPE_H |
lib/libcxx/libc/src/__support/CPP/type_traits/type_identity.h created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | //===-- type_identity type_traits -------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H | |
| 10 | ||
| 11 | #include "src/__support/macros/config.h" | |
| 12 | ||
| 13 | namespace LIBC_NAMESPACE_DECL { | |
| 14 | namespace cpp { | |
| 15 | ||
| 16 | // type_identity | |
| 17 | template <typename T> struct type_identity { | |
| 18 | using type = T; | |
| 19 | }; | |
| 20 | ||
| 21 | } // namespace cpp | |
| 22 | } // namespace LIBC_NAMESPACE_DECL | |
| 23 | ||
| 24 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_TYPE_IDENTITY_H |
lib/libcxx/libc/src/__support/CPP/type_traits/void_t.h created+29| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | //===-- void_t type_traits --------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_VOID_T_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_VOID_T_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/type_identity.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // void_t | |
| 18 | ||
| 19 | namespace detail { | |
| 20 | template <typename... Ts> struct make_void : cpp::type_identity<void> {}; | |
| 21 | } // namespace detail | |
| 22 | ||
| 23 | template <typename... Ts> | |
| 24 | using void_t = typename detail::make_void<Ts...>::type; | |
| 25 | ||
| 26 | } // namespace cpp | |
| 27 | } // namespace LIBC_NAMESPACE_DECL | |
| 28 | ||
| 29 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_TYPE_TRAITS_VOID_T_H |
lib/libcxx/libc/src/__support/CPP/utility.h created+18| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | //===-- Analogous to <utility> ----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_H | |
| 11 | ||
| 12 | #include "src/__support/CPP/utility/declval.h" | |
| 13 | #include "src/__support/CPP/utility/forward.h" | |
| 14 | #include "src/__support/CPP/utility/in_place.h" | |
| 15 | #include "src/__support/CPP/utility/integer_sequence.h" | |
| 16 | #include "src/__support/CPP/utility/move.h" | |
| 17 | ||
| 18 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_H |
lib/libcxx/libc/src/__support/CPP/utility/declval.h created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | //===-- declval utility -----------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_DECLVAL_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_DECLVAL_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/add_rvalue_reference.h" | |
| 12 | #include "src/__support/CPP/type_traits/always_false.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // declval | |
| 19 | template <typename T> cpp::add_rvalue_reference_t<T> declval() { | |
| 20 | static_assert(cpp::always_false<T>, | |
| 21 | "declval not allowed in an evaluated context"); | |
| 22 | } | |
| 23 | ||
| 24 | } // namespace cpp | |
| 25 | } // namespace LIBC_NAMESPACE_DECL | |
| 26 | ||
| 27 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_DECLVAL_H |
lib/libcxx/libc/src/__support/CPP/utility/forward.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | //===-- forward utility -----------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_FORWARD_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_FORWARD_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/is_lvalue_reference.h" | |
| 12 | #include "src/__support/CPP/type_traits/remove_reference.h" | |
| 13 | #include "src/__support/macros/attributes.h" | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // forward | |
| 20 | template <typename T> | |
| 21 | LIBC_INLINE constexpr T &&forward(remove_reference_t<T> &value) { | |
| 22 | return static_cast<T &&>(value); | |
| 23 | } | |
| 24 | ||
| 25 | template <typename T> | |
| 26 | LIBC_INLINE constexpr T &&forward(remove_reference_t<T> &&value) { | |
| 27 | static_assert(!is_lvalue_reference_v<T>, | |
| 28 | "cannot forward an rvalue as an lvalue"); | |
| 29 | return static_cast<T &&>(value); | |
| 30 | } | |
| 31 | ||
| 32 | } // namespace cpp | |
| 33 | } // namespace LIBC_NAMESPACE_DECL | |
| 34 | ||
| 35 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_FORWARD_H |
lib/libcxx/libc/src/__support/CPP/utility/in_place.h created+39| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | //===-- in_place utility ----------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_IN_PLACE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_IN_PLACE_H | |
| 10 | ||
| 11 | #include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | #include <stddef.h> // size_t | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace cpp { | |
| 18 | ||
| 19 | // in_place | |
| 20 | struct in_place_t { | |
| 21 | LIBC_INLINE explicit in_place_t() = default; | |
| 22 | }; | |
| 23 | LIBC_INLINE_VAR constexpr in_place_t in_place{}; | |
| 24 | ||
| 25 | template <class T> struct in_place_type_t { | |
| 26 | LIBC_INLINE explicit in_place_type_t() = default; | |
| 27 | }; | |
| 28 | template <class T> LIBC_INLINE_VAR constexpr in_place_type_t<T> in_place_type{}; | |
| 29 | ||
| 30 | template <size_t IDX> struct in_place_index_t { | |
| 31 | LIBC_INLINE explicit in_place_index_t() = default; | |
| 32 | }; | |
| 33 | template <size_t IDX> | |
| 34 | LIBC_INLINE_VAR constexpr in_place_index_t<IDX> in_place_index{}; | |
| 35 | ||
| 36 | } // namespace cpp | |
| 37 | } // namespace LIBC_NAMESPACE_DECL | |
| 38 | ||
| 39 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_IN_PLACE_H |
lib/libcxx/libc/src/__support/CPP/utility/integer_sequence.h created+40| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | //===-- integer_sequence utility --------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/is_integral.h" | |
| 12 | #include "src/__support/macros/config.h" | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | namespace cpp { | |
| 16 | ||
| 17 | // integer_sequence | |
| 18 | template <typename T, T... Ints> struct integer_sequence { | |
| 19 | static_assert(cpp::is_integral_v<T>); | |
| 20 | template <T Next> using append = integer_sequence<T, Ints..., Next>; | |
| 21 | }; | |
| 22 | ||
| 23 | namespace detail { | |
| 24 | template <typename T, int N> struct make_integer_sequence { | |
| 25 | using type = | |
| 26 | typename make_integer_sequence<T, N - 1>::type::template append<N>; | |
| 27 | }; | |
| 28 | template <typename T> struct make_integer_sequence<T, -1> { | |
| 29 | using type = integer_sequence<T>; | |
| 30 | }; | |
| 31 | } // namespace detail | |
| 32 | ||
| 33 | template <typename T, int N> | |
| 34 | using make_integer_sequence = | |
| 35 | typename detail::make_integer_sequence<T, N - 1>::type; | |
| 36 | ||
| 37 | } // namespace cpp | |
| 38 | } // namespace LIBC_NAMESPACE_DECL | |
| 39 | ||
| 40 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H |
lib/libcxx/libc/src/__support/CPP/utility/move.h created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | //===-- move utility --------------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_MOVE_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_MOVE_H | |
| 10 | ||
| 11 | #include "src/__support/CPP/type_traits/remove_reference.h" | |
| 12 | #include "src/__support/macros/attributes.h" // LIBC_INLINE | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace cpp { | |
| 17 | ||
| 18 | // move | |
| 19 | template <class T> | |
| 20 | LIBC_INLINE constexpr cpp::remove_reference_t<T> &&move(T &&t) { | |
| 21 | return static_cast<typename cpp::remove_reference_t<T> &&>(t); | |
| 22 | } | |
| 23 | ||
| 24 | } // namespace cpp | |
| 25 | } // namespace LIBC_NAMESPACE_DECL | |
| 26 | ||
| 27 | #endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_MOVE_H |
lib/libcxx/libc/src/__support/FPUtil/FPBits.h created+846| ... | ... | @@ -0,0 +1,846 @@ |
| 1 | //===-- Abstract class for bit manipulation of float numbers. ---*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // ----------------------------------------------------------------------------- | |
| 10 | // **** WARNING **** | |
| 11 | // This file is shared with libc++. You should also be careful when adding | |
| 12 | // dependencies to this file, since it needs to build for all libc++ targets. | |
| 13 | // ----------------------------------------------------------------------------- | |
| 14 | ||
| 15 | #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FPBITS_H | |
| 16 | #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FPBITS_H | |
| 17 | ||
| 18 | #include "src/__support/CPP/bit.h" | |
| 19 | #include "src/__support/CPP/type_traits.h" | |
| 20 | #include "src/__support/common.h" | |
| 21 | #include "src/__support/libc_assert.h" // LIBC_ASSERT | |
| 22 | #include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR | |
| 23 | #include "src/__support/macros/config.h" | |
| 24 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_FLOAT128 | |
| 25 | #include "src/__support/math_extras.h" // mask_trailing_ones | |
| 26 | #include "src/__support/sign.h" // Sign | |
| 27 | #include "src/__support/uint128.h" | |
| 28 | ||
| 29 | #include <stdint.h> | |
| 30 | ||
| 31 | namespace LIBC_NAMESPACE_DECL { | |
| 32 | namespace fputil { | |
| 33 | ||
| 34 | // The supported floating point types. | |
| 35 | enum class FPType { | |
| 36 | IEEE754_Binary16, | |
| 37 | IEEE754_Binary32, | |
| 38 | IEEE754_Binary64, | |
| 39 | IEEE754_Binary128, | |
| 40 | X86_Binary80, | |
| 41 | }; | |
| 42 | ||
| 43 | // The classes hierarchy is as follows: | |
| 44 | // | |
| 45 | // ┌───────────────────┐ | |
| 46 | // │ FPLayout<FPType> │ | |
| 47 | // └─────────â–²─────────┘ | |
| 48 | // │ | |
| 49 | // ┌─────────┴─────────┐ | |
| 50 | // │ FPStorage<FPType> │ | |
| 51 | // └─────────â–²─────────┘ | |
| 52 | // │ | |
| 53 | // ┌────────────┴─────────────┐ | |
| 54 | // │ │ | |
| 55 | // ┌────────┴─────────┐ ┌──────────────┴──────────────────┐ | |
| 56 | // │ FPRepSem<FPType> │ │ FPRepSem<FPType::X86_Binary80 │ | |
| 57 | // └────────â–²─────────┘ └──────────────â–²──────────────────┘ | |
| 58 | // │ │ | |
| 59 | // └────────────┬─────────────┘ | |
| 60 | // │ | |
| 61 | // ┌───────┴───────┐ | |
| 62 | // │ FPRepImpl<T> │ | |
| 63 | // └───────â–²───────┘ | |
| 64 | // │ | |
| 65 | // ┌────────┴────────┐ | |
| 66 | // ┌─────┴─────┐ ┌─────┴─────┐ | |
| 67 | // │ FPRep<T> │ │ FPBits<T> │ | |
| 68 | // └───────────┘ └───────────┘ | |
| 69 | // | |
| 70 | // - 'FPLayout' defines only a few constants, namely the 'StorageType' and | |
| 71 | // length of the sign, the exponent, fraction and significand parts. | |
| 72 | // - 'FPStorage' builds more constants on top of those from 'FPLayout' like | |
| 73 | // exponent bias and masks. It also holds the bit representation of the | |
| 74 | // floating point as a 'StorageType' type and defines tools to assemble or | |
| 75 | // test these parts. | |
| 76 | // - 'FPRepSem' defines functions to interact semantically with the floating | |
| 77 | // point representation. The default implementation is the one for 'IEEE754', | |
| 78 | // a specialization is provided for X86 Extended Precision. | |
| 79 | // - 'FPRepImpl' derives from 'FPRepSem' and adds functions that are common to | |
| 80 | // all implementations or build on the ones in 'FPRepSem'. | |
| 81 | // - 'FPRep' exposes all functions from 'FPRepImpl' and returns 'FPRep' | |
| 82 | // instances when using Builders (static functions to create values). | |
| 83 | // - 'FPBits' exposes all the functions from 'FPRepImpl' but operates on the | |
| 84 | // native C++ floating point type instead of 'FPType'. An additional 'get_val' | |
| 85 | // function allows getting the C++ floating point type value back. Builders | |
| 86 | // called from 'FPBits' return 'FPBits' instances. | |
| 87 | ||
| 88 | namespace internal { | |
| 89 | ||
| 90 | // Defines the layout (sign, exponent, significand) of a floating point type in | |
| 91 | // memory. It also defines its associated StorageType, i.e., the unsigned | |
| 92 | // integer type used to manipulate its representation. | |
| 93 | // Additionally we provide the fractional part length, i.e., the number of bits | |
| 94 | // after the decimal dot when the number is in normal form. | |
| 95 | template <FPType> struct FPLayout {}; | |
| 96 | ||
| 97 | template <> struct FPLayout<FPType::IEEE754_Binary16> { | |
| 98 | using StorageType = uint16_t; | |
| 99 | LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1; | |
| 100 | LIBC_INLINE_VAR static constexpr int EXP_LEN = 5; | |
| 101 | LIBC_INLINE_VAR static constexpr int SIG_LEN = 10; | |
| 102 | LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN; | |
| 103 | }; | |
| 104 | ||
| 105 | template <> struct FPLayout<FPType::IEEE754_Binary32> { | |
| 106 | using StorageType = uint32_t; | |
| 107 | LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1; | |
| 108 | LIBC_INLINE_VAR static constexpr int EXP_LEN = 8; | |
| 109 | LIBC_INLINE_VAR static constexpr int SIG_LEN = 23; | |
| 110 | LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN; | |
| 111 | }; | |
| 112 | ||
| 113 | template <> struct FPLayout<FPType::IEEE754_Binary64> { | |
| 114 | using StorageType = uint64_t; | |
| 115 | LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1; | |
| 116 | LIBC_INLINE_VAR static constexpr int EXP_LEN = 11; | |
| 117 | LIBC_INLINE_VAR static constexpr int SIG_LEN = 52; | |
| 118 | LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN; | |
| 119 | }; | |
| 120 | ||
| 121 | template <> struct FPLayout<FPType::IEEE754_Binary128> { | |
| 122 | using StorageType = UInt128; | |
| 123 | LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1; | |
| 124 | LIBC_INLINE_VAR static constexpr int EXP_LEN = 15; | |
| 125 | LIBC_INLINE_VAR static constexpr int SIG_LEN = 112; | |
| 126 | LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN; | |
| 127 | }; | |
| 128 | ||
| 129 | template <> struct FPLayout<FPType::X86_Binary80> { | |
| 130 | #if __SIZEOF_LONG_DOUBLE__ == 12 | |
| 131 | using StorageType = UInt<__SIZEOF_LONG_DOUBLE__ * CHAR_BIT>; | |
| 132 | #else | |
| 133 | using StorageType = UInt128; | |
| 134 | #endif | |
| 135 | LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1; | |
| 136 | LIBC_INLINE_VAR static constexpr int EXP_LEN = 15; | |
| 137 | LIBC_INLINE_VAR static constexpr int SIG_LEN = 64; | |
| 138 | LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN - 1; | |
| 139 | }; | |
| 140 | ||
| 141 | // FPStorage derives useful constants from the FPLayout above. | |
| 142 | template <FPType fp_type> struct FPStorage : public FPLayout<fp_type> { | |
| 143 | using UP = FPLayout<fp_type>; | |
| 144 | ||
| 145 | using UP::EXP_LEN; // The number of bits for the *exponent* part | |
| 146 | using UP::SIG_LEN; // The number of bits for the *significand* part | |
| 147 | using UP::SIGN_LEN; // The number of bits for the *sign* part | |
| 148 | // For convenience, the sum of `SIG_LEN`, `EXP_LEN`, and `SIGN_LEN`. | |
| 149 | LIBC_INLINE_VAR static constexpr int TOTAL_LEN = SIGN_LEN + EXP_LEN + SIG_LEN; | |
| 150 | ||
| 151 | // The number of bits after the decimal dot when the number is in normal form. | |
| 152 | using UP::FRACTION_LEN; | |
| 153 | ||
| 154 | // An unsigned integer that is wide enough to contain all of the floating | |
| 155 | // point bits. | |
| 156 | using StorageType = typename UP::StorageType; | |
| 157 | ||
| 158 | // The number of bits in StorageType. | |
| 159 | LIBC_INLINE_VAR static constexpr int STORAGE_LEN = | |
| 160 | sizeof(StorageType) * CHAR_BIT; | |
| 161 | static_assert(STORAGE_LEN >= TOTAL_LEN); | |
| 162 | ||
| 163 | // The exponent bias. Always positive. | |
| 164 | LIBC_INLINE_VAR static constexpr int32_t EXP_BIAS = | |
| 165 | (1U << (EXP_LEN - 1U)) - 1U; | |
| 166 | static_assert(EXP_BIAS > 0); | |
| 167 | ||
| 168 | // The bit pattern that keeps only the *significand* part. | |
| 169 | LIBC_INLINE_VAR static constexpr StorageType SIG_MASK = | |
| 170 | mask_trailing_ones<StorageType, SIG_LEN>(); | |
| 171 | // The bit pattern that keeps only the *exponent* part. | |
| 172 | LIBC_INLINE_VAR static constexpr StorageType EXP_MASK = | |
| 173 | mask_trailing_ones<StorageType, EXP_LEN>() << SIG_LEN; | |
| 174 | // The bit pattern that keeps only the *sign* part. | |
| 175 | LIBC_INLINE_VAR static constexpr StorageType SIGN_MASK = | |
| 176 | mask_trailing_ones<StorageType, SIGN_LEN>() << (EXP_LEN + SIG_LEN); | |
| 177 | // The bit pattern that keeps only the *exponent + significand* part. | |
| 178 | LIBC_INLINE_VAR static constexpr StorageType EXP_SIG_MASK = | |
| 179 | mask_trailing_ones<StorageType, EXP_LEN + SIG_LEN>(); | |
| 180 | // The bit pattern that keeps only the *sign + exponent + significand* part. | |
| 181 | LIBC_INLINE_VAR static constexpr StorageType FP_MASK = | |
| 182 | mask_trailing_ones<StorageType, TOTAL_LEN>(); | |
| 183 | // The bit pattern that keeps only the *fraction* part. | |
| 184 | // i.e., the *significand* without the leading one. | |
| 185 | LIBC_INLINE_VAR static constexpr StorageType FRACTION_MASK = | |
| 186 | mask_trailing_ones<StorageType, FRACTION_LEN>(); | |
| 187 | ||
| 188 | static_assert((SIG_MASK & EXP_MASK & SIGN_MASK) == 0, "masks disjoint"); | |
| 189 | static_assert((SIG_MASK | EXP_MASK | SIGN_MASK) == FP_MASK, "masks cover"); | |
| 190 | ||
| 191 | protected: | |
| 192 | // Merge bits from 'a' and 'b' values according to 'mask'. | |
| 193 | // Use 'a' bits when corresponding 'mask' bits are zeroes and 'b' bits when | |
| 194 | // corresponding bits are ones. | |
| 195 | LIBC_INLINE static constexpr StorageType merge(StorageType a, StorageType b, | |
| 196 | StorageType mask) { | |
| 197 | // https://graphics.stanford.edu/~seander/bithacks.html#MaskedMerge | |
| 198 | return a ^ ((a ^ b) & mask); | |
| 199 | } | |
| 200 | ||
| 201 | // A stongly typed integer that prevents mixing and matching integers with | |
| 202 | // different semantics. | |
| 203 | template <typename T> struct TypedInt { | |
| 204 | using value_type = T; | |
| 205 | LIBC_INLINE constexpr explicit TypedInt(T value) : value(value) {} | |
| 206 | LIBC_INLINE constexpr TypedInt(const TypedInt &value) = default; | |
| 207 | LIBC_INLINE constexpr TypedInt &operator=(const TypedInt &value) = default; | |
| 208 | ||
| 209 | LIBC_INLINE constexpr explicit operator T() const { return value; } | |
| 210 | ||
| 211 | LIBC_INLINE constexpr StorageType to_storage_type() const { | |
| 212 | return StorageType(value); | |
| 213 | } | |
| 214 | ||
| 215 | LIBC_INLINE friend constexpr bool operator==(TypedInt a, TypedInt b) { | |
| 216 | return a.value == b.value; | |
| 217 | } | |
| 218 | LIBC_INLINE friend constexpr bool operator!=(TypedInt a, TypedInt b) { | |
| 219 | return a.value != b.value; | |
| 220 | } | |
| 221 | ||
| 222 | protected: | |
| 223 | T value; | |
| 224 | }; | |
| 225 | ||
| 226 | // An opaque type to store a floating point exponent. | |
| 227 | // We define special values but it is valid to create arbitrary values as long | |
| 228 | // as they are in the range [min, max]. | |
| 229 | struct Exponent : public TypedInt<int32_t> { | |
| 230 | using UP = TypedInt<int32_t>; | |
| 231 | using UP::UP; | |
| 232 | LIBC_INLINE static constexpr auto subnormal() { | |
| 233 | return Exponent(-EXP_BIAS); | |
| 234 | } | |
| 235 | LIBC_INLINE static constexpr auto min() { return Exponent(1 - EXP_BIAS); } | |
| 236 | LIBC_INLINE static constexpr auto zero() { return Exponent(0); } | |
| 237 | LIBC_INLINE static constexpr auto max() { return Exponent(EXP_BIAS); } | |
| 238 | LIBC_INLINE static constexpr auto inf() { return Exponent(EXP_BIAS + 1); } | |
| 239 | }; | |
| 240 | ||
| 241 | // An opaque type to store a floating point biased exponent. | |
| 242 | // We define special values but it is valid to create arbitrary values as long | |
| 243 | // as they are in the range [zero, bits_all_ones]. | |
| 244 | // Values greater than bits_all_ones are truncated. | |
| 245 | struct BiasedExponent : public TypedInt<uint32_t> { | |
| 246 | using UP = TypedInt<uint32_t>; | |
| 247 | using UP::UP; | |
| 248 | ||
| 249 | LIBC_INLINE constexpr BiasedExponent(Exponent exp) | |
| 250 | : UP(static_cast<int32_t>(exp) + EXP_BIAS) {} | |
| 251 | ||
| 252 | // Cast operator to get convert from BiasedExponent to Exponent. | |
| 253 | LIBC_INLINE constexpr operator Exponent() const { | |
| 254 | return Exponent(UP::value - EXP_BIAS); | |
| 255 | } | |
| 256 | ||
| 257 | LIBC_INLINE constexpr BiasedExponent &operator++() { | |
| 258 | LIBC_ASSERT(*this != BiasedExponent(Exponent::inf())); | |
| 259 | ++UP::value; | |
| 260 | return *this; | |
| 261 | } | |
| 262 | ||
| 263 | LIBC_INLINE constexpr BiasedExponent &operator--() { | |
| 264 | LIBC_ASSERT(*this != BiasedExponent(Exponent::subnormal())); | |
| 265 | --UP::value; | |
| 266 | return *this; | |
| 267 | } | |
| 268 | }; | |
| 269 | ||
| 270 | // An opaque type to store a floating point significand. | |
| 271 | // We define special values but it is valid to create arbitrary values as long | |
| 272 | // as they are in the range [zero, bits_all_ones]. | |
| 273 | // Note that the semantics of the Significand are implementation dependent. | |
| 274 | // Values greater than bits_all_ones are truncated. | |
| 275 | struct Significand : public TypedInt<StorageType> { | |
| 276 | using UP = TypedInt<StorageType>; | |
| 277 | using UP::UP; | |
| 278 | ||
| 279 | LIBC_INLINE friend constexpr Significand operator|(const Significand a, | |
| 280 | const Significand b) { | |
| 281 | return Significand( | |
| 282 | StorageType(a.to_storage_type() | b.to_storage_type())); | |
| 283 | } | |
| 284 | LIBC_INLINE friend constexpr Significand operator^(const Significand a, | |
| 285 | const Significand b) { | |
| 286 | return Significand( | |
| 287 | StorageType(a.to_storage_type() ^ b.to_storage_type())); | |
| 288 | } | |
| 289 | LIBC_INLINE friend constexpr Significand operator>>(const Significand a, | |
| 290 | int shift) { | |
| 291 | return Significand(StorageType(a.to_storage_type() >> shift)); | |
| 292 | } | |
| 293 | ||
| 294 | LIBC_INLINE static constexpr auto zero() { | |
| 295 | return Significand(StorageType(0)); | |
| 296 | } | |
| 297 | LIBC_INLINE static constexpr auto lsb() { | |
| 298 | return Significand(StorageType(1)); | |
| 299 | } | |
| 300 | LIBC_INLINE static constexpr auto msb() { | |
| 301 | return Significand(StorageType(1) << (SIG_LEN - 1)); | |
| 302 | } | |
| 303 | LIBC_INLINE static constexpr auto bits_all_ones() { | |
| 304 | return Significand(SIG_MASK); | |
| 305 | } | |
| 306 | }; | |
| 307 | ||
| 308 | LIBC_INLINE static constexpr StorageType encode(BiasedExponent exp) { | |
| 309 | return (exp.to_storage_type() << SIG_LEN) & EXP_MASK; | |
| 310 | } | |
| 311 | ||
| 312 | LIBC_INLINE static constexpr StorageType encode(Significand value) { | |
| 313 | return value.to_storage_type() & SIG_MASK; | |
| 314 | } | |
| 315 | ||
| 316 | LIBC_INLINE static constexpr StorageType encode(BiasedExponent exp, | |
| 317 | Significand sig) { | |
| 318 | return encode(exp) | encode(sig); | |
| 319 | } | |
| 320 | ||
| 321 | LIBC_INLINE static constexpr StorageType encode(Sign sign, BiasedExponent exp, | |
| 322 | Significand sig) { | |
| 323 | if (sign.is_neg()) | |
| 324 | return SIGN_MASK | encode(exp, sig); | |
| 325 | return encode(exp, sig); | |
| 326 | } | |
| 327 | ||
| 328 | // The floating point number representation as an unsigned integer. | |
| 329 | StorageType bits{}; | |
| 330 | ||
| 331 | LIBC_INLINE constexpr FPStorage() : bits(0) {} | |
| 332 | LIBC_INLINE constexpr FPStorage(StorageType value) : bits(value) {} | |
| 333 | ||
| 334 | // Observers | |
| 335 | LIBC_INLINE constexpr StorageType exp_bits() const { return bits & EXP_MASK; } | |
| 336 | LIBC_INLINE constexpr StorageType sig_bits() const { return bits & SIG_MASK; } | |
| 337 | LIBC_INLINE constexpr StorageType exp_sig_bits() const { | |
| 338 | return bits & EXP_SIG_MASK; | |
| 339 | } | |
| 340 | ||
| 341 | // Parts | |
| 342 | LIBC_INLINE constexpr BiasedExponent biased_exponent() const { | |
| 343 | return BiasedExponent(static_cast<uint32_t>(exp_bits() >> SIG_LEN)); | |
| 344 | } | |
| 345 | LIBC_INLINE constexpr void set_biased_exponent(BiasedExponent biased) { | |
| 346 | bits = merge(bits, encode(biased), EXP_MASK); | |
| 347 | } | |
| 348 | ||
| 349 | public: | |
| 350 | LIBC_INLINE constexpr Sign sign() const { | |
| 351 | return (bits & SIGN_MASK) ? Sign::NEG : Sign::POS; | |
| 352 | } | |
| 353 | LIBC_INLINE constexpr void set_sign(Sign signVal) { | |
| 354 | if (sign() != signVal) | |
| 355 | bits ^= SIGN_MASK; | |
| 356 | } | |
| 357 | }; | |
| 358 | ||
| 359 | // This layer defines all functions that are specific to how the the floating | |
| 360 | // point type is encoded. It enables constructions, modification and observation | |
| 361 | // of values manipulated as 'StorageType'. | |
| 362 | template <FPType fp_type, typename RetT> | |
| 363 | struct FPRepSem : public FPStorage<fp_type> { | |
| 364 | using UP = FPStorage<fp_type>; | |
| 365 | using typename UP::StorageType; | |
| 366 | using UP::FRACTION_LEN; | |
| 367 | using UP::FRACTION_MASK; | |
| 368 | ||
| 369 | protected: | |
| 370 | using typename UP::Exponent; | |
| 371 | using typename UP::Significand; | |
| 372 | using UP::bits; | |
| 373 | using UP::encode; | |
| 374 | using UP::exp_bits; | |
| 375 | using UP::exp_sig_bits; | |
| 376 | using UP::sig_bits; | |
| 377 | using UP::UP; | |
| 378 | ||
| 379 | public: | |
| 380 | // Builders | |
| 381 | LIBC_INLINE static constexpr RetT zero(Sign sign = Sign::POS) { | |
| 382 | return RetT(encode(sign, Exponent::subnormal(), Significand::zero())); | |
| 383 | } | |
| 384 | LIBC_INLINE static constexpr RetT one(Sign sign = Sign::POS) { | |
| 385 | return RetT(encode(sign, Exponent::zero(), Significand::zero())); | |
| 386 | } | |
| 387 | LIBC_INLINE static constexpr RetT min_subnormal(Sign sign = Sign::POS) { | |
| 388 | return RetT(encode(sign, Exponent::subnormal(), Significand::lsb())); | |
| 389 | } | |
| 390 | LIBC_INLINE static constexpr RetT max_subnormal(Sign sign = Sign::POS) { | |
| 391 | return RetT( | |
| 392 | encode(sign, Exponent::subnormal(), Significand::bits_all_ones())); | |
| 393 | } | |
| 394 | LIBC_INLINE static constexpr RetT min_normal(Sign sign = Sign::POS) { | |
| 395 | return RetT(encode(sign, Exponent::min(), Significand::zero())); | |
| 396 | } | |
| 397 | LIBC_INLINE static constexpr RetT max_normal(Sign sign = Sign::POS) { | |
| 398 | return RetT(encode(sign, Exponent::max(), Significand::bits_all_ones())); | |
| 399 | } | |
| 400 | LIBC_INLINE static constexpr RetT inf(Sign sign = Sign::POS) { | |
| 401 | return RetT(encode(sign, Exponent::inf(), Significand::zero())); | |
| 402 | } | |
| 403 | LIBC_INLINE static constexpr RetT signaling_nan(Sign sign = Sign::POS, | |
| 404 | StorageType v = 0) { | |
| 405 | return RetT(encode(sign, Exponent::inf(), | |
| 406 | (v ? Significand(v) : (Significand::msb() >> 1)))); | |
| 407 | } | |
| 408 | LIBC_INLINE static constexpr RetT quiet_nan(Sign sign = Sign::POS, | |
| 409 | StorageType v = 0) { | |
| 410 | return RetT( | |
| 411 | encode(sign, Exponent::inf(), Significand::msb() | Significand(v))); | |
| 412 | } | |
| 413 | ||
| 414 | // Observers | |
| 415 | LIBC_INLINE constexpr bool is_zero() const { return exp_sig_bits() == 0; } | |
| 416 | LIBC_INLINE constexpr bool is_nan() const { | |
| 417 | return exp_sig_bits() > encode(Exponent::inf(), Significand::zero()); | |
| 418 | } | |
| 419 | LIBC_INLINE constexpr bool is_quiet_nan() const { | |
| 420 | return exp_sig_bits() >= encode(Exponent::inf(), Significand::msb()); | |
| 421 | } | |
| 422 | LIBC_INLINE constexpr bool is_signaling_nan() const { | |
| 423 | return is_nan() && !is_quiet_nan(); | |
| 424 | } | |
| 425 | LIBC_INLINE constexpr bool is_inf() const { | |
| 426 | return exp_sig_bits() == encode(Exponent::inf(), Significand::zero()); | |
| 427 | } | |
| 428 | LIBC_INLINE constexpr bool is_finite() const { | |
| 429 | return exp_bits() != encode(Exponent::inf()); | |
| 430 | } | |
| 431 | LIBC_INLINE | |
| 432 | constexpr bool is_subnormal() const { | |
| 433 | return exp_bits() == encode(Exponent::subnormal()); | |
| 434 | } | |
| 435 | LIBC_INLINE constexpr bool is_normal() const { | |
| 436 | return is_finite() && !is_subnormal(); | |
| 437 | } | |
| 438 | LIBC_INLINE constexpr RetT next_toward_inf() const { | |
| 439 | if (is_finite()) | |
| 440 | return RetT(bits + StorageType(1)); | |
| 441 | return RetT(bits); | |
| 442 | } | |
| 443 | ||
| 444 | // Returns the mantissa with the implicit bit set iff the current | |
| 445 | // value is a valid normal number. | |
| 446 | LIBC_INLINE constexpr StorageType get_explicit_mantissa() const { | |
| 447 | if (is_subnormal()) | |
| 448 | return sig_bits(); | |
| 449 | return (StorageType(1) << UP::SIG_LEN) | sig_bits(); | |
| 450 | } | |
| 451 | }; | |
| 452 | ||
| 453 | // Specialization for the X86 Extended Precision type. | |
| 454 | template <typename RetT> | |
| 455 | struct FPRepSem<FPType::X86_Binary80, RetT> | |
| 456 | : public FPStorage<FPType::X86_Binary80> { | |
| 457 | using UP = FPStorage<FPType::X86_Binary80>; | |
| 458 | using typename UP::StorageType; | |
| 459 | using UP::FRACTION_LEN; | |
| 460 | using UP::FRACTION_MASK; | |
| 461 | ||
| 462 | // The x86 80 bit float represents the leading digit of the mantissa | |
| 463 | // explicitly. This is the mask for that bit. | |
| 464 | static constexpr StorageType EXPLICIT_BIT_MASK = StorageType(1) | |
| 465 | << FRACTION_LEN; | |
| 466 | // The X80 significand is made of an explicit bit and the fractional part. | |
| 467 | static_assert((EXPLICIT_BIT_MASK & FRACTION_MASK) == 0, | |
| 468 | "the explicit bit and the fractional part should not overlap"); | |
| 469 | static_assert((EXPLICIT_BIT_MASK | FRACTION_MASK) == SIG_MASK, | |
| 470 | "the explicit bit and the fractional part should cover the " | |
| 471 | "whole significand"); | |
| 472 | ||
| 473 | protected: | |
| 474 | using typename UP::Exponent; | |
| 475 | using typename UP::Significand; | |
| 476 | using UP::encode; | |
| 477 | using UP::UP; | |
| 478 | ||
| 479 | public: | |
| 480 | // Builders | |
| 481 | LIBC_INLINE static constexpr RetT zero(Sign sign = Sign::POS) { | |
| 482 | return RetT(encode(sign, Exponent::subnormal(), Significand::zero())); | |
| 483 | } | |
| 484 | LIBC_INLINE static constexpr RetT one(Sign sign = Sign::POS) { | |
| 485 | return RetT(encode(sign, Exponent::zero(), Significand::msb())); | |
| 486 | } | |
| 487 | LIBC_INLINE static constexpr RetT min_subnormal(Sign sign = Sign::POS) { | |
| 488 | return RetT(encode(sign, Exponent::subnormal(), Significand::lsb())); | |
| 489 | } | |
| 490 | LIBC_INLINE static constexpr RetT max_subnormal(Sign sign = Sign::POS) { | |
| 491 | return RetT(encode(sign, Exponent::subnormal(), | |
| 492 | Significand::bits_all_ones() ^ Significand::msb())); | |
| 493 | } | |
| 494 | LIBC_INLINE static constexpr RetT min_normal(Sign sign = Sign::POS) { | |
| 495 | return RetT(encode(sign, Exponent::min(), Significand::msb())); | |
| 496 | } | |
| 497 | LIBC_INLINE static constexpr RetT max_normal(Sign sign = Sign::POS) { | |
| 498 | return RetT(encode(sign, Exponent::max(), Significand::bits_all_ones())); | |
| 499 | } | |
| 500 | LIBC_INLINE static constexpr RetT inf(Sign sign = Sign::POS) { | |
| 501 | return RetT(encode(sign, Exponent::inf(), Significand::msb())); | |
| 502 | } | |
| 503 | LIBC_INLINE static constexpr RetT signaling_nan(Sign sign = Sign::POS, | |
| 504 | StorageType v = 0) { | |
| 505 | return RetT(encode(sign, Exponent::inf(), | |
| 506 | Significand::msb() | | |
| 507 | (v ? Significand(v) : (Significand::msb() >> 2)))); | |
| 508 | } | |
| 509 | LIBC_INLINE static constexpr RetT quiet_nan(Sign sign = Sign::POS, | |
| 510 | StorageType v = 0) { | |
| 511 | return RetT(encode(sign, Exponent::inf(), | |
| 512 | Significand::msb() | (Significand::msb() >> 1) | | |
| 513 | Significand(v))); | |
| 514 | } | |
| 515 | ||
| 516 | // Observers | |
| 517 | LIBC_INLINE constexpr bool is_zero() const { return exp_sig_bits() == 0; } | |
| 518 | LIBC_INLINE constexpr bool is_nan() const { | |
| 519 | // Most encoding forms from the table found in | |
| 520 | // https://en.wikipedia.org/wiki/Extended_precision#x86_extended_precision_format | |
| 521 | // are interpreted as NaN. | |
| 522 | // More precisely : | |
| 523 | // - Pseudo-Infinity | |
| 524 | // - Pseudo Not a Number | |
| 525 | // - Signalling Not a Number | |
| 526 | // - Floating-point Indefinite | |
| 527 | // - Quiet Not a Number | |
| 528 | // - Unnormal | |
| 529 | // This can be reduced to the following logic: | |
| 530 | if (exp_bits() == encode(Exponent::inf())) | |
| 531 | return !is_inf(); | |
| 532 | if (exp_bits() != encode(Exponent::subnormal())) | |
| 533 | return (sig_bits() & encode(Significand::msb())) == 0; | |
| 534 | return false; | |
| 535 | } | |
| 536 | LIBC_INLINE constexpr bool is_quiet_nan() const { | |
| 537 | return exp_sig_bits() >= | |
| 538 | encode(Exponent::inf(), | |
| 539 | Significand::msb() | (Significand::msb() >> 1)); | |
| 540 | } | |
| 541 | LIBC_INLINE constexpr bool is_signaling_nan() const { | |
| 542 | return is_nan() && !is_quiet_nan(); | |
| 543 | } | |
| 544 | LIBC_INLINE constexpr bool is_inf() const { | |
| 545 | return exp_sig_bits() == encode(Exponent::inf(), Significand::msb()); | |
| 546 | } | |
| 547 | LIBC_INLINE constexpr bool is_finite() const { | |
| 548 | return !is_inf() && !is_nan(); | |
| 549 | } | |
| 550 | LIBC_INLINE | |
| 551 | constexpr bool is_subnormal() const { | |
| 552 | return exp_bits() == encode(Exponent::subnormal()); | |
| 553 | } | |
| 554 | LIBC_INLINE constexpr bool is_normal() const { | |
| 555 | const auto exp = exp_bits(); | |
| 556 | if (exp == encode(Exponent::subnormal()) || exp == encode(Exponent::inf())) | |
| 557 | return false; | |
| 558 | return get_implicit_bit(); | |
| 559 | } | |
| 560 | LIBC_INLINE constexpr RetT next_toward_inf() const { | |
| 561 | if (is_finite()) { | |
| 562 | if (exp_sig_bits() == max_normal().uintval()) { | |
| 563 | return inf(sign()); | |
| 564 | } else if (exp_sig_bits() == max_subnormal().uintval()) { | |
| 565 | return min_normal(sign()); | |
| 566 | } else if (sig_bits() == SIG_MASK) { | |
| 567 | return RetT(encode(sign(), ++biased_exponent(), Significand::zero())); | |
| 568 | } else { | |
| 569 | return RetT(bits + StorageType(1)); | |
| 570 | } | |
| 571 | } | |
| 572 | return RetT(bits); | |
| 573 | } | |
| 574 | ||
| 575 | LIBC_INLINE constexpr StorageType get_explicit_mantissa() const { | |
| 576 | return sig_bits(); | |
| 577 | } | |
| 578 | ||
| 579 | // This functions is specific to FPRepSem<FPType::X86_Binary80>. | |
| 580 | // TODO: Remove if possible. | |
| 581 | LIBC_INLINE constexpr bool get_implicit_bit() const { | |
| 582 | return static_cast<bool>(bits & EXPLICIT_BIT_MASK); | |
| 583 | } | |
| 584 | ||
| 585 | // This functions is specific to FPRepSem<FPType::X86_Binary80>. | |
| 586 | // TODO: Remove if possible. | |
| 587 | LIBC_INLINE constexpr void set_implicit_bit(bool implicitVal) { | |
| 588 | if (get_implicit_bit() != implicitVal) | |
| 589 | bits ^= EXPLICIT_BIT_MASK; | |
| 590 | } | |
| 591 | }; | |
| 592 | ||
| 593 | // 'FPRepImpl' is the bottom of the class hierarchy that only deals with | |
| 594 | // 'FPType'. The operations dealing with specific float semantics are | |
| 595 | // implemented by 'FPRepSem' above and specialized when needed. | |
| 596 | // | |
| 597 | // The 'RetT' type is being propagated up to 'FPRepSem' so that the functions | |
| 598 | // creating new values (Builders) can return the appropriate type. That is, when | |
| 599 | // creating a value through 'FPBits' below the builder will return an 'FPBits' | |
| 600 | // value. | |
| 601 | // FPBits<float>::zero(); // returns an FPBits<> | |
| 602 | // | |
| 603 | // When we don't care about specific C++ floating point type we can use | |
| 604 | // 'FPRep' and specify the 'FPType' directly. | |
| 605 | // FPRep<FPType::IEEE754_Binary32:>::zero() // returns an FPRep<> | |
| 606 | template <FPType fp_type, typename RetT> | |
| 607 | struct FPRepImpl : public FPRepSem<fp_type, RetT> { | |
| 608 | using UP = FPRepSem<fp_type, RetT>; | |
| 609 | using StorageType = typename UP::StorageType; | |
| 610 | ||
| 611 | protected: | |
| 612 | using UP::bits; | |
| 613 | using UP::encode; | |
| 614 | using UP::exp_bits; | |
| 615 | using UP::exp_sig_bits; | |
| 616 | ||
| 617 | using typename UP::BiasedExponent; | |
| 618 | using typename UP::Exponent; | |
| 619 | using typename UP::Significand; | |
| 620 | ||
| 621 | using UP::FP_MASK; | |
| 622 | ||
| 623 | public: | |
| 624 | // Constants. | |
| 625 | using UP::EXP_BIAS; | |
| 626 | using UP::EXP_MASK; | |
| 627 | using UP::FRACTION_MASK; | |
| 628 | using UP::SIG_LEN; | |
| 629 | using UP::SIG_MASK; | |
| 630 | using UP::SIGN_MASK; | |
| 631 | LIBC_INLINE_VAR static constexpr int MAX_BIASED_EXPONENT = | |
| 632 | (1 << UP::EXP_LEN) - 1; | |
| 633 | ||
| 634 | // CTors | |
| 635 | LIBC_INLINE constexpr FPRepImpl() = default; | |
| 636 | LIBC_INLINE constexpr explicit FPRepImpl(StorageType x) : UP(x) {} | |
| 637 | ||
| 638 | // Comparison | |
| 639 | LIBC_INLINE constexpr friend bool operator==(FPRepImpl a, FPRepImpl b) { | |
| 640 | return a.uintval() == b.uintval(); | |
| 641 | } | |
| 642 | LIBC_INLINE constexpr friend bool operator!=(FPRepImpl a, FPRepImpl b) { | |
| 643 | return a.uintval() != b.uintval(); | |
| 644 | } | |
| 645 | ||
| 646 | // Representation | |
| 647 | LIBC_INLINE constexpr StorageType uintval() const { return bits & FP_MASK; } | |
| 648 | LIBC_INLINE constexpr void set_uintval(StorageType value) { | |
| 649 | bits = (value & FP_MASK); | |
| 650 | } | |
| 651 | ||
| 652 | // Builders | |
| 653 | using UP::inf; | |
| 654 | using UP::max_normal; | |
| 655 | using UP::max_subnormal; | |
| 656 | using UP::min_normal; | |
| 657 | using UP::min_subnormal; | |
| 658 | using UP::one; | |
| 659 | using UP::quiet_nan; | |
| 660 | using UP::signaling_nan; | |
| 661 | using UP::zero; | |
| 662 | ||
| 663 | // Modifiers | |
| 664 | LIBC_INLINE constexpr RetT abs() const { | |
| 665 | return RetT(static_cast<StorageType>(bits & UP::EXP_SIG_MASK)); | |
| 666 | } | |
| 667 | ||
| 668 | // Observers | |
| 669 | using UP::get_explicit_mantissa; | |
| 670 | using UP::is_finite; | |
| 671 | using UP::is_inf; | |
| 672 | using UP::is_nan; | |
| 673 | using UP::is_normal; | |
| 674 | using UP::is_quiet_nan; | |
| 675 | using UP::is_signaling_nan; | |
| 676 | using UP::is_subnormal; | |
| 677 | using UP::is_zero; | |
| 678 | using UP::next_toward_inf; | |
| 679 | using UP::sign; | |
| 680 | LIBC_INLINE constexpr bool is_inf_or_nan() const { return !is_finite(); } | |
| 681 | LIBC_INLINE constexpr bool is_neg() const { return sign().is_neg(); } | |
| 682 | LIBC_INLINE constexpr bool is_pos() const { return sign().is_pos(); } | |
| 683 | ||
| 684 | LIBC_INLINE constexpr uint16_t get_biased_exponent() const { | |
| 685 | return static_cast<uint16_t>(static_cast<uint32_t>(UP::biased_exponent())); | |
| 686 | } | |
| 687 | ||
| 688 | LIBC_INLINE constexpr void set_biased_exponent(StorageType biased) { | |
| 689 | UP::set_biased_exponent(BiasedExponent((int32_t)biased)); | |
| 690 | } | |
| 691 | ||
| 692 | LIBC_INLINE constexpr int get_exponent() const { | |
| 693 | return static_cast<int32_t>(Exponent(UP::biased_exponent())); | |
| 694 | } | |
| 695 | ||
| 696 | // If the number is subnormal, the exponent is treated as if it were the | |
| 697 | // minimum exponent for a normal number. This is to keep continuity between | |
| 698 | // the normal and subnormal ranges, but it causes problems for functions where | |
| 699 | // values are calculated from the exponent, since just subtracting the bias | |
| 700 | // will give a slightly incorrect result. Additionally, zero has an exponent | |
| 701 | // of zero, and that should actually be treated as zero. | |
| 702 | LIBC_INLINE constexpr int get_explicit_exponent() const { | |
| 703 | Exponent exponent(UP::biased_exponent()); | |
| 704 | if (is_zero()) | |
| 705 | exponent = Exponent::zero(); | |
| 706 | if (exponent == Exponent::subnormal()) | |
| 707 | exponent = Exponent::min(); | |
| 708 | return static_cast<int32_t>(exponent); | |
| 709 | } | |
| 710 | ||
| 711 | LIBC_INLINE constexpr StorageType get_mantissa() const { | |
| 712 | return bits & FRACTION_MASK; | |
| 713 | } | |
| 714 | ||
| 715 | LIBC_INLINE constexpr void set_mantissa(StorageType mantVal) { | |
| 716 | bits = UP::merge(bits, mantVal, FRACTION_MASK); | |
| 717 | } | |
| 718 | ||
| 719 | LIBC_INLINE constexpr void set_significand(StorageType sigVal) { | |
| 720 | bits = UP::merge(bits, sigVal, SIG_MASK); | |
| 721 | } | |
| 722 | // Unsafe function to create a floating point representation. | |
| 723 | // It simply packs the sign, biased exponent and mantissa values without | |
| 724 | // checking bound nor normalization. | |
| 725 | // | |
| 726 | // WARNING: For X86 Extended Precision, implicit bit needs to be set correctly | |
| 727 | // in the 'mantissa' by the caller. This function will not check for its | |
| 728 | // validity. | |
| 729 | // | |
| 730 | // FIXME: Use an uint32_t for 'biased_exp'. | |
| 731 | LIBC_INLINE static constexpr RetT | |
| 732 | create_value(Sign sign, StorageType biased_exp, StorageType mantissa) { | |
| 733 | return RetT(encode(sign, BiasedExponent(static_cast<uint32_t>(biased_exp)), | |
| 734 | Significand(mantissa))); | |
| 735 | } | |
| 736 | ||
| 737 | // The function converts integer number and unbiased exponent to proper | |
| 738 | // float T type: | |
| 739 | // Result = number * 2^(ep+1 - exponent_bias) | |
| 740 | // Be careful! | |
| 741 | // 1) "ep" is the raw exponent value. | |
| 742 | // 2) The function adds +1 to ep for seamless normalized to denormalized | |
| 743 | // transition. | |
| 744 | // 3) The function does not check exponent high limit. | |
| 745 | // 4) "number" zero value is not processed correctly. | |
| 746 | // 5) Number is unsigned, so the result can be only positive. | |
| 747 | LIBC_INLINE static constexpr RetT make_value(StorageType number, int ep) { | |
| 748 | FPRepImpl result(0); | |
| 749 | int lz = | |
| 750 | UP::FRACTION_LEN + 1 - (UP::STORAGE_LEN - cpp::countl_zero(number)); | |
| 751 | ||
| 752 | number <<= lz; | |
| 753 | ep -= lz; | |
| 754 | ||
| 755 | if (LIBC_LIKELY(ep >= 0)) { | |
| 756 | // Implicit number bit will be removed by mask | |
| 757 | result.set_significand(number); | |
| 758 | result.set_biased_exponent(static_cast<StorageType>(ep + 1)); | |
| 759 | } else { | |
| 760 | result.set_significand(number >> -ep); | |
| 761 | } | |
| 762 | return RetT(result.uintval()); | |
| 763 | } | |
| 764 | }; | |
| 765 | ||
| 766 | // A generic class to manipulate floating point formats. | |
| 767 | // It derives its functionality to FPRepImpl above. | |
| 768 | template <FPType fp_type> | |
| 769 | struct FPRep : public FPRepImpl<fp_type, FPRep<fp_type>> { | |
| 770 | using UP = FPRepImpl<fp_type, FPRep<fp_type>>; | |
| 771 | using StorageType = typename UP::StorageType; | |
| 772 | using UP::UP; | |
| 773 | ||
| 774 | LIBC_INLINE constexpr explicit operator StorageType() const { | |
| 775 | return UP::uintval(); | |
| 776 | } | |
| 777 | }; | |
| 778 | ||
| 779 | } // namespace internal | |
| 780 | ||
| 781 | // Returns the FPType corresponding to C++ type T on the host. | |
| 782 | template <typename T> LIBC_INLINE static constexpr FPType get_fp_type() { | |
| 783 | using UnqualT = cpp::remove_cv_t<T>; | |
| 784 | if constexpr (cpp::is_same_v<UnqualT, float> && __FLT_MANT_DIG__ == 24) | |
| 785 | return FPType::IEEE754_Binary32; | |
| 786 | else if constexpr (cpp::is_same_v<UnqualT, double> && __DBL_MANT_DIG__ == 53) | |
| 787 | return FPType::IEEE754_Binary64; | |
| 788 | else if constexpr (cpp::is_same_v<UnqualT, long double>) { | |
| 789 | if constexpr (__LDBL_MANT_DIG__ == 53) | |
| 790 | return FPType::IEEE754_Binary64; | |
| 791 | else if constexpr (__LDBL_MANT_DIG__ == 64) | |
| 792 | return FPType::X86_Binary80; | |
| 793 | else if constexpr (__LDBL_MANT_DIG__ == 113) | |
| 794 | return FPType::IEEE754_Binary128; | |
| 795 | } | |
| 796 | #if defined(LIBC_TYPES_HAS_FLOAT16) | |
| 797 | else if constexpr (cpp::is_same_v<UnqualT, float16>) | |
| 798 | return FPType::IEEE754_Binary16; | |
| 799 | #endif | |
| 800 | #if defined(LIBC_TYPES_HAS_FLOAT128) | |
| 801 | else if constexpr (cpp::is_same_v<UnqualT, float128>) | |
| 802 | return FPType::IEEE754_Binary128; | |
| 803 | #endif | |
| 804 | else | |
| 805 | static_assert(cpp::always_false<UnqualT>, "Unsupported type"); | |
| 806 | } | |
| 807 | ||
| 808 | // ----------------------------------------------------------------------------- | |
| 809 | // **** WARNING **** | |
| 810 | // This interface is shared with libc++, if you change this interface you need | |
| 811 | // to update it in both libc and libc++. You should also be careful when adding | |
| 812 | // dependencies to this file, since it needs to build for all libc++ targets. | |
| 813 | // ----------------------------------------------------------------------------- | |
| 814 | // A generic class to manipulate C++ floating point formats. | |
| 815 | // It derives its functionality to FPRepImpl above. | |
| 816 | template <typename T> | |
| 817 | struct FPBits final : public internal::FPRepImpl<get_fp_type<T>(), FPBits<T>> { | |
| 818 | static_assert(cpp::is_floating_point_v<T>, | |
| 819 | "FPBits instantiated with invalid type."); | |
| 820 | using UP = internal::FPRepImpl<get_fp_type<T>(), FPBits<T>>; | |
| 821 | using StorageType = typename UP::StorageType; | |
| 822 | ||
| 823 | // Constructors. | |
| 824 | LIBC_INLINE constexpr FPBits() = default; | |
| 825 | ||
| 826 | template <typename XType> LIBC_INLINE constexpr explicit FPBits(XType x) { | |
| 827 | using Unqual = typename cpp::remove_cv_t<XType>; | |
| 828 | if constexpr (cpp::is_same_v<Unqual, T>) { | |
| 829 | UP::bits = cpp::bit_cast<StorageType>(x); | |
| 830 | } else if constexpr (cpp::is_same_v<Unqual, StorageType>) { | |
| 831 | UP::bits = x; | |
| 832 | } else { | |
| 833 | // We don't want accidental type promotions/conversions, so we require | |
| 834 | // exact type match. | |
| 835 | static_assert(cpp::always_false<XType>); | |
| 836 | } | |
| 837 | } | |
| 838 | ||
| 839 | // Floating-point conversions. | |
| 840 | LIBC_INLINE constexpr T get_val() const { return cpp::bit_cast<T>(UP::bits); } | |
| 841 | }; | |
| 842 | ||
| 843 | } // namespace fputil | |
| 844 | } // namespace LIBC_NAMESPACE_DECL | |
| 845 | ||
| 846 | #endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_FPBITS_H |
lib/libcxx/libc/src/__support/FPUtil/rounding_mode.h created+81| ... | ... | @@ -0,0 +1,81 @@ |
| 1 | //===---- Free-standing function to detect rounding mode --------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H | |
| 11 | ||
| 12 | #include "hdr/fenv_macros.h" | |
| 13 | #include "src/__support/macros/attributes.h" // LIBC_INLINE | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | ||
| 16 | namespace LIBC_NAMESPACE_DECL { | |
| 17 | namespace fputil { | |
| 18 | ||
| 19 | // Quick free-standing test whether fegetround() == FE_UPWARD. | |
| 20 | // Using the following observation: | |
| 21 | // 1.0f + 2^-25 = 1.0f for FE_TONEAREST, FE_DOWNWARD, FE_TOWARDZERO | |
| 22 | // = 0x1.000002f for FE_UPWARD. | |
| 23 | LIBC_INLINE bool fenv_is_round_up() { | |
| 24 | volatile float x = 0x1.0p-25f; | |
| 25 | return (1.0f + x != 1.0f); | |
| 26 | } | |
| 27 | ||
| 28 | // Quick free-standing test whether fegetround() == FE_DOWNWARD. | |
| 29 | // Using the following observation: | |
| 30 | // -1.0f - 2^-25 = -1.0f for FE_TONEAREST, FE_UPWARD, FE_TOWARDZERO | |
| 31 | // = -0x1.000002f for FE_DOWNWARD. | |
| 32 | LIBC_INLINE bool fenv_is_round_down() { | |
| 33 | volatile float x = 0x1.0p-25f; | |
| 34 | return (-1.0f - x != -1.0f); | |
| 35 | } | |
| 36 | ||
| 37 | // Quick free-standing test whether fegetround() == FE_TONEAREST. | |
| 38 | // Using the following observation: | |
| 39 | // 1.5f + 2^-24 = 1.5f for FE_TONEAREST, FE_DOWNWARD, FE_TOWARDZERO | |
| 40 | // = 0x1.100002p0f for FE_UPWARD, | |
| 41 | // 1.5f - 2^-24 = 1.5f for FE_TONEAREST, FE_UPWARD | |
| 42 | // = 0x1.0ffffep-1f for FE_DOWNWARD, FE_TOWARDZERO | |
| 43 | LIBC_INLINE bool fenv_is_round_to_nearest() { | |
| 44 | static volatile float x = 0x1.0p-24f; | |
| 45 | float y = x; | |
| 46 | return (1.5f + y == 1.5f - y); | |
| 47 | } | |
| 48 | ||
| 49 | // Quick free-standing test whether fegetround() == FE_TOWARDZERO. | |
| 50 | // Using the following observation: | |
| 51 | // 1.0f + 2^-23 + 2^-24 = 0x1.000002p0f for FE_DOWNWARD, FE_TOWARDZERO | |
| 52 | // = 0x1.000004p0f for FE_TONEAREST, FE_UPWARD, | |
| 53 | // -1.0f - 2^-24 = -1.0f for FE_TONEAREST, FE_UPWARD, FE_TOWARDZERO | |
| 54 | // = -0x1.000002p0f for FE_DOWNWARD | |
| 55 | // So: | |
| 56 | // (0x1.000002p0f + 2^-24) + (-1.0f - 2^-24) = 2^-23 for FE_TOWARDZERO | |
| 57 | // = 2^-22 for FE_TONEAREST, FE_UPWARD | |
| 58 | // = 0 for FE_DOWNWARD | |
| 59 | LIBC_INLINE bool fenv_is_round_to_zero() { | |
| 60 | static volatile float x = 0x1.0p-24f; | |
| 61 | float y = x; | |
| 62 | return ((0x1.000002p0f + y) + (-1.0f - y) == 0x1.0p-23f); | |
| 63 | } | |
| 64 | ||
| 65 | // Quick free standing get rounding mode based on the above observations. | |
| 66 | LIBC_INLINE int quick_get_round() { | |
| 67 | static volatile float x = 0x1.0p-24f; | |
| 68 | float y = x; | |
| 69 | float z = (0x1.000002p0f + y) + (-1.0f - y); | |
| 70 | ||
| 71 | if (z == 0.0f) | |
| 72 | return FE_DOWNWARD; | |
| 73 | if (z == 0x1.0p-23f) | |
| 74 | return FE_TOWARDZERO; | |
| 75 | return (2.0f + y == 2.0f) ? FE_TONEAREST : FE_UPWARD; | |
| 76 | } | |
| 77 | ||
| 78 | } // namespace fputil | |
| 79 | } // namespace LIBC_NAMESPACE_DECL | |
| 80 | ||
| 81 | #endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H |
lib/libcxx/libc/src/__support/big_int.h created+1384| ... | ... | @@ -0,0 +1,1384 @@ |
| 1 | //===-- A class to manipulate wide integers. --------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_BIG_INT_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_BIG_INT_H | |
| 11 | ||
| 12 | #include "src/__support/CPP/array.h" | |
| 13 | #include "src/__support/CPP/bit.h" // countl_zero | |
| 14 | #include "src/__support/CPP/limits.h" | |
| 15 | #include "src/__support/CPP/optional.h" | |
| 16 | #include "src/__support/CPP/type_traits.h" | |
| 17 | #include "src/__support/macros/attributes.h" // LIBC_INLINE | |
| 18 | #include "src/__support/macros/config.h" | |
| 19 | #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY | |
| 20 | #include "src/__support/macros/properties/compiler.h" // LIBC_COMPILER_IS_CLANG | |
| 21 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128, LIBC_TYPES_HAS_INT64 | |
| 22 | #include "src/__support/math_extras.h" // add_with_carry, sub_with_borrow | |
| 23 | #include "src/__support/number_pair.h" | |
| 24 | ||
| 25 | #include <stddef.h> // For size_t | |
| 26 | #include <stdint.h> | |
| 27 | ||
| 28 | namespace LIBC_NAMESPACE_DECL { | |
| 29 | ||
| 30 | namespace multiword { | |
| 31 | ||
| 32 | // A type trait mapping unsigned integers to their half-width unsigned | |
| 33 | // counterparts. | |
| 34 | template <typename T> struct half_width; | |
| 35 | template <> struct half_width<uint16_t> : cpp::type_identity<uint8_t> {}; | |
| 36 | template <> struct half_width<uint32_t> : cpp::type_identity<uint16_t> {}; | |
| 37 | #ifdef LIBC_TYPES_HAS_INT64 | |
| 38 | template <> struct half_width<uint64_t> : cpp::type_identity<uint32_t> {}; | |
| 39 | #ifdef LIBC_TYPES_HAS_INT128 | |
| 40 | template <> struct half_width<__uint128_t> : cpp::type_identity<uint64_t> {}; | |
| 41 | #endif // LIBC_TYPES_HAS_INT128 | |
| 42 | #endif // LIBC_TYPES_HAS_INT64 | |
| 43 | template <typename T> using half_width_t = typename half_width<T>::type; | |
| 44 | ||
| 45 | // An array of two elements that can be used in multiword operations. | |
| 46 | template <typename T> struct DoubleWide final : cpp::array<T, 2> { | |
| 47 | using UP = cpp::array<T, 2>; | |
| 48 | using UP::UP; | |
| 49 | LIBC_INLINE constexpr DoubleWide(T lo, T hi) : UP({lo, hi}) {} | |
| 50 | }; | |
| 51 | ||
| 52 | // Converts an unsigned value into a DoubleWide<half_width_t<T>>. | |
| 53 | template <typename T> LIBC_INLINE constexpr auto split(T value) { | |
| 54 | static_assert(cpp::is_unsigned_v<T>); | |
| 55 | using half_type = half_width_t<T>; | |
| 56 | return DoubleWide<half_type>( | |
| 57 | half_type(value), | |
| 58 | half_type(value >> cpp::numeric_limits<half_type>::digits)); | |
| 59 | } | |
| 60 | ||
| 61 | // The low part of a DoubleWide value. | |
| 62 | template <typename T> LIBC_INLINE constexpr T lo(const DoubleWide<T> &value) { | |
| 63 | return value[0]; | |
| 64 | } | |
| 65 | // The high part of a DoubleWide value. | |
| 66 | template <typename T> LIBC_INLINE constexpr T hi(const DoubleWide<T> &value) { | |
| 67 | return value[1]; | |
| 68 | } | |
| 69 | // The low part of an unsigned value. | |
| 70 | template <typename T> LIBC_INLINE constexpr half_width_t<T> lo(T value) { | |
| 71 | return lo(split(value)); | |
| 72 | } | |
| 73 | // The high part of an unsigned value. | |
| 74 | template <typename T> LIBC_INLINE constexpr half_width_t<T> hi(T value) { | |
| 75 | return hi(split(value)); | |
| 76 | } | |
| 77 | ||
| 78 | // Returns 'a' times 'b' in a DoubleWide<word>. Cannot overflow by construction. | |
| 79 | template <typename word> | |
| 80 | LIBC_INLINE constexpr DoubleWide<word> mul2(word a, word b) { | |
| 81 | if constexpr (cpp::is_same_v<word, uint8_t>) { | |
| 82 | return split<uint16_t>(uint16_t(a) * uint16_t(b)); | |
| 83 | } else if constexpr (cpp::is_same_v<word, uint16_t>) { | |
| 84 | return split<uint32_t>(uint32_t(a) * uint32_t(b)); | |
| 85 | } | |
| 86 | #ifdef LIBC_TYPES_HAS_INT64 | |
| 87 | else if constexpr (cpp::is_same_v<word, uint32_t>) { | |
| 88 | return split<uint64_t>(uint64_t(a) * uint64_t(b)); | |
| 89 | } | |
| 90 | #endif | |
| 91 | #ifdef LIBC_TYPES_HAS_INT128 | |
| 92 | else if constexpr (cpp::is_same_v<word, uint64_t>) { | |
| 93 | return split<__uint128_t>(__uint128_t(a) * __uint128_t(b)); | |
| 94 | } | |
| 95 | #endif | |
| 96 | else { | |
| 97 | using half_word = half_width_t<word>; | |
| 98 | const auto shiftl = [](word value) -> word { | |
| 99 | return value << cpp::numeric_limits<half_word>::digits; | |
| 100 | }; | |
| 101 | const auto shiftr = [](word value) -> word { | |
| 102 | return value >> cpp::numeric_limits<half_word>::digits; | |
| 103 | }; | |
| 104 | // Here we do a one digit multiplication where 'a' and 'b' are of type | |
| 105 | // word. We split 'a' and 'b' into half words and perform the classic long | |
| 106 | // multiplication with 'a' and 'b' being two-digit numbers. | |
| 107 | ||
| 108 | // a a_hi a_lo | |
| 109 | // x b => x b_hi b_lo | |
| 110 | // ---- ----------- | |
| 111 | // c result | |
| 112 | // We convert 'lo' and 'hi' from 'half_word' to 'word' so multiplication | |
| 113 | // doesn't overflow. | |
| 114 | const word a_lo = lo(a); | |
| 115 | const word b_lo = lo(b); | |
| 116 | const word a_hi = hi(a); | |
| 117 | const word b_hi = hi(b); | |
| 118 | const word step1 = b_lo * a_lo; // no overflow; | |
| 119 | const word step2 = b_lo * a_hi; // no overflow; | |
| 120 | const word step3 = b_hi * a_lo; // no overflow; | |
| 121 | const word step4 = b_hi * a_hi; // no overflow; | |
| 122 | word lo_digit = step1; | |
| 123 | word hi_digit = step4; | |
| 124 | const word no_carry = 0; | |
| 125 | word carry; | |
| 126 | word _; // unused carry variable. | |
| 127 | lo_digit = add_with_carry<word>(lo_digit, shiftl(step2), no_carry, carry); | |
| 128 | hi_digit = add_with_carry<word>(hi_digit, shiftr(step2), carry, _); | |
| 129 | lo_digit = add_with_carry<word>(lo_digit, shiftl(step3), no_carry, carry); | |
| 130 | hi_digit = add_with_carry<word>(hi_digit, shiftr(step3), carry, _); | |
| 131 | return DoubleWide<word>(lo_digit, hi_digit); | |
| 132 | } | |
| 133 | } | |
| 134 | ||
| 135 | // In-place 'dst op= rhs' with operation with carry propagation. Returns carry. | |
| 136 | template <typename Function, typename word, size_t N, size_t M> | |
| 137 | LIBC_INLINE constexpr word inplace_binop(Function op_with_carry, | |
| 138 | cpp::array<word, N> &dst, | |
| 139 | const cpp::array<word, M> &rhs) { | |
| 140 | static_assert(N >= M); | |
| 141 | word carry_out = 0; | |
| 142 | for (size_t i = 0; i < N; ++i) { | |
| 143 | const bool has_rhs_value = i < M; | |
| 144 | const word rhs_value = has_rhs_value ? rhs[i] : 0; | |
| 145 | const word carry_in = carry_out; | |
| 146 | dst[i] = op_with_carry(dst[i], rhs_value, carry_in, carry_out); | |
| 147 | // stop early when rhs is over and no carry is to be propagated. | |
| 148 | if (!has_rhs_value && carry_out == 0) | |
| 149 | break; | |
| 150 | } | |
| 151 | return carry_out; | |
| 152 | } | |
| 153 | ||
| 154 | // In-place addition. Returns carry. | |
| 155 | template <typename word, size_t N, size_t M> | |
| 156 | LIBC_INLINE constexpr word add_with_carry(cpp::array<word, N> &dst, | |
| 157 | const cpp::array<word, M> &rhs) { | |
| 158 | return inplace_binop(LIBC_NAMESPACE::add_with_carry<word>, dst, rhs); | |
| 159 | } | |
| 160 | ||
| 161 | // In-place subtraction. Returns borrow. | |
| 162 | template <typename word, size_t N, size_t M> | |
| 163 | LIBC_INLINE constexpr word sub_with_borrow(cpp::array<word, N> &dst, | |
| 164 | const cpp::array<word, M> &rhs) { | |
| 165 | return inplace_binop(LIBC_NAMESPACE::sub_with_borrow<word>, dst, rhs); | |
| 166 | } | |
| 167 | ||
| 168 | // In-place multiply-add. Returns carry. | |
| 169 | // i.e., 'dst += b * c' | |
| 170 | template <typename word, size_t N> | |
| 171 | LIBC_INLINE constexpr word mul_add_with_carry(cpp::array<word, N> &dst, word b, | |
| 172 | word c) { | |
| 173 | return add_with_carry(dst, mul2(b, c)); | |
| 174 | } | |
| 175 | ||
| 176 | // An array of two elements serving as an accumulator during multiword | |
| 177 | // computations. | |
| 178 | template <typename T> struct Accumulator final : cpp::array<T, 2> { | |
| 179 | using UP = cpp::array<T, 2>; | |
| 180 | LIBC_INLINE constexpr Accumulator() : UP({0, 0}) {} | |
| 181 | LIBC_INLINE constexpr T advance(T carry_in) { | |
| 182 | auto result = UP::front(); | |
| 183 | UP::front() = UP::back(); | |
| 184 | UP::back() = carry_in; | |
| 185 | return result; | |
| 186 | } | |
| 187 | LIBC_INLINE constexpr T sum() const { return UP::front(); } | |
| 188 | LIBC_INLINE constexpr T carry() const { return UP::back(); } | |
| 189 | }; | |
| 190 | ||
| 191 | // In-place multiplication by a single word. Returns carry. | |
| 192 | template <typename word, size_t N> | |
| 193 | LIBC_INLINE constexpr word scalar_multiply_with_carry(cpp::array<word, N> &dst, | |
| 194 | word x) { | |
| 195 | Accumulator<word> acc; | |
| 196 | for (auto &val : dst) { | |
| 197 | const word carry = mul_add_with_carry(acc, val, x); | |
| 198 | val = acc.advance(carry); | |
| 199 | } | |
| 200 | return acc.carry(); | |
| 201 | } | |
| 202 | ||
| 203 | // Multiplication of 'lhs' by 'rhs' into 'dst'. Returns carry. | |
| 204 | // This function is safe to use for signed numbers. | |
| 205 | // https://stackoverflow.com/a/20793834 | |
| 206 | // https://pages.cs.wisc.edu/%7Emarkhill/cs354/Fall2008/beyond354/int.mult.html | |
| 207 | template <typename word, size_t O, size_t M, size_t N> | |
| 208 | LIBC_INLINE constexpr word multiply_with_carry(cpp::array<word, O> &dst, | |
| 209 | const cpp::array<word, M> &lhs, | |
| 210 | const cpp::array<word, N> &rhs) { | |
| 211 | static_assert(O >= M + N); | |
| 212 | Accumulator<word> acc; | |
| 213 | for (size_t i = 0; i < O; ++i) { | |
| 214 | const size_t lower_idx = i < N ? 0 : i - N + 1; | |
| 215 | const size_t upper_idx = i < M ? i : M - 1; | |
| 216 | word carry = 0; | |
| 217 | for (size_t j = lower_idx; j <= upper_idx; ++j) | |
| 218 | carry += mul_add_with_carry(acc, lhs[j], rhs[i - j]); | |
| 219 | dst[i] = acc.advance(carry); | |
| 220 | } | |
| 221 | return acc.carry(); | |
| 222 | } | |
| 223 | ||
| 224 | template <typename word, size_t N> | |
| 225 | LIBC_INLINE constexpr void quick_mul_hi(cpp::array<word, N> &dst, | |
| 226 | const cpp::array<word, N> &lhs, | |
| 227 | const cpp::array<word, N> &rhs) { | |
| 228 | Accumulator<word> acc; | |
| 229 | word carry = 0; | |
| 230 | // First round of accumulation for those at N - 1 in the full product. | |
| 231 | for (size_t i = 0; i < N; ++i) | |
| 232 | carry += mul_add_with_carry(acc, lhs[i], rhs[N - 1 - i]); | |
| 233 | for (size_t i = N; i < 2 * N - 1; ++i) { | |
| 234 | acc.advance(carry); | |
| 235 | carry = 0; | |
| 236 | for (size_t j = i - N + 1; j < N; ++j) | |
| 237 | carry += mul_add_with_carry(acc, lhs[j], rhs[i - j]); | |
| 238 | dst[i - N] = acc.sum(); | |
| 239 | } | |
| 240 | dst.back() = acc.carry(); | |
| 241 | } | |
| 242 | ||
| 243 | template <typename word, size_t N> | |
| 244 | LIBC_INLINE constexpr bool is_negative(cpp::array<word, N> &array) { | |
| 245 | using signed_word = cpp::make_signed_t<word>; | |
| 246 | return cpp::bit_cast<signed_word>(array.back()) < 0; | |
| 247 | } | |
| 248 | ||
| 249 | // An enum for the shift function below. | |
| 250 | enum Direction { LEFT, RIGHT }; | |
| 251 | ||
| 252 | // A bitwise shift on an array of elements. | |
| 253 | // 'offset' must be less than TOTAL_BITS (i.e., sizeof(word) * CHAR_BIT * N) | |
| 254 | // otherwise the behavior is undefined. | |
| 255 | template <Direction direction, bool is_signed, typename word, size_t N> | |
| 256 | LIBC_INLINE constexpr cpp::array<word, N> shift(cpp::array<word, N> array, | |
| 257 | size_t offset) { | |
| 258 | static_assert(direction == LEFT || direction == RIGHT); | |
| 259 | constexpr size_t WORD_BITS = cpp::numeric_limits<word>::digits; | |
| 260 | #ifdef LIBC_TYPES_HAS_INT128 | |
| 261 | constexpr size_t TOTAL_BITS = N * WORD_BITS; | |
| 262 | if constexpr (TOTAL_BITS == 128) { | |
| 263 | using type = cpp::conditional_t<is_signed, __int128_t, __uint128_t>; | |
| 264 | auto tmp = cpp::bit_cast<type>(array); | |
| 265 | if constexpr (direction == LEFT) | |
| 266 | tmp <<= offset; | |
| 267 | else | |
| 268 | tmp >>= offset; | |
| 269 | return cpp::bit_cast<cpp::array<word, N>>(tmp); | |
| 270 | } | |
| 271 | #endif | |
| 272 | if (LIBC_UNLIKELY(offset == 0)) | |
| 273 | return array; | |
| 274 | const bool is_neg = is_signed && is_negative(array); | |
| 275 | constexpr auto at = [](size_t index) -> int { | |
| 276 | // reverse iteration when direction == LEFT. | |
| 277 | if constexpr (direction == LEFT) | |
| 278 | return int(N) - int(index) - 1; | |
| 279 | return int(index); | |
| 280 | }; | |
| 281 | const auto safe_get_at = [&](size_t index) -> word { | |
| 282 | // return appropriate value when accessing out of bound elements. | |
| 283 | const int i = at(index); | |
| 284 | if (i < 0) | |
| 285 | return 0; | |
| 286 | if (i >= int(N)) | |
| 287 | return is_neg ? -1 : 0; | |
| 288 | return array[i]; | |
| 289 | }; | |
| 290 | const size_t index_offset = offset / WORD_BITS; | |
| 291 | const size_t bit_offset = offset % WORD_BITS; | |
| 292 | #ifdef LIBC_COMPILER_IS_CLANG | |
| 293 | __builtin_assume(index_offset < N); | |
| 294 | #endif | |
| 295 | cpp::array<word, N> out = {}; | |
| 296 | for (size_t index = 0; index < N; ++index) { | |
| 297 | const word part1 = safe_get_at(index + index_offset); | |
| 298 | const word part2 = safe_get_at(index + index_offset + 1); | |
| 299 | word &dst = out[at(index)]; | |
| 300 | if (bit_offset == 0) | |
| 301 | dst = part1; // no crosstalk between parts. | |
| 302 | else if constexpr (direction == LEFT) | |
| 303 | dst = static_cast<word>((part1 << bit_offset) | | |
| 304 | (part2 >> (WORD_BITS - bit_offset))); | |
| 305 | else | |
| 306 | dst = static_cast<word>((part1 >> bit_offset) | | |
| 307 | (part2 << (WORD_BITS - bit_offset))); | |
| 308 | } | |
| 309 | return out; | |
| 310 | } | |
| 311 | ||
| 312 | #define DECLARE_COUNTBIT(NAME, INDEX_EXPR) \ | |
| 313 | template <typename word, size_t N> \ | |
| 314 | LIBC_INLINE constexpr int NAME(const cpp::array<word, N> &val) { \ | |
| 315 | int bit_count = 0; \ | |
| 316 | for (size_t i = 0; i < N; ++i) { \ | |
| 317 | const int word_count = cpp::NAME<word>(val[INDEX_EXPR]); \ | |
| 318 | bit_count += word_count; \ | |
| 319 | if (word_count != cpp::numeric_limits<word>::digits) \ | |
| 320 | break; \ | |
| 321 | } \ | |
| 322 | return bit_count; \ | |
| 323 | } | |
| 324 | ||
| 325 | DECLARE_COUNTBIT(countr_zero, i) // iterating forward | |
| 326 | DECLARE_COUNTBIT(countr_one, i) // iterating forward | |
| 327 | DECLARE_COUNTBIT(countl_zero, N - i - 1) // iterating backward | |
| 328 | DECLARE_COUNTBIT(countl_one, N - i - 1) // iterating backward | |
| 329 | ||
| 330 | } // namespace multiword | |
| 331 | ||
| 332 | template <size_t Bits, bool Signed, typename WordType = uint64_t> | |
| 333 | struct BigInt { | |
| 334 | private: | |
| 335 | static_assert(cpp::is_integral_v<WordType> && cpp::is_unsigned_v<WordType>, | |
| 336 | "WordType must be unsigned integer."); | |
| 337 | ||
| 338 | struct Division { | |
| 339 | BigInt quotient; | |
| 340 | BigInt remainder; | |
| 341 | }; | |
| 342 | ||
| 343 | public: | |
| 344 | using word_type = WordType; | |
| 345 | using unsigned_type = BigInt<Bits, false, word_type>; | |
| 346 | using signed_type = BigInt<Bits, true, word_type>; | |
| 347 | ||
| 348 | LIBC_INLINE_VAR static constexpr bool SIGNED = Signed; | |
| 349 | LIBC_INLINE_VAR static constexpr size_t BITS = Bits; | |
| 350 | LIBC_INLINE_VAR | |
| 351 | static constexpr size_t WORD_SIZE = sizeof(WordType) * CHAR_BIT; | |
| 352 | ||
| 353 | static_assert(Bits > 0 && Bits % WORD_SIZE == 0, | |
| 354 | "Number of bits in BigInt should be a multiple of WORD_SIZE."); | |
| 355 | ||
| 356 | LIBC_INLINE_VAR static constexpr size_t WORD_COUNT = Bits / WORD_SIZE; | |
| 357 | ||
| 358 | cpp::array<WordType, WORD_COUNT> val{}; // zero initialized. | |
| 359 | ||
| 360 | LIBC_INLINE constexpr BigInt() = default; | |
| 361 | ||
| 362 | LIBC_INLINE constexpr BigInt(const BigInt &other) = default; | |
| 363 | ||
| 364 | template <size_t OtherBits, bool OtherSigned, typename OtherWordType> | |
| 365 | LIBC_INLINE constexpr BigInt( | |
| 366 | const BigInt<OtherBits, OtherSigned, OtherWordType> &other) { | |
| 367 | using BigIntOther = BigInt<OtherBits, OtherSigned, OtherWordType>; | |
| 368 | const bool should_sign_extend = Signed && other.is_neg(); | |
| 369 | ||
| 370 | static_assert(!(Bits == OtherBits && WORD_SIZE != BigIntOther::WORD_SIZE) && | |
| 371 | "This is currently untested for casting between bigints with " | |
| 372 | "the same bit width but different word sizes."); | |
| 373 | ||
| 374 | if constexpr (BigIntOther::WORD_SIZE < WORD_SIZE) { | |
| 375 | // OtherWordType is smaller | |
| 376 | constexpr size_t WORD_SIZE_RATIO = WORD_SIZE / BigIntOther::WORD_SIZE; | |
| 377 | static_assert( | |
| 378 | (WORD_SIZE % BigIntOther::WORD_SIZE) == 0 && | |
| 379 | "Word types must be multiples of each other for correct conversion."); | |
| 380 | if constexpr (OtherBits >= Bits) { // truncate | |
| 381 | // for each big word | |
| 382 | for (size_t i = 0; i < WORD_COUNT; ++i) { | |
| 383 | WordType cur_word = 0; | |
| 384 | // combine WORD_SIZE_RATIO small words into a big word | |
| 385 | for (size_t j = 0; j < WORD_SIZE_RATIO; ++j) | |
| 386 | cur_word |= static_cast<WordType>(other[(i * WORD_SIZE_RATIO) + j]) | |
| 387 | << (BigIntOther::WORD_SIZE * j); | |
| 388 | ||
| 389 | val[i] = cur_word; | |
| 390 | } | |
| 391 | } else { // zero or sign extend | |
| 392 | size_t i = 0; | |
| 393 | WordType cur_word = 0; | |
| 394 | // for each small word | |
| 395 | for (; i < BigIntOther::WORD_COUNT; ++i) { | |
| 396 | // combine WORD_SIZE_RATIO small words into a big word | |
| 397 | cur_word |= static_cast<WordType>(other[i]) | |
| 398 | << (BigIntOther::WORD_SIZE * (i % WORD_SIZE_RATIO)); | |
| 399 | // if we've completed a big word, copy it into place and reset | |
| 400 | if ((i % WORD_SIZE_RATIO) == WORD_SIZE_RATIO - 1) { | |
| 401 | val[i / WORD_SIZE_RATIO] = cur_word; | |
| 402 | cur_word = 0; | |
| 403 | } | |
| 404 | } | |
| 405 | // Pretend there are extra words of the correct sign extension as needed | |
| 406 | ||
| 407 | const WordType extension_bits = | |
| 408 | should_sign_extend ? cpp::numeric_limits<WordType>::max() | |
| 409 | : cpp::numeric_limits<WordType>::min(); | |
| 410 | if ((i % WORD_SIZE_RATIO) != 0) { | |
| 411 | cur_word |= static_cast<WordType>(extension_bits) | |
| 412 | << (BigIntOther::WORD_SIZE * (i % WORD_SIZE_RATIO)); | |
| 413 | } | |
| 414 | // Copy the last word into place. | |
| 415 | val[(i / WORD_SIZE_RATIO)] = cur_word; | |
| 416 | extend((i / WORD_SIZE_RATIO) + 1, should_sign_extend); | |
| 417 | } | |
| 418 | } else if constexpr (BigIntOther::WORD_SIZE == WORD_SIZE) { | |
| 419 | if constexpr (OtherBits >= Bits) { // truncate | |
| 420 | for (size_t i = 0; i < WORD_COUNT; ++i) | |
| 421 | val[i] = other[i]; | |
| 422 | } else { // zero or sign extend | |
| 423 | size_t i = 0; | |
| 424 | for (; i < BigIntOther::WORD_COUNT; ++i) | |
| 425 | val[i] = other[i]; | |
| 426 | extend(i, should_sign_extend); | |
| 427 | } | |
| 428 | } else { | |
| 429 | // OtherWordType is bigger. | |
| 430 | constexpr size_t WORD_SIZE_RATIO = BigIntOther::WORD_SIZE / WORD_SIZE; | |
| 431 | static_assert( | |
| 432 | (BigIntOther::WORD_SIZE % WORD_SIZE) == 0 && | |
| 433 | "Word types must be multiples of each other for correct conversion."); | |
| 434 | if constexpr (OtherBits >= Bits) { // truncate | |
| 435 | // for each small word | |
| 436 | for (size_t i = 0; i < WORD_COUNT; ++i) { | |
| 437 | // split each big word into WORD_SIZE_RATIO small words | |
| 438 | val[i] = static_cast<WordType>(other[i / WORD_SIZE_RATIO] >> | |
| 439 | ((i % WORD_SIZE_RATIO) * WORD_SIZE)); | |
| 440 | } | |
| 441 | } else { // zero or sign extend | |
| 442 | size_t i = 0; | |
| 443 | // for each big word | |
| 444 | for (; i < BigIntOther::WORD_COUNT; ++i) { | |
| 445 | // split each big word into WORD_SIZE_RATIO small words | |
| 446 | for (size_t j = 0; j < WORD_SIZE_RATIO; ++j) | |
| 447 | val[(i * WORD_SIZE_RATIO) + j] = | |
| 448 | static_cast<WordType>(other[i] >> (j * WORD_SIZE)); | |
| 449 | } | |
| 450 | extend(i * WORD_SIZE_RATIO, should_sign_extend); | |
| 451 | } | |
| 452 | } | |
| 453 | } | |
| 454 | ||
| 455 | // Construct a BigInt from a C array. | |
| 456 | template <size_t N> LIBC_INLINE constexpr BigInt(const WordType (&nums)[N]) { | |
| 457 | static_assert(N == WORD_COUNT); | |
| 458 | for (size_t i = 0; i < WORD_COUNT; ++i) | |
| 459 | val[i] = nums[i]; | |
| 460 | } | |
| 461 | ||
| 462 | LIBC_INLINE constexpr explicit BigInt( | |
| 463 | const cpp::array<WordType, WORD_COUNT> &words) { | |
| 464 | val = words; | |
| 465 | } | |
| 466 | ||
| 467 | // Initialize the first word to |v| and the rest to 0. | |
| 468 | template <typename T, typename = cpp::enable_if_t<cpp::is_integral_v<T> && | |
| 469 | !cpp::is_same_v<T, bool>>> | |
| 470 | LIBC_INLINE constexpr BigInt(T v) { | |
| 471 | constexpr size_t T_SIZE = sizeof(T) * CHAR_BIT; | |
| 472 | const bool is_neg = v < 0; | |
| 473 | for (size_t i = 0; i < WORD_COUNT; ++i) { | |
| 474 | if (v == 0) { | |
| 475 | extend(i, is_neg); | |
| 476 | return; | |
| 477 | } | |
| 478 | val[i] = static_cast<WordType>(v); | |
| 479 | if constexpr (T_SIZE > WORD_SIZE) | |
| 480 | v >>= WORD_SIZE; | |
| 481 | else | |
| 482 | v = 0; | |
| 483 | } | |
| 484 | } | |
| 485 | LIBC_INLINE constexpr BigInt &operator=(const BigInt &other) = default; | |
| 486 | ||
| 487 | // constants | |
| 488 | LIBC_INLINE static constexpr BigInt zero() { return BigInt(); } | |
| 489 | LIBC_INLINE static constexpr BigInt one() { return BigInt(1); } | |
| 490 | LIBC_INLINE static constexpr BigInt all_ones() { return ~zero(); } | |
| 491 | LIBC_INLINE static constexpr BigInt min() { | |
| 492 | BigInt out; | |
| 493 | if constexpr (SIGNED) | |
| 494 | out.set_msb(); | |
| 495 | return out; | |
| 496 | } | |
| 497 | LIBC_INLINE static constexpr BigInt max() { | |
| 498 | BigInt out = all_ones(); | |
| 499 | if constexpr (SIGNED) | |
| 500 | out.clear_msb(); | |
| 501 | return out; | |
| 502 | } | |
| 503 | ||
| 504 | // TODO: Reuse the Sign type. | |
| 505 | LIBC_INLINE constexpr bool is_neg() const { return SIGNED && get_msb(); } | |
| 506 | ||
| 507 | template <size_t OtherBits, bool OtherSigned, typename OtherWordType> | |
| 508 | LIBC_INLINE constexpr explicit | |
| 509 | operator BigInt<OtherBits, OtherSigned, OtherWordType>() const { | |
| 510 | return BigInt<OtherBits, OtherSigned, OtherWordType>(this); | |
| 511 | } | |
| 512 | ||
| 513 | template <typename T> LIBC_INLINE constexpr explicit operator T() const { | |
| 514 | return to<T>(); | |
| 515 | } | |
| 516 | ||
| 517 | template <typename T> | |
| 518 | LIBC_INLINE constexpr cpp::enable_if_t< | |
| 519 | cpp::is_integral_v<T> && !cpp::is_same_v<T, bool>, T> | |
| 520 | to() const { | |
| 521 | constexpr size_t T_SIZE = sizeof(T) * CHAR_BIT; | |
| 522 | T lo = static_cast<T>(val[0]); | |
| 523 | if constexpr (T_SIZE <= WORD_SIZE) | |
| 524 | return lo; | |
| 525 | constexpr size_t MAX_COUNT = | |
| 526 | T_SIZE > Bits ? WORD_COUNT : T_SIZE / WORD_SIZE; | |
| 527 | for (size_t i = 1; i < MAX_COUNT; ++i) | |
| 528 | lo += static_cast<T>(static_cast<T>(val[i]) << (WORD_SIZE * i)); | |
| 529 | if constexpr (Signed && (T_SIZE > Bits)) { | |
| 530 | // Extend sign for negative numbers. | |
| 531 | constexpr T MASK = (~T(0) << Bits); | |
| 532 | if (is_neg()) | |
| 533 | lo |= MASK; | |
| 534 | } | |
| 535 | return lo; | |
| 536 | } | |
| 537 | ||
| 538 | LIBC_INLINE constexpr explicit operator bool() const { return !is_zero(); } | |
| 539 | ||
| 540 | LIBC_INLINE constexpr bool is_zero() const { | |
| 541 | for (auto part : val) | |
| 542 | if (part != 0) | |
| 543 | return false; | |
| 544 | return true; | |
| 545 | } | |
| 546 | ||
| 547 | // Add 'rhs' to this number and store the result in this number. | |
| 548 | // Returns the carry value produced by the addition operation. | |
| 549 | LIBC_INLINE constexpr WordType add_overflow(const BigInt &rhs) { | |
| 550 | return multiword::add_with_carry(val, rhs.val); | |
| 551 | } | |
| 552 | ||
| 553 | LIBC_INLINE constexpr BigInt operator+(const BigInt &other) const { | |
| 554 | BigInt result = *this; | |
| 555 | result.add_overflow(other); | |
| 556 | return result; | |
| 557 | } | |
| 558 | ||
| 559 | // This will only apply when initializing a variable from constant values, so | |
| 560 | // it will always use the constexpr version of add_with_carry. | |
| 561 | LIBC_INLINE constexpr BigInt operator+(BigInt &&other) const { | |
| 562 | // We use addition commutativity to reuse 'other' and prevent allocation. | |
| 563 | other.add_overflow(*this); // Returned carry value is ignored. | |
| 564 | return other; | |
| 565 | } | |
| 566 | ||
| 567 | LIBC_INLINE constexpr BigInt &operator+=(const BigInt &other) { | |
| 568 | add_overflow(other); // Returned carry value is ignored. | |
| 569 | return *this; | |
| 570 | } | |
| 571 | ||
| 572 | // Subtract 'rhs' to this number and store the result in this number. | |
| 573 | // Returns the carry value produced by the subtraction operation. | |
| 574 | LIBC_INLINE constexpr WordType sub_overflow(const BigInt &rhs) { | |
| 575 | return multiword::sub_with_borrow(val, rhs.val); | |
| 576 | } | |
| 577 | ||
| 578 | LIBC_INLINE constexpr BigInt operator-(const BigInt &other) const { | |
| 579 | BigInt result = *this; | |
| 580 | result.sub_overflow(other); // Returned carry value is ignored. | |
| 581 | return result; | |
| 582 | } | |
| 583 | ||
| 584 | LIBC_INLINE constexpr BigInt operator-(BigInt &&other) const { | |
| 585 | BigInt result = *this; | |
| 586 | result.sub_overflow(other); // Returned carry value is ignored. | |
| 587 | return result; | |
| 588 | } | |
| 589 | ||
| 590 | LIBC_INLINE constexpr BigInt &operator-=(const BigInt &other) { | |
| 591 | // TODO(lntue): Set overflow flag / errno when carry is true. | |
| 592 | sub_overflow(other); // Returned carry value is ignored. | |
| 593 | return *this; | |
| 594 | } | |
| 595 | ||
| 596 | // Multiply this number with x and store the result in this number. | |
| 597 | LIBC_INLINE constexpr WordType mul(WordType x) { | |
| 598 | return multiword::scalar_multiply_with_carry(val, x); | |
| 599 | } | |
| 600 | ||
| 601 | // Return the full product. | |
| 602 | template <size_t OtherBits> | |
| 603 | LIBC_INLINE constexpr auto | |
| 604 | ful_mul(const BigInt<OtherBits, Signed, WordType> &other) const { | |
| 605 | BigInt<Bits + OtherBits, Signed, WordType> result; | |
| 606 | multiword::multiply_with_carry(result.val, val, other.val); | |
| 607 | return result; | |
| 608 | } | |
| 609 | ||
| 610 | LIBC_INLINE constexpr BigInt operator*(const BigInt &other) const { | |
| 611 | // Perform full mul and truncate. | |
| 612 | return BigInt(ful_mul(other)); | |
| 613 | } | |
| 614 | ||
| 615 | // Fast hi part of the full product. The normal product `operator*` returns | |
| 616 | // `Bits` least significant bits of the full product, while this function will | |
| 617 | // approximate `Bits` most significant bits of the full product with errors | |
| 618 | // bounded by: | |
| 619 | // 0 <= (a.full_mul(b) >> Bits) - a.quick_mul_hi(b)) <= WORD_COUNT - 1. | |
| 620 | // | |
| 621 | // An example usage of this is to quickly (but less accurately) compute the | |
| 622 | // product of (normalized) mantissas of floating point numbers: | |
| 623 | // (mant_1, mant_2) -> quick_mul_hi -> normalize leading bit | |
| 624 | // is much more efficient than: | |
| 625 | // (mant_1, mant_2) -> ful_mul -> normalize leading bit | |
| 626 | // -> convert back to same Bits width by shifting/rounding, | |
| 627 | // especially for higher precisions. | |
| 628 | // | |
| 629 | // Performance summary: | |
| 630 | // Number of 64-bit x 64-bit -> 128-bit multiplications performed. | |
| 631 | // Bits WORD_COUNT ful_mul quick_mul_hi Error bound | |
| 632 | // 128 2 4 3 1 | |
| 633 | // 196 3 9 6 2 | |
| 634 | // 256 4 16 10 3 | |
| 635 | // 512 8 64 36 7 | |
| 636 | LIBC_INLINE constexpr BigInt quick_mul_hi(const BigInt &other) const { | |
| 637 | BigInt result; | |
| 638 | multiword::quick_mul_hi(result.val, val, other.val); | |
| 639 | return result; | |
| 640 | } | |
| 641 | ||
| 642 | // BigInt(x).pow_n(n) computes x ^ n. | |
| 643 | // Note 0 ^ 0 == 1. | |
| 644 | LIBC_INLINE constexpr void pow_n(uint64_t power) { | |
| 645 | static_assert(!Signed); | |
| 646 | BigInt result = one(); | |
| 647 | BigInt cur_power = *this; | |
| 648 | while (power > 0) { | |
| 649 | if ((power % 2) > 0) | |
| 650 | result *= cur_power; | |
| 651 | power >>= 1; | |
| 652 | cur_power *= cur_power; | |
| 653 | } | |
| 654 | *this = result; | |
| 655 | } | |
| 656 | ||
| 657 | // Performs inplace signed / unsigned division. Returns remainder if not | |
| 658 | // dividing by zero. | |
| 659 | // For signed numbers it behaves like C++ signed integer division. | |
| 660 | // That is by truncating the fractionnal part | |
| 661 | // https://stackoverflow.com/a/3602857 | |
| 662 | LIBC_INLINE constexpr cpp::optional<BigInt> div(const BigInt &divider) { | |
| 663 | if (LIBC_UNLIKELY(divider.is_zero())) | |
| 664 | return cpp::nullopt; | |
| 665 | if (LIBC_UNLIKELY(divider == BigInt::one())) | |
| 666 | return BigInt::zero(); | |
| 667 | Division result; | |
| 668 | if constexpr (SIGNED) | |
| 669 | result = divide_signed(*this, divider); | |
| 670 | else | |
| 671 | result = divide_unsigned(*this, divider); | |
| 672 | *this = result.quotient; | |
| 673 | return result.remainder; | |
| 674 | } | |
| 675 | ||
| 676 | // Efficiently perform BigInt / (x * 2^e), where x is a half-word-size | |
| 677 | // unsigned integer, and return the remainder. The main idea is as follow: | |
| 678 | // Let q = y / (x * 2^e) be the quotient, and | |
| 679 | // r = y % (x * 2^e) be the remainder. | |
| 680 | // First, notice that: | |
| 681 | // r % (2^e) = y % (2^e), | |
| 682 | // so we just need to focus on all the bits of y that is >= 2^e. | |
| 683 | // To speed up the shift-and-add steps, we only use x as the divisor, and | |
| 684 | // performing 32-bit shiftings instead of bit-by-bit shiftings. | |
| 685 | // Since the remainder of each division step < x < 2^(WORD_SIZE / 2), the | |
| 686 | // computation of each step is now properly contained within WordType. | |
| 687 | // And finally we perform some extra alignment steps for the remaining bits. | |
| 688 | LIBC_INLINE constexpr cpp::optional<BigInt> | |
| 689 | div_uint_half_times_pow_2(multiword::half_width_t<WordType> x, size_t e) { | |
| 690 | BigInt remainder; | |
| 691 | if (x == 0) | |
| 692 | return cpp::nullopt; | |
| 693 | if (e >= Bits) { | |
| 694 | remainder = *this; | |
| 695 | *this = BigInt<Bits, false, WordType>(); | |
| 696 | return remainder; | |
| 697 | } | |
| 698 | BigInt quotient; | |
| 699 | WordType x_word = static_cast<WordType>(x); | |
| 700 | constexpr size_t LOG2_WORD_SIZE = cpp::bit_width(WORD_SIZE) - 1; | |
| 701 | constexpr size_t HALF_WORD_SIZE = WORD_SIZE >> 1; | |
| 702 | constexpr WordType HALF_MASK = ((WordType(1) << HALF_WORD_SIZE) - 1); | |
| 703 | // lower = smallest multiple of WORD_SIZE that is >= e. | |
| 704 | size_t lower = ((e >> LOG2_WORD_SIZE) + ((e & (WORD_SIZE - 1)) != 0)) | |
| 705 | << LOG2_WORD_SIZE; | |
| 706 | // lower_pos is the index of the closest WORD_SIZE-bit chunk >= 2^e. | |
| 707 | size_t lower_pos = lower / WORD_SIZE; | |
| 708 | // Keep track of current remainder mod x * 2^(32*i) | |
| 709 | WordType rem = 0; | |
| 710 | // pos is the index of the current 64-bit chunk that we are processing. | |
| 711 | size_t pos = WORD_COUNT; | |
| 712 | ||
| 713 | // TODO: look into if constexpr(Bits > 256) skip leading zeroes. | |
| 714 | ||
| 715 | for (size_t q_pos = WORD_COUNT - lower_pos; q_pos > 0; --q_pos) { | |
| 716 | // q_pos is 1 + the index of the current WORD_SIZE-bit chunk of the | |
| 717 | // quotient being processed. Performing the division / modulus with | |
| 718 | // divisor: | |
| 719 | // x * 2^(WORD_SIZE*q_pos - WORD_SIZE/2), | |
| 720 | // i.e. using the upper (WORD_SIZE/2)-bit of the current WORD_SIZE-bit | |
| 721 | // chunk. | |
| 722 | rem <<= HALF_WORD_SIZE; | |
| 723 | rem += val[--pos] >> HALF_WORD_SIZE; | |
| 724 | WordType q_tmp = rem / x_word; | |
| 725 | rem %= x_word; | |
| 726 | ||
| 727 | // Performing the division / modulus with divisor: | |
| 728 | // x * 2^(WORD_SIZE*(q_pos - 1)), | |
| 729 | // i.e. using the lower (WORD_SIZE/2)-bit of the current WORD_SIZE-bit | |
| 730 | // chunk. | |
| 731 | rem <<= HALF_WORD_SIZE; | |
| 732 | rem += val[pos] & HALF_MASK; | |
| 733 | quotient.val[q_pos - 1] = (q_tmp << HALF_WORD_SIZE) + rem / x_word; | |
| 734 | rem %= x_word; | |
| 735 | } | |
| 736 | ||
| 737 | // So far, what we have is: | |
| 738 | // quotient = y / (x * 2^lower), and | |
| 739 | // rem = (y % (x * 2^lower)) / 2^lower. | |
| 740 | // If (lower > e), we will need to perform an extra adjustment of the | |
| 741 | // quotient and remainder, namely: | |
| 742 | // y / (x * 2^e) = [ y / (x * 2^lower) ] * 2^(lower - e) + | |
| 743 | // + (rem * 2^(lower - e)) / x | |
| 744 | // (y % (x * 2^e)) / 2^e = (rem * 2^(lower - e)) % x | |
| 745 | size_t last_shift = lower - e; | |
| 746 | ||
| 747 | if (last_shift > 0) { | |
| 748 | // quotient * 2^(lower - e) | |
| 749 | quotient <<= last_shift; | |
| 750 | WordType q_tmp = 0; | |
| 751 | WordType d = val[--pos]; | |
| 752 | if (last_shift >= HALF_WORD_SIZE) { | |
| 753 | // The shifting (rem * 2^(lower - e)) might overflow WordTyoe, so we | |
| 754 | // perform a HALF_WORD_SIZE-bit shift first. | |
| 755 | rem <<= HALF_WORD_SIZE; | |
| 756 | rem += d >> HALF_WORD_SIZE; | |
| 757 | d &= HALF_MASK; | |
| 758 | q_tmp = rem / x_word; | |
| 759 | rem %= x_word; | |
| 760 | last_shift -= HALF_WORD_SIZE; | |
| 761 | } else { | |
| 762 | // Only use the upper HALF_WORD_SIZE-bit of the current WORD_SIZE-bit | |
| 763 | // chunk. | |
| 764 | d >>= HALF_WORD_SIZE; | |
| 765 | } | |
| 766 | ||
| 767 | if (last_shift > 0) { | |
| 768 | rem <<= HALF_WORD_SIZE; | |
| 769 | rem += d; | |
| 770 | q_tmp <<= last_shift; | |
| 771 | x_word <<= HALF_WORD_SIZE - last_shift; | |
| 772 | q_tmp += rem / x_word; | |
| 773 | rem %= x_word; | |
| 774 | } | |
| 775 | ||
| 776 | quotient.val[0] += q_tmp; | |
| 777 | ||
| 778 | if (lower - e <= HALF_WORD_SIZE) { | |
| 779 | // The remainder rem * 2^(lower - e) might overflow to the higher | |
| 780 | // WORD_SIZE-bit chunk. | |
| 781 | if (pos < WORD_COUNT - 1) { | |
| 782 | remainder[pos + 1] = rem >> HALF_WORD_SIZE; | |
| 783 | } | |
| 784 | remainder[pos] = (rem << HALF_WORD_SIZE) + (val[pos] & HALF_MASK); | |
| 785 | } else { | |
| 786 | remainder[pos] = rem; | |
| 787 | } | |
| 788 | ||
| 789 | } else { | |
| 790 | remainder[pos] = rem; | |
| 791 | } | |
| 792 | ||
| 793 | // Set the remaining lower bits of the remainder. | |
| 794 | for (; pos > 0; --pos) { | |
| 795 | remainder[pos - 1] = val[pos - 1]; | |
| 796 | } | |
| 797 | ||
| 798 | *this = quotient; | |
| 799 | return remainder; | |
| 800 | } | |
| 801 | ||
| 802 | LIBC_INLINE constexpr BigInt operator/(const BigInt &other) const { | |
| 803 | BigInt result(*this); | |
| 804 | result.div(other); | |
| 805 | return result; | |
| 806 | } | |
| 807 | ||
| 808 | LIBC_INLINE constexpr BigInt &operator/=(const BigInt &other) { | |
| 809 | div(other); | |
| 810 | return *this; | |
| 811 | } | |
| 812 | ||
| 813 | LIBC_INLINE constexpr BigInt operator%(const BigInt &other) const { | |
| 814 | BigInt result(*this); | |
| 815 | return *result.div(other); | |
| 816 | } | |
| 817 | ||
| 818 | LIBC_INLINE constexpr BigInt operator%=(const BigInt &other) { | |
| 819 | *this = *this % other; | |
| 820 | return *this; | |
| 821 | } | |
| 822 | ||
| 823 | LIBC_INLINE constexpr BigInt &operator*=(const BigInt &other) { | |
| 824 | *this = *this * other; | |
| 825 | return *this; | |
| 826 | } | |
| 827 | ||
| 828 | LIBC_INLINE constexpr BigInt &operator<<=(size_t s) { | |
| 829 | val = multiword::shift<multiword::LEFT, SIGNED>(val, s); | |
| 830 | return *this; | |
| 831 | } | |
| 832 | ||
| 833 | LIBC_INLINE constexpr BigInt operator<<(size_t s) const { | |
| 834 | return BigInt(multiword::shift<multiword::LEFT, SIGNED>(val, s)); | |
| 835 | } | |
| 836 | ||
| 837 | LIBC_INLINE constexpr BigInt &operator>>=(size_t s) { | |
| 838 | val = multiword::shift<multiword::RIGHT, SIGNED>(val, s); | |
| 839 | return *this; | |
| 840 | } | |
| 841 | ||
| 842 | LIBC_INLINE constexpr BigInt operator>>(size_t s) const { | |
| 843 | return BigInt(multiword::shift<multiword::RIGHT, SIGNED>(val, s)); | |
| 844 | } | |
| 845 | ||
| 846 | #define DEFINE_BINOP(OP) \ | |
| 847 | LIBC_INLINE friend constexpr BigInt operator OP(const BigInt &lhs, \ | |
| 848 | const BigInt &rhs) { \ | |
| 849 | BigInt result; \ | |
| 850 | for (size_t i = 0; i < WORD_COUNT; ++i) \ | |
| 851 | result[i] = lhs[i] OP rhs[i]; \ | |
| 852 | return result; \ | |
| 853 | } \ | |
| 854 | LIBC_INLINE friend constexpr BigInt operator OP##=(BigInt &lhs, \ | |
| 855 | const BigInt &rhs) { \ | |
| 856 | for (size_t i = 0; i < WORD_COUNT; ++i) \ | |
| 857 | lhs[i] OP## = rhs[i]; \ | |
| 858 | return lhs; \ | |
| 859 | } | |
| 860 | ||
| 861 | DEFINE_BINOP(&) // & and &= | |
| 862 | DEFINE_BINOP(|) // | and |= | |
| 863 | DEFINE_BINOP(^) // ^ and ^= | |
| 864 | #undef DEFINE_BINOP | |
| 865 | ||
| 866 | LIBC_INLINE constexpr BigInt operator~() const { | |
| 867 | BigInt result; | |
| 868 | for (size_t i = 0; i < WORD_COUNT; ++i) | |
| 869 | result[i] = ~val[i]; | |
| 870 | return result; | |
| 871 | } | |
| 872 | ||
| 873 | LIBC_INLINE constexpr BigInt operator-() const { | |
| 874 | BigInt result(*this); | |
| 875 | result.negate(); | |
| 876 | return result; | |
| 877 | } | |
| 878 | ||
| 879 | LIBC_INLINE friend constexpr bool operator==(const BigInt &lhs, | |
| 880 | const BigInt &rhs) { | |
| 881 | for (size_t i = 0; i < WORD_COUNT; ++i) | |
| 882 | if (lhs.val[i] != rhs.val[i]) | |
| 883 | return false; | |
| 884 | return true; | |
| 885 | } | |
| 886 | ||
| 887 | LIBC_INLINE friend constexpr bool operator!=(const BigInt &lhs, | |
| 888 | const BigInt &rhs) { | |
| 889 | return !(lhs == rhs); | |
| 890 | } | |
| 891 | ||
| 892 | LIBC_INLINE friend constexpr bool operator>(const BigInt &lhs, | |
| 893 | const BigInt &rhs) { | |
| 894 | return cmp(lhs, rhs) > 0; | |
| 895 | } | |
| 896 | LIBC_INLINE friend constexpr bool operator>=(const BigInt &lhs, | |
| 897 | const BigInt &rhs) { | |
| 898 | return cmp(lhs, rhs) >= 0; | |
| 899 | } | |
| 900 | LIBC_INLINE friend constexpr bool operator<(const BigInt &lhs, | |
| 901 | const BigInt &rhs) { | |
| 902 | return cmp(lhs, rhs) < 0; | |
| 903 | } | |
| 904 | LIBC_INLINE friend constexpr bool operator<=(const BigInt &lhs, | |
| 905 | const BigInt &rhs) { | |
| 906 | return cmp(lhs, rhs) <= 0; | |
| 907 | } | |
| 908 | ||
| 909 | LIBC_INLINE constexpr BigInt &operator++() { | |
| 910 | increment(); | |
| 911 | return *this; | |
| 912 | } | |
| 913 | ||
| 914 | LIBC_INLINE constexpr BigInt operator++(int) { | |
| 915 | BigInt oldval(*this); | |
| 916 | increment(); | |
| 917 | return oldval; | |
| 918 | } | |
| 919 | ||
| 920 | LIBC_INLINE constexpr BigInt &operator--() { | |
| 921 | decrement(); | |
| 922 | return *this; | |
| 923 | } | |
| 924 | ||
| 925 | LIBC_INLINE constexpr BigInt operator--(int) { | |
| 926 | BigInt oldval(*this); | |
| 927 | decrement(); | |
| 928 | return oldval; | |
| 929 | } | |
| 930 | ||
| 931 | // Return the i-th word of the number. | |
| 932 | LIBC_INLINE constexpr const WordType &operator[](size_t i) const { | |
| 933 | return val[i]; | |
| 934 | } | |
| 935 | ||
| 936 | // Return the i-th word of the number. | |
| 937 | LIBC_INLINE constexpr WordType &operator[](size_t i) { return val[i]; } | |
| 938 | ||
| 939 | private: | |
| 940 | LIBC_INLINE friend constexpr int cmp(const BigInt &lhs, const BigInt &rhs) { | |
| 941 | constexpr auto compare = [](WordType a, WordType b) { | |
| 942 | return a == b ? 0 : a > b ? 1 : -1; | |
| 943 | }; | |
| 944 | if constexpr (Signed) { | |
| 945 | const bool lhs_is_neg = lhs.is_neg(); | |
| 946 | const bool rhs_is_neg = rhs.is_neg(); | |
| 947 | if (lhs_is_neg != rhs_is_neg) | |
| 948 | return rhs_is_neg ? 1 : -1; | |
| 949 | } | |
| 950 | for (size_t i = WORD_COUNT; i-- > 0;) | |
| 951 | if (auto cmp = compare(lhs[i], rhs[i]); cmp != 0) | |
| 952 | return cmp; | |
| 953 | return 0; | |
| 954 | } | |
| 955 | ||
| 956 | LIBC_INLINE constexpr void bitwise_not() { | |
| 957 | for (auto &part : val) | |
| 958 | part = ~part; | |
| 959 | } | |
| 960 | ||
| 961 | LIBC_INLINE constexpr void negate() { | |
| 962 | bitwise_not(); | |
| 963 | increment(); | |
| 964 | } | |
| 965 | ||
| 966 | LIBC_INLINE constexpr void increment() { | |
| 967 | multiword::add_with_carry(val, cpp::array<WordType, 1>{1}); | |
| 968 | } | |
| 969 | ||
| 970 | LIBC_INLINE constexpr void decrement() { | |
| 971 | multiword::add_with_carry(val, cpp::array<WordType, 1>{1}); | |
| 972 | } | |
| 973 | ||
| 974 | LIBC_INLINE constexpr void extend(size_t index, bool is_neg) { | |
| 975 | const WordType value = is_neg ? cpp::numeric_limits<WordType>::max() | |
| 976 | : cpp::numeric_limits<WordType>::min(); | |
| 977 | for (size_t i = index; i < WORD_COUNT; ++i) | |
| 978 | val[i] = value; | |
| 979 | } | |
| 980 | ||
| 981 | LIBC_INLINE constexpr bool get_msb() const { | |
| 982 | return val.back() >> (WORD_SIZE - 1); | |
| 983 | } | |
| 984 | ||
| 985 | LIBC_INLINE constexpr void set_msb() { | |
| 986 | val.back() |= mask_leading_ones<WordType, 1>(); | |
| 987 | } | |
| 988 | ||
| 989 | LIBC_INLINE constexpr void clear_msb() { | |
| 990 | val.back() &= mask_trailing_ones<WordType, WORD_SIZE - 1>(); | |
| 991 | } | |
| 992 | ||
| 993 | LIBC_INLINE constexpr void set_bit(size_t i) { | |
| 994 | const size_t word_index = i / WORD_SIZE; | |
| 995 | val[word_index] |= WordType(1) << (i % WORD_SIZE); | |
| 996 | } | |
| 997 | ||
| 998 | LIBC_INLINE constexpr static Division divide_unsigned(const BigInt &dividend, | |
| 999 | const BigInt &divider) { | |
| 1000 | BigInt remainder = dividend; | |
| 1001 | BigInt quotient; | |
| 1002 | if (remainder >= divider) { | |
| 1003 | BigInt subtractor = divider; | |
| 1004 | int cur_bit = multiword::countl_zero(subtractor.val) - | |
| 1005 | multiword::countl_zero(remainder.val); | |
| 1006 | subtractor <<= cur_bit; | |
| 1007 | for (; cur_bit >= 0 && remainder > 0; --cur_bit, subtractor >>= 1) { | |
| 1008 | if (remainder < subtractor) | |
| 1009 | continue; | |
| 1010 | remainder -= subtractor; | |
| 1011 | quotient.set_bit(cur_bit); | |
| 1012 | } | |
| 1013 | } | |
| 1014 | return Division{quotient, remainder}; | |
| 1015 | } | |
| 1016 | ||
| 1017 | LIBC_INLINE constexpr static Division divide_signed(const BigInt &dividend, | |
| 1018 | const BigInt &divider) { | |
| 1019 | // Special case because it is not possible to negate the min value of a | |
| 1020 | // signed integer. | |
| 1021 | if (dividend == min() && divider == min()) | |
| 1022 | return Division{one(), zero()}; | |
| 1023 | // 1. Convert the dividend and divisor to unsigned representation. | |
| 1024 | unsigned_type udividend(dividend); | |
| 1025 | unsigned_type udivider(divider); | |
| 1026 | // 2. Negate the dividend if it's negative, and similarly for the divisor. | |
| 1027 | const bool dividend_is_neg = dividend.is_neg(); | |
| 1028 | const bool divider_is_neg = divider.is_neg(); | |
| 1029 | if (dividend_is_neg) | |
| 1030 | udividend.negate(); | |
| 1031 | if (divider_is_neg) | |
| 1032 | udivider.negate(); | |
| 1033 | // 3. Use unsigned multiword division algorithm. | |
| 1034 | const auto unsigned_result = divide_unsigned(udividend, udivider); | |
| 1035 | // 4. Convert the quotient and remainder to signed representation. | |
| 1036 | Division result; | |
| 1037 | result.quotient = signed_type(unsigned_result.quotient); | |
| 1038 | result.remainder = signed_type(unsigned_result.remainder); | |
| 1039 | // 5. Negate the quotient if the dividend and divisor had opposite signs. | |
| 1040 | if (dividend_is_neg != divider_is_neg) | |
| 1041 | result.quotient.negate(); | |
| 1042 | // 6. Negate the remainder if the dividend was negative. | |
| 1043 | if (dividend_is_neg) | |
| 1044 | result.remainder.negate(); | |
| 1045 | return result; | |
| 1046 | } | |
| 1047 | ||
| 1048 | friend signed_type; | |
| 1049 | friend unsigned_type; | |
| 1050 | }; | |
| 1051 | ||
| 1052 | namespace internal { | |
| 1053 | // We default BigInt's WordType to 'uint64_t' or 'uint32_t' depending on type | |
| 1054 | // availability. | |
| 1055 | template <size_t Bits> | |
| 1056 | struct WordTypeSelector : cpp::type_identity< | |
| 1057 | #ifdef LIBC_TYPES_HAS_INT64 | |
| 1058 | uint64_t | |
| 1059 | #else | |
| 1060 | uint32_t | |
| 1061 | #endif // LIBC_TYPES_HAS_INT64 | |
| 1062 | > { | |
| 1063 | }; | |
| 1064 | // Except if we request 16 or 32 bits explicitly. | |
| 1065 | template <> struct WordTypeSelector<16> : cpp::type_identity<uint16_t> {}; | |
| 1066 | template <> struct WordTypeSelector<32> : cpp::type_identity<uint32_t> {}; | |
| 1067 | template <> struct WordTypeSelector<96> : cpp::type_identity<uint32_t> {}; | |
| 1068 | ||
| 1069 | template <size_t Bits> | |
| 1070 | using WordTypeSelectorT = typename WordTypeSelector<Bits>::type; | |
| 1071 | } // namespace internal | |
| 1072 | ||
| 1073 | template <size_t Bits> | |
| 1074 | using UInt = BigInt<Bits, false, internal::WordTypeSelectorT<Bits>>; | |
| 1075 | ||
| 1076 | template <size_t Bits> | |
| 1077 | using Int = BigInt<Bits, true, internal::WordTypeSelectorT<Bits>>; | |
| 1078 | ||
| 1079 | // Provides limits of BigInt. | |
| 1080 | template <size_t Bits, bool Signed, typename T> | |
| 1081 | struct cpp::numeric_limits<BigInt<Bits, Signed, T>> { | |
| 1082 | LIBC_INLINE static constexpr BigInt<Bits, Signed, T> max() { | |
| 1083 | return BigInt<Bits, Signed, T>::max(); | |
| 1084 | } | |
| 1085 | LIBC_INLINE static constexpr BigInt<Bits, Signed, T> min() { | |
| 1086 | return BigInt<Bits, Signed, T>::min(); | |
| 1087 | } | |
| 1088 | // Meant to match std::numeric_limits interface. | |
| 1089 | // NOLINTNEXTLINE(readability-identifier-naming) | |
| 1090 | LIBC_INLINE_VAR static constexpr int digits = Bits - Signed; | |
| 1091 | }; | |
| 1092 | ||
| 1093 | // type traits to determine whether a T is a BigInt. | |
| 1094 | template <typename T> struct is_big_int : cpp::false_type {}; | |
| 1095 | ||
| 1096 | template <size_t Bits, bool Signed, typename T> | |
| 1097 | struct is_big_int<BigInt<Bits, Signed, T>> : cpp::true_type {}; | |
| 1098 | ||
| 1099 | template <class T> | |
| 1100 | LIBC_INLINE_VAR constexpr bool is_big_int_v = is_big_int<T>::value; | |
| 1101 | ||
| 1102 | // extensions of type traits to include BigInt | |
| 1103 | ||
| 1104 | // is_integral_or_big_int | |
| 1105 | template <typename T> | |
| 1106 | struct is_integral_or_big_int | |
| 1107 | : cpp::bool_constant<(cpp::is_integral_v<T> || is_big_int_v<T>)> {}; | |
| 1108 | ||
| 1109 | template <typename T> | |
| 1110 | LIBC_INLINE_VAR constexpr bool is_integral_or_big_int_v = | |
| 1111 | is_integral_or_big_int<T>::value; | |
| 1112 | ||
| 1113 | // make_big_int_unsigned | |
| 1114 | template <typename T> struct make_big_int_unsigned; | |
| 1115 | ||
| 1116 | template <size_t Bits, bool Signed, typename T> | |
| 1117 | struct make_big_int_unsigned<BigInt<Bits, Signed, T>> | |
| 1118 | : cpp::type_identity<BigInt<Bits, false, T>> {}; | |
| 1119 | ||
| 1120 | template <typename T> | |
| 1121 | using make_big_int_unsigned_t = typename make_big_int_unsigned<T>::type; | |
| 1122 | ||
| 1123 | // make_big_int_signed | |
| 1124 | template <typename T> struct make_big_int_signed; | |
| 1125 | ||
| 1126 | template <size_t Bits, bool Signed, typename T> | |
| 1127 | struct make_big_int_signed<BigInt<Bits, Signed, T>> | |
| 1128 | : cpp::type_identity<BigInt<Bits, true, T>> {}; | |
| 1129 | ||
| 1130 | template <typename T> | |
| 1131 | using make_big_int_signed_t = typename make_big_int_signed<T>::type; | |
| 1132 | ||
| 1133 | // make_integral_or_big_int_unsigned | |
| 1134 | template <typename T, class = void> struct make_integral_or_big_int_unsigned; | |
| 1135 | ||
| 1136 | template <typename T> | |
| 1137 | struct make_integral_or_big_int_unsigned< | |
| 1138 | T, cpp::enable_if_t<cpp::is_integral_v<T>>> : cpp::make_unsigned<T> {}; | |
| 1139 | ||
| 1140 | template <typename T> | |
| 1141 | struct make_integral_or_big_int_unsigned<T, cpp::enable_if_t<is_big_int_v<T>>> | |
| 1142 | : make_big_int_unsigned<T> {}; | |
| 1143 | ||
| 1144 | template <typename T> | |
| 1145 | using make_integral_or_big_int_unsigned_t = | |
| 1146 | typename make_integral_or_big_int_unsigned<T>::type; | |
| 1147 | ||
| 1148 | // make_integral_or_big_int_signed | |
| 1149 | template <typename T, class = void> struct make_integral_or_big_int_signed; | |
| 1150 | ||
| 1151 | template <typename T> | |
| 1152 | struct make_integral_or_big_int_signed<T, | |
| 1153 | cpp::enable_if_t<cpp::is_integral_v<T>>> | |
| 1154 | : cpp::make_signed<T> {}; | |
| 1155 | ||
| 1156 | template <typename T> | |
| 1157 | struct make_integral_or_big_int_signed<T, cpp::enable_if_t<is_big_int_v<T>>> | |
| 1158 | : make_big_int_signed<T> {}; | |
| 1159 | ||
| 1160 | template <typename T> | |
| 1161 | using make_integral_or_big_int_signed_t = | |
| 1162 | typename make_integral_or_big_int_signed<T>::type; | |
| 1163 | ||
| 1164 | // is_unsigned_integral_or_big_int | |
| 1165 | template <typename T> | |
| 1166 | struct is_unsigned_integral_or_big_int | |
| 1167 | : cpp::bool_constant< | |
| 1168 | cpp::is_same_v<T, make_integral_or_big_int_unsigned_t<T>>> {}; | |
| 1169 | ||
| 1170 | template <typename T> | |
| 1171 | // Meant to look like <type_traits> helper variable templates. | |
| 1172 | // NOLINTNEXTLINE(readability-identifier-naming) | |
| 1173 | LIBC_INLINE_VAR constexpr bool is_unsigned_integral_or_big_int_v = | |
| 1174 | is_unsigned_integral_or_big_int<T>::value; | |
| 1175 | ||
| 1176 | namespace cpp { | |
| 1177 | ||
| 1178 | // Specialization of cpp::bit_cast ('bit.h') from T to BigInt. | |
| 1179 | template <typename To, typename From> | |
| 1180 | LIBC_INLINE constexpr cpp::enable_if_t< | |
| 1181 | (sizeof(To) == sizeof(From)) && cpp::is_trivially_copyable<To>::value && | |
| 1182 | cpp::is_trivially_copyable<From>::value && is_big_int<To>::value, | |
| 1183 | To> | |
| 1184 | bit_cast(const From &from) { | |
| 1185 | To out; | |
| 1186 | using Storage = decltype(out.val); | |
| 1187 | out.val = cpp::bit_cast<Storage>(from); | |
| 1188 | return out; | |
| 1189 | } | |
| 1190 | ||
| 1191 | // Specialization of cpp::bit_cast ('bit.h') from BigInt to T. | |
| 1192 | template <typename To, size_t Bits> | |
| 1193 | LIBC_INLINE constexpr cpp::enable_if_t< | |
| 1194 | sizeof(To) == sizeof(UInt<Bits>) && | |
| 1195 | cpp::is_trivially_constructible<To>::value && | |
| 1196 | cpp::is_trivially_copyable<To>::value && | |
| 1197 | cpp::is_trivially_copyable<UInt<Bits>>::value, | |
| 1198 | To> | |
| 1199 | bit_cast(const UInt<Bits> &from) { | |
| 1200 | return cpp::bit_cast<To>(from.val); | |
| 1201 | } | |
| 1202 | ||
| 1203 | // Specialization of cpp::popcount ('bit.h') for BigInt. | |
| 1204 | template <typename T> | |
| 1205 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1206 | popcount(T value) { | |
| 1207 | int bits = 0; | |
| 1208 | for (auto word : value.val) | |
| 1209 | if (word) | |
| 1210 | bits += popcount(word); | |
| 1211 | return bits; | |
| 1212 | } | |
| 1213 | ||
| 1214 | // Specialization of cpp::has_single_bit ('bit.h') for BigInt. | |
| 1215 | template <typename T> | |
| 1216 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, bool> | |
| 1217 | has_single_bit(T value) { | |
| 1218 | int bits = 0; | |
| 1219 | for (auto word : value.val) { | |
| 1220 | if (word == 0) | |
| 1221 | continue; | |
| 1222 | bits += popcount(word); | |
| 1223 | if (bits > 1) | |
| 1224 | return false; | |
| 1225 | } | |
| 1226 | return bits == 1; | |
| 1227 | } | |
| 1228 | ||
| 1229 | // Specialization of cpp::countr_zero ('bit.h') for BigInt. | |
| 1230 | template <typename T> | |
| 1231 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1232 | countr_zero(const T &value) { | |
| 1233 | return multiword::countr_zero(value.val); | |
| 1234 | } | |
| 1235 | ||
| 1236 | // Specialization of cpp::countl_zero ('bit.h') for BigInt. | |
| 1237 | template <typename T> | |
| 1238 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1239 | countl_zero(const T &value) { | |
| 1240 | return multiword::countl_zero(value.val); | |
| 1241 | } | |
| 1242 | ||
| 1243 | // Specialization of cpp::countl_one ('bit.h') for BigInt. | |
| 1244 | template <typename T> | |
| 1245 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1246 | countl_one(T value) { | |
| 1247 | return multiword::countl_one(value.val); | |
| 1248 | } | |
| 1249 | ||
| 1250 | // Specialization of cpp::countr_one ('bit.h') for BigInt. | |
| 1251 | template <typename T> | |
| 1252 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1253 | countr_one(T value) { | |
| 1254 | return multiword::countr_one(value.val); | |
| 1255 | } | |
| 1256 | ||
| 1257 | // Specialization of cpp::bit_width ('bit.h') for BigInt. | |
| 1258 | template <typename T> | |
| 1259 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1260 | bit_width(T value) { | |
| 1261 | return cpp::numeric_limits<T>::digits - cpp::countl_zero(value); | |
| 1262 | } | |
| 1263 | ||
| 1264 | // Forward-declare rotr so that rotl can use it. | |
| 1265 | template <typename T> | |
| 1266 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> | |
| 1267 | rotr(T value, int rotate); | |
| 1268 | ||
| 1269 | // Specialization of cpp::rotl ('bit.h') for BigInt. | |
| 1270 | template <typename T> | |
| 1271 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> | |
| 1272 | rotl(T value, int rotate) { | |
| 1273 | constexpr unsigned N = cpp::numeric_limits<T>::digits; | |
| 1274 | rotate = rotate % N; | |
| 1275 | if (!rotate) | |
| 1276 | return value; | |
| 1277 | if (rotate < 0) | |
| 1278 | return cpp::rotr<T>(value, -rotate); | |
| 1279 | return (value << rotate) | (value >> (N - rotate)); | |
| 1280 | } | |
| 1281 | ||
| 1282 | // Specialization of cpp::rotr ('bit.h') for BigInt. | |
| 1283 | template <typename T> | |
| 1284 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> | |
| 1285 | rotr(T value, int rotate) { | |
| 1286 | constexpr unsigned N = cpp::numeric_limits<T>::digits; | |
| 1287 | rotate = rotate % N; | |
| 1288 | if (!rotate) | |
| 1289 | return value; | |
| 1290 | if (rotate < 0) | |
| 1291 | return cpp::rotl<T>(value, -rotate); | |
| 1292 | return (value >> rotate) | (value << (N - rotate)); | |
| 1293 | } | |
| 1294 | ||
| 1295 | } // namespace cpp | |
| 1296 | ||
| 1297 | // Specialization of mask_trailing_ones ('math_extras.h') for BigInt. | |
| 1298 | template <typename T, size_t count> | |
| 1299 | LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> | |
| 1300 | mask_trailing_ones() { | |
| 1301 | static_assert(!T::SIGNED && count <= T::BITS); | |
| 1302 | if (count == T::BITS) | |
| 1303 | return T::all_ones(); | |
| 1304 | constexpr size_t QUOTIENT = count / T::WORD_SIZE; | |
| 1305 | constexpr size_t REMAINDER = count % T::WORD_SIZE; | |
| 1306 | T out; // zero initialized | |
| 1307 | for (size_t i = 0; i <= QUOTIENT; ++i) | |
| 1308 | out[i] = i < QUOTIENT | |
| 1309 | ? -1 | |
| 1310 | : mask_trailing_ones<typename T::word_type, REMAINDER>(); | |
| 1311 | return out; | |
| 1312 | } | |
| 1313 | ||
| 1314 | // Specialization of mask_leading_ones ('math_extras.h') for BigInt. | |
| 1315 | template <typename T, size_t count> | |
| 1316 | LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> mask_leading_ones() { | |
| 1317 | static_assert(!T::SIGNED && count <= T::BITS); | |
| 1318 | if (count == T::BITS) | |
| 1319 | return T::all_ones(); | |
| 1320 | constexpr size_t QUOTIENT = (T::BITS - count - 1U) / T::WORD_SIZE; | |
| 1321 | constexpr size_t REMAINDER = count % T::WORD_SIZE; | |
| 1322 | T out; // zero initialized | |
| 1323 | for (size_t i = QUOTIENT; i < T::WORD_COUNT; ++i) | |
| 1324 | out[i] = i > QUOTIENT | |
| 1325 | ? -1 | |
| 1326 | : mask_leading_ones<typename T::word_type, REMAINDER>(); | |
| 1327 | return out; | |
| 1328 | } | |
| 1329 | ||
| 1330 | // Specialization of mask_trailing_zeros ('math_extras.h') for BigInt. | |
| 1331 | template <typename T, size_t count> | |
| 1332 | LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> | |
| 1333 | mask_trailing_zeros() { | |
| 1334 | return mask_leading_ones<T, T::BITS - count>(); | |
| 1335 | } | |
| 1336 | ||
| 1337 | // Specialization of mask_leading_zeros ('math_extras.h') for BigInt. | |
| 1338 | template <typename T, size_t count> | |
| 1339 | LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> | |
| 1340 | mask_leading_zeros() { | |
| 1341 | return mask_trailing_ones<T, T::BITS - count>(); | |
| 1342 | } | |
| 1343 | ||
| 1344 | // Specialization of count_zeros ('math_extras.h') for BigInt. | |
| 1345 | template <typename T> | |
| 1346 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1347 | count_zeros(T value) { | |
| 1348 | return cpp::popcount(~value); | |
| 1349 | } | |
| 1350 | ||
| 1351 | // Specialization of first_leading_zero ('math_extras.h') for BigInt. | |
| 1352 | template <typename T> | |
| 1353 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1354 | first_leading_zero(T value) { | |
| 1355 | return value == cpp::numeric_limits<T>::max() ? 0 | |
| 1356 | : cpp::countl_one(value) + 1; | |
| 1357 | } | |
| 1358 | ||
| 1359 | // Specialization of first_leading_one ('math_extras.h') for BigInt. | |
| 1360 | template <typename T> | |
| 1361 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1362 | first_leading_one(T value) { | |
| 1363 | return first_leading_zero(~value); | |
| 1364 | } | |
| 1365 | ||
| 1366 | // Specialization of first_trailing_zero ('math_extras.h') for BigInt. | |
| 1367 | template <typename T> | |
| 1368 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1369 | first_trailing_zero(T value) { | |
| 1370 | return value == cpp::numeric_limits<T>::max() ? 0 | |
| 1371 | : cpp::countr_zero(~value) + 1; | |
| 1372 | } | |
| 1373 | ||
| 1374 | // Specialization of first_trailing_one ('math_extras.h') for BigInt. | |
| 1375 | template <typename T> | |
| 1376 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int> | |
| 1377 | first_trailing_one(T value) { | |
| 1378 | return value == cpp::numeric_limits<T>::max() ? 0 | |
| 1379 | : cpp::countr_zero(value) + 1; | |
| 1380 | } | |
| 1381 | ||
| 1382 | } // namespace LIBC_NAMESPACE_DECL | |
| 1383 | ||
| 1384 | #endif // LLVM_LIBC_SRC___SUPPORT_BIG_INT_H |
lib/libcxx/libc/src/__support/common.h created+82| ... | ... | @@ -0,0 +1,82 @@ |
| 1 | //===-- Common internal contructs -------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_COMMON_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_COMMON_H | |
| 11 | ||
| 12 | #ifndef LIBC_NAMESPACE | |
| 13 | #error "LIBC_NAMESPACE macro is not defined." | |
| 14 | #endif | |
| 15 | ||
| 16 | #include "src/__support/macros/attributes.h" | |
| 17 | #include "src/__support/macros/config.h" | |
| 18 | #include "src/__support/macros/properties/architectures.h" | |
| 19 | ||
| 20 | #ifndef LLVM_LIBC_FUNCTION_ATTR | |
| 21 | #define LLVM_LIBC_FUNCTION_ATTR | |
| 22 | #endif | |
| 23 | ||
| 24 | // clang-format off | |
| 25 | // Allow each function `func` to have extra attributes specified by defining: | |
| 26 | // `LLVM_LIBC_FUNCTION_ATTR_func` macro, which should always start with | |
| 27 | // "LLVM_LIBC_EMPTY, " | |
| 28 | // | |
| 29 | // For examples: | |
| 30 | // #define LLVM_LIBC_FUNCTION_ATTR_memcpy LLVM_LIBC_EMPTY, [[gnu::weak]] | |
| 31 | // #define LLVM_LIBC_FUNCTION_ATTR_memchr LLVM_LIBC_EMPTY, [[gnu::weak]] [[gnu::visibility("default")]] | |
| 32 | // clang-format on | |
| 33 | #define LLVM_LIBC_EMPTY | |
| 34 | ||
| 35 | #define GET_SECOND(first, second, ...) second | |
| 36 | #define EXPAND_THEN_SECOND(name) GET_SECOND(name, LLVM_LIBC_EMPTY) | |
| 37 | ||
| 38 | #define LLVM_LIBC_ATTR(name) EXPAND_THEN_SECOND(LLVM_LIBC_FUNCTION_ATTR_##name) | |
| 39 | ||
| 40 | // MacOS needs to be excluded because it does not support aliasing. | |
| 41 | #if defined(LIBC_COPT_PUBLIC_PACKAGING) && (!defined(__APPLE__)) | |
| 42 | #define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist) \ | |
| 43 | LLVM_LIBC_ATTR(name) \ | |
| 44 | LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::name) \ | |
| 45 | __##name##_impl__ __asm__(#name); \ | |
| 46 | decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]]; \ | |
| 47 | type __##name##_impl__ arglist | |
| 48 | #else | |
| 49 | #define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist) type name arglist | |
| 50 | #endif | |
| 51 | ||
| 52 | // This extra layer of macro allows `name` to be a macro to rename a function. | |
| 53 | #define LLVM_LIBC_FUNCTION(type, name, arglist) \ | |
| 54 | LLVM_LIBC_FUNCTION_IMPL(type, name, arglist) | |
| 55 | ||
| 56 | namespace LIBC_NAMESPACE_DECL { | |
| 57 | namespace internal { | |
| 58 | LIBC_INLINE constexpr bool same_string(char const *lhs, char const *rhs) { | |
| 59 | for (; *lhs || *rhs; ++lhs, ++rhs) | |
| 60 | if (*lhs != *rhs) | |
| 61 | return false; | |
| 62 | return true; | |
| 63 | } | |
| 64 | } // namespace internal | |
| 65 | } // namespace LIBC_NAMESPACE_DECL | |
| 66 | ||
| 67 | #define __LIBC_MACRO_TO_STRING(str) #str | |
| 68 | #define LIBC_MACRO_TO_STRING(str) __LIBC_MACRO_TO_STRING(str) | |
| 69 | ||
| 70 | // LLVM_LIBC_IS_DEFINED checks whether a particular macro is defined. | |
| 71 | // Usage: constexpr bool kUseAvx = LLVM_LIBC_IS_DEFINED(__AVX__); | |
| 72 | // | |
| 73 | // This works by comparing the stringified version of the macro with and without | |
| 74 | // evaluation. If FOO is not undefined both stringifications yield "FOO". If FOO | |
| 75 | // is defined, one stringification yields "FOO" while the other yields its | |
| 76 | // stringified value "1". | |
| 77 | #define LLVM_LIBC_IS_DEFINED(macro) \ | |
| 78 | !LIBC_NAMESPACE::internal::same_string( \ | |
| 79 | LLVM_LIBC_IS_DEFINED__EVAL_AND_STRINGIZE(macro), #macro) | |
| 80 | #define LLVM_LIBC_IS_DEFINED__EVAL_AND_STRINGIZE(s) #s | |
| 81 | ||
| 82 | #endif // LLVM_LIBC_SRC___SUPPORT_COMMON_H |
lib/libcxx/libc/src/__support/ctype_utils.h created+584| ... | ... | @@ -0,0 +1,584 @@ |
| 1 | //===-- Collection of utils for implementing ctype functions-------*-C++-*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_CTYPE_UTILS_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_CTYPE_UTILS_H | |
| 11 | ||
| 12 | #include "src/__support/macros/attributes.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | namespace LIBC_NAMESPACE_DECL { | |
| 16 | namespace internal { | |
| 17 | ||
| 18 | // ----------------------------------------------------------------------------- | |
| 19 | // ****************** WARNING ****************** | |
| 20 | // ****************** DO NOT TRY TO OPTIMIZE THESE FUNCTIONS! ****************** | |
| 21 | // ----------------------------------------------------------------------------- | |
| 22 | // This switch/case form is easier for the compiler to understand, and is | |
| 23 | // optimized into a form that is almost always the same as or better than | |
| 24 | // versions written by hand (see https://godbolt.org/z/qvrebqvvr). Also this | |
| 25 | // form makes these functions encoding independent. If you want to rewrite these | |
| 26 | // functions, make sure you have benchmarks to show your new solution is faster, | |
| 27 | // as well as a way to support non-ASCII character encodings. | |
| 28 | ||
| 29 | // Similarly, do not change these functions to use case ranges. e.g. | |
| 30 | // bool islower(int ch) { | |
| 31 | // switch(ch) { | |
| 32 | // case 'a'...'z': | |
| 33 | // return true; | |
| 34 | // } | |
| 35 | // } | |
| 36 | // This assumes the character ranges are contiguous, which they aren't in | |
| 37 | // EBCDIC. Technically we could use some smaller ranges, but that's even harder | |
| 38 | // to read. | |
| 39 | ||
| 40 | LIBC_INLINE static constexpr bool islower(int ch) { | |
| 41 | switch (ch) { | |
| 42 | case 'a': | |
| 43 | case 'b': | |
| 44 | case 'c': | |
| 45 | case 'd': | |
| 46 | case 'e': | |
| 47 | case 'f': | |
| 48 | case 'g': | |
| 49 | case 'h': | |
| 50 | case 'i': | |
| 51 | case 'j': | |
| 52 | case 'k': | |
| 53 | case 'l': | |
| 54 | case 'm': | |
| 55 | case 'n': | |
| 56 | case 'o': | |
| 57 | case 'p': | |
| 58 | case 'q': | |
| 59 | case 'r': | |
| 60 | case 's': | |
| 61 | case 't': | |
| 62 | case 'u': | |
| 63 | case 'v': | |
| 64 | case 'w': | |
| 65 | case 'x': | |
| 66 | case 'y': | |
| 67 | case 'z': | |
| 68 | return true; | |
| 69 | default: | |
| 70 | return false; | |
| 71 | } | |
| 72 | } | |
| 73 | ||
| 74 | LIBC_INLINE static constexpr bool isupper(int ch) { | |
| 75 | switch (ch) { | |
| 76 | case 'A': | |
| 77 | case 'B': | |
| 78 | case 'C': | |
| 79 | case 'D': | |
| 80 | case 'E': | |
| 81 | case 'F': | |
| 82 | case 'G': | |
| 83 | case 'H': | |
| 84 | case 'I': | |
| 85 | case 'J': | |
| 86 | case 'K': | |
| 87 | case 'L': | |
| 88 | case 'M': | |
| 89 | case 'N': | |
| 90 | case 'O': | |
| 91 | case 'P': | |
| 92 | case 'Q': | |
| 93 | case 'R': | |
| 94 | case 'S': | |
| 95 | case 'T': | |
| 96 | case 'U': | |
| 97 | case 'V': | |
| 98 | case 'W': | |
| 99 | case 'X': | |
| 100 | case 'Y': | |
| 101 | case 'Z': | |
| 102 | return true; | |
| 103 | default: | |
| 104 | return false; | |
| 105 | } | |
| 106 | } | |
| 107 | ||
| 108 | LIBC_INLINE static constexpr bool isdigit(int ch) { | |
| 109 | switch (ch) { | |
| 110 | case '0': | |
| 111 | case '1': | |
| 112 | case '2': | |
| 113 | case '3': | |
| 114 | case '4': | |
| 115 | case '5': | |
| 116 | case '6': | |
| 117 | case '7': | |
| 118 | case '8': | |
| 119 | case '9': | |
| 120 | return true; | |
| 121 | default: | |
| 122 | return false; | |
| 123 | } | |
| 124 | } | |
| 125 | ||
| 126 | LIBC_INLINE static constexpr int tolower(int ch) { | |
| 127 | switch (ch) { | |
| 128 | case 'A': | |
| 129 | return 'a'; | |
| 130 | case 'B': | |
| 131 | return 'b'; | |
| 132 | case 'C': | |
| 133 | return 'c'; | |
| 134 | case 'D': | |
| 135 | return 'd'; | |
| 136 | case 'E': | |
| 137 | return 'e'; | |
| 138 | case 'F': | |
| 139 | return 'f'; | |
| 140 | case 'G': | |
| 141 | return 'g'; | |
| 142 | case 'H': | |
| 143 | return 'h'; | |
| 144 | case 'I': | |
| 145 | return 'i'; | |
| 146 | case 'J': | |
| 147 | return 'j'; | |
| 148 | case 'K': | |
| 149 | return 'k'; | |
| 150 | case 'L': | |
| 151 | return 'l'; | |
| 152 | case 'M': | |
| 153 | return 'm'; | |
| 154 | case 'N': | |
| 155 | return 'n'; | |
| 156 | case 'O': | |
| 157 | return 'o'; | |
| 158 | case 'P': | |
| 159 | return 'p'; | |
| 160 | case 'Q': | |
| 161 | return 'q'; | |
| 162 | case 'R': | |
| 163 | return 'r'; | |
| 164 | case 'S': | |
| 165 | return 's'; | |
| 166 | case 'T': | |
| 167 | return 't'; | |
| 168 | case 'U': | |
| 169 | return 'u'; | |
| 170 | case 'V': | |
| 171 | return 'v'; | |
| 172 | case 'W': | |
| 173 | return 'w'; | |
| 174 | case 'X': | |
| 175 | return 'x'; | |
| 176 | case 'Y': | |
| 177 | return 'y'; | |
| 178 | case 'Z': | |
| 179 | return 'z'; | |
| 180 | default: | |
| 181 | return ch; | |
| 182 | } | |
| 183 | } | |
| 184 | ||
| 185 | LIBC_INLINE static constexpr int toupper(int ch) { | |
| 186 | switch (ch) { | |
| 187 | case 'a': | |
| 188 | return 'A'; | |
| 189 | case 'b': | |
| 190 | return 'B'; | |
| 191 | case 'c': | |
| 192 | return 'C'; | |
| 193 | case 'd': | |
| 194 | return 'D'; | |
| 195 | case 'e': | |
| 196 | return 'E'; | |
| 197 | case 'f': | |
| 198 | return 'F'; | |
| 199 | case 'g': | |
| 200 | return 'G'; | |
| 201 | case 'h': | |
| 202 | return 'H'; | |
| 203 | case 'i': | |
| 204 | return 'I'; | |
| 205 | case 'j': | |
| 206 | return 'J'; | |
| 207 | case 'k': | |
| 208 | return 'K'; | |
| 209 | case 'l': | |
| 210 | return 'L'; | |
| 211 | case 'm': | |
| 212 | return 'M'; | |
| 213 | case 'n': | |
| 214 | return 'N'; | |
| 215 | case 'o': | |
| 216 | return 'O'; | |
| 217 | case 'p': | |
| 218 | return 'P'; | |
| 219 | case 'q': | |
| 220 | return 'Q'; | |
| 221 | case 'r': | |
| 222 | return 'R'; | |
| 223 | case 's': | |
| 224 | return 'S'; | |
| 225 | case 't': | |
| 226 | return 'T'; | |
| 227 | case 'u': | |
| 228 | return 'U'; | |
| 229 | case 'v': | |
| 230 | return 'V'; | |
| 231 | case 'w': | |
| 232 | return 'W'; | |
| 233 | case 'x': | |
| 234 | return 'X'; | |
| 235 | case 'y': | |
| 236 | return 'Y'; | |
| 237 | case 'z': | |
| 238 | return 'Z'; | |
| 239 | default: | |
| 240 | return ch; | |
| 241 | } | |
| 242 | } | |
| 243 | ||
| 244 | LIBC_INLINE static constexpr bool isalpha(int ch) { | |
| 245 | switch (ch) { | |
| 246 | case 'a': | |
| 247 | case 'b': | |
| 248 | case 'c': | |
| 249 | case 'd': | |
| 250 | case 'e': | |
| 251 | case 'f': | |
| 252 | case 'g': | |
| 253 | case 'h': | |
| 254 | case 'i': | |
| 255 | case 'j': | |
| 256 | case 'k': | |
| 257 | case 'l': | |
| 258 | case 'm': | |
| 259 | case 'n': | |
| 260 | case 'o': | |
| 261 | case 'p': | |
| 262 | case 'q': | |
| 263 | case 'r': | |
| 264 | case 's': | |
| 265 | case 't': | |
| 266 | case 'u': | |
| 267 | case 'v': | |
| 268 | case 'w': | |
| 269 | case 'x': | |
| 270 | case 'y': | |
| 271 | case 'z': | |
| 272 | case 'A': | |
| 273 | case 'B': | |
| 274 | case 'C': | |
| 275 | case 'D': | |
| 276 | case 'E': | |
| 277 | case 'F': | |
| 278 | case 'G': | |
| 279 | case 'H': | |
| 280 | case 'I': | |
| 281 | case 'J': | |
| 282 | case 'K': | |
| 283 | case 'L': | |
| 284 | case 'M': | |
| 285 | case 'N': | |
| 286 | case 'O': | |
| 287 | case 'P': | |
| 288 | case 'Q': | |
| 289 | case 'R': | |
| 290 | case 'S': | |
| 291 | case 'T': | |
| 292 | case 'U': | |
| 293 | case 'V': | |
| 294 | case 'W': | |
| 295 | case 'X': | |
| 296 | case 'Y': | |
| 297 | case 'Z': | |
| 298 | return true; | |
| 299 | default: | |
| 300 | return false; | |
| 301 | } | |
| 302 | } | |
| 303 | ||
| 304 | LIBC_INLINE static constexpr bool isalnum(int ch) { | |
| 305 | switch (ch) { | |
| 306 | case 'a': | |
| 307 | case 'b': | |
| 308 | case 'c': | |
| 309 | case 'd': | |
| 310 | case 'e': | |
| 311 | case 'f': | |
| 312 | case 'g': | |
| 313 | case 'h': | |
| 314 | case 'i': | |
| 315 | case 'j': | |
| 316 | case 'k': | |
| 317 | case 'l': | |
| 318 | case 'm': | |
| 319 | case 'n': | |
| 320 | case 'o': | |
| 321 | case 'p': | |
| 322 | case 'q': | |
| 323 | case 'r': | |
| 324 | case 's': | |
| 325 | case 't': | |
| 326 | case 'u': | |
| 327 | case 'v': | |
| 328 | case 'w': | |
| 329 | case 'x': | |
| 330 | case 'y': | |
| 331 | case 'z': | |
| 332 | case 'A': | |
| 333 | case 'B': | |
| 334 | case 'C': | |
| 335 | case 'D': | |
| 336 | case 'E': | |
| 337 | case 'F': | |
| 338 | case 'G': | |
| 339 | case 'H': | |
| 340 | case 'I': | |
| 341 | case 'J': | |
| 342 | case 'K': | |
| 343 | case 'L': | |
| 344 | case 'M': | |
| 345 | case 'N': | |
| 346 | case 'O': | |
| 347 | case 'P': | |
| 348 | case 'Q': | |
| 349 | case 'R': | |
| 350 | case 'S': | |
| 351 | case 'T': | |
| 352 | case 'U': | |
| 353 | case 'V': | |
| 354 | case 'W': | |
| 355 | case 'X': | |
| 356 | case 'Y': | |
| 357 | case 'Z': | |
| 358 | case '0': | |
| 359 | case '1': | |
| 360 | case '2': | |
| 361 | case '3': | |
| 362 | case '4': | |
| 363 | case '5': | |
| 364 | case '6': | |
| 365 | case '7': | |
| 366 | case '8': | |
| 367 | case '9': | |
| 368 | return true; | |
| 369 | default: | |
| 370 | return false; | |
| 371 | } | |
| 372 | } | |
| 373 | ||
| 374 | LIBC_INLINE static constexpr int b36_char_to_int(int ch) { | |
| 375 | switch (ch) { | |
| 376 | case '0': | |
| 377 | return 0; | |
| 378 | case '1': | |
| 379 | return 1; | |
| 380 | case '2': | |
| 381 | return 2; | |
| 382 | case '3': | |
| 383 | return 3; | |
| 384 | case '4': | |
| 385 | return 4; | |
| 386 | case '5': | |
| 387 | return 5; | |
| 388 | case '6': | |
| 389 | return 6; | |
| 390 | case '7': | |
| 391 | return 7; | |
| 392 | case '8': | |
| 393 | return 8; | |
| 394 | case '9': | |
| 395 | return 9; | |
| 396 | case 'a': | |
| 397 | case 'A': | |
| 398 | return 10; | |
| 399 | case 'b': | |
| 400 | case 'B': | |
| 401 | return 11; | |
| 402 | case 'c': | |
| 403 | case 'C': | |
| 404 | return 12; | |
| 405 | case 'd': | |
| 406 | case 'D': | |
| 407 | return 13; | |
| 408 | case 'e': | |
| 409 | case 'E': | |
| 410 | return 14; | |
| 411 | case 'f': | |
| 412 | case 'F': | |
| 413 | return 15; | |
| 414 | case 'g': | |
| 415 | case 'G': | |
| 416 | return 16; | |
| 417 | case 'h': | |
| 418 | case 'H': | |
| 419 | return 17; | |
| 420 | case 'i': | |
| 421 | case 'I': | |
| 422 | return 18; | |
| 423 | case 'j': | |
| 424 | case 'J': | |
| 425 | return 19; | |
| 426 | case 'k': | |
| 427 | case 'K': | |
| 428 | return 20; | |
| 429 | case 'l': | |
| 430 | case 'L': | |
| 431 | return 21; | |
| 432 | case 'm': | |
| 433 | case 'M': | |
| 434 | return 22; | |
| 435 | case 'n': | |
| 436 | case 'N': | |
| 437 | return 23; | |
| 438 | case 'o': | |
| 439 | case 'O': | |
| 440 | return 24; | |
| 441 | case 'p': | |
| 442 | case 'P': | |
| 443 | return 25; | |
| 444 | case 'q': | |
| 445 | case 'Q': | |
| 446 | return 26; | |
| 447 | case 'r': | |
| 448 | case 'R': | |
| 449 | return 27; | |
| 450 | case 's': | |
| 451 | case 'S': | |
| 452 | return 28; | |
| 453 | case 't': | |
| 454 | case 'T': | |
| 455 | return 29; | |
| 456 | case 'u': | |
| 457 | case 'U': | |
| 458 | return 30; | |
| 459 | case 'v': | |
| 460 | case 'V': | |
| 461 | return 31; | |
| 462 | case 'w': | |
| 463 | case 'W': | |
| 464 | return 32; | |
| 465 | case 'x': | |
| 466 | case 'X': | |
| 467 | return 33; | |
| 468 | case 'y': | |
| 469 | case 'Y': | |
| 470 | return 34; | |
| 471 | case 'z': | |
| 472 | case 'Z': | |
| 473 | return 35; | |
| 474 | default: | |
| 475 | return 0; | |
| 476 | } | |
| 477 | } | |
| 478 | ||
| 479 | LIBC_INLINE static constexpr int int_to_b36_char(int num) { | |
| 480 | // Can't actually use LIBC_ASSERT here because it depends on integer_to_string | |
| 481 | // which depends on this. | |
| 482 | ||
| 483 | // LIBC_ASSERT(num < 36); | |
| 484 | switch (num) { | |
| 485 | case 0: | |
| 486 | return '0'; | |
| 487 | case 1: | |
| 488 | return '1'; | |
| 489 | case 2: | |
| 490 | return '2'; | |
| 491 | case 3: | |
| 492 | return '3'; | |
| 493 | case 4: | |
| 494 | return '4'; | |
| 495 | case 5: | |
| 496 | return '5'; | |
| 497 | case 6: | |
| 498 | return '6'; | |
| 499 | case 7: | |
| 500 | return '7'; | |
| 501 | case 8: | |
| 502 | return '8'; | |
| 503 | case 9: | |
| 504 | return '9'; | |
| 505 | case 10: | |
| 506 | return 'a'; | |
| 507 | case 11: | |
| 508 | return 'b'; | |
| 509 | case 12: | |
| 510 | return 'c'; | |
| 511 | case 13: | |
| 512 | return 'd'; | |
| 513 | case 14: | |
| 514 | return 'e'; | |
| 515 | case 15: | |
| 516 | return 'f'; | |
| 517 | case 16: | |
| 518 | return 'g'; | |
| 519 | case 17: | |
| 520 | return 'h'; | |
| 521 | case 18: | |
| 522 | return 'i'; | |
| 523 | case 19: | |
| 524 | return 'j'; | |
| 525 | case 20: | |
| 526 | return 'k'; | |
| 527 | case 21: | |
| 528 | return 'l'; | |
| 529 | case 22: | |
| 530 | return 'm'; | |
| 531 | case 23: | |
| 532 | return 'n'; | |
| 533 | case 24: | |
| 534 | return 'o'; | |
| 535 | case 25: | |
| 536 | return 'p'; | |
| 537 | case 26: | |
| 538 | return 'q'; | |
| 539 | case 27: | |
| 540 | return 'r'; | |
| 541 | case 28: | |
| 542 | return 's'; | |
| 543 | case 29: | |
| 544 | return 't'; | |
| 545 | case 30: | |
| 546 | return 'u'; | |
| 547 | case 31: | |
| 548 | return 'v'; | |
| 549 | case 32: | |
| 550 | return 'w'; | |
| 551 | case 33: | |
| 552 | return 'x'; | |
| 553 | case 34: | |
| 554 | return 'y'; | |
| 555 | case 35: | |
| 556 | return 'z'; | |
| 557 | default: | |
| 558 | return '!'; | |
| 559 | } | |
| 560 | } | |
| 561 | ||
| 562 | LIBC_INLINE static constexpr bool isspace(int ch) { | |
| 563 | switch (ch) { | |
| 564 | case ' ': | |
| 565 | case '\t': | |
| 566 | case '\n': | |
| 567 | case '\v': | |
| 568 | case '\f': | |
| 569 | case '\r': | |
| 570 | return true; | |
| 571 | default: | |
| 572 | return false; | |
| 573 | } | |
| 574 | } | |
| 575 | ||
| 576 | // not yet encoding independent. | |
| 577 | LIBC_INLINE static constexpr bool isgraph(int ch) { | |
| 578 | return 0x20 < ch && ch < 0x7f; | |
| 579 | } | |
| 580 | ||
| 581 | } // namespace internal | |
| 582 | } // namespace LIBC_NAMESPACE_DECL | |
| 583 | ||
| 584 | #endif // LLVM_LIBC_SRC___SUPPORT_CTYPE_UTILS_H |
lib/libcxx/libc/src/__support/detailed_powers_of_ten.h created+740| ... | ... | @@ -0,0 +1,740 @@ |
| 1 | //===-- detailed powers of ten ----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_DETAILED_POWERS_OF_TEN_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_DETAILED_POWERS_OF_TEN_H | |
| 11 | ||
| 12 | #include "src/__support/common.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | #include <stdint.h> | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | namespace internal { | |
| 19 | ||
| 20 | // TODO(michaelrj): write a script that will generate this table. | |
| 21 | ||
| 22 | // This table was generated by | |
| 23 | // https://github.com/google/wuffs/blob/788479dd64f35cb6b4e998a851acb06ee962435b/script/print-mpb-powers-of-10.go | |
| 24 | // and contains the 128 bit mantissa approximations of the powers of 10 from | |
| 25 | // -348 to 347. The exponents are implied by a linear expression with slope | |
| 26 | // 217706.0/65536.0 ≈ log(10)/log(2). This is used by the Eisel-Lemire algorithm | |
| 27 | // in str_to_float.h. | |
| 28 | ||
| 29 | constexpr int32_t DETAILED_POWERS_OF_TEN_MIN_EXP_10 = -348; | |
| 30 | constexpr int32_t DETAILED_POWERS_OF_TEN_MAX_EXP_10 = 347; | |
| 31 | ||
| 32 | // This rescales the base 10 exponent by a factor of log(10)/log(2). | |
| 33 | LIBC_INLINE int32_t exp10_to_exp2(int32_t exp10) { | |
| 34 | // Valid if exp10 < 646 456 636. | |
| 35 | return static_cast<int32_t>((217706 * static_cast<int64_t>(exp10)) >> 16); | |
| 36 | } | |
| 37 | ||
| 38 | static constexpr uint64_t DETAILED_POWERS_OF_TEN[696][2] = { | |
| 39 | {0x1732C869CD60E453, 0xFA8FD5A0081C0288}, // 1e-348 | |
| 40 | {0x0E7FBD42205C8EB4, 0x9C99E58405118195}, // 1e-347 | |
| 41 | {0x521FAC92A873B261, 0xC3C05EE50655E1FA}, // 1e-346 | |
| 42 | {0xE6A797B752909EF9, 0xF4B0769E47EB5A78}, // 1e-345 | |
| 43 | {0x9028BED2939A635C, 0x98EE4A22ECF3188B}, // 1e-344 | |
| 44 | {0x7432EE873880FC33, 0xBF29DCABA82FDEAE}, // 1e-343 | |
| 45 | {0x113FAA2906A13B3F, 0xEEF453D6923BD65A}, // 1e-342 | |
| 46 | {0x4AC7CA59A424C507, 0x9558B4661B6565F8}, // 1e-341 | |
| 47 | {0x5D79BCF00D2DF649, 0xBAAEE17FA23EBF76}, // 1e-340 | |
| 48 | {0xF4D82C2C107973DC, 0xE95A99DF8ACE6F53}, // 1e-339 | |
| 49 | {0x79071B9B8A4BE869, 0x91D8A02BB6C10594}, // 1e-338 | |
| 50 | {0x9748E2826CDEE284, 0xB64EC836A47146F9}, // 1e-337 | |
| 51 | {0xFD1B1B2308169B25, 0xE3E27A444D8D98B7}, // 1e-336 | |
| 52 | {0xFE30F0F5E50E20F7, 0x8E6D8C6AB0787F72}, // 1e-335 | |
| 53 | {0xBDBD2D335E51A935, 0xB208EF855C969F4F}, // 1e-334 | |
| 54 | {0xAD2C788035E61382, 0xDE8B2B66B3BC4723}, // 1e-333 | |
| 55 | {0x4C3BCB5021AFCC31, 0x8B16FB203055AC76}, // 1e-332 | |
| 56 | {0xDF4ABE242A1BBF3D, 0xADDCB9E83C6B1793}, // 1e-331 | |
| 57 | {0xD71D6DAD34A2AF0D, 0xD953E8624B85DD78}, // 1e-330 | |
| 58 | {0x8672648C40E5AD68, 0x87D4713D6F33AA6B}, // 1e-329 | |
| 59 | {0x680EFDAF511F18C2, 0xA9C98D8CCB009506}, // 1e-328 | |
| 60 | {0x0212BD1B2566DEF2, 0xD43BF0EFFDC0BA48}, // 1e-327 | |
| 61 | {0x014BB630F7604B57, 0x84A57695FE98746D}, // 1e-326 | |
| 62 | {0x419EA3BD35385E2D, 0xA5CED43B7E3E9188}, // 1e-325 | |
| 63 | {0x52064CAC828675B9, 0xCF42894A5DCE35EA}, // 1e-324 | |
| 64 | {0x7343EFEBD1940993, 0x818995CE7AA0E1B2}, // 1e-323 | |
| 65 | {0x1014EBE6C5F90BF8, 0xA1EBFB4219491A1F}, // 1e-322 | |
| 66 | {0xD41A26E077774EF6, 0xCA66FA129F9B60A6}, // 1e-321 | |
| 67 | {0x8920B098955522B4, 0xFD00B897478238D0}, // 1e-320 | |
| 68 | {0x55B46E5F5D5535B0, 0x9E20735E8CB16382}, // 1e-319 | |
| 69 | {0xEB2189F734AA831D, 0xC5A890362FDDBC62}, // 1e-318 | |
| 70 | {0xA5E9EC7501D523E4, 0xF712B443BBD52B7B}, // 1e-317 | |
| 71 | {0x47B233C92125366E, 0x9A6BB0AA55653B2D}, // 1e-316 | |
| 72 | {0x999EC0BB696E840A, 0xC1069CD4EABE89F8}, // 1e-315 | |
| 73 | {0xC00670EA43CA250D, 0xF148440A256E2C76}, // 1e-314 | |
| 74 | {0x380406926A5E5728, 0x96CD2A865764DBCA}, // 1e-313 | |
| 75 | {0xC605083704F5ECF2, 0xBC807527ED3E12BC}, // 1e-312 | |
| 76 | {0xF7864A44C633682E, 0xEBA09271E88D976B}, // 1e-311 | |
| 77 | {0x7AB3EE6AFBE0211D, 0x93445B8731587EA3}, // 1e-310 | |
| 78 | {0x5960EA05BAD82964, 0xB8157268FDAE9E4C}, // 1e-309 | |
| 79 | {0x6FB92487298E33BD, 0xE61ACF033D1A45DF}, // 1e-308 | |
| 80 | {0xA5D3B6D479F8E056, 0x8FD0C16206306BAB}, // 1e-307 | |
| 81 | {0x8F48A4899877186C, 0xB3C4F1BA87BC8696}, // 1e-306 | |
| 82 | {0x331ACDABFE94DE87, 0xE0B62E2929ABA83C}, // 1e-305 | |
| 83 | {0x9FF0C08B7F1D0B14, 0x8C71DCD9BA0B4925}, // 1e-304 | |
| 84 | {0x07ECF0AE5EE44DD9, 0xAF8E5410288E1B6F}, // 1e-303 | |
| 85 | {0xC9E82CD9F69D6150, 0xDB71E91432B1A24A}, // 1e-302 | |
| 86 | {0xBE311C083A225CD2, 0x892731AC9FAF056E}, // 1e-301 | |
| 87 | {0x6DBD630A48AAF406, 0xAB70FE17C79AC6CA}, // 1e-300 | |
| 88 | {0x092CBBCCDAD5B108, 0xD64D3D9DB981787D}, // 1e-299 | |
| 89 | {0x25BBF56008C58EA5, 0x85F0468293F0EB4E}, // 1e-298 | |
| 90 | {0xAF2AF2B80AF6F24E, 0xA76C582338ED2621}, // 1e-297 | |
| 91 | {0x1AF5AF660DB4AEE1, 0xD1476E2C07286FAA}, // 1e-296 | |
| 92 | {0x50D98D9FC890ED4D, 0x82CCA4DB847945CA}, // 1e-295 | |
| 93 | {0xE50FF107BAB528A0, 0xA37FCE126597973C}, // 1e-294 | |
| 94 | {0x1E53ED49A96272C8, 0xCC5FC196FEFD7D0C}, // 1e-293 | |
| 95 | {0x25E8E89C13BB0F7A, 0xFF77B1FCBEBCDC4F}, // 1e-292 | |
| 96 | {0x77B191618C54E9AC, 0x9FAACF3DF73609B1}, // 1e-291 | |
| 97 | {0xD59DF5B9EF6A2417, 0xC795830D75038C1D}, // 1e-290 | |
| 98 | {0x4B0573286B44AD1D, 0xF97AE3D0D2446F25}, // 1e-289 | |
| 99 | {0x4EE367F9430AEC32, 0x9BECCE62836AC577}, // 1e-288 | |
| 100 | {0x229C41F793CDA73F, 0xC2E801FB244576D5}, // 1e-287 | |
| 101 | {0x6B43527578C1110F, 0xF3A20279ED56D48A}, // 1e-286 | |
| 102 | {0x830A13896B78AAA9, 0x9845418C345644D6}, // 1e-285 | |
| 103 | {0x23CC986BC656D553, 0xBE5691EF416BD60C}, // 1e-284 | |
| 104 | {0x2CBFBE86B7EC8AA8, 0xEDEC366B11C6CB8F}, // 1e-283 | |
| 105 | {0x7BF7D71432F3D6A9, 0x94B3A202EB1C3F39}, // 1e-282 | |
| 106 | {0xDAF5CCD93FB0CC53, 0xB9E08A83A5E34F07}, // 1e-281 | |
| 107 | {0xD1B3400F8F9CFF68, 0xE858AD248F5C22C9}, // 1e-280 | |
| 108 | {0x23100809B9C21FA1, 0x91376C36D99995BE}, // 1e-279 | |
| 109 | {0xABD40A0C2832A78A, 0xB58547448FFFFB2D}, // 1e-278 | |
| 110 | {0x16C90C8F323F516C, 0xE2E69915B3FFF9F9}, // 1e-277 | |
| 111 | {0xAE3DA7D97F6792E3, 0x8DD01FAD907FFC3B}, // 1e-276 | |
| 112 | {0x99CD11CFDF41779C, 0xB1442798F49FFB4A}, // 1e-275 | |
| 113 | {0x40405643D711D583, 0xDD95317F31C7FA1D}, // 1e-274 | |
| 114 | {0x482835EA666B2572, 0x8A7D3EEF7F1CFC52}, // 1e-273 | |
| 115 | {0xDA3243650005EECF, 0xAD1C8EAB5EE43B66}, // 1e-272 | |
| 116 | {0x90BED43E40076A82, 0xD863B256369D4A40}, // 1e-271 | |
| 117 | {0x5A7744A6E804A291, 0x873E4F75E2224E68}, // 1e-270 | |
| 118 | {0x711515D0A205CB36, 0xA90DE3535AAAE202}, // 1e-269 | |
| 119 | {0x0D5A5B44CA873E03, 0xD3515C2831559A83}, // 1e-268 | |
| 120 | {0xE858790AFE9486C2, 0x8412D9991ED58091}, // 1e-267 | |
| 121 | {0x626E974DBE39A872, 0xA5178FFF668AE0B6}, // 1e-266 | |
| 122 | {0xFB0A3D212DC8128F, 0xCE5D73FF402D98E3}, // 1e-265 | |
| 123 | {0x7CE66634BC9D0B99, 0x80FA687F881C7F8E}, // 1e-264 | |
| 124 | {0x1C1FFFC1EBC44E80, 0xA139029F6A239F72}, // 1e-263 | |
| 125 | {0xA327FFB266B56220, 0xC987434744AC874E}, // 1e-262 | |
| 126 | {0x4BF1FF9F0062BAA8, 0xFBE9141915D7A922}, // 1e-261 | |
| 127 | {0x6F773FC3603DB4A9, 0x9D71AC8FADA6C9B5}, // 1e-260 | |
| 128 | {0xCB550FB4384D21D3, 0xC4CE17B399107C22}, // 1e-259 | |
| 129 | {0x7E2A53A146606A48, 0xF6019DA07F549B2B}, // 1e-258 | |
| 130 | {0x2EDA7444CBFC426D, 0x99C102844F94E0FB}, // 1e-257 | |
| 131 | {0xFA911155FEFB5308, 0xC0314325637A1939}, // 1e-256 | |
| 132 | {0x793555AB7EBA27CA, 0xF03D93EEBC589F88}, // 1e-255 | |
| 133 | {0x4BC1558B2F3458DE, 0x96267C7535B763B5}, // 1e-254 | |
| 134 | {0x9EB1AAEDFB016F16, 0xBBB01B9283253CA2}, // 1e-253 | |
| 135 | {0x465E15A979C1CADC, 0xEA9C227723EE8BCB}, // 1e-252 | |
| 136 | {0x0BFACD89EC191EC9, 0x92A1958A7675175F}, // 1e-251 | |
| 137 | {0xCEF980EC671F667B, 0xB749FAED14125D36}, // 1e-250 | |
| 138 | {0x82B7E12780E7401A, 0xE51C79A85916F484}, // 1e-249 | |
| 139 | {0xD1B2ECB8B0908810, 0x8F31CC0937AE58D2}, // 1e-248 | |
| 140 | {0x861FA7E6DCB4AA15, 0xB2FE3F0B8599EF07}, // 1e-247 | |
| 141 | {0x67A791E093E1D49A, 0xDFBDCECE67006AC9}, // 1e-246 | |
| 142 | {0xE0C8BB2C5C6D24E0, 0x8BD6A141006042BD}, // 1e-245 | |
| 143 | {0x58FAE9F773886E18, 0xAECC49914078536D}, // 1e-244 | |
| 144 | {0xAF39A475506A899E, 0xDA7F5BF590966848}, // 1e-243 | |
| 145 | {0x6D8406C952429603, 0x888F99797A5E012D}, // 1e-242 | |
| 146 | {0xC8E5087BA6D33B83, 0xAAB37FD7D8F58178}, // 1e-241 | |
| 147 | {0xFB1E4A9A90880A64, 0xD5605FCDCF32E1D6}, // 1e-240 | |
| 148 | {0x5CF2EEA09A55067F, 0x855C3BE0A17FCD26}, // 1e-239 | |
| 149 | {0xF42FAA48C0EA481E, 0xA6B34AD8C9DFC06F}, // 1e-238 | |
| 150 | {0xF13B94DAF124DA26, 0xD0601D8EFC57B08B}, // 1e-237 | |
| 151 | {0x76C53D08D6B70858, 0x823C12795DB6CE57}, // 1e-236 | |
| 152 | {0x54768C4B0C64CA6E, 0xA2CB1717B52481ED}, // 1e-235 | |
| 153 | {0xA9942F5DCF7DFD09, 0xCB7DDCDDA26DA268}, // 1e-234 | |
| 154 | {0xD3F93B35435D7C4C, 0xFE5D54150B090B02}, // 1e-233 | |
| 155 | {0xC47BC5014A1A6DAF, 0x9EFA548D26E5A6E1}, // 1e-232 | |
| 156 | {0x359AB6419CA1091B, 0xC6B8E9B0709F109A}, // 1e-231 | |
| 157 | {0xC30163D203C94B62, 0xF867241C8CC6D4C0}, // 1e-230 | |
| 158 | {0x79E0DE63425DCF1D, 0x9B407691D7FC44F8}, // 1e-229 | |
| 159 | {0x985915FC12F542E4, 0xC21094364DFB5636}, // 1e-228 | |
| 160 | {0x3E6F5B7B17B2939D, 0xF294B943E17A2BC4}, // 1e-227 | |
| 161 | {0xA705992CEECF9C42, 0x979CF3CA6CEC5B5A}, // 1e-226 | |
| 162 | {0x50C6FF782A838353, 0xBD8430BD08277231}, // 1e-225 | |
| 163 | {0xA4F8BF5635246428, 0xECE53CEC4A314EBD}, // 1e-224 | |
| 164 | {0x871B7795E136BE99, 0x940F4613AE5ED136}, // 1e-223 | |
| 165 | {0x28E2557B59846E3F, 0xB913179899F68584}, // 1e-222 | |
| 166 | {0x331AEADA2FE589CF, 0xE757DD7EC07426E5}, // 1e-221 | |
| 167 | {0x3FF0D2C85DEF7621, 0x9096EA6F3848984F}, // 1e-220 | |
| 168 | {0x0FED077A756B53A9, 0xB4BCA50B065ABE63}, // 1e-219 | |
| 169 | {0xD3E8495912C62894, 0xE1EBCE4DC7F16DFB}, // 1e-218 | |
| 170 | {0x64712DD7ABBBD95C, 0x8D3360F09CF6E4BD}, // 1e-217 | |
| 171 | {0xBD8D794D96AACFB3, 0xB080392CC4349DEC}, // 1e-216 | |
| 172 | {0xECF0D7A0FC5583A0, 0xDCA04777F541C567}, // 1e-215 | |
| 173 | {0xF41686C49DB57244, 0x89E42CAAF9491B60}, // 1e-214 | |
| 174 | {0x311C2875C522CED5, 0xAC5D37D5B79B6239}, // 1e-213 | |
| 175 | {0x7D633293366B828B, 0xD77485CB25823AC7}, // 1e-212 | |
| 176 | {0xAE5DFF9C02033197, 0x86A8D39EF77164BC}, // 1e-211 | |
| 177 | {0xD9F57F830283FDFC, 0xA8530886B54DBDEB}, // 1e-210 | |
| 178 | {0xD072DF63C324FD7B, 0xD267CAA862A12D66}, // 1e-209 | |
| 179 | {0x4247CB9E59F71E6D, 0x8380DEA93DA4BC60}, // 1e-208 | |
| 180 | {0x52D9BE85F074E608, 0xA46116538D0DEB78}, // 1e-207 | |
| 181 | {0x67902E276C921F8B, 0xCD795BE870516656}, // 1e-206 | |
| 182 | {0x00BA1CD8A3DB53B6, 0x806BD9714632DFF6}, // 1e-205 | |
| 183 | {0x80E8A40ECCD228A4, 0xA086CFCD97BF97F3}, // 1e-204 | |
| 184 | {0x6122CD128006B2CD, 0xC8A883C0FDAF7DF0}, // 1e-203 | |
| 185 | {0x796B805720085F81, 0xFAD2A4B13D1B5D6C}, // 1e-202 | |
| 186 | {0xCBE3303674053BB0, 0x9CC3A6EEC6311A63}, // 1e-201 | |
| 187 | {0xBEDBFC4411068A9C, 0xC3F490AA77BD60FC}, // 1e-200 | |
| 188 | {0xEE92FB5515482D44, 0xF4F1B4D515ACB93B}, // 1e-199 | |
| 189 | {0x751BDD152D4D1C4A, 0x991711052D8BF3C5}, // 1e-198 | |
| 190 | {0xD262D45A78A0635D, 0xBF5CD54678EEF0B6}, // 1e-197 | |
| 191 | {0x86FB897116C87C34, 0xEF340A98172AACE4}, // 1e-196 | |
| 192 | {0xD45D35E6AE3D4DA0, 0x9580869F0E7AAC0E}, // 1e-195 | |
| 193 | {0x8974836059CCA109, 0xBAE0A846D2195712}, // 1e-194 | |
| 194 | {0x2BD1A438703FC94B, 0xE998D258869FACD7}, // 1e-193 | |
| 195 | {0x7B6306A34627DDCF, 0x91FF83775423CC06}, // 1e-192 | |
| 196 | {0x1A3BC84C17B1D542, 0xB67F6455292CBF08}, // 1e-191 | |
| 197 | {0x20CABA5F1D9E4A93, 0xE41F3D6A7377EECA}, // 1e-190 | |
| 198 | {0x547EB47B7282EE9C, 0x8E938662882AF53E}, // 1e-189 | |
| 199 | {0xE99E619A4F23AA43, 0xB23867FB2A35B28D}, // 1e-188 | |
| 200 | {0x6405FA00E2EC94D4, 0xDEC681F9F4C31F31}, // 1e-187 | |
| 201 | {0xDE83BC408DD3DD04, 0x8B3C113C38F9F37E}, // 1e-186 | |
| 202 | {0x9624AB50B148D445, 0xAE0B158B4738705E}, // 1e-185 | |
| 203 | {0x3BADD624DD9B0957, 0xD98DDAEE19068C76}, // 1e-184 | |
| 204 | {0xE54CA5D70A80E5D6, 0x87F8A8D4CFA417C9}, // 1e-183 | |
| 205 | {0x5E9FCF4CCD211F4C, 0xA9F6D30A038D1DBC}, // 1e-182 | |
| 206 | {0x7647C3200069671F, 0xD47487CC8470652B}, // 1e-181 | |
| 207 | {0x29ECD9F40041E073, 0x84C8D4DFD2C63F3B}, // 1e-180 | |
| 208 | {0xF468107100525890, 0xA5FB0A17C777CF09}, // 1e-179 | |
| 209 | {0x7182148D4066EEB4, 0xCF79CC9DB955C2CC}, // 1e-178 | |
| 210 | {0xC6F14CD848405530, 0x81AC1FE293D599BF}, // 1e-177 | |
| 211 | {0xB8ADA00E5A506A7C, 0xA21727DB38CB002F}, // 1e-176 | |
| 212 | {0xA6D90811F0E4851C, 0xCA9CF1D206FDC03B}, // 1e-175 | |
| 213 | {0x908F4A166D1DA663, 0xFD442E4688BD304A}, // 1e-174 | |
| 214 | {0x9A598E4E043287FE, 0x9E4A9CEC15763E2E}, // 1e-173 | |
| 215 | {0x40EFF1E1853F29FD, 0xC5DD44271AD3CDBA}, // 1e-172 | |
| 216 | {0xD12BEE59E68EF47C, 0xF7549530E188C128}, // 1e-171 | |
| 217 | {0x82BB74F8301958CE, 0x9A94DD3E8CF578B9}, // 1e-170 | |
| 218 | {0xE36A52363C1FAF01, 0xC13A148E3032D6E7}, // 1e-169 | |
| 219 | {0xDC44E6C3CB279AC1, 0xF18899B1BC3F8CA1}, // 1e-168 | |
| 220 | {0x29AB103A5EF8C0B9, 0x96F5600F15A7B7E5}, // 1e-167 | |
| 221 | {0x7415D448F6B6F0E7, 0xBCB2B812DB11A5DE}, // 1e-166 | |
| 222 | {0x111B495B3464AD21, 0xEBDF661791D60F56}, // 1e-165 | |
| 223 | {0xCAB10DD900BEEC34, 0x936B9FCEBB25C995}, // 1e-164 | |
| 224 | {0x3D5D514F40EEA742, 0xB84687C269EF3BFB}, // 1e-163 | |
| 225 | {0x0CB4A5A3112A5112, 0xE65829B3046B0AFA}, // 1e-162 | |
| 226 | {0x47F0E785EABA72AB, 0x8FF71A0FE2C2E6DC}, // 1e-161 | |
| 227 | {0x59ED216765690F56, 0xB3F4E093DB73A093}, // 1e-160 | |
| 228 | {0x306869C13EC3532C, 0xE0F218B8D25088B8}, // 1e-159 | |
| 229 | {0x1E414218C73A13FB, 0x8C974F7383725573}, // 1e-158 | |
| 230 | {0xE5D1929EF90898FA, 0xAFBD2350644EEACF}, // 1e-157 | |
| 231 | {0xDF45F746B74ABF39, 0xDBAC6C247D62A583}, // 1e-156 | |
| 232 | {0x6B8BBA8C328EB783, 0x894BC396CE5DA772}, // 1e-155 | |
| 233 | {0x066EA92F3F326564, 0xAB9EB47C81F5114F}, // 1e-154 | |
| 234 | {0xC80A537B0EFEFEBD, 0xD686619BA27255A2}, // 1e-153 | |
| 235 | {0xBD06742CE95F5F36, 0x8613FD0145877585}, // 1e-152 | |
| 236 | {0x2C48113823B73704, 0xA798FC4196E952E7}, // 1e-151 | |
| 237 | {0xF75A15862CA504C5, 0xD17F3B51FCA3A7A0}, // 1e-150 | |
| 238 | {0x9A984D73DBE722FB, 0x82EF85133DE648C4}, // 1e-149 | |
| 239 | {0xC13E60D0D2E0EBBA, 0xA3AB66580D5FDAF5}, // 1e-148 | |
| 240 | {0x318DF905079926A8, 0xCC963FEE10B7D1B3}, // 1e-147 | |
| 241 | {0xFDF17746497F7052, 0xFFBBCFE994E5C61F}, // 1e-146 | |
| 242 | {0xFEB6EA8BEDEFA633, 0x9FD561F1FD0F9BD3}, // 1e-145 | |
| 243 | {0xFE64A52EE96B8FC0, 0xC7CABA6E7C5382C8}, // 1e-144 | |
| 244 | {0x3DFDCE7AA3C673B0, 0xF9BD690A1B68637B}, // 1e-143 | |
| 245 | {0x06BEA10CA65C084E, 0x9C1661A651213E2D}, // 1e-142 | |
| 246 | {0x486E494FCFF30A62, 0xC31BFA0FE5698DB8}, // 1e-141 | |
| 247 | {0x5A89DBA3C3EFCCFA, 0xF3E2F893DEC3F126}, // 1e-140 | |
| 248 | {0xF89629465A75E01C, 0x986DDB5C6B3A76B7}, // 1e-139 | |
| 249 | {0xF6BBB397F1135823, 0xBE89523386091465}, // 1e-138 | |
| 250 | {0x746AA07DED582E2C, 0xEE2BA6C0678B597F}, // 1e-137 | |
| 251 | {0xA8C2A44EB4571CDC, 0x94DB483840B717EF}, // 1e-136 | |
| 252 | {0x92F34D62616CE413, 0xBA121A4650E4DDEB}, // 1e-135 | |
| 253 | {0x77B020BAF9C81D17, 0xE896A0D7E51E1566}, // 1e-134 | |
| 254 | {0x0ACE1474DC1D122E, 0x915E2486EF32CD60}, // 1e-133 | |
| 255 | {0x0D819992132456BA, 0xB5B5ADA8AAFF80B8}, // 1e-132 | |
| 256 | {0x10E1FFF697ED6C69, 0xE3231912D5BF60E6}, // 1e-131 | |
| 257 | {0xCA8D3FFA1EF463C1, 0x8DF5EFABC5979C8F}, // 1e-130 | |
| 258 | {0xBD308FF8A6B17CB2, 0xB1736B96B6FD83B3}, // 1e-129 | |
| 259 | {0xAC7CB3F6D05DDBDE, 0xDDD0467C64BCE4A0}, // 1e-128 | |
| 260 | {0x6BCDF07A423AA96B, 0x8AA22C0DBEF60EE4}, // 1e-127 | |
| 261 | {0x86C16C98D2C953C6, 0xAD4AB7112EB3929D}, // 1e-126 | |
| 262 | {0xE871C7BF077BA8B7, 0xD89D64D57A607744}, // 1e-125 | |
| 263 | {0x11471CD764AD4972, 0x87625F056C7C4A8B}, // 1e-124 | |
| 264 | {0xD598E40D3DD89BCF, 0xA93AF6C6C79B5D2D}, // 1e-123 | |
| 265 | {0x4AFF1D108D4EC2C3, 0xD389B47879823479}, // 1e-122 | |
| 266 | {0xCEDF722A585139BA, 0x843610CB4BF160CB}, // 1e-121 | |
| 267 | {0xC2974EB4EE658828, 0xA54394FE1EEDB8FE}, // 1e-120 | |
| 268 | {0x733D226229FEEA32, 0xCE947A3DA6A9273E}, // 1e-119 | |
| 269 | {0x0806357D5A3F525F, 0x811CCC668829B887}, // 1e-118 | |
| 270 | {0xCA07C2DCB0CF26F7, 0xA163FF802A3426A8}, // 1e-117 | |
| 271 | {0xFC89B393DD02F0B5, 0xC9BCFF6034C13052}, // 1e-116 | |
| 272 | {0xBBAC2078D443ACE2, 0xFC2C3F3841F17C67}, // 1e-115 | |
| 273 | {0xD54B944B84AA4C0D, 0x9D9BA7832936EDC0}, // 1e-114 | |
| 274 | {0x0A9E795E65D4DF11, 0xC5029163F384A931}, // 1e-113 | |
| 275 | {0x4D4617B5FF4A16D5, 0xF64335BCF065D37D}, // 1e-112 | |
| 276 | {0x504BCED1BF8E4E45, 0x99EA0196163FA42E}, // 1e-111 | |
| 277 | {0xE45EC2862F71E1D6, 0xC06481FB9BCF8D39}, // 1e-110 | |
| 278 | {0x5D767327BB4E5A4C, 0xF07DA27A82C37088}, // 1e-109 | |
| 279 | {0x3A6A07F8D510F86F, 0x964E858C91BA2655}, // 1e-108 | |
| 280 | {0x890489F70A55368B, 0xBBE226EFB628AFEA}, // 1e-107 | |
| 281 | {0x2B45AC74CCEA842E, 0xEADAB0ABA3B2DBE5}, // 1e-106 | |
| 282 | {0x3B0B8BC90012929D, 0x92C8AE6B464FC96F}, // 1e-105 | |
| 283 | {0x09CE6EBB40173744, 0xB77ADA0617E3BBCB}, // 1e-104 | |
| 284 | {0xCC420A6A101D0515, 0xE55990879DDCAABD}, // 1e-103 | |
| 285 | {0x9FA946824A12232D, 0x8F57FA54C2A9EAB6}, // 1e-102 | |
| 286 | {0x47939822DC96ABF9, 0xB32DF8E9F3546564}, // 1e-101 | |
| 287 | {0x59787E2B93BC56F7, 0xDFF9772470297EBD}, // 1e-100 | |
| 288 | {0x57EB4EDB3C55B65A, 0x8BFBEA76C619EF36}, // 1e-99 | |
| 289 | {0xEDE622920B6B23F1, 0xAEFAE51477A06B03}, // 1e-98 | |
| 290 | {0xE95FAB368E45ECED, 0xDAB99E59958885C4}, // 1e-97 | |
| 291 | {0x11DBCB0218EBB414, 0x88B402F7FD75539B}, // 1e-96 | |
| 292 | {0xD652BDC29F26A119, 0xAAE103B5FCD2A881}, // 1e-95 | |
| 293 | {0x4BE76D3346F0495F, 0xD59944A37C0752A2}, // 1e-94 | |
| 294 | {0x6F70A4400C562DDB, 0x857FCAE62D8493A5}, // 1e-93 | |
| 295 | {0xCB4CCD500F6BB952, 0xA6DFBD9FB8E5B88E}, // 1e-92 | |
| 296 | {0x7E2000A41346A7A7, 0xD097AD07A71F26B2}, // 1e-91 | |
| 297 | {0x8ED400668C0C28C8, 0x825ECC24C873782F}, // 1e-90 | |
| 298 | {0x728900802F0F32FA, 0xA2F67F2DFA90563B}, // 1e-89 | |
| 299 | {0x4F2B40A03AD2FFB9, 0xCBB41EF979346BCA}, // 1e-88 | |
| 300 | {0xE2F610C84987BFA8, 0xFEA126B7D78186BC}, // 1e-87 | |
| 301 | {0x0DD9CA7D2DF4D7C9, 0x9F24B832E6B0F436}, // 1e-86 | |
| 302 | {0x91503D1C79720DBB, 0xC6EDE63FA05D3143}, // 1e-85 | |
| 303 | {0x75A44C6397CE912A, 0xF8A95FCF88747D94}, // 1e-84 | |
| 304 | {0xC986AFBE3EE11ABA, 0x9B69DBE1B548CE7C}, // 1e-83 | |
| 305 | {0xFBE85BADCE996168, 0xC24452DA229B021B}, // 1e-82 | |
| 306 | {0xFAE27299423FB9C3, 0xF2D56790AB41C2A2}, // 1e-81 | |
| 307 | {0xDCCD879FC967D41A, 0x97C560BA6B0919A5}, // 1e-80 | |
| 308 | {0x5400E987BBC1C920, 0xBDB6B8E905CB600F}, // 1e-79 | |
| 309 | {0x290123E9AAB23B68, 0xED246723473E3813}, // 1e-78 | |
| 310 | {0xF9A0B6720AAF6521, 0x9436C0760C86E30B}, // 1e-77 | |
| 311 | {0xF808E40E8D5B3E69, 0xB94470938FA89BCE}, // 1e-76 | |
| 312 | {0xB60B1D1230B20E04, 0xE7958CB87392C2C2}, // 1e-75 | |
| 313 | {0xB1C6F22B5E6F48C2, 0x90BD77F3483BB9B9}, // 1e-74 | |
| 314 | {0x1E38AEB6360B1AF3, 0xB4ECD5F01A4AA828}, // 1e-73 | |
| 315 | {0x25C6DA63C38DE1B0, 0xE2280B6C20DD5232}, // 1e-72 | |
| 316 | {0x579C487E5A38AD0E, 0x8D590723948A535F}, // 1e-71 | |
| 317 | {0x2D835A9DF0C6D851, 0xB0AF48EC79ACE837}, // 1e-70 | |
| 318 | {0xF8E431456CF88E65, 0xDCDB1B2798182244}, // 1e-69 | |
| 319 | {0x1B8E9ECB641B58FF, 0x8A08F0F8BF0F156B}, // 1e-68 | |
| 320 | {0xE272467E3D222F3F, 0xAC8B2D36EED2DAC5}, // 1e-67 | |
| 321 | {0x5B0ED81DCC6ABB0F, 0xD7ADF884AA879177}, // 1e-66 | |
| 322 | {0x98E947129FC2B4E9, 0x86CCBB52EA94BAEA}, // 1e-65 | |
| 323 | {0x3F2398D747B36224, 0xA87FEA27A539E9A5}, // 1e-64 | |
| 324 | {0x8EEC7F0D19A03AAD, 0xD29FE4B18E88640E}, // 1e-63 | |
| 325 | {0x1953CF68300424AC, 0x83A3EEEEF9153E89}, // 1e-62 | |
| 326 | {0x5FA8C3423C052DD7, 0xA48CEAAAB75A8E2B}, // 1e-61 | |
| 327 | {0x3792F412CB06794D, 0xCDB02555653131B6}, // 1e-60 | |
| 328 | {0xE2BBD88BBEE40BD0, 0x808E17555F3EBF11}, // 1e-59 | |
| 329 | {0x5B6ACEAEAE9D0EC4, 0xA0B19D2AB70E6ED6}, // 1e-58 | |
| 330 | {0xF245825A5A445275, 0xC8DE047564D20A8B}, // 1e-57 | |
| 331 | {0xEED6E2F0F0D56712, 0xFB158592BE068D2E}, // 1e-56 | |
| 332 | {0x55464DD69685606B, 0x9CED737BB6C4183D}, // 1e-55 | |
| 333 | {0xAA97E14C3C26B886, 0xC428D05AA4751E4C}, // 1e-54 | |
| 334 | {0xD53DD99F4B3066A8, 0xF53304714D9265DF}, // 1e-53 | |
| 335 | {0xE546A8038EFE4029, 0x993FE2C6D07B7FAB}, // 1e-52 | |
| 336 | {0xDE98520472BDD033, 0xBF8FDB78849A5F96}, // 1e-51 | |
| 337 | {0x963E66858F6D4440, 0xEF73D256A5C0F77C}, // 1e-50 | |
| 338 | {0xDDE7001379A44AA8, 0x95A8637627989AAD}, // 1e-49 | |
| 339 | {0x5560C018580D5D52, 0xBB127C53B17EC159}, // 1e-48 | |
| 340 | {0xAAB8F01E6E10B4A6, 0xE9D71B689DDE71AF}, // 1e-47 | |
| 341 | {0xCAB3961304CA70E8, 0x9226712162AB070D}, // 1e-46 | |
| 342 | {0x3D607B97C5FD0D22, 0xB6B00D69BB55C8D1}, // 1e-45 | |
| 343 | {0x8CB89A7DB77C506A, 0xE45C10C42A2B3B05}, // 1e-44 | |
| 344 | {0x77F3608E92ADB242, 0x8EB98A7A9A5B04E3}, // 1e-43 | |
| 345 | {0x55F038B237591ED3, 0xB267ED1940F1C61C}, // 1e-42 | |
| 346 | {0x6B6C46DEC52F6688, 0xDF01E85F912E37A3}, // 1e-41 | |
| 347 | {0x2323AC4B3B3DA015, 0x8B61313BBABCE2C6}, // 1e-40 | |
| 348 | {0xABEC975E0A0D081A, 0xAE397D8AA96C1B77}, // 1e-39 | |
| 349 | {0x96E7BD358C904A21, 0xD9C7DCED53C72255}, // 1e-38 | |
| 350 | {0x7E50D64177DA2E54, 0x881CEA14545C7575}, // 1e-37 | |
| 351 | {0xDDE50BD1D5D0B9E9, 0xAA242499697392D2}, // 1e-36 | |
| 352 | {0x955E4EC64B44E864, 0xD4AD2DBFC3D07787}, // 1e-35 | |
| 353 | {0xBD5AF13BEF0B113E, 0x84EC3C97DA624AB4}, // 1e-34 | |
| 354 | {0xECB1AD8AEACDD58E, 0xA6274BBDD0FADD61}, // 1e-33 | |
| 355 | {0x67DE18EDA5814AF2, 0xCFB11EAD453994BA}, // 1e-32 | |
| 356 | {0x80EACF948770CED7, 0x81CEB32C4B43FCF4}, // 1e-31 | |
| 357 | {0xA1258379A94D028D, 0xA2425FF75E14FC31}, // 1e-30 | |
| 358 | {0x096EE45813A04330, 0xCAD2F7F5359A3B3E}, // 1e-29 | |
| 359 | {0x8BCA9D6E188853FC, 0xFD87B5F28300CA0D}, // 1e-28 | |
| 360 | {0x775EA264CF55347D, 0x9E74D1B791E07E48}, // 1e-27 | |
| 361 | {0x95364AFE032A819D, 0xC612062576589DDA}, // 1e-26 | |
| 362 | {0x3A83DDBD83F52204, 0xF79687AED3EEC551}, // 1e-25 | |
| 363 | {0xC4926A9672793542, 0x9ABE14CD44753B52}, // 1e-24 | |
| 364 | {0x75B7053C0F178293, 0xC16D9A0095928A27}, // 1e-23 | |
| 365 | {0x5324C68B12DD6338, 0xF1C90080BAF72CB1}, // 1e-22 | |
| 366 | {0xD3F6FC16EBCA5E03, 0x971DA05074DA7BEE}, // 1e-21 | |
| 367 | {0x88F4BB1CA6BCF584, 0xBCE5086492111AEA}, // 1e-20 | |
| 368 | {0x2B31E9E3D06C32E5, 0xEC1E4A7DB69561A5}, // 1e-19 | |
| 369 | {0x3AFF322E62439FCF, 0x9392EE8E921D5D07}, // 1e-18 | |
| 370 | {0x09BEFEB9FAD487C2, 0xB877AA3236A4B449}, // 1e-17 | |
| 371 | {0x4C2EBE687989A9B3, 0xE69594BEC44DE15B}, // 1e-16 | |
| 372 | {0x0F9D37014BF60A10, 0x901D7CF73AB0ACD9}, // 1e-15 | |
| 373 | {0x538484C19EF38C94, 0xB424DC35095CD80F}, // 1e-14 | |
| 374 | {0x2865A5F206B06FB9, 0xE12E13424BB40E13}, // 1e-13 | |
| 375 | {0xF93F87B7442E45D3, 0x8CBCCC096F5088CB}, // 1e-12 | |
| 376 | {0xF78F69A51539D748, 0xAFEBFF0BCB24AAFE}, // 1e-11 | |
| 377 | {0xB573440E5A884D1B, 0xDBE6FECEBDEDD5BE}, // 1e-10 | |
| 378 | {0x31680A88F8953030, 0x89705F4136B4A597}, // 1e-9 | |
| 379 | {0xFDC20D2B36BA7C3D, 0xABCC77118461CEFC}, // 1e-8 | |
| 380 | {0x3D32907604691B4C, 0xD6BF94D5E57A42BC}, // 1e-7 | |
| 381 | {0xA63F9A49C2C1B10F, 0x8637BD05AF6C69B5}, // 1e-6 | |
| 382 | {0x0FCF80DC33721D53, 0xA7C5AC471B478423}, // 1e-5 | |
| 383 | {0xD3C36113404EA4A8, 0xD1B71758E219652B}, // 1e-4 | |
| 384 | {0x645A1CAC083126E9, 0x83126E978D4FDF3B}, // 1e-3 | |
| 385 | {0x3D70A3D70A3D70A3, 0xA3D70A3D70A3D70A}, // 1e-2 | |
| 386 | {0xCCCCCCCCCCCCCCCC, 0xCCCCCCCCCCCCCCCC}, // 1e-1 | |
| 387 | {0x0000000000000000, 0x8000000000000000}, // 1e0 | |
| 388 | {0x0000000000000000, 0xA000000000000000}, // 1e1 | |
| 389 | {0x0000000000000000, 0xC800000000000000}, // 1e2 | |
| 390 | {0x0000000000000000, 0xFA00000000000000}, // 1e3 | |
| 391 | {0x0000000000000000, 0x9C40000000000000}, // 1e4 | |
| 392 | {0x0000000000000000, 0xC350000000000000}, // 1e5 | |
| 393 | {0x0000000000000000, 0xF424000000000000}, // 1e6 | |
| 394 | {0x0000000000000000, 0x9896800000000000}, // 1e7 | |
| 395 | {0x0000000000000000, 0xBEBC200000000000}, // 1e8 | |
| 396 | {0x0000000000000000, 0xEE6B280000000000}, // 1e9 | |
| 397 | {0x0000000000000000, 0x9502F90000000000}, // 1e10 | |
| 398 | {0x0000000000000000, 0xBA43B74000000000}, // 1e11 | |
| 399 | {0x0000000000000000, 0xE8D4A51000000000}, // 1e12 | |
| 400 | {0x0000000000000000, 0x9184E72A00000000}, // 1e13 | |
| 401 | {0x0000000000000000, 0xB5E620F480000000}, // 1e14 | |
| 402 | {0x0000000000000000, 0xE35FA931A0000000}, // 1e15 | |
| 403 | {0x0000000000000000, 0x8E1BC9BF04000000}, // 1e16 | |
| 404 | {0x0000000000000000, 0xB1A2BC2EC5000000}, // 1e17 | |
| 405 | {0x0000000000000000, 0xDE0B6B3A76400000}, // 1e18 | |
| 406 | {0x0000000000000000, 0x8AC7230489E80000}, // 1e19 | |
| 407 | {0x0000000000000000, 0xAD78EBC5AC620000}, // 1e20 | |
| 408 | {0x0000000000000000, 0xD8D726B7177A8000}, // 1e21 | |
| 409 | {0x0000000000000000, 0x878678326EAC9000}, // 1e22 | |
| 410 | {0x0000000000000000, 0xA968163F0A57B400}, // 1e23 | |
| 411 | {0x0000000000000000, 0xD3C21BCECCEDA100}, // 1e24 | |
| 412 | {0x0000000000000000, 0x84595161401484A0}, // 1e25 | |
| 413 | {0x0000000000000000, 0xA56FA5B99019A5C8}, // 1e26 | |
| 414 | {0x0000000000000000, 0xCECB8F27F4200F3A}, // 1e27 | |
| 415 | {0x4000000000000000, 0x813F3978F8940984}, // 1e28 | |
| 416 | {0x5000000000000000, 0xA18F07D736B90BE5}, // 1e29 | |
| 417 | {0xA400000000000000, 0xC9F2C9CD04674EDE}, // 1e30 | |
| 418 | {0x4D00000000000000, 0xFC6F7C4045812296}, // 1e31 | |
| 419 | {0xF020000000000000, 0x9DC5ADA82B70B59D}, // 1e32 | |
| 420 | {0x6C28000000000000, 0xC5371912364CE305}, // 1e33 | |
| 421 | {0xC732000000000000, 0xF684DF56C3E01BC6}, // 1e34 | |
| 422 | {0x3C7F400000000000, 0x9A130B963A6C115C}, // 1e35 | |
| 423 | {0x4B9F100000000000, 0xC097CE7BC90715B3}, // 1e36 | |
| 424 | {0x1E86D40000000000, 0xF0BDC21ABB48DB20}, // 1e37 | |
| 425 | {0x1314448000000000, 0x96769950B50D88F4}, // 1e38 | |
| 426 | {0x17D955A000000000, 0xBC143FA4E250EB31}, // 1e39 | |
| 427 | {0x5DCFAB0800000000, 0xEB194F8E1AE525FD}, // 1e40 | |
| 428 | {0x5AA1CAE500000000, 0x92EFD1B8D0CF37BE}, // 1e41 | |
| 429 | {0xF14A3D9E40000000, 0xB7ABC627050305AD}, // 1e42 | |
| 430 | {0x6D9CCD05D0000000, 0xE596B7B0C643C719}, // 1e43 | |
| 431 | {0xE4820023A2000000, 0x8F7E32CE7BEA5C6F}, // 1e44 | |
| 432 | {0xDDA2802C8A800000, 0xB35DBF821AE4F38B}, // 1e45 | |
| 433 | {0xD50B2037AD200000, 0xE0352F62A19E306E}, // 1e46 | |
| 434 | {0x4526F422CC340000, 0x8C213D9DA502DE45}, // 1e47 | |
| 435 | {0x9670B12B7F410000, 0xAF298D050E4395D6}, // 1e48 | |
| 436 | {0x3C0CDD765F114000, 0xDAF3F04651D47B4C}, // 1e49 | |
| 437 | {0xA5880A69FB6AC800, 0x88D8762BF324CD0F}, // 1e50 | |
| 438 | {0x8EEA0D047A457A00, 0xAB0E93B6EFEE0053}, // 1e51 | |
| 439 | {0x72A4904598D6D880, 0xD5D238A4ABE98068}, // 1e52 | |
| 440 | {0x47A6DA2B7F864750, 0x85A36366EB71F041}, // 1e53 | |
| 441 | {0x999090B65F67D924, 0xA70C3C40A64E6C51}, // 1e54 | |
| 442 | {0xFFF4B4E3F741CF6D, 0xD0CF4B50CFE20765}, // 1e55 | |
| 443 | {0xBFF8F10E7A8921A4, 0x82818F1281ED449F}, // 1e56 | |
| 444 | {0xAFF72D52192B6A0D, 0xA321F2D7226895C7}, // 1e57 | |
| 445 | {0x9BF4F8A69F764490, 0xCBEA6F8CEB02BB39}, // 1e58 | |
| 446 | {0x02F236D04753D5B4, 0xFEE50B7025C36A08}, // 1e59 | |
| 447 | {0x01D762422C946590, 0x9F4F2726179A2245}, // 1e60 | |
| 448 | {0x424D3AD2B7B97EF5, 0xC722F0EF9D80AAD6}, // 1e61 | |
| 449 | {0xD2E0898765A7DEB2, 0xF8EBAD2B84E0D58B}, // 1e62 | |
| 450 | {0x63CC55F49F88EB2F, 0x9B934C3B330C8577}, // 1e63 | |
| 451 | {0x3CBF6B71C76B25FB, 0xC2781F49FFCFA6D5}, // 1e64 | |
| 452 | {0x8BEF464E3945EF7A, 0xF316271C7FC3908A}, // 1e65 | |
| 453 | {0x97758BF0E3CBB5AC, 0x97EDD871CFDA3A56}, // 1e66 | |
| 454 | {0x3D52EEED1CBEA317, 0xBDE94E8E43D0C8EC}, // 1e67 | |
| 455 | {0x4CA7AAA863EE4BDD, 0xED63A231D4C4FB27}, // 1e68 | |
| 456 | {0x8FE8CAA93E74EF6A, 0x945E455F24FB1CF8}, // 1e69 | |
| 457 | {0xB3E2FD538E122B44, 0xB975D6B6EE39E436}, // 1e70 | |
| 458 | {0x60DBBCA87196B616, 0xE7D34C64A9C85D44}, // 1e71 | |
| 459 | {0xBC8955E946FE31CD, 0x90E40FBEEA1D3A4A}, // 1e72 | |
| 460 | {0x6BABAB6398BDBE41, 0xB51D13AEA4A488DD}, // 1e73 | |
| 461 | {0xC696963C7EED2DD1, 0xE264589A4DCDAB14}, // 1e74 | |
| 462 | {0xFC1E1DE5CF543CA2, 0x8D7EB76070A08AEC}, // 1e75 | |
| 463 | {0x3B25A55F43294BCB, 0xB0DE65388CC8ADA8}, // 1e76 | |
| 464 | {0x49EF0EB713F39EBE, 0xDD15FE86AFFAD912}, // 1e77 | |
| 465 | {0x6E3569326C784337, 0x8A2DBF142DFCC7AB}, // 1e78 | |
| 466 | {0x49C2C37F07965404, 0xACB92ED9397BF996}, // 1e79 | |
| 467 | {0xDC33745EC97BE906, 0xD7E77A8F87DAF7FB}, // 1e80 | |
| 468 | {0x69A028BB3DED71A3, 0x86F0AC99B4E8DAFD}, // 1e81 | |
| 469 | {0xC40832EA0D68CE0C, 0xA8ACD7C0222311BC}, // 1e82 | |
| 470 | {0xF50A3FA490C30190, 0xD2D80DB02AABD62B}, // 1e83 | |
| 471 | {0x792667C6DA79E0FA, 0x83C7088E1AAB65DB}, // 1e84 | |
| 472 | {0x577001B891185938, 0xA4B8CAB1A1563F52}, // 1e85 | |
| 473 | {0xED4C0226B55E6F86, 0xCDE6FD5E09ABCF26}, // 1e86 | |
| 474 | {0x544F8158315B05B4, 0x80B05E5AC60B6178}, // 1e87 | |
| 475 | {0x696361AE3DB1C721, 0xA0DC75F1778E39D6}, // 1e88 | |
| 476 | {0x03BC3A19CD1E38E9, 0xC913936DD571C84C}, // 1e89 | |
| 477 | {0x04AB48A04065C723, 0xFB5878494ACE3A5F}, // 1e90 | |
| 478 | {0x62EB0D64283F9C76, 0x9D174B2DCEC0E47B}, // 1e91 | |
| 479 | {0x3BA5D0BD324F8394, 0xC45D1DF942711D9A}, // 1e92 | |
| 480 | {0xCA8F44EC7EE36479, 0xF5746577930D6500}, // 1e93 | |
| 481 | {0x7E998B13CF4E1ECB, 0x9968BF6ABBE85F20}, // 1e94 | |
| 482 | {0x9E3FEDD8C321A67E, 0xBFC2EF456AE276E8}, // 1e95 | |
| 483 | {0xC5CFE94EF3EA101E, 0xEFB3AB16C59B14A2}, // 1e96 | |
| 484 | {0xBBA1F1D158724A12, 0x95D04AEE3B80ECE5}, // 1e97 | |
| 485 | {0x2A8A6E45AE8EDC97, 0xBB445DA9CA61281F}, // 1e98 | |
| 486 | {0xF52D09D71A3293BD, 0xEA1575143CF97226}, // 1e99 | |
| 487 | {0x593C2626705F9C56, 0x924D692CA61BE758}, // 1e100 | |
| 488 | {0x6F8B2FB00C77836C, 0xB6E0C377CFA2E12E}, // 1e101 | |
| 489 | {0x0B6DFB9C0F956447, 0xE498F455C38B997A}, // 1e102 | |
| 490 | {0x4724BD4189BD5EAC, 0x8EDF98B59A373FEC}, // 1e103 | |
| 491 | {0x58EDEC91EC2CB657, 0xB2977EE300C50FE7}, // 1e104 | |
| 492 | {0x2F2967B66737E3ED, 0xDF3D5E9BC0F653E1}, // 1e105 | |
| 493 | {0xBD79E0D20082EE74, 0x8B865B215899F46C}, // 1e106 | |
| 494 | {0xECD8590680A3AA11, 0xAE67F1E9AEC07187}, // 1e107 | |
| 495 | {0xE80E6F4820CC9495, 0xDA01EE641A708DE9}, // 1e108 | |
| 496 | {0x3109058D147FDCDD, 0x884134FE908658B2}, // 1e109 | |
| 497 | {0xBD4B46F0599FD415, 0xAA51823E34A7EEDE}, // 1e110 | |
| 498 | {0x6C9E18AC7007C91A, 0xD4E5E2CDC1D1EA96}, // 1e111 | |
| 499 | {0x03E2CF6BC604DDB0, 0x850FADC09923329E}, // 1e112 | |
| 500 | {0x84DB8346B786151C, 0xA6539930BF6BFF45}, // 1e113 | |
| 501 | {0xE612641865679A63, 0xCFE87F7CEF46FF16}, // 1e114 | |
| 502 | {0x4FCB7E8F3F60C07E, 0x81F14FAE158C5F6E}, // 1e115 | |
| 503 | {0xE3BE5E330F38F09D, 0xA26DA3999AEF7749}, // 1e116 | |
| 504 | {0x5CADF5BFD3072CC5, 0xCB090C8001AB551C}, // 1e117 | |
| 505 | {0x73D9732FC7C8F7F6, 0xFDCB4FA002162A63}, // 1e118 | |
| 506 | {0x2867E7FDDCDD9AFA, 0x9E9F11C4014DDA7E}, // 1e119 | |
| 507 | {0xB281E1FD541501B8, 0xC646D63501A1511D}, // 1e120 | |
| 508 | {0x1F225A7CA91A4226, 0xF7D88BC24209A565}, // 1e121 | |
| 509 | {0x3375788DE9B06958, 0x9AE757596946075F}, // 1e122 | |
| 510 | {0x0052D6B1641C83AE, 0xC1A12D2FC3978937}, // 1e123 | |
| 511 | {0xC0678C5DBD23A49A, 0xF209787BB47D6B84}, // 1e124 | |
| 512 | {0xF840B7BA963646E0, 0x9745EB4D50CE6332}, // 1e125 | |
| 513 | {0xB650E5A93BC3D898, 0xBD176620A501FBFF}, // 1e126 | |
| 514 | {0xA3E51F138AB4CEBE, 0xEC5D3FA8CE427AFF}, // 1e127 | |
| 515 | {0xC66F336C36B10137, 0x93BA47C980E98CDF}, // 1e128 | |
| 516 | {0xB80B0047445D4184, 0xB8A8D9BBE123F017}, // 1e129 | |
| 517 | {0xA60DC059157491E5, 0xE6D3102AD96CEC1D}, // 1e130 | |
| 518 | {0x87C89837AD68DB2F, 0x9043EA1AC7E41392}, // 1e131 | |
| 519 | {0x29BABE4598C311FB, 0xB454E4A179DD1877}, // 1e132 | |
| 520 | {0xF4296DD6FEF3D67A, 0xE16A1DC9D8545E94}, // 1e133 | |
| 521 | {0x1899E4A65F58660C, 0x8CE2529E2734BB1D}, // 1e134 | |
| 522 | {0x5EC05DCFF72E7F8F, 0xB01AE745B101E9E4}, // 1e135 | |
| 523 | {0x76707543F4FA1F73, 0xDC21A1171D42645D}, // 1e136 | |
| 524 | {0x6A06494A791C53A8, 0x899504AE72497EBA}, // 1e137 | |
| 525 | {0x0487DB9D17636892, 0xABFA45DA0EDBDE69}, // 1e138 | |
| 526 | {0x45A9D2845D3C42B6, 0xD6F8D7509292D603}, // 1e139 | |
| 527 | {0x0B8A2392BA45A9B2, 0x865B86925B9BC5C2}, // 1e140 | |
| 528 | {0x8E6CAC7768D7141E, 0xA7F26836F282B732}, // 1e141 | |
| 529 | {0x3207D795430CD926, 0xD1EF0244AF2364FF}, // 1e142 | |
| 530 | {0x7F44E6BD49E807B8, 0x8335616AED761F1F}, // 1e143 | |
| 531 | {0x5F16206C9C6209A6, 0xA402B9C5A8D3A6E7}, // 1e144 | |
| 532 | {0x36DBA887C37A8C0F, 0xCD036837130890A1}, // 1e145 | |
| 533 | {0xC2494954DA2C9789, 0x802221226BE55A64}, // 1e146 | |
| 534 | {0xF2DB9BAA10B7BD6C, 0xA02AA96B06DEB0FD}, // 1e147 | |
| 535 | {0x6F92829494E5ACC7, 0xC83553C5C8965D3D}, // 1e148 | |
| 536 | {0xCB772339BA1F17F9, 0xFA42A8B73ABBF48C}, // 1e149 | |
| 537 | {0xFF2A760414536EFB, 0x9C69A97284B578D7}, // 1e150 | |
| 538 | {0xFEF5138519684ABA, 0xC38413CF25E2D70D}, // 1e151 | |
| 539 | {0x7EB258665FC25D69, 0xF46518C2EF5B8CD1}, // 1e152 | |
| 540 | {0xEF2F773FFBD97A61, 0x98BF2F79D5993802}, // 1e153 | |
| 541 | {0xAAFB550FFACFD8FA, 0xBEEEFB584AFF8603}, // 1e154 | |
| 542 | {0x95BA2A53F983CF38, 0xEEAABA2E5DBF6784}, // 1e155 | |
| 543 | {0xDD945A747BF26183, 0x952AB45CFA97A0B2}, // 1e156 | |
| 544 | {0x94F971119AEEF9E4, 0xBA756174393D88DF}, // 1e157 | |
| 545 | {0x7A37CD5601AAB85D, 0xE912B9D1478CEB17}, // 1e158 | |
| 546 | {0xAC62E055C10AB33A, 0x91ABB422CCB812EE}, // 1e159 | |
| 547 | {0x577B986B314D6009, 0xB616A12B7FE617AA}, // 1e160 | |
| 548 | {0xED5A7E85FDA0B80B, 0xE39C49765FDF9D94}, // 1e161 | |
| 549 | {0x14588F13BE847307, 0x8E41ADE9FBEBC27D}, // 1e162 | |
| 550 | {0x596EB2D8AE258FC8, 0xB1D219647AE6B31C}, // 1e163 | |
| 551 | {0x6FCA5F8ED9AEF3BB, 0xDE469FBD99A05FE3}, // 1e164 | |
| 552 | {0x25DE7BB9480D5854, 0x8AEC23D680043BEE}, // 1e165 | |
| 553 | {0xAF561AA79A10AE6A, 0xADA72CCC20054AE9}, // 1e166 | |
| 554 | {0x1B2BA1518094DA04, 0xD910F7FF28069DA4}, // 1e167 | |
| 555 | {0x90FB44D2F05D0842, 0x87AA9AFF79042286}, // 1e168 | |
| 556 | {0x353A1607AC744A53, 0xA99541BF57452B28}, // 1e169 | |
| 557 | {0x42889B8997915CE8, 0xD3FA922F2D1675F2}, // 1e170 | |
| 558 | {0x69956135FEBADA11, 0x847C9B5D7C2E09B7}, // 1e171 | |
| 559 | {0x43FAB9837E699095, 0xA59BC234DB398C25}, // 1e172 | |
| 560 | {0x94F967E45E03F4BB, 0xCF02B2C21207EF2E}, // 1e173 | |
| 561 | {0x1D1BE0EEBAC278F5, 0x8161AFB94B44F57D}, // 1e174 | |
| 562 | {0x6462D92A69731732, 0xA1BA1BA79E1632DC}, // 1e175 | |
| 563 | {0x7D7B8F7503CFDCFE, 0xCA28A291859BBF93}, // 1e176 | |
| 564 | {0x5CDA735244C3D43E, 0xFCB2CB35E702AF78}, // 1e177 | |
| 565 | {0x3A0888136AFA64A7, 0x9DEFBF01B061ADAB}, // 1e178 | |
| 566 | {0x088AAA1845B8FDD0, 0xC56BAEC21C7A1916}, // 1e179 | |
| 567 | {0x8AAD549E57273D45, 0xF6C69A72A3989F5B}, // 1e180 | |
| 568 | {0x36AC54E2F678864B, 0x9A3C2087A63F6399}, // 1e181 | |
| 569 | {0x84576A1BB416A7DD, 0xC0CB28A98FCF3C7F}, // 1e182 | |
| 570 | {0x656D44A2A11C51D5, 0xF0FDF2D3F3C30B9F}, // 1e183 | |
| 571 | {0x9F644AE5A4B1B325, 0x969EB7C47859E743}, // 1e184 | |
| 572 | {0x873D5D9F0DDE1FEE, 0xBC4665B596706114}, // 1e185 | |
| 573 | {0xA90CB506D155A7EA, 0xEB57FF22FC0C7959}, // 1e186 | |
| 574 | {0x09A7F12442D588F2, 0x9316FF75DD87CBD8}, // 1e187 | |
| 575 | {0x0C11ED6D538AEB2F, 0xB7DCBF5354E9BECE}, // 1e188 | |
| 576 | {0x8F1668C8A86DA5FA, 0xE5D3EF282A242E81}, // 1e189 | |
| 577 | {0xF96E017D694487BC, 0x8FA475791A569D10}, // 1e190 | |
| 578 | {0x37C981DCC395A9AC, 0xB38D92D760EC4455}, // 1e191 | |
| 579 | {0x85BBE253F47B1417, 0xE070F78D3927556A}, // 1e192 | |
| 580 | {0x93956D7478CCEC8E, 0x8C469AB843B89562}, // 1e193 | |
| 581 | {0x387AC8D1970027B2, 0xAF58416654A6BABB}, // 1e194 | |
| 582 | {0x06997B05FCC0319E, 0xDB2E51BFE9D0696A}, // 1e195 | |
| 583 | {0x441FECE3BDF81F03, 0x88FCF317F22241E2}, // 1e196 | |
| 584 | {0xD527E81CAD7626C3, 0xAB3C2FDDEEAAD25A}, // 1e197 | |
| 585 | {0x8A71E223D8D3B074, 0xD60B3BD56A5586F1}, // 1e198 | |
| 586 | {0xF6872D5667844E49, 0x85C7056562757456}, // 1e199 | |
| 587 | {0xB428F8AC016561DB, 0xA738C6BEBB12D16C}, // 1e200 | |
| 588 | {0xE13336D701BEBA52, 0xD106F86E69D785C7}, // 1e201 | |
| 589 | {0xECC0024661173473, 0x82A45B450226B39C}, // 1e202 | |
| 590 | {0x27F002D7F95D0190, 0xA34D721642B06084}, // 1e203 | |
| 591 | {0x31EC038DF7B441F4, 0xCC20CE9BD35C78A5}, // 1e204 | |
| 592 | {0x7E67047175A15271, 0xFF290242C83396CE}, // 1e205 | |
| 593 | {0x0F0062C6E984D386, 0x9F79A169BD203E41}, // 1e206 | |
| 594 | {0x52C07B78A3E60868, 0xC75809C42C684DD1}, // 1e207 | |
| 595 | {0xA7709A56CCDF8A82, 0xF92E0C3537826145}, // 1e208 | |
| 596 | {0x88A66076400BB691, 0x9BBCC7A142B17CCB}, // 1e209 | |
| 597 | {0x6ACFF893D00EA435, 0xC2ABF989935DDBFE}, // 1e210 | |
| 598 | {0x0583F6B8C4124D43, 0xF356F7EBF83552FE}, // 1e211 | |
| 599 | {0xC3727A337A8B704A, 0x98165AF37B2153DE}, // 1e212 | |
| 600 | {0x744F18C0592E4C5C, 0xBE1BF1B059E9A8D6}, // 1e213 | |
| 601 | {0x1162DEF06F79DF73, 0xEDA2EE1C7064130C}, // 1e214 | |
| 602 | {0x8ADDCB5645AC2BA8, 0x9485D4D1C63E8BE7}, // 1e215 | |
| 603 | {0x6D953E2BD7173692, 0xB9A74A0637CE2EE1}, // 1e216 | |
| 604 | {0xC8FA8DB6CCDD0437, 0xE8111C87C5C1BA99}, // 1e217 | |
| 605 | {0x1D9C9892400A22A2, 0x910AB1D4DB9914A0}, // 1e218 | |
| 606 | {0x2503BEB6D00CAB4B, 0xB54D5E4A127F59C8}, // 1e219 | |
| 607 | {0x2E44AE64840FD61D, 0xE2A0B5DC971F303A}, // 1e220 | |
| 608 | {0x5CEAECFED289E5D2, 0x8DA471A9DE737E24}, // 1e221 | |
| 609 | {0x7425A83E872C5F47, 0xB10D8E1456105DAD}, // 1e222 | |
| 610 | {0xD12F124E28F77719, 0xDD50F1996B947518}, // 1e223 | |
| 611 | {0x82BD6B70D99AAA6F, 0x8A5296FFE33CC92F}, // 1e224 | |
| 612 | {0x636CC64D1001550B, 0xACE73CBFDC0BFB7B}, // 1e225 | |
| 613 | {0x3C47F7E05401AA4E, 0xD8210BEFD30EFA5A}, // 1e226 | |
| 614 | {0x65ACFAEC34810A71, 0x8714A775E3E95C78}, // 1e227 | |
| 615 | {0x7F1839A741A14D0D, 0xA8D9D1535CE3B396}, // 1e228 | |
| 616 | {0x1EDE48111209A050, 0xD31045A8341CA07C}, // 1e229 | |
| 617 | {0x934AED0AAB460432, 0x83EA2B892091E44D}, // 1e230 | |
| 618 | {0xF81DA84D5617853F, 0xA4E4B66B68B65D60}, // 1e231 | |
| 619 | {0x36251260AB9D668E, 0xCE1DE40642E3F4B9}, // 1e232 | |
| 620 | {0xC1D72B7C6B426019, 0x80D2AE83E9CE78F3}, // 1e233 | |
| 621 | {0xB24CF65B8612F81F, 0xA1075A24E4421730}, // 1e234 | |
| 622 | {0xDEE033F26797B627, 0xC94930AE1D529CFC}, // 1e235 | |
| 623 | {0x169840EF017DA3B1, 0xFB9B7CD9A4A7443C}, // 1e236 | |
| 624 | {0x8E1F289560EE864E, 0x9D412E0806E88AA5}, // 1e237 | |
| 625 | {0xF1A6F2BAB92A27E2, 0xC491798A08A2AD4E}, // 1e238 | |
| 626 | {0xAE10AF696774B1DB, 0xF5B5D7EC8ACB58A2}, // 1e239 | |
| 627 | {0xACCA6DA1E0A8EF29, 0x9991A6F3D6BF1765}, // 1e240 | |
| 628 | {0x17FD090A58D32AF3, 0xBFF610B0CC6EDD3F}, // 1e241 | |
| 629 | {0xDDFC4B4CEF07F5B0, 0xEFF394DCFF8A948E}, // 1e242 | |
| 630 | {0x4ABDAF101564F98E, 0x95F83D0A1FB69CD9}, // 1e243 | |
| 631 | {0x9D6D1AD41ABE37F1, 0xBB764C4CA7A4440F}, // 1e244 | |
| 632 | {0x84C86189216DC5ED, 0xEA53DF5FD18D5513}, // 1e245 | |
| 633 | {0x32FD3CF5B4E49BB4, 0x92746B9BE2F8552C}, // 1e246 | |
| 634 | {0x3FBC8C33221DC2A1, 0xB7118682DBB66A77}, // 1e247 | |
| 635 | {0x0FABAF3FEAA5334A, 0xE4D5E82392A40515}, // 1e248 | |
| 636 | {0x29CB4D87F2A7400E, 0x8F05B1163BA6832D}, // 1e249 | |
| 637 | {0x743E20E9EF511012, 0xB2C71D5BCA9023F8}, // 1e250 | |
| 638 | {0x914DA9246B255416, 0xDF78E4B2BD342CF6}, // 1e251 | |
| 639 | {0x1AD089B6C2F7548E, 0x8BAB8EEFB6409C1A}, // 1e252 | |
| 640 | {0xA184AC2473B529B1, 0xAE9672ABA3D0C320}, // 1e253 | |
| 641 | {0xC9E5D72D90A2741E, 0xDA3C0F568CC4F3E8}, // 1e254 | |
| 642 | {0x7E2FA67C7A658892, 0x8865899617FB1871}, // 1e255 | |
| 643 | {0xDDBB901B98FEEAB7, 0xAA7EEBFB9DF9DE8D}, // 1e256 | |
| 644 | {0x552A74227F3EA565, 0xD51EA6FA85785631}, // 1e257 | |
| 645 | {0xD53A88958F87275F, 0x8533285C936B35DE}, // 1e258 | |
| 646 | {0x8A892ABAF368F137, 0xA67FF273B8460356}, // 1e259 | |
| 647 | {0x2D2B7569B0432D85, 0xD01FEF10A657842C}, // 1e260 | |
| 648 | {0x9C3B29620E29FC73, 0x8213F56A67F6B29B}, // 1e261 | |
| 649 | {0x8349F3BA91B47B8F, 0xA298F2C501F45F42}, // 1e262 | |
| 650 | {0x241C70A936219A73, 0xCB3F2F7642717713}, // 1e263 | |
| 651 | {0xED238CD383AA0110, 0xFE0EFB53D30DD4D7}, // 1e264 | |
| 652 | {0xF4363804324A40AA, 0x9EC95D1463E8A506}, // 1e265 | |
| 653 | {0xB143C6053EDCD0D5, 0xC67BB4597CE2CE48}, // 1e266 | |
| 654 | {0xDD94B7868E94050A, 0xF81AA16FDC1B81DA}, // 1e267 | |
| 655 | {0xCA7CF2B4191C8326, 0x9B10A4E5E9913128}, // 1e268 | |
| 656 | {0xFD1C2F611F63A3F0, 0xC1D4CE1F63F57D72}, // 1e269 | |
| 657 | {0xBC633B39673C8CEC, 0xF24A01A73CF2DCCF}, // 1e270 | |
| 658 | {0xD5BE0503E085D813, 0x976E41088617CA01}, // 1e271 | |
| 659 | {0x4B2D8644D8A74E18, 0xBD49D14AA79DBC82}, // 1e272 | |
| 660 | {0xDDF8E7D60ED1219E, 0xEC9C459D51852BA2}, // 1e273 | |
| 661 | {0xCABB90E5C942B503, 0x93E1AB8252F33B45}, // 1e274 | |
| 662 | {0x3D6A751F3B936243, 0xB8DA1662E7B00A17}, // 1e275 | |
| 663 | {0x0CC512670A783AD4, 0xE7109BFBA19C0C9D}, // 1e276 | |
| 664 | {0x27FB2B80668B24C5, 0x906A617D450187E2}, // 1e277 | |
| 665 | {0xB1F9F660802DEDF6, 0xB484F9DC9641E9DA}, // 1e278 | |
| 666 | {0x5E7873F8A0396973, 0xE1A63853BBD26451}, // 1e279 | |
| 667 | {0xDB0B487B6423E1E8, 0x8D07E33455637EB2}, // 1e280 | |
| 668 | {0x91CE1A9A3D2CDA62, 0xB049DC016ABC5E5F}, // 1e281 | |
| 669 | {0x7641A140CC7810FB, 0xDC5C5301C56B75F7}, // 1e282 | |
| 670 | {0xA9E904C87FCB0A9D, 0x89B9B3E11B6329BA}, // 1e283 | |
| 671 | {0x546345FA9FBDCD44, 0xAC2820D9623BF429}, // 1e284 | |
| 672 | {0xA97C177947AD4095, 0xD732290FBACAF133}, // 1e285 | |
| 673 | {0x49ED8EABCCCC485D, 0x867F59A9D4BED6C0}, // 1e286 | |
| 674 | {0x5C68F256BFFF5A74, 0xA81F301449EE8C70}, // 1e287 | |
| 675 | {0x73832EEC6FFF3111, 0xD226FC195C6A2F8C}, // 1e288 | |
| 676 | {0xC831FD53C5FF7EAB, 0x83585D8FD9C25DB7}, // 1e289 | |
| 677 | {0xBA3E7CA8B77F5E55, 0xA42E74F3D032F525}, // 1e290 | |
| 678 | {0x28CE1BD2E55F35EB, 0xCD3A1230C43FB26F}, // 1e291 | |
| 679 | {0x7980D163CF5B81B3, 0x80444B5E7AA7CF85}, // 1e292 | |
| 680 | {0xD7E105BCC332621F, 0xA0555E361951C366}, // 1e293 | |
| 681 | {0x8DD9472BF3FEFAA7, 0xC86AB5C39FA63440}, // 1e294 | |
| 682 | {0xB14F98F6F0FEB951, 0xFA856334878FC150}, // 1e295 | |
| 683 | {0x6ED1BF9A569F33D3, 0x9C935E00D4B9D8D2}, // 1e296 | |
| 684 | {0x0A862F80EC4700C8, 0xC3B8358109E84F07}, // 1e297 | |
| 685 | {0xCD27BB612758C0FA, 0xF4A642E14C6262C8}, // 1e298 | |
| 686 | {0x8038D51CB897789C, 0x98E7E9CCCFBD7DBD}, // 1e299 | |
| 687 | {0xE0470A63E6BD56C3, 0xBF21E44003ACDD2C}, // 1e300 | |
| 688 | {0x1858CCFCE06CAC74, 0xEEEA5D5004981478}, // 1e301 | |
| 689 | {0x0F37801E0C43EBC8, 0x95527A5202DF0CCB}, // 1e302 | |
| 690 | {0xD30560258F54E6BA, 0xBAA718E68396CFFD}, // 1e303 | |
| 691 | {0x47C6B82EF32A2069, 0xE950DF20247C83FD}, // 1e304 | |
| 692 | {0x4CDC331D57FA5441, 0x91D28B7416CDD27E}, // 1e305 | |
| 693 | {0xE0133FE4ADF8E952, 0xB6472E511C81471D}, // 1e306 | |
| 694 | {0x58180FDDD97723A6, 0xE3D8F9E563A198E5}, // 1e307 | |
| 695 | {0x570F09EAA7EA7648, 0x8E679C2F5E44FF8F}, // 1e308 | |
| 696 | {0x2CD2CC6551E513DA, 0xB201833B35D63F73}, // 1e309 | |
| 697 | {0xF8077F7EA65E58D1, 0xDE81E40A034BCF4F}, // 1e310 | |
| 698 | {0xFB04AFAF27FAF782, 0x8B112E86420F6191}, // 1e311 | |
| 699 | {0x79C5DB9AF1F9B563, 0xADD57A27D29339F6}, // 1e312 | |
| 700 | {0x18375281AE7822BC, 0xD94AD8B1C7380874}, // 1e313 | |
| 701 | {0x8F2293910D0B15B5, 0x87CEC76F1C830548}, // 1e314 | |
| 702 | {0xB2EB3875504DDB22, 0xA9C2794AE3A3C69A}, // 1e315 | |
| 703 | {0x5FA60692A46151EB, 0xD433179D9C8CB841}, // 1e316 | |
| 704 | {0xDBC7C41BA6BCD333, 0x849FEEC281D7F328}, // 1e317 | |
| 705 | {0x12B9B522906C0800, 0xA5C7EA73224DEFF3}, // 1e318 | |
| 706 | {0xD768226B34870A00, 0xCF39E50FEAE16BEF}, // 1e319 | |
| 707 | {0xE6A1158300D46640, 0x81842F29F2CCE375}, // 1e320 | |
| 708 | {0x60495AE3C1097FD0, 0xA1E53AF46F801C53}, // 1e321 | |
| 709 | {0x385BB19CB14BDFC4, 0xCA5E89B18B602368}, // 1e322 | |
| 710 | {0x46729E03DD9ED7B5, 0xFCF62C1DEE382C42}, // 1e323 | |
| 711 | {0x6C07A2C26A8346D1, 0x9E19DB92B4E31BA9}, // 1e324 | |
| 712 | {0xC7098B7305241885, 0xC5A05277621BE293}, // 1e325 | |
| 713 | {0xB8CBEE4FC66D1EA7, 0xF70867153AA2DB38}, // 1e326 | |
| 714 | {0x737F74F1DC043328, 0x9A65406D44A5C903}, // 1e327 | |
| 715 | {0x505F522E53053FF2, 0xC0FE908895CF3B44}, // 1e328 | |
| 716 | {0x647726B9E7C68FEF, 0xF13E34AABB430A15}, // 1e329 | |
| 717 | {0x5ECA783430DC19F5, 0x96C6E0EAB509E64D}, // 1e330 | |
| 718 | {0xB67D16413D132072, 0xBC789925624C5FE0}, // 1e331 | |
| 719 | {0xE41C5BD18C57E88F, 0xEB96BF6EBADF77D8}, // 1e332 | |
| 720 | {0x8E91B962F7B6F159, 0x933E37A534CBAAE7}, // 1e333 | |
| 721 | {0x723627BBB5A4ADB0, 0xB80DC58E81FE95A1}, // 1e334 | |
| 722 | {0xCEC3B1AAA30DD91C, 0xE61136F2227E3B09}, // 1e335 | |
| 723 | {0x213A4F0AA5E8A7B1, 0x8FCAC257558EE4E6}, // 1e336 | |
| 724 | {0xA988E2CD4F62D19D, 0xB3BD72ED2AF29E1F}, // 1e337 | |
| 725 | {0x93EB1B80A33B8605, 0xE0ACCFA875AF45A7}, // 1e338 | |
| 726 | {0xBC72F130660533C3, 0x8C6C01C9498D8B88}, // 1e339 | |
| 727 | {0xEB8FAD7C7F8680B4, 0xAF87023B9BF0EE6A}, // 1e340 | |
| 728 | {0xA67398DB9F6820E1, 0xDB68C2CA82ED2A05}, // 1e341 | |
| 729 | {0x88083F8943A1148C, 0x892179BE91D43A43}, // 1e342 | |
| 730 | {0x6A0A4F6B948959B0, 0xAB69D82E364948D4}, // 1e343 | |
| 731 | {0x848CE34679ABB01C, 0xD6444E39C3DB9B09}, // 1e344 | |
| 732 | {0xF2D80E0C0C0B4E11, 0x85EAB0E41A6940E5}, // 1e345 | |
| 733 | {0x6F8E118F0F0E2195, 0xA7655D1D2103911F}, // 1e346 | |
| 734 | {0x4B7195F2D2D1A9FB, 0xD13EB46469447567}, // 1e347 | |
| 735 | }; | |
| 736 | ||
| 737 | } // namespace internal | |
| 738 | } // namespace LIBC_NAMESPACE_DECL | |
| 739 | ||
| 740 | #endif // LLVM_LIBC_SRC___SUPPORT_DETAILED_POWERS_OF_TEN_H |
lib/libcxx/libc/src/__support/high_precision_decimal.h created+442| ... | ... | @@ -0,0 +1,442 @@ |
| 1 | //===-- High Precision Decimal ----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See httpss//llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // ----------------------------------------------------------------------------- | |
| 10 | // **** WARNING **** | |
| 11 | // This file is shared with libc++. You should also be careful when adding | |
| 12 | // dependencies to this file, since it needs to build for all libc++ targets. | |
| 13 | // ----------------------------------------------------------------------------- | |
| 14 | ||
| 15 | #ifndef LLVM_LIBC_SRC___SUPPORT_HIGH_PRECISION_DECIMAL_H | |
| 16 | #define LLVM_LIBC_SRC___SUPPORT_HIGH_PRECISION_DECIMAL_H | |
| 17 | ||
| 18 | #include "src/__support/CPP/limits.h" | |
| 19 | #include "src/__support/ctype_utils.h" | |
| 20 | #include "src/__support/macros/config.h" | |
| 21 | #include "src/__support/str_to_integer.h" | |
| 22 | #include <stdint.h> | |
| 23 | ||
| 24 | namespace LIBC_NAMESPACE_DECL { | |
| 25 | namespace internal { | |
| 26 | ||
| 27 | struct LShiftTableEntry { | |
| 28 | uint32_t new_digits; | |
| 29 | char const *power_of_five; | |
| 30 | }; | |
| 31 | ||
| 32 | // ----------------------------------------------------------------------------- | |
| 33 | // **** WARNING **** | |
| 34 | // This interface is shared with libc++, if you change this interface you need | |
| 35 | // to update it in both libc and libc++. | |
| 36 | // ----------------------------------------------------------------------------- | |
| 37 | // This is used in both this file and in the main str_to_float.h. | |
| 38 | // TODO: Figure out where to put this. | |
| 39 | enum class RoundDirection { Up, Down, Nearest }; | |
| 40 | ||
| 41 | // This is based on the HPD data structure described as part of the Simple | |
| 42 | // Decimal Conversion algorithm by Nigel Tao, described at this link: | |
| 43 | // https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html | |
| 44 | class HighPrecisionDecimal { | |
| 45 | ||
| 46 | // This precomputed table speeds up left shifts by having the number of new | |
| 47 | // digits that will be added by multiplying 5^i by 2^i. If the number is less | |
| 48 | // than 5^i then it will add one fewer digit. There are only 60 entries since | |
| 49 | // that's the max shift amount. | |
| 50 | // This table was generated by the script at | |
| 51 | // libc/utils/mathtools/GenerateHPDConstants.py | |
| 52 | static constexpr LShiftTableEntry LEFT_SHIFT_DIGIT_TABLE[] = { | |
| 53 | {0, ""}, | |
| 54 | {1, "5"}, | |
| 55 | {1, "25"}, | |
| 56 | {1, "125"}, | |
| 57 | {2, "625"}, | |
| 58 | {2, "3125"}, | |
| 59 | {2, "15625"}, | |
| 60 | {3, "78125"}, | |
| 61 | {3, "390625"}, | |
| 62 | {3, "1953125"}, | |
| 63 | {4, "9765625"}, | |
| 64 | {4, "48828125"}, | |
| 65 | {4, "244140625"}, | |
| 66 | {4, "1220703125"}, | |
| 67 | {5, "6103515625"}, | |
| 68 | {5, "30517578125"}, | |
| 69 | {5, "152587890625"}, | |
| 70 | {6, "762939453125"}, | |
| 71 | {6, "3814697265625"}, | |
| 72 | {6, "19073486328125"}, | |
| 73 | {7, "95367431640625"}, | |
| 74 | {7, "476837158203125"}, | |
| 75 | {7, "2384185791015625"}, | |
| 76 | {7, "11920928955078125"}, | |
| 77 | {8, "59604644775390625"}, | |
| 78 | {8, "298023223876953125"}, | |
| 79 | {8, "1490116119384765625"}, | |
| 80 | {9, "7450580596923828125"}, | |
| 81 | {9, "37252902984619140625"}, | |
| 82 | {9, "186264514923095703125"}, | |
| 83 | {10, "931322574615478515625"}, | |
| 84 | {10, "4656612873077392578125"}, | |
| 85 | {10, "23283064365386962890625"}, | |
| 86 | {10, "116415321826934814453125"}, | |
| 87 | {11, "582076609134674072265625"}, | |
| 88 | {11, "2910383045673370361328125"}, | |
| 89 | {11, "14551915228366851806640625"}, | |
| 90 | {12, "72759576141834259033203125"}, | |
| 91 | {12, "363797880709171295166015625"}, | |
| 92 | {12, "1818989403545856475830078125"}, | |
| 93 | {13, "9094947017729282379150390625"}, | |
| 94 | {13, "45474735088646411895751953125"}, | |
| 95 | {13, "227373675443232059478759765625"}, | |
| 96 | {13, "1136868377216160297393798828125"}, | |
| 97 | {14, "5684341886080801486968994140625"}, | |
| 98 | {14, "28421709430404007434844970703125"}, | |
| 99 | {14, "142108547152020037174224853515625"}, | |
| 100 | {15, "710542735760100185871124267578125"}, | |
| 101 | {15, "3552713678800500929355621337890625"}, | |
| 102 | {15, "17763568394002504646778106689453125"}, | |
| 103 | {16, "88817841970012523233890533447265625"}, | |
| 104 | {16, "444089209850062616169452667236328125"}, | |
| 105 | {16, "2220446049250313080847263336181640625"}, | |
| 106 | {16, "11102230246251565404236316680908203125"}, | |
| 107 | {17, "55511151231257827021181583404541015625"}, | |
| 108 | {17, "277555756156289135105907917022705078125"}, | |
| 109 | {17, "1387778780781445675529539585113525390625"}, | |
| 110 | {18, "6938893903907228377647697925567626953125"}, | |
| 111 | {18, "34694469519536141888238489627838134765625"}, | |
| 112 | {18, "173472347597680709441192448139190673828125"}, | |
| 113 | {19, "867361737988403547205962240695953369140625"}, | |
| 114 | }; | |
| 115 | ||
| 116 | // The maximum amount we can shift is the number of bits used in the | |
| 117 | // accumulator, minus the number of bits needed to represent the base (in this | |
| 118 | // case 4). | |
| 119 | static constexpr uint32_t MAX_SHIFT_AMOUNT = sizeof(uint64_t) - 4; | |
| 120 | ||
| 121 | // 800 is an arbitrary number of digits, but should be | |
| 122 | // large enough for any practical number. | |
| 123 | static constexpr uint32_t MAX_NUM_DIGITS = 800; | |
| 124 | ||
| 125 | uint32_t num_digits = 0; | |
| 126 | int32_t decimal_point = 0; | |
| 127 | bool truncated = false; | |
| 128 | uint8_t digits[MAX_NUM_DIGITS]; | |
| 129 | ||
| 130 | private: | |
| 131 | LIBC_INLINE bool should_round_up(int32_t round_to_digit, | |
| 132 | RoundDirection round) { | |
| 133 | if (round_to_digit < 0 || | |
| 134 | static_cast<uint32_t>(round_to_digit) >= this->num_digits) { | |
| 135 | return false; | |
| 136 | } | |
| 137 | ||
| 138 | // The above condition handles all cases where all of the trailing digits | |
| 139 | // are zero. In that case, if the rounding mode is up, then this number | |
| 140 | // should be rounded up. Similarly, if the rounding mode is down, then it | |
| 141 | // should always round down. | |
| 142 | if (round == RoundDirection::Up) { | |
| 143 | return true; | |
| 144 | } else if (round == RoundDirection::Down) { | |
| 145 | return false; | |
| 146 | } | |
| 147 | // Else round to nearest. | |
| 148 | ||
| 149 | // If we're right in the middle and there are no extra digits | |
| 150 | if (this->digits[round_to_digit] == 5 && | |
| 151 | static_cast<uint32_t>(round_to_digit + 1) == this->num_digits) { | |
| 152 | ||
| 153 | // Round up if we've truncated (since that means the result is slightly | |
| 154 | // higher than what's represented.) | |
| 155 | if (this->truncated) { | |
| 156 | return true; | |
| 157 | } | |
| 158 | ||
| 159 | // If this exactly halfway, round to even. | |
| 160 | if (round_to_digit == 0) | |
| 161 | // When the input is ".5". | |
| 162 | return false; | |
| 163 | return this->digits[round_to_digit - 1] % 2 != 0; | |
| 164 | } | |
| 165 | // If there are digits after round_to_digit, they must be non-zero since we | |
| 166 | // trim trailing zeroes after all operations that change digits. | |
| 167 | return this->digits[round_to_digit] >= 5; | |
| 168 | } | |
| 169 | ||
| 170 | // Takes an amount to left shift and returns the number of new digits needed | |
| 171 | // to store the result based on LEFT_SHIFT_DIGIT_TABLE. | |
| 172 | LIBC_INLINE uint32_t get_num_new_digits(uint32_t lshift_amount) { | |
| 173 | const char *power_of_five = | |
| 174 | LEFT_SHIFT_DIGIT_TABLE[lshift_amount].power_of_five; | |
| 175 | uint32_t new_digits = LEFT_SHIFT_DIGIT_TABLE[lshift_amount].new_digits; | |
| 176 | uint32_t digit_index = 0; | |
| 177 | while (power_of_five[digit_index] != 0) { | |
| 178 | if (digit_index >= this->num_digits) { | |
| 179 | return new_digits - 1; | |
| 180 | } | |
| 181 | if (this->digits[digit_index] != | |
| 182 | internal::b36_char_to_int(power_of_five[digit_index])) { | |
| 183 | return new_digits - | |
| 184 | ((this->digits[digit_index] < | |
| 185 | internal::b36_char_to_int(power_of_five[digit_index])) | |
| 186 | ? 1 | |
| 187 | : 0); | |
| 188 | } | |
| 189 | ++digit_index; | |
| 190 | } | |
| 191 | return new_digits; | |
| 192 | } | |
| 193 | ||
| 194 | // Trim all trailing 0s | |
| 195 | LIBC_INLINE void trim_trailing_zeroes() { | |
| 196 | while (this->num_digits > 0 && this->digits[this->num_digits - 1] == 0) { | |
| 197 | --this->num_digits; | |
| 198 | } | |
| 199 | if (this->num_digits == 0) { | |
| 200 | this->decimal_point = 0; | |
| 201 | } | |
| 202 | } | |
| 203 | ||
| 204 | // Perform a digitwise binary non-rounding right shift on this value by | |
| 205 | // shift_amount. The shift_amount can't be more than MAX_SHIFT_AMOUNT to | |
| 206 | // prevent overflow. | |
| 207 | LIBC_INLINE void right_shift(uint32_t shift_amount) { | |
| 208 | uint32_t read_index = 0; | |
| 209 | uint32_t write_index = 0; | |
| 210 | ||
| 211 | uint64_t accumulator = 0; | |
| 212 | ||
| 213 | const uint64_t shift_mask = (uint64_t(1) << shift_amount) - 1; | |
| 214 | ||
| 215 | // Warm Up phase: we don't have enough digits to start writing, so just | |
| 216 | // read them into the accumulator. | |
| 217 | while (accumulator >> shift_amount == 0) { | |
| 218 | uint64_t read_digit = 0; | |
| 219 | // If there are still digits to read, read the next one, else the digit is | |
| 220 | // assumed to be 0. | |
| 221 | if (read_index < this->num_digits) { | |
| 222 | read_digit = this->digits[read_index]; | |
| 223 | } | |
| 224 | accumulator = accumulator * 10 + read_digit; | |
| 225 | ++read_index; | |
| 226 | } | |
| 227 | ||
| 228 | // Shift the decimal point by the number of digits it took to fill the | |
| 229 | // accumulator. | |
| 230 | this->decimal_point -= read_index - 1; | |
| 231 | ||
| 232 | // Middle phase: we have enough digits to write, as well as more digits to | |
| 233 | // read. Keep reading until we run out of digits. | |
| 234 | while (read_index < this->num_digits) { | |
| 235 | uint64_t read_digit = this->digits[read_index]; | |
| 236 | uint64_t write_digit = accumulator >> shift_amount; | |
| 237 | accumulator &= shift_mask; | |
| 238 | this->digits[write_index] = static_cast<uint8_t>(write_digit); | |
| 239 | accumulator = accumulator * 10 + read_digit; | |
| 240 | ++read_index; | |
| 241 | ++write_index; | |
| 242 | } | |
| 243 | ||
| 244 | // Cool Down phase: All of the readable digits have been read, so just write | |
| 245 | // the remainder, while treating any more digits as 0. | |
| 246 | while (accumulator > 0) { | |
| 247 | uint64_t write_digit = accumulator >> shift_amount; | |
| 248 | accumulator &= shift_mask; | |
| 249 | if (write_index < MAX_NUM_DIGITS) { | |
| 250 | this->digits[write_index] = static_cast<uint8_t>(write_digit); | |
| 251 | ++write_index; | |
| 252 | } else if (write_digit > 0) { | |
| 253 | this->truncated = true; | |
| 254 | } | |
| 255 | accumulator = accumulator * 10; | |
| 256 | } | |
| 257 | this->num_digits = write_index; | |
| 258 | this->trim_trailing_zeroes(); | |
| 259 | } | |
| 260 | ||
| 261 | // Perform a digitwise binary non-rounding left shift on this value by | |
| 262 | // shift_amount. The shift_amount can't be more than MAX_SHIFT_AMOUNT to | |
| 263 | // prevent overflow. | |
| 264 | LIBC_INLINE void left_shift(uint32_t shift_amount) { | |
| 265 | uint32_t new_digits = this->get_num_new_digits(shift_amount); | |
| 266 | ||
| 267 | int32_t read_index = this->num_digits - 1; | |
| 268 | uint32_t write_index = this->num_digits + new_digits; | |
| 269 | ||
| 270 | uint64_t accumulator = 0; | |
| 271 | ||
| 272 | // No Warm Up phase. Since we're putting digits in at the top and taking | |
| 273 | // digits from the bottom we don't have to wait for the accumulator to fill. | |
| 274 | ||
| 275 | // Middle phase: while we have more digits to read, keep reading as well as | |
| 276 | // writing. | |
| 277 | while (read_index >= 0) { | |
| 278 | accumulator += static_cast<uint64_t>(this->digits[read_index]) | |
| 279 | << shift_amount; | |
| 280 | uint64_t next_accumulator = accumulator / 10; | |
| 281 | uint64_t write_digit = accumulator - (10 * next_accumulator); | |
| 282 | --write_index; | |
| 283 | if (write_index < MAX_NUM_DIGITS) { | |
| 284 | this->digits[write_index] = static_cast<uint8_t>(write_digit); | |
| 285 | } else if (write_digit != 0) { | |
| 286 | this->truncated = true; | |
| 287 | } | |
| 288 | accumulator = next_accumulator; | |
| 289 | --read_index; | |
| 290 | } | |
| 291 | ||
| 292 | // Cool Down phase: there are no more digits to read, so just write the | |
| 293 | // remaining digits in the accumulator. | |
| 294 | while (accumulator > 0) { | |
| 295 | uint64_t next_accumulator = accumulator / 10; | |
| 296 | uint64_t write_digit = accumulator - (10 * next_accumulator); | |
| 297 | --write_index; | |
| 298 | if (write_index < MAX_NUM_DIGITS) { | |
| 299 | this->digits[write_index] = static_cast<uint8_t>(write_digit); | |
| 300 | } else if (write_digit != 0) { | |
| 301 | this->truncated = true; | |
| 302 | } | |
| 303 | accumulator = next_accumulator; | |
| 304 | } | |
| 305 | ||
| 306 | this->num_digits += new_digits; | |
| 307 | if (this->num_digits > MAX_NUM_DIGITS) { | |
| 308 | this->num_digits = MAX_NUM_DIGITS; | |
| 309 | } | |
| 310 | this->decimal_point += new_digits; | |
| 311 | this->trim_trailing_zeroes(); | |
| 312 | } | |
| 313 | ||
| 314 | public: | |
| 315 | // num_string is assumed to be a string of numeric characters. It doesn't | |
| 316 | // handle leading spaces. | |
| 317 | LIBC_INLINE | |
| 318 | HighPrecisionDecimal( | |
| 319 | const char *__restrict num_string, | |
| 320 | const size_t num_len = cpp::numeric_limits<size_t>::max()) { | |
| 321 | bool saw_dot = false; | |
| 322 | size_t num_cur = 0; | |
| 323 | // This counts the digits in the number, even if there isn't space to store | |
| 324 | // them all. | |
| 325 | uint32_t total_digits = 0; | |
| 326 | while (num_cur < num_len && | |
| 327 | (isdigit(num_string[num_cur]) || num_string[num_cur] == '.')) { | |
| 328 | if (num_string[num_cur] == '.') { | |
| 329 | if (saw_dot) { | |
| 330 | break; | |
| 331 | } | |
| 332 | this->decimal_point = total_digits; | |
| 333 | saw_dot = true; | |
| 334 | } else { | |
| 335 | if (num_string[num_cur] == '0' && this->num_digits == 0) { | |
| 336 | --this->decimal_point; | |
| 337 | ++num_cur; | |
| 338 | continue; | |
| 339 | } | |
| 340 | ++total_digits; | |
| 341 | if (this->num_digits < MAX_NUM_DIGITS) { | |
| 342 | this->digits[this->num_digits] = static_cast<uint8_t>( | |
| 343 | internal::b36_char_to_int(num_string[num_cur])); | |
| 344 | ++this->num_digits; | |
| 345 | } else if (num_string[num_cur] != '0') { | |
| 346 | this->truncated = true; | |
| 347 | } | |
| 348 | } | |
| 349 | ++num_cur; | |
| 350 | } | |
| 351 | ||
| 352 | if (!saw_dot) | |
| 353 | this->decimal_point = total_digits; | |
| 354 | ||
| 355 | if (num_cur < num_len && | |
| 356 | (num_string[num_cur] == 'e' || num_string[num_cur] == 'E')) { | |
| 357 | ++num_cur; | |
| 358 | if (isdigit(num_string[num_cur]) || num_string[num_cur] == '+' || | |
| 359 | num_string[num_cur] == '-') { | |
| 360 | auto result = | |
| 361 | strtointeger<int32_t>(num_string + num_cur, 10, num_len - num_cur); | |
| 362 | if (result.has_error()) { | |
| 363 | // TODO: handle error | |
| 364 | } | |
| 365 | int32_t add_to_exponent = result.value; | |
| 366 | ||
| 367 | // Here we do this operation as int64 to avoid overflow. | |
| 368 | int64_t temp_exponent = static_cast<int64_t>(this->decimal_point) + | |
| 369 | static_cast<int64_t>(add_to_exponent); | |
| 370 | ||
| 371 | // Theoretically these numbers should be MAX_BIASED_EXPONENT for long | |
| 372 | // double, but that should be ~16,000 which is much less than 1 << 30. | |
| 373 | if (temp_exponent > (1 << 30)) { | |
| 374 | temp_exponent = (1 << 30); | |
| 375 | } else if (temp_exponent < -(1 << 30)) { | |
| 376 | temp_exponent = -(1 << 30); | |
| 377 | } | |
| 378 | this->decimal_point = static_cast<int32_t>(temp_exponent); | |
| 379 | } | |
| 380 | } | |
| 381 | ||
| 382 | this->trim_trailing_zeroes(); | |
| 383 | } | |
| 384 | ||
| 385 | // Binary shift left (shift_amount > 0) or right (shift_amount < 0) | |
| 386 | LIBC_INLINE void shift(int shift_amount) { | |
| 387 | if (shift_amount == 0) { | |
| 388 | return; | |
| 389 | } | |
| 390 | // Left | |
| 391 | else if (shift_amount > 0) { | |
| 392 | while (static_cast<uint32_t>(shift_amount) > MAX_SHIFT_AMOUNT) { | |
| 393 | this->left_shift(MAX_SHIFT_AMOUNT); | |
| 394 | shift_amount -= MAX_SHIFT_AMOUNT; | |
| 395 | } | |
| 396 | this->left_shift(shift_amount); | |
| 397 | } | |
| 398 | // Right | |
| 399 | else { | |
| 400 | while (static_cast<uint32_t>(shift_amount) < -MAX_SHIFT_AMOUNT) { | |
| 401 | this->right_shift(MAX_SHIFT_AMOUNT); | |
| 402 | shift_amount += MAX_SHIFT_AMOUNT; | |
| 403 | } | |
| 404 | this->right_shift(-shift_amount); | |
| 405 | } | |
| 406 | } | |
| 407 | ||
| 408 | // Round the number represented to the closest value of unsigned int type T. | |
| 409 | // This is done ignoring overflow. | |
| 410 | template <class T> | |
| 411 | LIBC_INLINE T | |
| 412 | round_to_integer_type(RoundDirection round = RoundDirection::Nearest) { | |
| 413 | T result = 0; | |
| 414 | uint32_t cur_digit = 0; | |
| 415 | ||
| 416 | while (static_cast<int32_t>(cur_digit) < this->decimal_point && | |
| 417 | cur_digit < this->num_digits) { | |
| 418 | result = result * 10 + (this->digits[cur_digit]); | |
| 419 | ++cur_digit; | |
| 420 | } | |
| 421 | ||
| 422 | // If there are implicit 0s at the end of the number, include those. | |
| 423 | while (static_cast<int32_t>(cur_digit) < this->decimal_point) { | |
| 424 | result *= 10; | |
| 425 | ++cur_digit; | |
| 426 | } | |
| 427 | return result + static_cast<unsigned int>( | |
| 428 | this->should_round_up(this->decimal_point, round)); | |
| 429 | } | |
| 430 | ||
| 431 | // Extra functions for testing. | |
| 432 | ||
| 433 | LIBC_INLINE uint8_t *get_digits() { return this->digits; } | |
| 434 | LIBC_INLINE uint32_t get_num_digits() { return this->num_digits; } | |
| 435 | LIBC_INLINE int32_t get_decimal_point() { return this->decimal_point; } | |
| 436 | LIBC_INLINE void set_truncated(bool trunc) { this->truncated = trunc; } | |
| 437 | }; | |
| 438 | ||
| 439 | } // namespace internal | |
| 440 | } // namespace LIBC_NAMESPACE_DECL | |
| 441 | ||
| 442 | #endif // LLVM_LIBC_SRC___SUPPORT_HIGH_PRECISION_DECIMAL_H |
lib/libcxx/libc/src/__support/libc_assert.h created+88| ... | ... | @@ -0,0 +1,88 @@ |
| 1 | //===-- Definition of a libc internal assert macro --------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H | |
| 11 | ||
| 12 | #include "src/__support/macros/config.h" | |
| 13 | #if defined(LIBC_COPT_USE_C_ASSERT) || !defined(LIBC_FULL_BUILD) | |
| 14 | ||
| 15 | // The build is configured to just use the public <assert.h> API | |
| 16 | // for libc's internal assertions. | |
| 17 | ||
| 18 | #include <assert.h> | |
| 19 | ||
| 20 | #define LIBC_ASSERT(COND) assert(COND) | |
| 21 | ||
| 22 | #else // Not LIBC_COPT_USE_C_ASSERT | |
| 23 | ||
| 24 | #include "src/__support/OSUtil/exit.h" | |
| 25 | #include "src/__support/OSUtil/io.h" | |
| 26 | #include "src/__support/integer_to_string.h" | |
| 27 | #include "src/__support/macros/attributes.h" // For LIBC_INLINE | |
| 28 | #include "src/__support/macros/optimization.h" // For LIBC_UNLIKELY | |
| 29 | ||
| 30 | namespace LIBC_NAMESPACE_DECL { | |
| 31 | ||
| 32 | // This is intended to be removed in a future patch to use a similar design to | |
| 33 | // below, but it's necessary for the external assert. | |
| 34 | LIBC_INLINE void report_assertion_failure(const char *assertion, | |
| 35 | const char *filename, unsigned line, | |
| 36 | const char *funcname) { | |
| 37 | const IntegerToString<unsigned> line_buffer(line); | |
| 38 | write_to_stderr(filename); | |
| 39 | write_to_stderr(":"); | |
| 40 | write_to_stderr(line_buffer.view()); | |
| 41 | write_to_stderr(": Assertion failed: '"); | |
| 42 | write_to_stderr(assertion); | |
| 43 | write_to_stderr("' in function: '"); | |
| 44 | write_to_stderr(funcname); | |
| 45 | write_to_stderr("'\n"); | |
| 46 | } | |
| 47 | ||
| 48 | } // namespace LIBC_NAMESPACE_DECL | |
| 49 | ||
| 50 | #ifdef LIBC_ASSERT | |
| 51 | #error "Unexpected: LIBC_ASSERT macro already defined" | |
| 52 | #endif | |
| 53 | ||
| 54 | // The public "assert" macro calls abort on failure. Should it be same here? | |
| 55 | // The libc internal assert can fire from anywhere inside the libc. So, to | |
| 56 | // avoid potential chicken-and-egg problems, it is simple to do an exit | |
| 57 | // on assertion failure instead of calling abort. We also don't want to use | |
| 58 | // __builtin_trap as it could potentially be implemented using illegal | |
| 59 | // instructions which can be very misleading when debugging. | |
| 60 | #ifdef NDEBUG | |
| 61 | #define LIBC_ASSERT(COND) \ | |
| 62 | do { \ | |
| 63 | } while (false) | |
| 64 | #else | |
| 65 | ||
| 66 | // Convert __LINE__ to a string using macros. The indirection is necessary | |
| 67 | // because otherwise it will turn "__LINE__" into a string, not its value. The | |
| 68 | // value is evaluated in the indirection step. | |
| 69 | #define __LIBC_MACRO_TO_STR(x) #x | |
| 70 | #define __LIBC_MACRO_TO_STR_INDIR(y) __LIBC_MACRO_TO_STR(y) | |
| 71 | #define __LIBC_LINE_STR__ __LIBC_MACRO_TO_STR_INDIR(__LINE__) | |
| 72 | ||
| 73 | #define LIBC_ASSERT(COND) \ | |
| 74 | do { \ | |
| 75 | if (LIBC_UNLIKELY(!(COND))) { \ | |
| 76 | LIBC_NAMESPACE::write_to_stderr(__FILE__ ":" __LIBC_LINE_STR__ \ | |
| 77 | ": Assertion failed: '" #COND \ | |
| 78 | "' in function: '"); \ | |
| 79 | LIBC_NAMESPACE::write_to_stderr(__PRETTY_FUNCTION__); \ | |
| 80 | LIBC_NAMESPACE::write_to_stderr("'\n"); \ | |
| 81 | LIBC_NAMESPACE::internal::exit(0xFF); \ | |
| 82 | } \ | |
| 83 | } while (false) | |
| 84 | #endif // NDEBUG | |
| 85 | ||
| 86 | #endif // LIBC_COPT_USE_C_ASSERT | |
| 87 | ||
| 88 | #endif // LLVM_LIBC_SRC___SUPPORT_LIBC_ASSERT_H |
lib/libcxx/libc/src/__support/macros/attributes.h created+51| ... | ... | @@ -0,0 +1,51 @@ |
| 1 | //===-- Portable attributes -------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | // This header file defines macros for declaring attributes for functions, | |
| 9 | // types, and variables. | |
| 10 | // | |
| 11 | // These macros are used within llvm-libc and allow the compiler to optimize, | |
| 12 | // where applicable, certain function calls. | |
| 13 | // | |
| 14 | // Most macros here are exposing GCC or Clang features, and are stubbed out for | |
| 15 | // other compilers. | |
| 16 | ||
| 17 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H | |
| 18 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H | |
| 19 | ||
| 20 | #include "properties/architectures.h" | |
| 21 | ||
| 22 | #ifndef __has_attribute | |
| 23 | #define __has_attribute(x) 0 | |
| 24 | #endif | |
| 25 | ||
| 26 | #define LIBC_INLINE inline | |
| 27 | #define LIBC_INLINE_VAR inline | |
| 28 | #define LIBC_INLINE_ASM __asm__ __volatile__ | |
| 29 | #define LIBC_UNUSED __attribute__((unused)) | |
| 30 | ||
| 31 | #ifdef LIBC_TARGET_ARCH_IS_GPU | |
| 32 | #define LIBC_THREAD_LOCAL | |
| 33 | #else | |
| 34 | #define LIBC_THREAD_LOCAL thread_local | |
| 35 | #endif | |
| 36 | ||
| 37 | #if __cplusplus >= 202002L | |
| 38 | #define LIBC_CONSTINIT constinit | |
| 39 | #elif __has_attribute(__require_constant_initialization__) | |
| 40 | #define LIBC_CONSTINIT __attribute__((__require_constant_initialization__)) | |
| 41 | #else | |
| 42 | #define LIBC_CONSTINIT | |
| 43 | #endif | |
| 44 | ||
| 45 | #if defined(__clang__) && __has_attribute(preferred_type) | |
| 46 | #define LIBC_PREFERED_TYPE(TYPE) [[clang::preferred_type(TYPE)]] | |
| 47 | #else | |
| 48 | #define LIBC_PREFERED_TYPE(TYPE) | |
| 49 | #endif | |
| 50 | ||
| 51 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H |
lib/libcxx/libc/src/__support/macros/config.h created+46| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | //===-- Portable attributes -------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | // This header file defines a set of macros for checking the presence of | |
| 9 | // important compiler and platform features. Such macros can be used to | |
| 10 | // produce portable code by parameterizing compilation based on the presence or | |
| 11 | // lack of a given feature. | |
| 12 | ||
| 13 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H | |
| 14 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H | |
| 15 | ||
| 16 | // Workaround for compilers that do not support builtin detection. | |
| 17 | // FIXME: This is only required for the GPU portion which should be moved. | |
| 18 | #ifndef __has_builtin | |
| 19 | #define __has_builtin(b) 0 | |
| 20 | #endif | |
| 21 | ||
| 22 | // Compiler feature-detection. | |
| 23 | // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension | |
| 24 | #ifdef __has_feature | |
| 25 | #define LIBC_HAS_FEATURE(f) __has_feature(f) | |
| 26 | #else | |
| 27 | #define LIBC_HAS_FEATURE(f) 0 | |
| 28 | #endif | |
| 29 | ||
| 30 | #ifdef __clang__ | |
| 31 | // Declare a LIBC_NAMESPACE with hidden visibility. `namespace | |
| 32 | // LIBC_NAMESPACE_DECL {` should be used around all declarations and definitions | |
| 33 | // for libc internals as opposed to just `namespace LIBC_NAMESPACE {`. This | |
| 34 | // ensures that all declarations within this namespace have hidden | |
| 35 | // visibility, which optimizes codegen for uses of symbols defined in other | |
| 36 | // translation units in ways that can be necessary for correctness by avoiding | |
| 37 | // dynamic relocations. This does not affect the public C symbols which are | |
| 38 | // controlled independently via `LLVM_LIBC_FUNCTION_ATTR`. | |
| 39 | #define LIBC_NAMESPACE_DECL [[gnu::visibility("hidden")]] LIBC_NAMESPACE | |
| 40 | #else | |
| 41 | // TODO(#98548): GCC emits a warning when using the visibility attribute which | |
| 42 | // needs to be diagnosed and addressed. | |
| 43 | #define LIBC_NAMESPACE_DECL LIBC_NAMESPACE | |
| 44 | #endif | |
| 45 | ||
| 46 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_CONFIG_H |
lib/libcxx/libc/src/__support/macros/null_check.h created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | //===-- Safe nullptr check --------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_NULL_CHECK_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_NULL_CHECK_H | |
| 11 | ||
| 12 | #include "src/__support/macros/config.h" | |
| 13 | #include "src/__support/macros/optimization.h" | |
| 14 | #include "src/__support/macros/sanitizer.h" | |
| 15 | ||
| 16 | #if defined(LIBC_ADD_NULL_CHECKS) && !defined(LIBC_HAS_SANITIZER) | |
| 17 | #define LIBC_CRASH_ON_NULLPTR(ptr) \ | |
| 18 | do { \ | |
| 19 | if (LIBC_UNLIKELY((ptr) == nullptr)) \ | |
| 20 | __builtin_trap(); \ | |
| 21 | } while (0) | |
| 22 | #else | |
| 23 | #define LIBC_CRASH_ON_NULLPTR(ptr) \ | |
| 24 | do { \ | |
| 25 | } while (0) | |
| 26 | #endif | |
| 27 | ||
| 28 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_NULL_CHECK_H |
lib/libcxx/libc/src/__support/macros/optimization.h created+61| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | //===-- Portable optimization macros ----------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | // This header file defines portable macros for performance optimization. | |
| 9 | ||
| 10 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_OPTIMIZATION_H | |
| 11 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_OPTIMIZATION_H | |
| 12 | ||
| 13 | #include "src/__support/macros/attributes.h" // LIBC_INLINE | |
| 14 | #include "src/__support/macros/config.h" | |
| 15 | #include "src/__support/macros/properties/compiler.h" // LIBC_COMPILER_IS_CLANG | |
| 16 | ||
| 17 | // We use a template to implement likely/unlikely to make sure that we don't | |
| 18 | // accidentally pass an integer. | |
| 19 | namespace LIBC_NAMESPACE_DECL { | |
| 20 | namespace details { | |
| 21 | template <typename T> | |
| 22 | LIBC_INLINE constexpr bool expects_bool_condition(T value, T expected) { | |
| 23 | return __builtin_expect(value, expected); | |
| 24 | } | |
| 25 | } // namespace details | |
| 26 | } // namespace LIBC_NAMESPACE_DECL | |
| 27 | #define LIBC_LIKELY(x) LIBC_NAMESPACE::details::expects_bool_condition(x, true) | |
| 28 | #define LIBC_UNLIKELY(x) \ | |
| 29 | LIBC_NAMESPACE::details::expects_bool_condition(x, false) | |
| 30 | ||
| 31 | #if defined(LIBC_COMPILER_IS_CLANG) | |
| 32 | #define LIBC_LOOP_NOUNROLL _Pragma("nounroll") | |
| 33 | #elif defined(LIBC_COMPILER_IS_GCC) | |
| 34 | #define LIBC_LOOP_NOUNROLL _Pragma("GCC unroll 0") | |
| 35 | #else | |
| 36 | #error "Unhandled compiler" | |
| 37 | #endif | |
| 38 | ||
| 39 | // Defining optimization options for math functions. | |
| 40 | // TODO: Exporting this to public generated headers? | |
| 41 | #define LIBC_MATH_SKIP_ACCURATE_PASS 0x01 | |
| 42 | #define LIBC_MATH_SMALL_TABLES 0x02 | |
| 43 | #define LIBC_MATH_NO_ERRNO 0x04 | |
| 44 | #define LIBC_MATH_NO_EXCEPT 0x08 | |
| 45 | #define LIBC_MATH_FAST \ | |
| 46 | (LIBC_MATH_SKIP_ACCURATE_PASS | LIBC_MATH_SMALL_TABLES | \ | |
| 47 | LIBC_MATH_NO_ERRNO | LIBC_MATH_NO_EXCEPT) | |
| 48 | ||
| 49 | #ifndef LIBC_MATH | |
| 50 | #define LIBC_MATH 0 | |
| 51 | #endif // LIBC_MATH | |
| 52 | ||
| 53 | #if (LIBC_MATH & LIBC_MATH_SKIP_ACCURATE_PASS) | |
| 54 | #define LIBC_MATH_HAS_SKIP_ACCURATE_PASS | |
| 55 | #endif | |
| 56 | ||
| 57 | #if (LIBC_MATH & LIBC_MATH_SMALL_TABLES) | |
| 58 | #define LIBC_MATH_HAS_SMALL_TABLES | |
| 59 | #endif | |
| 60 | ||
| 61 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_OPTIMIZATION_H |
lib/libcxx/libc/src/__support/macros/properties/architectures.h created+64| ... | ... | @@ -0,0 +1,64 @@ |
| 1 | //===-- Compile time architecture detection ---------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_ARCHITECTURES_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_ARCHITECTURES_H | |
| 11 | ||
| 12 | #if defined(__AMDGPU__) | |
| 13 | #define LIBC_TARGET_ARCH_IS_AMDGPU | |
| 14 | #endif | |
| 15 | ||
| 16 | #if defined(__NVPTX__) | |
| 17 | #define LIBC_TARGET_ARCH_IS_NVPTX | |
| 18 | #endif | |
| 19 | ||
| 20 | #if defined(LIBC_TARGET_ARCH_IS_NVPTX) || defined(LIBC_TARGET_ARCH_IS_AMDGPU) | |
| 21 | #define LIBC_TARGET_ARCH_IS_GPU | |
| 22 | #endif | |
| 23 | ||
| 24 | #if defined(__pnacl__) || defined(__CLR_VER) || defined(LIBC_TARGET_ARCH_IS_GPU) | |
| 25 | #define LIBC_TARGET_ARCH_IS_VM | |
| 26 | #endif | |
| 27 | ||
| 28 | #if (defined(_M_IX86) || defined(__i386__)) && !defined(LIBC_TARGET_ARCH_IS_VM) | |
| 29 | #define LIBC_TARGET_ARCH_IS_X86_32 | |
| 30 | #endif | |
| 31 | ||
| 32 | #if (defined(_M_X64) || defined(__x86_64__)) && !defined(LIBC_TARGET_ARCH_IS_VM) | |
| 33 | #define LIBC_TARGET_ARCH_IS_X86_64 | |
| 34 | #endif | |
| 35 | ||
| 36 | #if defined(LIBC_TARGET_ARCH_IS_X86_32) || defined(LIBC_TARGET_ARCH_IS_X86_64) | |
| 37 | #define LIBC_TARGET_ARCH_IS_X86 | |
| 38 | #endif | |
| 39 | ||
| 40 | #if (defined(__arm__) || defined(_M_ARM)) | |
| 41 | #define LIBC_TARGET_ARCH_IS_ARM | |
| 42 | #endif | |
| 43 | ||
| 44 | #if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) | |
| 45 | #define LIBC_TARGET_ARCH_IS_AARCH64 | |
| 46 | #endif | |
| 47 | ||
| 48 | #if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_ARM) | |
| 49 | #define LIBC_TARGET_ARCH_IS_ANY_ARM | |
| 50 | #endif | |
| 51 | ||
| 52 | #if defined(__riscv) && (__riscv_xlen == 64) | |
| 53 | #define LIBC_TARGET_ARCH_IS_RISCV64 | |
| 54 | #endif | |
| 55 | ||
| 56 | #if defined(__riscv) && (__riscv_xlen == 32) | |
| 57 | #define LIBC_TARGET_ARCH_IS_RISCV32 | |
| 58 | #endif | |
| 59 | ||
| 60 | #if defined(LIBC_TARGET_ARCH_IS_RISCV64) || defined(LIBC_TARGET_ARCH_IS_RISCV32) | |
| 61 | #define LIBC_TARGET_ARCH_IS_ANY_RISCV | |
| 62 | #endif | |
| 63 | ||
| 64 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_ARCHITECTURES_H |
lib/libcxx/libc/src/__support/macros/properties/compiler.h created+43| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | //===-- Compile time compiler detection -------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H | |
| 11 | ||
| 12 | // Example usage of compiler version checks | |
| 13 | // #if defined(LIBC_COMPILER_CLANG_VER) | |
| 14 | // # if LIBC_COMPILER_CLANG_VER < 1500 | |
| 15 | // # warning "Libc only supports Clang 15 and later" | |
| 16 | // # endif | |
| 17 | // #elif defined(LIBC_COMPILER_GCC_VER) | |
| 18 | // # if LIBC_COMPILER_GCC_VER < 1500 | |
| 19 | // # warning "Libc only supports GCC 15 and later" | |
| 20 | // # endif | |
| 21 | // #elif defined(LIBC_COMPILER_MSC_VER) | |
| 22 | // # if LIBC_COMPILER_MSC_VER < 1930 | |
| 23 | // # warning "Libc only supports Visual Studio 2022 RTW (17.0) and later" | |
| 24 | // # endif | |
| 25 | // #endif | |
| 26 | ||
| 27 | #if defined(__clang__) | |
| 28 | #define LIBC_COMPILER_IS_CLANG | |
| 29 | #define LIBC_COMPILER_CLANG_VER (__clang_major__ * 100 + __clang_minor__) | |
| 30 | #endif | |
| 31 | ||
| 32 | #if defined(__GNUC__) && !defined(__clang__) | |
| 33 | #define LIBC_COMPILER_IS_GCC | |
| 34 | #define LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__) | |
| 35 | #endif | |
| 36 | ||
| 37 | #if defined(_MSC_VER) | |
| 38 | #define LIBC_COMPILER_IS_MSC | |
| 39 | // https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros | |
| 40 | #define LIBC_COMPILER_MSC_VER (_MSC_VER) | |
| 41 | #endif | |
| 42 | ||
| 43 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H |
lib/libcxx/libc/src/__support/macros/properties/complex_types.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===-- Complex Types support -----------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | // Complex Types detection and support. | |
| 9 | ||
| 10 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H | |
| 11 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H | |
| 12 | ||
| 13 | #include "include/llvm-libc-types/cfloat128.h" | |
| 14 | #include "include/llvm-libc-types/cfloat16.h" | |
| 15 | #include "types.h" | |
| 16 | ||
| 17 | // -- cfloat16 support -------------------------------------------------------- | |
| 18 | // LIBC_TYPES_HAS_CFLOAT16 and 'cfloat16' type is provided by | |
| 19 | // "include/llvm-libc-types/cfloat16.h" | |
| 20 | ||
| 21 | // -- cfloat128 support ------------------------------------------------------- | |
| 22 | // LIBC_TYPES_HAS_CFLOAT128 and 'cfloat128' type are provided by | |
| 23 | // "include/llvm-libc-types/cfloat128.h" | |
| 24 | ||
| 25 | #if defined(LIBC_TYPES_HAS_CFLOAT128) && \ | |
| 26 | !defined(LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE) | |
| 27 | #define LIBC_TYPES_CFLOAT128_IS_NOT_COMPLEX_LONG_DOUBLE | |
| 28 | #endif | |
| 29 | ||
| 30 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CTYPES_H |
lib/libcxx/libc/src/__support/macros/properties/cpu_features.h created+60| ... | ... | @@ -0,0 +1,60 @@ |
| 1 | //===-- Compile time cpu feature detection ----------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | // This file lists target cpu features by introspecting compiler enabled | |
| 9 | // preprocessor definitions. | |
| 10 | //===----------------------------------------------------------------------===// | |
| 11 | ||
| 12 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CPU_FEATURES_H | |
| 13 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CPU_FEATURES_H | |
| 14 | ||
| 15 | #include "architectures.h" | |
| 16 | ||
| 17 | #if defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC) | |
| 18 | #define LIBC_TARGET_CPU_HAS_FULLFP16 | |
| 19 | #endif | |
| 20 | ||
| 21 | #if defined(__SSE2__) | |
| 22 | #define LIBC_TARGET_CPU_HAS_SSE2 | |
| 23 | #endif | |
| 24 | ||
| 25 | #if defined(__SSE4_2__) | |
| 26 | #define LIBC_TARGET_CPU_HAS_SSE4_2 | |
| 27 | #endif | |
| 28 | ||
| 29 | #if defined(__AVX__) | |
| 30 | #define LIBC_TARGET_CPU_HAS_AVX | |
| 31 | #endif | |
| 32 | ||
| 33 | #if defined(__AVX2__) | |
| 34 | #define LIBC_TARGET_CPU_HAS_AVX2 | |
| 35 | #endif | |
| 36 | ||
| 37 | #if defined(__AVX512F__) | |
| 38 | #define LIBC_TARGET_CPU_HAS_AVX512F | |
| 39 | #endif | |
| 40 | ||
| 41 | #if defined(__AVX512BW__) | |
| 42 | #define LIBC_TARGET_CPU_HAS_AVX512BW | |
| 43 | #endif | |
| 44 | ||
| 45 | #if defined(__ARM_FEATURE_FMA) || (defined(__AVX2__) && defined(__FMA__)) || \ | |
| 46 | defined(__NVPTX__) || defined(__AMDGPU__) || defined(__LIBC_RISCV_USE_FMA) | |
| 47 | #define LIBC_TARGET_CPU_HAS_FMA | |
| 48 | #endif | |
| 49 | ||
| 50 | #if defined(LIBC_TARGET_ARCH_IS_AARCH64) || \ | |
| 51 | (defined(LIBC_TARGET_ARCH_IS_X86_64) && \ | |
| 52 | defined(LIBC_TARGET_CPU_HAS_SSE4_2)) | |
| 53 | #define LIBC_TARGET_CPU_HAS_NEAREST_INT | |
| 54 | #endif | |
| 55 | ||
| 56 | #if defined(LIBC_TARGET_ARCH_IS_AARCH64) || defined(LIBC_TARGET_ARCH_IS_GPU) | |
| 57 | #define LIBC_TARGET_CPU_HAS_FAST_FLOAT16_OPS | |
| 58 | #endif | |
| 59 | ||
| 60 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_CPU_FEATURES_H |
lib/libcxx/libc/src/__support/macros/properties/os.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===-- Target OS detection -------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H | |
| 9 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H | |
| 10 | ||
| 11 | #if (defined(__freebsd__) || defined(__FreeBSD__)) | |
| 12 | #define LIBC_TARGET_OS_IS_FREEBSD | |
| 13 | #endif | |
| 14 | ||
| 15 | #if defined(__ANDROID__) | |
| 16 | #define LIBC_TARGET_OS_IS_ANDROID | |
| 17 | #endif | |
| 18 | ||
| 19 | #if defined(__linux__) && !defined(LIBC_TARGET_OS_IS_FREEBSD) && \ | |
| 20 | !defined(LIBC_TARGET_OS_IS_ANDROID) | |
| 21 | #define LIBC_TARGET_OS_IS_LINUX | |
| 22 | #endif | |
| 23 | ||
| 24 | #if (defined(_WIN64) || defined(_WIN32)) | |
| 25 | #define LIBC_TARGET_OS_IS_WINDOWS | |
| 26 | #endif | |
| 27 | ||
| 28 | #if defined(__Fuchsia__) | |
| 29 | #define LIBC_TARGET_OS_IS_FUCHSIA | |
| 30 | #endif | |
| 31 | ||
| 32 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_OS_H |
lib/libcxx/libc/src/__support/macros/properties/types.h created+61| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | //===-- Types support -------------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | // Types detection and support. | |
| 9 | ||
| 10 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H | |
| 11 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H | |
| 12 | ||
| 13 | #include "hdr/float_macros.h" // LDBL_MANT_DIG | |
| 14 | #include "include/llvm-libc-macros/float16-macros.h" // LIBC_TYPES_HAS_FLOAT16 | |
| 15 | #include "include/llvm-libc-types/float128.h" // float128 | |
| 16 | #include "src/__support/macros/properties/architectures.h" | |
| 17 | #include "src/__support/macros/properties/compiler.h" | |
| 18 | #include "src/__support/macros/properties/cpu_features.h" | |
| 19 | #include "src/__support/macros/properties/os.h" | |
| 20 | ||
| 21 | #include <stdint.h> // UINT64_MAX, __SIZEOF_INT128__ | |
| 22 | ||
| 23 | // 'long double' properties. | |
| 24 | #if (LDBL_MANT_DIG == 53) | |
| 25 | #define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64 | |
| 26 | #elif (LDBL_MANT_DIG == 64) | |
| 27 | #define LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80 | |
| 28 | #elif (LDBL_MANT_DIG == 113) | |
| 29 | #define LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128 | |
| 30 | #elif (LDBL_MANT_DIG == 106) | |
| 31 | #define LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE | |
| 32 | #endif | |
| 33 | ||
| 34 | #if defined(LIBC_TYPES_HAS_FLOAT128) && \ | |
| 35 | !defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128) | |
| 36 | #define LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE | |
| 37 | #endif | |
| 38 | ||
| 39 | // int64 / uint64 support | |
| 40 | #if defined(UINT64_MAX) | |
| 41 | #define LIBC_TYPES_HAS_INT64 | |
| 42 | #endif // UINT64_MAX | |
| 43 | ||
| 44 | // int128 / uint128 support | |
| 45 | #if defined(__SIZEOF_INT128__) && !defined(LIBC_TARGET_OS_IS_WINDOWS) | |
| 46 | #define LIBC_TYPES_HAS_INT128 | |
| 47 | #endif // defined(__SIZEOF_INT128__) | |
| 48 | ||
| 49 | // -- float16 support --------------------------------------------------------- | |
| 50 | // LIBC_TYPES_HAS_FLOAT16 is provided by | |
| 51 | // "include/llvm-libc-macros/float16-macros.h" | |
| 52 | #ifdef LIBC_TYPES_HAS_FLOAT16 | |
| 53 | // Type alias for internal use. | |
| 54 | using float16 = _Float16; | |
| 55 | #endif // LIBC_TYPES_HAS_FLOAT16 | |
| 56 | ||
| 57 | // -- float128 support -------------------------------------------------------- | |
| 58 | // LIBC_TYPES_HAS_FLOAT128 and 'float128' type are provided by | |
| 59 | // "include/llvm-libc-types/float128.h" | |
| 60 | ||
| 61 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_TYPES_H |
lib/libcxx/libc/src/__support/macros/sanitizer.h created+59| ... | ... | @@ -0,0 +1,59 @@ |
| 1 | //===-- Convenient sanitizer macros -----------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_SANITIZER_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_MACROS_SANITIZER_H | |
| 11 | ||
| 12 | #include "src/__support/macros/config.h" //LIBC_HAS_FEATURE | |
| 13 | ||
| 14 | //----------------------------------------------------------------------------- | |
| 15 | // Functions to unpoison memory | |
| 16 | //----------------------------------------------------------------------------- | |
| 17 | ||
| 18 | #if LIBC_HAS_FEATURE(address_sanitizer) || defined(__SANITIZE_ADDRESS__) | |
| 19 | #define LIBC_HAS_ADDRESS_SANITIZER | |
| 20 | #endif | |
| 21 | ||
| 22 | #if LIBC_HAS_FEATURE(memory_sanitizer) | |
| 23 | #define LIBC_HAS_MEMORY_SANITIZER | |
| 24 | #endif | |
| 25 | ||
| 26 | #if LIBC_HAS_FEATURE(undefined_behavior_sanitizer) | |
| 27 | #define LIBC_HAS_UNDEFINED_BEHAVIOR_SANITIZER | |
| 28 | #endif | |
| 29 | ||
| 30 | #if defined(LIBC_HAS_ADDRESS_SANITIZER) || \ | |
| 31 | defined(LIBC_HAS_MEMORY_SANITIZER) || \ | |
| 32 | defined(LIBC_HAS_UNDEFINED_BEHAVIOR_SANITIZER) | |
| 33 | #define LIBC_HAS_SANITIZER | |
| 34 | #endif | |
| 35 | ||
| 36 | #ifdef LIBC_HAS_MEMORY_SANITIZER | |
| 37 | // Only perform MSAN unpoison in non-constexpr context. | |
| 38 | #include <sanitizer/msan_interface.h> | |
| 39 | #define MSAN_UNPOISON(addr, size) \ | |
| 40 | do { \ | |
| 41 | if (!__builtin_is_constant_evaluated()) \ | |
| 42 | __msan_unpoison(addr, size); \ | |
| 43 | } while (0) | |
| 44 | #else | |
| 45 | #define MSAN_UNPOISON(ptr, size) | |
| 46 | #endif | |
| 47 | ||
| 48 | #ifdef LIBC_HAS_ADDRESS_SANITIZER | |
| 49 | #include <sanitizer/asan_interface.h> | |
| 50 | #define ASAN_POISON_MEMORY_REGION(addr, size) \ | |
| 51 | __asan_poison_memory_region((addr), (size)) | |
| 52 | #define ASAN_UNPOISON_MEMORY_REGION(addr, size) \ | |
| 53 | __asan_unpoison_memory_region((addr), (size)) | |
| 54 | #else | |
| 55 | #define ASAN_POISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size)) | |
| 56 | #define ASAN_UNPOISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size)) | |
| 57 | #endif | |
| 58 | ||
| 59 | #endif // LLVM_LIBC_SRC___SUPPORT_MACROS_SANITIZER_H |
lib/libcxx/libc/src/__support/math_extras.h created+161| ... | ... | @@ -0,0 +1,161 @@ |
| 1 | //===-- Mimics llvm/Support/MathExtras.h ------------------------*- C++ -*-===// | |
| 2 | // Provides useful math functions. | |
| 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 LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H | |
| 11 | #define LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H | |
| 12 | ||
| 13 | #include "src/__support/CPP/bit.h" // countl_one, countr_zero | |
| 14 | #include "src/__support/CPP/limits.h" // CHAR_BIT, numeric_limits | |
| 15 | #include "src/__support/CPP/type_traits.h" // is_unsigned_v, is_constant_evaluated | |
| 16 | #include "src/__support/macros/attributes.h" // LIBC_INLINE | |
| 17 | #include "src/__support/macros/config.h" | |
| 18 | ||
| 19 | namespace LIBC_NAMESPACE_DECL { | |
| 20 | ||
| 21 | // Create a bitmask with the count right-most bits set to 1, and all other bits | |
| 22 | // set to 0. Only unsigned types are allowed. | |
| 23 | template <typename T, size_t count> | |
| 24 | LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 25 | mask_trailing_ones() { | |
| 26 | constexpr unsigned T_BITS = CHAR_BIT * sizeof(T); | |
| 27 | static_assert(count <= T_BITS && "Invalid bit index"); | |
| 28 | return count == 0 ? 0 : (T(-1) >> (T_BITS - count)); | |
| 29 | } | |
| 30 | ||
| 31 | // Create a bitmask with the count left-most bits set to 1, and all other bits | |
| 32 | // set to 0. Only unsigned types are allowed. | |
| 33 | template <typename T, size_t count> | |
| 34 | LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 35 | mask_leading_ones() { | |
| 36 | return T(~mask_trailing_ones<T, CHAR_BIT * sizeof(T) - count>()); | |
| 37 | } | |
| 38 | ||
| 39 | // Create a bitmask with the count right-most bits set to 0, and all other bits | |
| 40 | // set to 1. Only unsigned types are allowed. | |
| 41 | template <typename T, size_t count> | |
| 42 | LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 43 | mask_trailing_zeros() { | |
| 44 | return mask_leading_ones<T, CHAR_BIT * sizeof(T) - count>(); | |
| 45 | } | |
| 46 | ||
| 47 | // Create a bitmask with the count left-most bits set to 0, and all other bits | |
| 48 | // set to 1. Only unsigned types are allowed. | |
| 49 | template <typename T, size_t count> | |
| 50 | LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 51 | mask_leading_zeros() { | |
| 52 | return mask_trailing_ones<T, CHAR_BIT * sizeof(T) - count>(); | |
| 53 | } | |
| 54 | ||
| 55 | // Returns whether 'a + b' overflows, the result is stored in 'res'. | |
| 56 | template <typename T> | |
| 57 | [[nodiscard]] LIBC_INLINE constexpr bool add_overflow(T a, T b, T &res) { | |
| 58 | return __builtin_add_overflow(a, b, &res); | |
| 59 | } | |
| 60 | ||
| 61 | // Returns whether 'a - b' overflows, the result is stored in 'res'. | |
| 62 | template <typename T> | |
| 63 | [[nodiscard]] LIBC_INLINE constexpr bool sub_overflow(T a, T b, T &res) { | |
| 64 | return __builtin_sub_overflow(a, b, &res); | |
| 65 | } | |
| 66 | ||
| 67 | #define RETURN_IF(TYPE, BUILTIN) \ | |
| 68 | if constexpr (cpp::is_same_v<T, TYPE>) \ | |
| 69 | return BUILTIN(a, b, carry_in, carry_out); | |
| 70 | ||
| 71 | // Returns the result of 'a + b' taking into account 'carry_in'. | |
| 72 | // The carry out is stored in 'carry_out' it not 'nullptr', dropped otherwise. | |
| 73 | // We keep the pass by pointer interface for consistency with the intrinsic. | |
| 74 | template <typename T> | |
| 75 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 76 | add_with_carry(T a, T b, T carry_in, T &carry_out) { | |
| 77 | if constexpr (!cpp::is_constant_evaluated()) { | |
| 78 | #if __has_builtin(__builtin_addcb) | |
| 79 | RETURN_IF(unsigned char, __builtin_addcb) | |
| 80 | #elif __has_builtin(__builtin_addcs) | |
| 81 | RETURN_IF(unsigned short, __builtin_addcs) | |
| 82 | #elif __has_builtin(__builtin_addc) | |
| 83 | RETURN_IF(unsigned int, __builtin_addc) | |
| 84 | #elif __has_builtin(__builtin_addcl) | |
| 85 | RETURN_IF(unsigned long, __builtin_addcl) | |
| 86 | #elif __has_builtin(__builtin_addcll) | |
| 87 | RETURN_IF(unsigned long long, __builtin_addcll) | |
| 88 | #endif | |
| 89 | } | |
| 90 | T sum = {}; | |
| 91 | T carry1 = add_overflow(a, b, sum); | |
| 92 | T carry2 = add_overflow(sum, carry_in, sum); | |
| 93 | carry_out = carry1 | carry2; | |
| 94 | return sum; | |
| 95 | } | |
| 96 | ||
| 97 | // Returns the result of 'a - b' taking into account 'carry_in'. | |
| 98 | // The carry out is stored in 'carry_out' it not 'nullptr', dropped otherwise. | |
| 99 | // We keep the pass by pointer interface for consistency with the intrinsic. | |
| 100 | template <typename T> | |
| 101 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T> | |
| 102 | sub_with_borrow(T a, T b, T carry_in, T &carry_out) { | |
| 103 | if constexpr (!cpp::is_constant_evaluated()) { | |
| 104 | #if __has_builtin(__builtin_subcb) | |
| 105 | RETURN_IF(unsigned char, __builtin_subcb) | |
| 106 | #elif __has_builtin(__builtin_subcs) | |
| 107 | RETURN_IF(unsigned short, __builtin_subcs) | |
| 108 | #elif __has_builtin(__builtin_subc) | |
| 109 | RETURN_IF(unsigned int, __builtin_subc) | |
| 110 | #elif __has_builtin(__builtin_subcl) | |
| 111 | RETURN_IF(unsigned long, __builtin_subcl) | |
| 112 | #elif __has_builtin(__builtin_subcll) | |
| 113 | RETURN_IF(unsigned long long, __builtin_subcll) | |
| 114 | #endif | |
| 115 | } | |
| 116 | T sub = {}; | |
| 117 | T carry1 = sub_overflow(a, b, sub); | |
| 118 | T carry2 = sub_overflow(sub, carry_in, sub); | |
| 119 | carry_out = carry1 | carry2; | |
| 120 | return sub; | |
| 121 | } | |
| 122 | ||
| 123 | #undef RETURN_IF | |
| 124 | ||
| 125 | template <typename T> | |
| 126 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 127 | first_leading_zero(T value) { | |
| 128 | return value == cpp::numeric_limits<T>::max() ? 0 | |
| 129 | : cpp::countl_one(value) + 1; | |
| 130 | } | |
| 131 | ||
| 132 | template <typename T> | |
| 133 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 134 | first_leading_one(T value) { | |
| 135 | return first_leading_zero(static_cast<T>(~value)); | |
| 136 | } | |
| 137 | ||
| 138 | template <typename T> | |
| 139 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 140 | first_trailing_zero(T value) { | |
| 141 | return value == cpp::numeric_limits<T>::max() | |
| 142 | ? 0 | |
| 143 | : cpp::countr_zero(static_cast<T>(~value)) + 1; | |
| 144 | } | |
| 145 | ||
| 146 | template <typename T> | |
| 147 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 148 | first_trailing_one(T value) { | |
| 149 | return value == cpp::numeric_limits<T>::max() ? 0 | |
| 150 | : cpp::countr_zero(value) + 1; | |
| 151 | } | |
| 152 | ||
| 153 | template <typename T> | |
| 154 | [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> | |
| 155 | count_zeros(T value) { | |
| 156 | return cpp::popcount<T>(static_cast<T>(~value)); | |
| 157 | } | |
| 158 | ||
| 159 | } // namespace LIBC_NAMESPACE_DECL | |
| 160 | ||
| 161 | #endif // LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H |
lib/libcxx/libc/src/__support/number_pair.h created+26| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | //===-- Utilities for pairs of numbers. -------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H | |
| 11 | ||
| 12 | #include "CPP/type_traits.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | ||
| 15 | #include <stddef.h> | |
| 16 | ||
| 17 | namespace LIBC_NAMESPACE_DECL { | |
| 18 | ||
| 19 | template <typename T> struct NumberPair { | |
| 20 | T lo = T(0); | |
| 21 | T hi = T(0); | |
| 22 | }; | |
| 23 | ||
| 24 | } // namespace LIBC_NAMESPACE_DECL | |
| 25 | ||
| 26 | #endif // LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H |
lib/libcxx/libc/src/__support/sign.h created+43| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | //===-- A simple sign type --------------------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_SIGN_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_SIGN_H | |
| 11 | ||
| 12 | #include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR | |
| 13 | ||
| 14 | namespace LIBC_NAMESPACE_DECL { | |
| 15 | ||
| 16 | // A type to interact with signed arithmetic types. | |
| 17 | struct Sign { | |
| 18 | LIBC_INLINE constexpr bool is_pos() const { return !is_negative; } | |
| 19 | LIBC_INLINE constexpr bool is_neg() const { return is_negative; } | |
| 20 | ||
| 21 | LIBC_INLINE friend constexpr bool operator==(Sign a, Sign b) { | |
| 22 | return a.is_negative == b.is_negative; | |
| 23 | } | |
| 24 | ||
| 25 | LIBC_INLINE friend constexpr bool operator!=(Sign a, Sign b) { | |
| 26 | return !(a == b); | |
| 27 | } | |
| 28 | ||
| 29 | static const Sign POS; | |
| 30 | static const Sign NEG; | |
| 31 | ||
| 32 | private: | |
| 33 | LIBC_INLINE constexpr explicit Sign(bool is_negative) | |
| 34 | : is_negative(is_negative) {} | |
| 35 | ||
| 36 | bool is_negative; | |
| 37 | }; | |
| 38 | ||
| 39 | LIBC_INLINE_VAR constexpr Sign Sign::NEG = Sign(true); | |
| 40 | LIBC_INLINE_VAR constexpr Sign Sign::POS = Sign(false); | |
| 41 | ||
| 42 | } // namespace LIBC_NAMESPACE_DECL | |
| 43 | #endif // LLVM_LIBC_SRC___SUPPORT_SIGN_H |
lib/libcxx/libc/src/__support/str_to_float.h created+1275| ... | ... | @@ -0,0 +1,1275 @@ |
| 1 | //===-- String to float conversion utils ------------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // ----------------------------------------------------------------------------- | |
| 10 | // **** WARNING **** | |
| 11 | // This file is shared with libc++. You should also be careful when adding | |
| 12 | // dependencies to this file, since it needs to build for all libc++ targets. | |
| 13 | // ----------------------------------------------------------------------------- | |
| 14 | ||
| 15 | #ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H | |
| 16 | #define LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H | |
| 17 | ||
| 18 | #include "src/__support/CPP/bit.h" | |
| 19 | #include "src/__support/CPP/limits.h" | |
| 20 | #include "src/__support/CPP/optional.h" | |
| 21 | #include "src/__support/CPP/string_view.h" | |
| 22 | #include "src/__support/FPUtil/FPBits.h" | |
| 23 | #include "src/__support/FPUtil/rounding_mode.h" | |
| 24 | #include "src/__support/common.h" | |
| 25 | #include "src/__support/ctype_utils.h" | |
| 26 | #include "src/__support/detailed_powers_of_ten.h" | |
| 27 | #include "src/__support/high_precision_decimal.h" | |
| 28 | #include "src/__support/macros/config.h" | |
| 29 | #include "src/__support/macros/null_check.h" | |
| 30 | #include "src/__support/macros/optimization.h" | |
| 31 | #include "src/__support/str_to_integer.h" | |
| 32 | #include "src/__support/str_to_num_result.h" | |
| 33 | #include "src/__support/uint128.h" | |
| 34 | #include "src/errno/libc_errno.h" // For ERANGE | |
| 35 | ||
| 36 | #include <stdint.h> | |
| 37 | ||
| 38 | namespace LIBC_NAMESPACE_DECL { | |
| 39 | namespace internal { | |
| 40 | ||
| 41 | // ----------------------------------------------------------------------------- | |
| 42 | // **** WARNING **** | |
| 43 | // This interface is shared with libc++, if you change this interface you need | |
| 44 | // to update it in both libc and libc++. | |
| 45 | // ----------------------------------------------------------------------------- | |
| 46 | template <class T> struct ExpandedFloat { | |
| 47 | typename fputil::FPBits<T>::StorageType mantissa; | |
| 48 | int32_t exponent; | |
| 49 | }; | |
| 50 | ||
| 51 | // ----------------------------------------------------------------------------- | |
| 52 | // **** WARNING **** | |
| 53 | // This interface is shared with libc++, if you change this interface you need | |
| 54 | // to update it in both libc and libc++. | |
| 55 | // ----------------------------------------------------------------------------- | |
| 56 | template <class T> struct FloatConvertReturn { | |
| 57 | ExpandedFloat<T> num = {0, 0}; | |
| 58 | int error = 0; | |
| 59 | }; | |
| 60 | ||
| 61 | LIBC_INLINE uint64_t low64(const UInt128 &num) { | |
| 62 | return static_cast<uint64_t>(num & 0xffffffffffffffff); | |
| 63 | } | |
| 64 | ||
| 65 | LIBC_INLINE uint64_t high64(const UInt128 &num) { | |
| 66 | return static_cast<uint64_t>(num >> 64); | |
| 67 | } | |
| 68 | ||
| 69 | template <class T> LIBC_INLINE void set_implicit_bit(fputil::FPBits<T> &) { | |
| 70 | return; | |
| 71 | } | |
| 72 | ||
| 73 | #if defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80) | |
| 74 | template <> | |
| 75 | LIBC_INLINE void | |
| 76 | set_implicit_bit<long double>(fputil::FPBits<long double> &result) { | |
| 77 | result.set_implicit_bit(result.get_biased_exponent() != 0); | |
| 78 | } | |
| 79 | #endif // LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80 | |
| 80 | ||
| 81 | // This Eisel-Lemire implementation is based on the algorithm described in the | |
| 82 | // paper Number Parsing at a Gigabyte per Second, Software: Practice and | |
| 83 | // Experience 51 (8), 2021 (https://arxiv.org/abs/2101.11408), as well as the | |
| 84 | // description by Nigel Tao | |
| 85 | // (https://nigeltao.github.io/blog/2020/eisel-lemire.html) and the golang | |
| 86 | // implementation, also by Nigel Tao | |
| 87 | // (https://github.com/golang/go/blob/release-branch.go1.16/src/strconv/eisel_lemire.go#L25) | |
| 88 | // for some optimizations as well as handling 32 bit floats. | |
| 89 | template <class T> | |
| 90 | LIBC_INLINE cpp::optional<ExpandedFloat<T>> | |
| 91 | eisel_lemire(ExpandedFloat<T> init_num, | |
| 92 | RoundDirection round = RoundDirection::Nearest) { | |
| 93 | using FPBits = typename fputil::FPBits<T>; | |
| 94 | using StorageType = typename FPBits::StorageType; | |
| 95 | ||
| 96 | StorageType mantissa = init_num.mantissa; | |
| 97 | int32_t exp10 = init_num.exponent; | |
| 98 | ||
| 99 | if (sizeof(T) > 8) { // This algorithm cannot handle anything longer than a | |
| 100 | // double, so we skip straight to the fallback. | |
| 101 | return cpp::nullopt; | |
| 102 | } | |
| 103 | ||
| 104 | // Exp10 Range | |
| 105 | if (exp10 < DETAILED_POWERS_OF_TEN_MIN_EXP_10 || | |
| 106 | exp10 > DETAILED_POWERS_OF_TEN_MAX_EXP_10) { | |
| 107 | return cpp::nullopt; | |
| 108 | } | |
| 109 | ||
| 110 | // Normalization | |
| 111 | uint32_t clz = cpp::countl_zero<StorageType>(mantissa); | |
| 112 | mantissa <<= clz; | |
| 113 | ||
| 114 | int32_t exp2 = | |
| 115 | exp10_to_exp2(exp10) + FPBits::STORAGE_LEN + FPBits::EXP_BIAS - clz; | |
| 116 | ||
| 117 | // Multiplication | |
| 118 | const uint64_t *power_of_ten = | |
| 119 | DETAILED_POWERS_OF_TEN[exp10 - DETAILED_POWERS_OF_TEN_MIN_EXP_10]; | |
| 120 | ||
| 121 | UInt128 first_approx = | |
| 122 | static_cast<UInt128>(mantissa) * static_cast<UInt128>(power_of_ten[1]); | |
| 123 | ||
| 124 | // Wider Approximation | |
| 125 | UInt128 final_approx; | |
| 126 | // The halfway constant is used to check if the bits that will be shifted away | |
| 127 | // intially are all 1. For doubles this is 64 (bitstype size) - 52 (final | |
| 128 | // mantissa size) - 3 (we shift away the last two bits separately for | |
| 129 | // accuracy, and the most significant bit is ignored.) = 9 bits. Similarly, | |
| 130 | // it's 6 bits for floats in this case. | |
| 131 | const uint64_t halfway_constant = | |
| 132 | (uint64_t(1) << (FPBits::STORAGE_LEN - (FPBits::FRACTION_LEN + 3))) - 1; | |
| 133 | if ((high64(first_approx) & halfway_constant) == halfway_constant && | |
| 134 | low64(first_approx) + mantissa < mantissa) { | |
| 135 | UInt128 low_bits = | |
| 136 | static_cast<UInt128>(mantissa) * static_cast<UInt128>(power_of_ten[0]); | |
| 137 | UInt128 second_approx = | |
| 138 | first_approx + static_cast<UInt128>(high64(low_bits)); | |
| 139 | ||
| 140 | if ((high64(second_approx) & halfway_constant) == halfway_constant && | |
| 141 | low64(second_approx) + 1 == 0 && | |
| 142 | low64(low_bits) + mantissa < mantissa) { | |
| 143 | return cpp::nullopt; | |
| 144 | } | |
| 145 | final_approx = second_approx; | |
| 146 | } else { | |
| 147 | final_approx = first_approx; | |
| 148 | } | |
| 149 | ||
| 150 | // Shifting to 54 bits for doubles and 25 bits for floats | |
| 151 | StorageType msb = static_cast<StorageType>(high64(final_approx) >> | |
| 152 | (FPBits::STORAGE_LEN - 1)); | |
| 153 | StorageType final_mantissa = static_cast<StorageType>( | |
| 154 | high64(final_approx) >> | |
| 155 | (msb + FPBits::STORAGE_LEN - (FPBits::FRACTION_LEN + 3))); | |
| 156 | exp2 -= static_cast<uint32_t>(1 ^ msb); // same as !msb | |
| 157 | ||
| 158 | if (round == RoundDirection::Nearest) { | |
| 159 | // Half-way ambiguity | |
| 160 | if (low64(final_approx) == 0 && | |
| 161 | (high64(final_approx) & halfway_constant) == 0 && | |
| 162 | (final_mantissa & 3) == 1) { | |
| 163 | return cpp::nullopt; | |
| 164 | } | |
| 165 | ||
| 166 | // Round to even. | |
| 167 | final_mantissa += final_mantissa & 1; | |
| 168 | ||
| 169 | } else if (round == RoundDirection::Up) { | |
| 170 | // If any of the bits being rounded away are non-zero, then round up. | |
| 171 | if (low64(final_approx) > 0 || | |
| 172 | (high64(final_approx) & halfway_constant) > 0) { | |
| 173 | // Add two since the last current lowest bit is about to be shifted away. | |
| 174 | final_mantissa += 2; | |
| 175 | } | |
| 176 | } | |
| 177 | // else round down, which has no effect. | |
| 178 | ||
| 179 | // From 54 to 53 bits for doubles and 25 to 24 bits for floats | |
| 180 | final_mantissa >>= 1; | |
| 181 | if ((final_mantissa >> (FPBits::FRACTION_LEN + 1)) > 0) { | |
| 182 | final_mantissa >>= 1; | |
| 183 | ++exp2; | |
| 184 | } | |
| 185 | ||
| 186 | // The if block is equivalent to (but has fewer branches than): | |
| 187 | // if exp2 <= 0 || exp2 >= 0x7FF { etc } | |
| 188 | if (static_cast<uint32_t>(exp2) - 1 >= (1 << FPBits::EXP_LEN) - 2) { | |
| 189 | return cpp::nullopt; | |
| 190 | } | |
| 191 | ||
| 192 | ExpandedFloat<T> output; | |
| 193 | output.mantissa = final_mantissa; | |
| 194 | output.exponent = exp2; | |
| 195 | return output; | |
| 196 | } | |
| 197 | ||
| 198 | // TODO: Re-enable eisel-lemire for long double is double double once it's | |
| 199 | // properly supported. | |
| 200 | #if !defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64) && \ | |
| 201 | !defined(LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE) | |
| 202 | template <> | |
| 203 | LIBC_INLINE cpp::optional<ExpandedFloat<long double>> | |
| 204 | eisel_lemire<long double>(ExpandedFloat<long double> init_num, | |
| 205 | RoundDirection round) { | |
| 206 | using FPBits = typename fputil::FPBits<long double>; | |
| 207 | using StorageType = typename FPBits::StorageType; | |
| 208 | ||
| 209 | UInt128 mantissa = init_num.mantissa; | |
| 210 | int32_t exp10 = init_num.exponent; | |
| 211 | ||
| 212 | // Exp10 Range | |
| 213 | // This doesn't reach very far into the range for long doubles, since it's | |
| 214 | // sized for doubles and their 11 exponent bits, and not for long doubles and | |
| 215 | // their 15 exponent bits (max exponent of ~300 for double vs ~5000 for long | |
| 216 | // double). This is a known tradeoff, and was made because a proper long | |
| 217 | // double table would be approximately 16 times larger. This would have | |
| 218 | // significant memory and storage costs all the time to speed up a relatively | |
| 219 | // uncommon path. In addition the exp10_to_exp2 function only approximates | |
| 220 | // multiplying by log(10)/log(2), and that approximation may not be accurate | |
| 221 | // out to the full long double range. | |
| 222 | if (exp10 < DETAILED_POWERS_OF_TEN_MIN_EXP_10 || | |
| 223 | exp10 > DETAILED_POWERS_OF_TEN_MAX_EXP_10) { | |
| 224 | return cpp::nullopt; | |
| 225 | } | |
| 226 | ||
| 227 | // Normalization | |
| 228 | uint32_t clz = cpp::countl_zero(mantissa) - | |
| 229 | ((sizeof(UInt128) - sizeof(StorageType)) * CHAR_BIT); | |
| 230 | mantissa <<= clz; | |
| 231 | ||
| 232 | int32_t exp2 = | |
| 233 | exp10_to_exp2(exp10) + FPBits::STORAGE_LEN + FPBits::EXP_BIAS - clz; | |
| 234 | ||
| 235 | // Multiplication | |
| 236 | const uint64_t *power_of_ten = | |
| 237 | DETAILED_POWERS_OF_TEN[exp10 - DETAILED_POWERS_OF_TEN_MIN_EXP_10]; | |
| 238 | ||
| 239 | // Since the input mantissa is more than 64 bits, we have to multiply with the | |
| 240 | // full 128 bits of the power of ten to get an approximation with the same | |
| 241 | // number of significant bits. This means that we only get the one | |
| 242 | // approximation, and that approximation is 256 bits long. | |
| 243 | UInt128 approx_upper = static_cast<UInt128>(high64(mantissa)) * | |
| 244 | static_cast<UInt128>(power_of_ten[1]); | |
| 245 | ||
| 246 | UInt128 approx_middle_a = static_cast<UInt128>(high64(mantissa)) * | |
| 247 | static_cast<UInt128>(power_of_ten[0]); | |
| 248 | UInt128 approx_middle_b = static_cast<UInt128>(low64(mantissa)) * | |
| 249 | static_cast<UInt128>(power_of_ten[1]); | |
| 250 | ||
| 251 | UInt128 approx_middle = approx_middle_a + approx_middle_b; | |
| 252 | ||
| 253 | // Handle overflow in the middle | |
| 254 | approx_upper += (approx_middle < approx_middle_a) ? UInt128(1) << 64 : 0; | |
| 255 | ||
| 256 | UInt128 approx_lower = static_cast<UInt128>(low64(mantissa)) * | |
| 257 | static_cast<UInt128>(power_of_ten[0]); | |
| 258 | ||
| 259 | UInt128 final_approx_lower = | |
| 260 | approx_lower + (static_cast<UInt128>(low64(approx_middle)) << 64); | |
| 261 | UInt128 final_approx_upper = approx_upper + high64(approx_middle) + | |
| 262 | (final_approx_lower < approx_lower ? 1 : 0); | |
| 263 | ||
| 264 | // The halfway constant is used to check if the bits that will be shifted away | |
| 265 | // intially are all 1. For 80 bit floats this is 128 (bitstype size) - 64 | |
| 266 | // (final mantissa size) - 3 (we shift away the last two bits separately for | |
| 267 | // accuracy, and the most significant bit is ignored.) = 61 bits. Similarly, | |
| 268 | // it's 12 bits for 128 bit floats in this case. | |
| 269 | constexpr UInt128 HALFWAY_CONSTANT = | |
| 270 | (UInt128(1) << (FPBits::STORAGE_LEN - (FPBits::FRACTION_LEN + 3))) - 1; | |
| 271 | ||
| 272 | if ((final_approx_upper & HALFWAY_CONSTANT) == HALFWAY_CONSTANT && | |
| 273 | final_approx_lower + mantissa < mantissa) { | |
| 274 | return cpp::nullopt; | |
| 275 | } | |
| 276 | ||
| 277 | // Shifting to 65 bits for 80 bit floats and 113 bits for 128 bit floats | |
| 278 | uint32_t msb = | |
| 279 | static_cast<uint32_t>(final_approx_upper >> (FPBits::STORAGE_LEN - 1)); | |
| 280 | UInt128 final_mantissa = final_approx_upper >> (msb + FPBits::STORAGE_LEN - | |
| 281 | (FPBits::FRACTION_LEN + 3)); | |
| 282 | exp2 -= static_cast<uint32_t>(1 ^ msb); // same as !msb | |
| 283 | ||
| 284 | if (round == RoundDirection::Nearest) { | |
| 285 | // Half-way ambiguity | |
| 286 | if (final_approx_lower == 0 && | |
| 287 | (final_approx_upper & HALFWAY_CONSTANT) == 0 && | |
| 288 | (final_mantissa & 3) == 1) { | |
| 289 | return cpp::nullopt; | |
| 290 | } | |
| 291 | // Round to even. | |
| 292 | final_mantissa += final_mantissa & 1; | |
| 293 | ||
| 294 | } else if (round == RoundDirection::Up) { | |
| 295 | // If any of the bits being rounded away are non-zero, then round up. | |
| 296 | if (final_approx_lower > 0 || (final_approx_upper & HALFWAY_CONSTANT) > 0) { | |
| 297 | // Add two since the last current lowest bit is about to be shifted away. | |
| 298 | final_mantissa += 2; | |
| 299 | } | |
| 300 | } | |
| 301 | // else round down, which has no effect. | |
| 302 | ||
| 303 | // From 65 to 64 bits for 80 bit floats and 113 to 112 bits for 128 bit | |
| 304 | // floats | |
| 305 | final_mantissa >>= 1; | |
| 306 | if ((final_mantissa >> (FPBits::FRACTION_LEN + 1)) > 0) { | |
| 307 | final_mantissa >>= 1; | |
| 308 | ++exp2; | |
| 309 | } | |
| 310 | ||
| 311 | // The if block is equivalent to (but has fewer branches than): | |
| 312 | // if exp2 <= 0 || exp2 >= MANTISSA_MAX { etc } | |
| 313 | if (exp2 - 1 >= (1 << FPBits::EXP_LEN) - 2) { | |
| 314 | return cpp::nullopt; | |
| 315 | } | |
| 316 | ||
| 317 | ExpandedFloat<long double> output; | |
| 318 | output.mantissa = static_cast<StorageType>(final_mantissa); | |
| 319 | output.exponent = exp2; | |
| 320 | return output; | |
| 321 | } | |
| 322 | #endif // !defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64) && | |
| 323 | // !defined(LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE) | |
| 324 | ||
| 325 | // The nth item in POWERS_OF_TWO represents the greatest power of two less than | |
| 326 | // 10^n. This tells us how much we can safely shift without overshooting. | |
| 327 | constexpr uint8_t POWERS_OF_TWO[19] = { | |
| 328 | 0, 3, 6, 9, 13, 16, 19, 23, 26, 29, 33, 36, 39, 43, 46, 49, 53, 56, 59, | |
| 329 | }; | |
| 330 | constexpr int32_t NUM_POWERS_OF_TWO = | |
| 331 | sizeof(POWERS_OF_TWO) / sizeof(POWERS_OF_TWO[0]); | |
| 332 | ||
| 333 | // Takes a mantissa and base 10 exponent and converts it into its closest | |
| 334 | // floating point type T equivalent. This is the fallback algorithm used when | |
| 335 | // the Eisel-Lemire algorithm fails, it's slower but more accurate. It's based | |
| 336 | // on the Simple Decimal Conversion algorithm by Nigel Tao, described at this | |
| 337 | // link: https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html | |
| 338 | template <class T> | |
| 339 | LIBC_INLINE FloatConvertReturn<T> simple_decimal_conversion( | |
| 340 | const char *__restrict numStart, | |
| 341 | const size_t num_len = cpp::numeric_limits<size_t>::max(), | |
| 342 | RoundDirection round = RoundDirection::Nearest) { | |
| 343 | using FPBits = typename fputil::FPBits<T>; | |
| 344 | using StorageType = typename FPBits::StorageType; | |
| 345 | ||
| 346 | int32_t exp2 = 0; | |
| 347 | HighPrecisionDecimal hpd = HighPrecisionDecimal(numStart, num_len); | |
| 348 | ||
| 349 | FloatConvertReturn<T> output; | |
| 350 | ||
| 351 | if (hpd.get_num_digits() == 0) { | |
| 352 | output.num = {0, 0}; | |
| 353 | return output; | |
| 354 | } | |
| 355 | ||
| 356 | // If the exponent is too large and can't be represented in this size of | |
| 357 | // float, return inf. | |
| 358 | if (hpd.get_decimal_point() > 0 && | |
| 359 | exp10_to_exp2(hpd.get_decimal_point() - 1) > FPBits::EXP_BIAS) { | |
| 360 | output.num = {0, fputil::FPBits<T>::MAX_BIASED_EXPONENT}; | |
| 361 | output.error = ERANGE; | |
| 362 | return output; | |
| 363 | } | |
| 364 | // If the exponent is too small even for a subnormal, return 0. | |
| 365 | if (hpd.get_decimal_point() < 0 && | |
| 366 | exp10_to_exp2(-hpd.get_decimal_point()) > | |
| 367 | (FPBits::EXP_BIAS + static_cast<int32_t>(FPBits::FRACTION_LEN))) { | |
| 368 | output.num = {0, 0}; | |
| 369 | output.error = ERANGE; | |
| 370 | return output; | |
| 371 | } | |
| 372 | ||
| 373 | // Right shift until the number is smaller than 1. | |
| 374 | while (hpd.get_decimal_point() > 0) { | |
| 375 | int32_t shift_amount = 0; | |
| 376 | if (hpd.get_decimal_point() >= NUM_POWERS_OF_TWO) { | |
| 377 | shift_amount = 60; | |
| 378 | } else { | |
| 379 | shift_amount = POWERS_OF_TWO[hpd.get_decimal_point()]; | |
| 380 | } | |
| 381 | exp2 += shift_amount; | |
| 382 | hpd.shift(-shift_amount); | |
| 383 | } | |
| 384 | ||
| 385 | // Left shift until the number is between 1/2 and 1 | |
| 386 | while (hpd.get_decimal_point() < 0 || | |
| 387 | (hpd.get_decimal_point() == 0 && hpd.get_digits()[0] < 5)) { | |
| 388 | int32_t shift_amount = 0; | |
| 389 | ||
| 390 | if (-hpd.get_decimal_point() >= NUM_POWERS_OF_TWO) { | |
| 391 | shift_amount = 60; | |
| 392 | } else if (hpd.get_decimal_point() != 0) { | |
| 393 | shift_amount = POWERS_OF_TWO[-hpd.get_decimal_point()]; | |
| 394 | } else { // This handles the case of the number being between .1 and .5 | |
| 395 | shift_amount = 1; | |
| 396 | } | |
| 397 | exp2 -= shift_amount; | |
| 398 | hpd.shift(shift_amount); | |
| 399 | } | |
| 400 | ||
| 401 | // Left shift once so that the number is between 1 and 2 | |
| 402 | --exp2; | |
| 403 | hpd.shift(1); | |
| 404 | ||
| 405 | // Get the biased exponent | |
| 406 | exp2 += FPBits::EXP_BIAS; | |
| 407 | ||
| 408 | // Handle the exponent being too large (and return inf). | |
| 409 | if (exp2 >= FPBits::MAX_BIASED_EXPONENT) { | |
| 410 | output.num = {0, FPBits::MAX_BIASED_EXPONENT}; | |
| 411 | output.error = ERANGE; | |
| 412 | return output; | |
| 413 | } | |
| 414 | ||
| 415 | // Shift left to fill the mantissa | |
| 416 | hpd.shift(FPBits::FRACTION_LEN); | |
| 417 | StorageType final_mantissa = hpd.round_to_integer_type<StorageType>(); | |
| 418 | ||
| 419 | // Handle subnormals | |
| 420 | if (exp2 <= 0) { | |
| 421 | // Shift right until there is a valid exponent | |
| 422 | while (exp2 < 0) { | |
| 423 | hpd.shift(-1); | |
| 424 | ++exp2; | |
| 425 | } | |
| 426 | // Shift right one more time to compensate for the left shift to get it | |
| 427 | // between 1 and 2. | |
| 428 | hpd.shift(-1); | |
| 429 | final_mantissa = hpd.round_to_integer_type<StorageType>(round); | |
| 430 | ||
| 431 | // Check if by shifting right we've caused this to round to a normal number. | |
| 432 | if ((final_mantissa >> FPBits::FRACTION_LEN) != 0) { | |
| 433 | ++exp2; | |
| 434 | } | |
| 435 | } | |
| 436 | ||
| 437 | // Check if rounding added a bit, and shift down if that's the case. | |
| 438 | if (final_mantissa == StorageType(2) << FPBits::FRACTION_LEN) { | |
| 439 | final_mantissa >>= 1; | |
| 440 | ++exp2; | |
| 441 | ||
| 442 | // Check if this rounding causes exp2 to go out of range and make the result | |
| 443 | // INF. If this is the case, then finalMantissa and exp2 are already the | |
| 444 | // correct values for an INF result. | |
| 445 | if (exp2 >= FPBits::MAX_BIASED_EXPONENT) { | |
| 446 | output.error = ERANGE; | |
| 447 | } | |
| 448 | } | |
| 449 | ||
| 450 | if (exp2 == 0) { | |
| 451 | output.error = ERANGE; | |
| 452 | } | |
| 453 | ||
| 454 | output.num = {final_mantissa, exp2}; | |
| 455 | return output; | |
| 456 | } | |
| 457 | ||
| 458 | // This class is used for templating the constants for Clinger's Fast Path, | |
| 459 | // described as a method of approximation in | |
| 460 | // Clinger WD. How to Read Floating Point Numbers Accurately. SIGPLAN Not 1990 | |
| 461 | // Jun;25(6):92–101. https://doi.org/10.1145/93548.93557. | |
| 462 | // As well as the additions by Gay that extend the useful range by the number of | |
| 463 | // exact digits stored by the float type, described in | |
| 464 | // Gay DM, Correctly rounded binary-decimal and decimal-binary conversions; | |
| 465 | // 1990. AT&T Bell Laboratories Numerical Analysis Manuscript 90-10. | |
| 466 | template <class T> class ClingerConsts; | |
| 467 | ||
| 468 | template <> class ClingerConsts<float> { | |
| 469 | public: | |
| 470 | static constexpr float POWERS_OF_TEN_ARRAY[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5, | |
| 471 | 1e6, 1e7, 1e8, 1e9, 1e10}; | |
| 472 | static constexpr int32_t EXACT_POWERS_OF_TEN = 10; | |
| 473 | static constexpr int32_t DIGITS_IN_MANTISSA = 7; | |
| 474 | static constexpr float MAX_EXACT_INT = 16777215.0; | |
| 475 | }; | |
| 476 | ||
| 477 | template <> class ClingerConsts<double> { | |
| 478 | public: | |
| 479 | static constexpr double POWERS_OF_TEN_ARRAY[] = { | |
| 480 | 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, | |
| 481 | 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; | |
| 482 | static constexpr int32_t EXACT_POWERS_OF_TEN = 22; | |
| 483 | static constexpr int32_t DIGITS_IN_MANTISSA = 15; | |
| 484 | static constexpr double MAX_EXACT_INT = 9007199254740991.0; | |
| 485 | }; | |
| 486 | ||
| 487 | #if defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT64) | |
| 488 | template <> class ClingerConsts<long double> { | |
| 489 | public: | |
| 490 | static constexpr long double POWERS_OF_TEN_ARRAY[] = { | |
| 491 | 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, | |
| 492 | 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; | |
| 493 | static constexpr int32_t EXACT_POWERS_OF_TEN = | |
| 494 | ClingerConsts<double>::EXACT_POWERS_OF_TEN; | |
| 495 | static constexpr int32_t DIGITS_IN_MANTISSA = | |
| 496 | ClingerConsts<double>::DIGITS_IN_MANTISSA; | |
| 497 | static constexpr long double MAX_EXACT_INT = | |
| 498 | ClingerConsts<double>::MAX_EXACT_INT; | |
| 499 | }; | |
| 500 | #elif defined(LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80) | |
| 501 | template <> class ClingerConsts<long double> { | |
| 502 | public: | |
| 503 | static constexpr long double POWERS_OF_TEN_ARRAY[] = { | |
| 504 | 1e0L, 1e1L, 1e2L, 1e3L, 1e4L, 1e5L, 1e6L, 1e7L, 1e8L, 1e9L, | |
| 505 | 1e10L, 1e11L, 1e12L, 1e13L, 1e14L, 1e15L, 1e16L, 1e17L, 1e18L, 1e19L, | |
| 506 | 1e20L, 1e21L, 1e22L, 1e23L, 1e24L, 1e25L, 1e26L, 1e27L}; | |
| 507 | static constexpr int32_t EXACT_POWERS_OF_TEN = 27; | |
| 508 | static constexpr int32_t DIGITS_IN_MANTISSA = 21; | |
| 509 | static constexpr long double MAX_EXACT_INT = 18446744073709551615.0L; | |
| 510 | }; | |
| 511 | #elif defined(LIBC_TYPES_LONG_DOUBLE_IS_FLOAT128) | |
| 512 | template <> class ClingerConsts<long double> { | |
| 513 | public: | |
| 514 | static constexpr long double POWERS_OF_TEN_ARRAY[] = { | |
| 515 | 1e0L, 1e1L, 1e2L, 1e3L, 1e4L, 1e5L, 1e6L, 1e7L, 1e8L, 1e9L, | |
| 516 | 1e10L, 1e11L, 1e12L, 1e13L, 1e14L, 1e15L, 1e16L, 1e17L, 1e18L, 1e19L, | |
| 517 | 1e20L, 1e21L, 1e22L, 1e23L, 1e24L, 1e25L, 1e26L, 1e27L, 1e28L, 1e29L, | |
| 518 | 1e30L, 1e31L, 1e32L, 1e33L, 1e34L, 1e35L, 1e36L, 1e37L, 1e38L, 1e39L, | |
| 519 | 1e40L, 1e41L, 1e42L, 1e43L, 1e44L, 1e45L, 1e46L, 1e47L, 1e48L}; | |
| 520 | static constexpr int32_t EXACT_POWERS_OF_TEN = 48; | |
| 521 | static constexpr int32_t DIGITS_IN_MANTISSA = 33; | |
| 522 | static constexpr long double MAX_EXACT_INT = | |
| 523 | 10384593717069655257060992658440191.0L; | |
| 524 | }; | |
| 525 | #elif defined(LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE) | |
| 526 | // TODO: Add proper double double type support here, currently using constants | |
| 527 | // for double since it should be safe. | |
| 528 | template <> class ClingerConsts<long double> { | |
| 529 | public: | |
| 530 | static constexpr double POWERS_OF_TEN_ARRAY[] = { | |
| 531 | 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, | |
| 532 | 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; | |
| 533 | static constexpr int32_t EXACT_POWERS_OF_TEN = 22; | |
| 534 | static constexpr int32_t DIGITS_IN_MANTISSA = 15; | |
| 535 | static constexpr double MAX_EXACT_INT = 9007199254740991.0; | |
| 536 | }; | |
| 537 | #else | |
| 538 | #error "Unknown long double type" | |
| 539 | #endif | |
| 540 | ||
| 541 | // Take an exact mantissa and exponent and attempt to convert it using only | |
| 542 | // exact floating point arithmetic. This only handles numbers with low | |
| 543 | // exponents, but handles them quickly. This is an implementation of Clinger's | |
| 544 | // Fast Path, as described above. | |
| 545 | template <class T> | |
| 546 | LIBC_INLINE cpp::optional<ExpandedFloat<T>> | |
| 547 | clinger_fast_path(ExpandedFloat<T> init_num, | |
| 548 | RoundDirection round = RoundDirection::Nearest) { | |
| 549 | using FPBits = typename fputil::FPBits<T>; | |
| 550 | using StorageType = typename FPBits::StorageType; | |
| 551 | ||
| 552 | StorageType mantissa = init_num.mantissa; | |
| 553 | int32_t exp10 = init_num.exponent; | |
| 554 | ||
| 555 | if ((mantissa >> FPBits::FRACTION_LEN) > 0) { | |
| 556 | return cpp::nullopt; | |
| 557 | } | |
| 558 | ||
| 559 | FPBits result; | |
| 560 | T float_mantissa; | |
| 561 | if constexpr (is_big_int_v<StorageType> || sizeof(T) > sizeof(uint64_t)) { | |
| 562 | float_mantissa = | |
| 563 | (static_cast<T>(uint64_t(mantissa >> 64)) * static_cast<T>(0x1.0p64)) + | |
| 564 | static_cast<T>(uint64_t(mantissa)); | |
| 565 | } else { | |
| 566 | float_mantissa = static_cast<T>(mantissa); | |
| 567 | } | |
| 568 | ||
| 569 | if (exp10 == 0) { | |
| 570 | result = FPBits(float_mantissa); | |
| 571 | } | |
| 572 | if (exp10 > 0) { | |
| 573 | if (exp10 > ClingerConsts<T>::EXACT_POWERS_OF_TEN + | |
| 574 | ClingerConsts<T>::DIGITS_IN_MANTISSA) { | |
| 575 | return cpp::nullopt; | |
| 576 | } | |
| 577 | if (exp10 > ClingerConsts<T>::EXACT_POWERS_OF_TEN) { | |
| 578 | float_mantissa = float_mantissa * | |
| 579 | ClingerConsts<T>::POWERS_OF_TEN_ARRAY | |
| 580 | [exp10 - ClingerConsts<T>::EXACT_POWERS_OF_TEN]; | |
| 581 | exp10 = ClingerConsts<T>::EXACT_POWERS_OF_TEN; | |
| 582 | } | |
| 583 | if (float_mantissa > ClingerConsts<T>::MAX_EXACT_INT) { | |
| 584 | return cpp::nullopt; | |
| 585 | } | |
| 586 | result = | |
| 587 | FPBits(float_mantissa * ClingerConsts<T>::POWERS_OF_TEN_ARRAY[exp10]); | |
| 588 | } else if (exp10 < 0) { | |
| 589 | if (-exp10 > ClingerConsts<T>::EXACT_POWERS_OF_TEN) { | |
| 590 | return cpp::nullopt; | |
| 591 | } | |
| 592 | result = | |
| 593 | FPBits(float_mantissa / ClingerConsts<T>::POWERS_OF_TEN_ARRAY[-exp10]); | |
| 594 | } | |
| 595 | ||
| 596 | // If the rounding mode is not nearest, then the sign of the number may affect | |
| 597 | // the result. To make sure the rounding mode is respected properly, the | |
| 598 | // calculation is redone with a negative result, and the rounding mode is used | |
| 599 | // to select the correct result. | |
| 600 | if (round != RoundDirection::Nearest) { | |
| 601 | FPBits negative_result; | |
| 602 | // I'm 99% sure this will break under fast math optimizations. | |
| 603 | negative_result = FPBits((-float_mantissa) * | |
| 604 | ClingerConsts<T>::POWERS_OF_TEN_ARRAY[exp10]); | |
| 605 | ||
| 606 | // If the results are equal, then we don't need to use the rounding mode. | |
| 607 | if (result.get_val() != -negative_result.get_val()) { | |
| 608 | FPBits lower_result; | |
| 609 | FPBits higher_result; | |
| 610 | ||
| 611 | if (result.get_val() < -negative_result.get_val()) { | |
| 612 | lower_result = result; | |
| 613 | higher_result = negative_result; | |
| 614 | } else { | |
| 615 | lower_result = negative_result; | |
| 616 | higher_result = result; | |
| 617 | } | |
| 618 | ||
| 619 | if (round == RoundDirection::Up) { | |
| 620 | result = higher_result; | |
| 621 | } else { | |
| 622 | result = lower_result; | |
| 623 | } | |
| 624 | } | |
| 625 | } | |
| 626 | ||
| 627 | ExpandedFloat<T> output; | |
| 628 | output.mantissa = result.get_explicit_mantissa(); | |
| 629 | output.exponent = result.get_biased_exponent(); | |
| 630 | return output; | |
| 631 | } | |
| 632 | ||
| 633 | // The upper bound is the highest base-10 exponent that could possibly give a | |
| 634 | // non-inf result for this size of float. The value is | |
| 635 | // log10(2^(exponent bias)). | |
| 636 | // The generic approximation uses the fact that log10(2^x) ~= x/3 | |
| 637 | template <typename T> LIBC_INLINE constexpr int32_t get_upper_bound() { | |
| 638 | return fputil::FPBits<T>::EXP_BIAS / 3; | |
| 639 | } | |
| 640 | ||
| 641 | template <> LIBC_INLINE constexpr int32_t get_upper_bound<float>() { | |
| 642 | return 39; | |
| 643 | } | |
| 644 | ||
| 645 | template <> LIBC_INLINE constexpr int32_t get_upper_bound<double>() { | |
| 646 | return 309; | |
| 647 | } | |
| 648 | ||
| 649 | // The lower bound is the largest negative base-10 exponent that could possibly | |
| 650 | // give a non-zero result for this size of float. The value is | |
| 651 | // log10(2^(exponent bias + final mantissa width + intermediate mantissa width)) | |
| 652 | // The intermediate mantissa is the integer that's been parsed from the string, | |
| 653 | // and the final mantissa is the fractional part of the output number. A very | |
| 654 | // low base 10 exponent with a very high intermediate mantissa can cancel each | |
| 655 | // other out, and subnormal numbers allow for the result to be at the very low | |
| 656 | // end of the final mantissa. | |
| 657 | template <typename T> LIBC_INLINE constexpr int32_t get_lower_bound() { | |
| 658 | using FPBits = typename fputil::FPBits<T>; | |
| 659 | return -((FPBits::EXP_BIAS + | |
| 660 | static_cast<int32_t>(FPBits::FRACTION_LEN + FPBits::STORAGE_LEN)) / | |
| 661 | 3); | |
| 662 | } | |
| 663 | ||
| 664 | template <> LIBC_INLINE constexpr int32_t get_lower_bound<float>() { | |
| 665 | return -(39 + 6 + 10); | |
| 666 | } | |
| 667 | ||
| 668 | template <> LIBC_INLINE constexpr int32_t get_lower_bound<double>() { | |
| 669 | return -(309 + 15 + 20); | |
| 670 | } | |
| 671 | ||
| 672 | // ----------------------------------------------------------------------------- | |
| 673 | // **** WARNING **** | |
| 674 | // This interface is shared with libc++, if you change this interface you need | |
| 675 | // to update it in both libc and libc++. | |
| 676 | // ----------------------------------------------------------------------------- | |
| 677 | // Takes a mantissa and base 10 exponent and converts it into its closest | |
| 678 | // floating point type T equivalient. First we try the Eisel-Lemire algorithm, | |
| 679 | // then if that fails then we fall back to a more accurate algorithm for | |
| 680 | // accuracy. The resulting mantissa and exponent are placed in outputMantissa | |
| 681 | // and outputExp2. | |
| 682 | template <class T> | |
| 683 | LIBC_INLINE FloatConvertReturn<T> decimal_exp_to_float( | |
| 684 | ExpandedFloat<T> init_num, bool truncated, RoundDirection round, | |
| 685 | const char *__restrict numStart, | |
| 686 | const size_t num_len = cpp::numeric_limits<size_t>::max()) { | |
| 687 | using FPBits = typename fputil::FPBits<T>; | |
| 688 | using StorageType = typename FPBits::StorageType; | |
| 689 | ||
| 690 | StorageType mantissa = init_num.mantissa; | |
| 691 | int32_t exp10 = init_num.exponent; | |
| 692 | ||
| 693 | FloatConvertReturn<T> output; | |
| 694 | cpp::optional<ExpandedFloat<T>> opt_output; | |
| 695 | ||
| 696 | // If the exponent is too large and can't be represented in this size of | |
| 697 | // float, return inf. These bounds are relatively loose, but are mostly | |
| 698 | // serving as a first pass. Some close numbers getting through is okay. | |
| 699 | if (exp10 > get_upper_bound<T>()) { | |
| 700 | output.num = {0, FPBits::MAX_BIASED_EXPONENT}; | |
| 701 | output.error = ERANGE; | |
| 702 | return output; | |
| 703 | } | |
| 704 | // If the exponent is too small even for a subnormal, return 0. | |
| 705 | if (exp10 < get_lower_bound<T>()) { | |
| 706 | output.num = {0, 0}; | |
| 707 | output.error = ERANGE; | |
| 708 | return output; | |
| 709 | } | |
| 710 | ||
| 711 | // Clinger's Fast Path and Eisel-Lemire can't set errno, but they can fail. | |
| 712 | // For this reason the "error" field in their return values is used to | |
| 713 | // represent whether they've failed as opposed to the errno value. Any | |
| 714 | // non-zero value represents a failure. | |
| 715 | ||
| 716 | #ifndef LIBC_COPT_STRTOFLOAT_DISABLE_CLINGER_FAST_PATH | |
| 717 | if (!truncated) { | |
| 718 | opt_output = clinger_fast_path<T>(init_num, round); | |
| 719 | // If the algorithm succeeded the error will be 0, else it will be a | |
| 720 | // non-zero number. | |
| 721 | if (opt_output.has_value()) { | |
| 722 | return {opt_output.value(), 0}; | |
| 723 | } | |
| 724 | } | |
| 725 | #endif // LIBC_COPT_STRTOFLOAT_DISABLE_CLINGER_FAST_PATH | |
| 726 | ||
| 727 | #ifndef LIBC_COPT_STRTOFLOAT_DISABLE_EISEL_LEMIRE | |
| 728 | // Try Eisel-Lemire | |
| 729 | opt_output = eisel_lemire<T>(init_num, round); | |
| 730 | if (opt_output.has_value()) { | |
| 731 | if (!truncated) { | |
| 732 | return {opt_output.value(), 0}; | |
| 733 | } | |
| 734 | // If the mantissa is truncated, then the result may be off by the LSB, so | |
| 735 | // check if rounding the mantissa up changes the result. If not, then it's | |
| 736 | // safe, else use the fallback. | |
| 737 | auto second_output = eisel_lemire<T>({mantissa + 1, exp10}, round); | |
| 738 | if (second_output.has_value()) { | |
| 739 | if (opt_output->mantissa == second_output->mantissa && | |
| 740 | opt_output->exponent == second_output->exponent) { | |
| 741 | return {opt_output.value(), 0}; | |
| 742 | } | |
| 743 | } | |
| 744 | } | |
| 745 | #endif // LIBC_COPT_STRTOFLOAT_DISABLE_EISEL_LEMIRE | |
| 746 | ||
| 747 | #ifndef LIBC_COPT_STRTOFLOAT_DISABLE_SIMPLE_DECIMAL_CONVERSION | |
| 748 | output = simple_decimal_conversion<T>(numStart, num_len, round); | |
| 749 | #else | |
| 750 | #warning "Simple decimal conversion is disabled, result may not be correct." | |
| 751 | #endif // LIBC_COPT_STRTOFLOAT_DISABLE_SIMPLE_DECIMAL_CONVERSION | |
| 752 | ||
| 753 | return output; | |
| 754 | } | |
| 755 | ||
| 756 | // ----------------------------------------------------------------------------- | |
| 757 | // **** WARNING **** | |
| 758 | // This interface is shared with libc++, if you change this interface you need | |
| 759 | // to update it in both libc and libc++. | |
| 760 | // ----------------------------------------------------------------------------- | |
| 761 | // Takes a mantissa and base 2 exponent and converts it into its closest | |
| 762 | // floating point type T equivalient. Since the exponent is already in the right | |
| 763 | // form, this is mostly just shifting and rounding. This is used for hexadecimal | |
| 764 | // numbers since a base 16 exponent multiplied by 4 is the base 2 exponent. | |
| 765 | template <class T> | |
| 766 | LIBC_INLINE FloatConvertReturn<T> binary_exp_to_float(ExpandedFloat<T> init_num, | |
| 767 | bool truncated, | |
| 768 | RoundDirection round) { | |
| 769 | using FPBits = typename fputil::FPBits<T>; | |
| 770 | using StorageType = typename FPBits::StorageType; | |
| 771 | ||
| 772 | StorageType mantissa = init_num.mantissa; | |
| 773 | int32_t exp2 = init_num.exponent; | |
| 774 | ||
| 775 | FloatConvertReturn<T> output; | |
| 776 | ||
| 777 | // This is the number of leading zeroes a properly normalized float of type T | |
| 778 | // should have. | |
| 779 | constexpr int32_t INF_EXP = (1 << FPBits::EXP_LEN) - 1; | |
| 780 | ||
| 781 | // Normalization step 1: Bring the leading bit to the highest bit of | |
| 782 | // StorageType. | |
| 783 | uint32_t amount_to_shift_left = cpp::countl_zero<StorageType>(mantissa); | |
| 784 | mantissa <<= amount_to_shift_left; | |
| 785 | ||
| 786 | // Keep exp2 representing the exponent of the lowest bit of StorageType. | |
| 787 | exp2 -= amount_to_shift_left; | |
| 788 | ||
| 789 | // biased_exponent represents the biased exponent of the most significant bit. | |
| 790 | int32_t biased_exponent = exp2 + FPBits::STORAGE_LEN + FPBits::EXP_BIAS - 1; | |
| 791 | ||
| 792 | // Handle numbers that're too large and get squashed to inf | |
| 793 | if (biased_exponent >= INF_EXP) { | |
| 794 | // This indicates an overflow, so we make the result INF and set errno. | |
| 795 | output.num = {0, (1 << FPBits::EXP_LEN) - 1}; | |
| 796 | output.error = ERANGE; | |
| 797 | return output; | |
| 798 | } | |
| 799 | ||
| 800 | uint32_t amount_to_shift_right = | |
| 801 | FPBits::STORAGE_LEN - FPBits::FRACTION_LEN - 1; | |
| 802 | ||
| 803 | // Handle subnormals. | |
| 804 | if (biased_exponent <= 0) { | |
| 805 | amount_to_shift_right += 1 - biased_exponent; | |
| 806 | biased_exponent = 0; | |
| 807 | ||
| 808 | if (amount_to_shift_right > FPBits::STORAGE_LEN) { | |
| 809 | // Return 0 if the exponent is too small. | |
| 810 | output.num = {0, 0}; | |
| 811 | output.error = ERANGE; | |
| 812 | return output; | |
| 813 | } | |
| 814 | } | |
| 815 | ||
| 816 | StorageType round_bit_mask = StorageType(1) << (amount_to_shift_right - 1); | |
| 817 | StorageType sticky_mask = round_bit_mask - 1; | |
| 818 | bool round_bit = static_cast<bool>(mantissa & round_bit_mask); | |
| 819 | bool sticky_bit = static_cast<bool>(mantissa & sticky_mask) || truncated; | |
| 820 | ||
| 821 | if (amount_to_shift_right < FPBits::STORAGE_LEN) { | |
| 822 | // Shift the mantissa and clear the implicit bit. | |
| 823 | mantissa >>= amount_to_shift_right; | |
| 824 | mantissa &= FPBits::FRACTION_MASK; | |
| 825 | } else { | |
| 826 | mantissa = 0; | |
| 827 | } | |
| 828 | bool least_significant_bit = static_cast<bool>(mantissa & StorageType(1)); | |
| 829 | ||
| 830 | // TODO: check that this rounding behavior is correct. | |
| 831 | ||
| 832 | if (round == RoundDirection::Nearest) { | |
| 833 | // Perform rounding-to-nearest, tie-to-even. | |
| 834 | if (round_bit && (least_significant_bit || sticky_bit)) { | |
| 835 | ++mantissa; | |
| 836 | } | |
| 837 | } else if (round == RoundDirection::Up) { | |
| 838 | if (round_bit || sticky_bit) { | |
| 839 | ++mantissa; | |
| 840 | } | |
| 841 | } else /* (round == RoundDirection::Down)*/ { | |
| 842 | if (round_bit && sticky_bit) { | |
| 843 | ++mantissa; | |
| 844 | } | |
| 845 | } | |
| 846 | ||
| 847 | if (mantissa > FPBits::FRACTION_MASK) { | |
| 848 | // Rounding causes the exponent to increase. | |
| 849 | ++biased_exponent; | |
| 850 | ||
| 851 | if (biased_exponent == INF_EXP) { | |
| 852 | output.error = ERANGE; | |
| 853 | } | |
| 854 | } | |
| 855 | ||
| 856 | if (biased_exponent == 0) { | |
| 857 | output.error = ERANGE; | |
| 858 | } | |
| 859 | ||
| 860 | output.num = {mantissa & FPBits::FRACTION_MASK, biased_exponent}; | |
| 861 | return output; | |
| 862 | } | |
| 863 | ||
| 864 | // checks if the next 4 characters of the string pointer are the start of a | |
| 865 | // hexadecimal floating point number. Does not advance the string pointer. | |
| 866 | LIBC_INLINE bool is_float_hex_start(const char *__restrict src, | |
| 867 | const char decimalPoint) { | |
| 868 | if (!(src[0] == '0' && tolower(src[1]) == 'x')) { | |
| 869 | return false; | |
| 870 | } | |
| 871 | size_t first_digit = 2; | |
| 872 | if (src[2] == decimalPoint) { | |
| 873 | ++first_digit; | |
| 874 | } | |
| 875 | return isalnum(src[first_digit]) && b36_char_to_int(src[first_digit]) < 16; | |
| 876 | } | |
| 877 | ||
| 878 | // Takes the start of a string representing a decimal float, as well as the | |
| 879 | // local decimalPoint. It returns if it suceeded in parsing any digits, and if | |
| 880 | // the return value is true then the outputs are pointer to the end of the | |
| 881 | // number, and the mantissa and exponent for the closest float T representation. | |
| 882 | // If the return value is false, then it is assumed that there is no number | |
| 883 | // here. | |
| 884 | template <class T> | |
| 885 | LIBC_INLINE StrToNumResult<ExpandedFloat<T>> | |
| 886 | decimal_string_to_float(const char *__restrict src, const char DECIMAL_POINT, | |
| 887 | RoundDirection round) { | |
| 888 | using FPBits = typename fputil::FPBits<T>; | |
| 889 | using StorageType = typename FPBits::StorageType; | |
| 890 | ||
| 891 | constexpr uint32_t BASE = 10; | |
| 892 | constexpr char EXPONENT_MARKER = 'e'; | |
| 893 | ||
| 894 | bool truncated = false; | |
| 895 | bool seen_digit = false; | |
| 896 | bool after_decimal = false; | |
| 897 | StorageType mantissa = 0; | |
| 898 | int32_t exponent = 0; | |
| 899 | ||
| 900 | size_t index = 0; | |
| 901 | ||
| 902 | StrToNumResult<ExpandedFloat<T>> output({0, 0}); | |
| 903 | ||
| 904 | // The goal for the first step of parsing is to convert the number in src to | |
| 905 | // the format mantissa * (base ^ exponent) | |
| 906 | ||
| 907 | // The loop fills the mantissa with as many digits as it can hold | |
| 908 | const StorageType bitstype_max_div_by_base = | |
| 909 | cpp::numeric_limits<StorageType>::max() / BASE; | |
| 910 | while (true) { | |
| 911 | if (isdigit(src[index])) { | |
| 912 | uint32_t digit = b36_char_to_int(src[index]); | |
| 913 | seen_digit = true; | |
| 914 | ||
| 915 | if (mantissa < bitstype_max_div_by_base) { | |
| 916 | mantissa = (mantissa * BASE) + digit; | |
| 917 | if (after_decimal) { | |
| 918 | --exponent; | |
| 919 | } | |
| 920 | } else { | |
| 921 | if (digit > 0) | |
| 922 | truncated = true; | |
| 923 | if (!after_decimal) | |
| 924 | ++exponent; | |
| 925 | } | |
| 926 | ||
| 927 | ++index; | |
| 928 | continue; | |
| 929 | } | |
| 930 | if (src[index] == DECIMAL_POINT) { | |
| 931 | if (after_decimal) { | |
| 932 | break; // this means that src[index] points to a second decimal point, | |
| 933 | // ending the number. | |
| 934 | } | |
| 935 | after_decimal = true; | |
| 936 | ++index; | |
| 937 | continue; | |
| 938 | } | |
| 939 | // The character is neither a digit nor a decimal point. | |
| 940 | break; | |
| 941 | } | |
| 942 | ||
| 943 | if (!seen_digit) | |
| 944 | return output; | |
| 945 | ||
| 946 | // TODO: When adding max length argument, handle the case of a trailing | |
| 947 | // EXPONENT MARKER, see scanf for more details. | |
| 948 | if (tolower(src[index]) == EXPONENT_MARKER) { | |
| 949 | bool has_sign = false; | |
| 950 | if (src[index + 1] == '+' || src[index + 1] == '-') { | |
| 951 | has_sign = true; | |
| 952 | } | |
| 953 | if (isdigit(src[index + 1 + static_cast<size_t>(has_sign)])) { | |
| 954 | ++index; | |
| 955 | auto result = strtointeger<int32_t>(src + index, 10); | |
| 956 | if (result.has_error()) | |
| 957 | output.error = result.error; | |
| 958 | int32_t add_to_exponent = result.value; | |
| 959 | index += result.parsed_len; | |
| 960 | ||
| 961 | // Here we do this operation as int64 to avoid overflow. | |
| 962 | int64_t temp_exponent = static_cast<int64_t>(exponent) + | |
| 963 | static_cast<int64_t>(add_to_exponent); | |
| 964 | ||
| 965 | // If the result is in the valid range, then we use it. The valid range is | |
| 966 | // also within the int32 range, so this prevents overflow issues. | |
| 967 | if (temp_exponent > FPBits::MAX_BIASED_EXPONENT) { | |
| 968 | exponent = FPBits::MAX_BIASED_EXPONENT; | |
| 969 | } else if (temp_exponent < -FPBits::MAX_BIASED_EXPONENT) { | |
| 970 | exponent = -FPBits::MAX_BIASED_EXPONENT; | |
| 971 | } else { | |
| 972 | exponent = static_cast<int32_t>(temp_exponent); | |
| 973 | } | |
| 974 | } | |
| 975 | } | |
| 976 | ||
| 977 | output.parsed_len = index; | |
| 978 | if (mantissa == 0) { // if we have a 0, then also 0 the exponent. | |
| 979 | output.value = {0, 0}; | |
| 980 | } else { | |
| 981 | auto temp = | |
| 982 | decimal_exp_to_float<T>({mantissa, exponent}, truncated, round, src); | |
| 983 | output.value = temp.num; | |
| 984 | output.error = temp.error; | |
| 985 | } | |
| 986 | return output; | |
| 987 | } | |
| 988 | ||
| 989 | // Takes the start of a string representing a hexadecimal float, as well as the | |
| 990 | // local decimal point. It returns if it suceeded in parsing any digits, and if | |
| 991 | // the return value is true then the outputs are pointer to the end of the | |
| 992 | // number, and the mantissa and exponent for the closest float T representation. | |
| 993 | // If the return value is false, then it is assumed that there is no number | |
| 994 | // here. | |
| 995 | template <class T> | |
| 996 | LIBC_INLINE StrToNumResult<ExpandedFloat<T>> | |
| 997 | hexadecimal_string_to_float(const char *__restrict src, | |
| 998 | const char DECIMAL_POINT, RoundDirection round) { | |
| 999 | using FPBits = typename fputil::FPBits<T>; | |
| 1000 | using StorageType = typename FPBits::StorageType; | |
| 1001 | ||
| 1002 | constexpr uint32_t BASE = 16; | |
| 1003 | constexpr char EXPONENT_MARKER = 'p'; | |
| 1004 | ||
| 1005 | bool truncated = false; | |
| 1006 | bool seen_digit = false; | |
| 1007 | bool after_decimal = false; | |
| 1008 | StorageType mantissa = 0; | |
| 1009 | int32_t exponent = 0; | |
| 1010 | ||
| 1011 | size_t index = 0; | |
| 1012 | ||
| 1013 | StrToNumResult<ExpandedFloat<T>> output({0, 0}); | |
| 1014 | ||
| 1015 | // The goal for the first step of parsing is to convert the number in src to | |
| 1016 | // the format mantissa * (base ^ exponent) | |
| 1017 | ||
| 1018 | // The loop fills the mantissa with as many digits as it can hold | |
| 1019 | const StorageType bitstype_max_div_by_base = | |
| 1020 | cpp::numeric_limits<StorageType>::max() / BASE; | |
| 1021 | while (true) { | |
| 1022 | if (isalnum(src[index])) { | |
| 1023 | uint32_t digit = b36_char_to_int(src[index]); | |
| 1024 | if (digit < BASE) | |
| 1025 | seen_digit = true; | |
| 1026 | else | |
| 1027 | break; | |
| 1028 | ||
| 1029 | if (mantissa < bitstype_max_div_by_base) { | |
| 1030 | mantissa = (mantissa * BASE) + digit; | |
| 1031 | if (after_decimal) | |
| 1032 | --exponent; | |
| 1033 | } else { | |
| 1034 | if (digit > 0) | |
| 1035 | truncated = true; | |
| 1036 | if (!after_decimal) | |
| 1037 | ++exponent; | |
| 1038 | } | |
| 1039 | ++index; | |
| 1040 | continue; | |
| 1041 | } | |
| 1042 | if (src[index] == DECIMAL_POINT) { | |
| 1043 | if (after_decimal) { | |
| 1044 | break; // this means that src[index] points to a second decimal point, | |
| 1045 | // ending the number. | |
| 1046 | } | |
| 1047 | after_decimal = true; | |
| 1048 | ++index; | |
| 1049 | continue; | |
| 1050 | } | |
| 1051 | // The character is neither a hexadecimal digit nor a decimal point. | |
| 1052 | break; | |
| 1053 | } | |
| 1054 | ||
| 1055 | if (!seen_digit) | |
| 1056 | return output; | |
| 1057 | ||
| 1058 | // Convert the exponent from having a base of 16 to having a base of 2. | |
| 1059 | exponent *= 4; | |
| 1060 | ||
| 1061 | if (tolower(src[index]) == EXPONENT_MARKER) { | |
| 1062 | bool has_sign = false; | |
| 1063 | if (src[index + 1] == '+' || src[index + 1] == '-') { | |
| 1064 | has_sign = true; | |
| 1065 | } | |
| 1066 | if (isdigit(src[index + 1 + static_cast<size_t>(has_sign)])) { | |
| 1067 | ++index; | |
| 1068 | auto result = strtointeger<int32_t>(src + index, 10); | |
| 1069 | if (result.has_error()) | |
| 1070 | output.error = result.error; | |
| 1071 | ||
| 1072 | int32_t add_to_exponent = result.value; | |
| 1073 | index += result.parsed_len; | |
| 1074 | ||
| 1075 | // Here we do this operation as int64 to avoid overflow. | |
| 1076 | int64_t temp_exponent = static_cast<int64_t>(exponent) + | |
| 1077 | static_cast<int64_t>(add_to_exponent); | |
| 1078 | ||
| 1079 | // If the result is in the valid range, then we use it. The valid range is | |
| 1080 | // also within the int32 range, so this prevents overflow issues. | |
| 1081 | if (temp_exponent > FPBits::MAX_BIASED_EXPONENT) { | |
| 1082 | exponent = FPBits::MAX_BIASED_EXPONENT; | |
| 1083 | } else if (temp_exponent < -FPBits::MAX_BIASED_EXPONENT) { | |
| 1084 | exponent = -FPBits::MAX_BIASED_EXPONENT; | |
| 1085 | } else { | |
| 1086 | exponent = static_cast<int32_t>(temp_exponent); | |
| 1087 | } | |
| 1088 | } | |
| 1089 | } | |
| 1090 | output.parsed_len = index; | |
| 1091 | if (mantissa == 0) { // if we have a 0, then also 0 the exponent. | |
| 1092 | output.value.exponent = 0; | |
| 1093 | output.value.mantissa = 0; | |
| 1094 | } else { | |
| 1095 | auto temp = binary_exp_to_float<T>({mantissa, exponent}, truncated, round); | |
| 1096 | output.error = temp.error; | |
| 1097 | output.value = temp.num; | |
| 1098 | } | |
| 1099 | return output; | |
| 1100 | } | |
| 1101 | ||
| 1102 | template <class T> | |
| 1103 | LIBC_INLINE typename fputil::FPBits<T>::StorageType | |
| 1104 | nan_mantissa_from_ncharseq(const cpp::string_view ncharseq) { | |
| 1105 | using FPBits = typename fputil::FPBits<T>; | |
| 1106 | using StorageType = typename FPBits::StorageType; | |
| 1107 | ||
| 1108 | StorageType nan_mantissa = 0; | |
| 1109 | ||
| 1110 | if (ncharseq.data() != nullptr && isdigit(ncharseq[0])) { | |
| 1111 | StrToNumResult<StorageType> strtoint_result = | |
| 1112 | strtointeger<StorageType>(ncharseq.data(), 0); | |
| 1113 | if (!strtoint_result.has_error()) | |
| 1114 | nan_mantissa = strtoint_result.value; | |
| 1115 | ||
| 1116 | if (strtoint_result.parsed_len != static_cast<ptrdiff_t>(ncharseq.size())) | |
| 1117 | nan_mantissa = 0; | |
| 1118 | } | |
| 1119 | ||
| 1120 | return nan_mantissa; | |
| 1121 | } | |
| 1122 | ||
| 1123 | // Takes a pointer to a string and a pointer to a string pointer. This function | |
| 1124 | // is used as the backend for all of the string to float functions. | |
| 1125 | // TODO: Add src_len member to match strtointeger. | |
| 1126 | // TODO: Next, move from char* and length to string_view | |
| 1127 | template <class T> | |
| 1128 | LIBC_INLINE StrToNumResult<T> strtofloatingpoint(const char *__restrict src) { | |
| 1129 | using FPBits = typename fputil::FPBits<T>; | |
| 1130 | using StorageType = typename FPBits::StorageType; | |
| 1131 | ||
| 1132 | FPBits result = FPBits(); | |
| 1133 | bool seen_digit = false; | |
| 1134 | char sign = '+'; | |
| 1135 | ||
| 1136 | int error = 0; | |
| 1137 | ||
| 1138 | ptrdiff_t index = first_non_whitespace(src) - src; | |
| 1139 | ||
| 1140 | if (src[index] == '+' || src[index] == '-') { | |
| 1141 | sign = src[index]; | |
| 1142 | ++index; | |
| 1143 | } | |
| 1144 | ||
| 1145 | if (sign == '-') { | |
| 1146 | result.set_sign(Sign::NEG); | |
| 1147 | } | |
| 1148 | ||
| 1149 | static constexpr char DECIMAL_POINT = '.'; | |
| 1150 | static const char *inf_string = "infinity"; | |
| 1151 | static const char *nan_string = "nan"; | |
| 1152 | ||
| 1153 | if (isdigit(src[index]) || src[index] == DECIMAL_POINT) { // regular number | |
| 1154 | int base = 10; | |
| 1155 | if (is_float_hex_start(src + index, DECIMAL_POINT)) { | |
| 1156 | base = 16; | |
| 1157 | index += 2; | |
| 1158 | seen_digit = true; | |
| 1159 | } | |
| 1160 | ||
| 1161 | RoundDirection round_direction = RoundDirection::Nearest; | |
| 1162 | ||
| 1163 | switch (fputil::quick_get_round()) { | |
| 1164 | case FE_TONEAREST: | |
| 1165 | round_direction = RoundDirection::Nearest; | |
| 1166 | break; | |
| 1167 | case FE_UPWARD: | |
| 1168 | if (sign == '+') { | |
| 1169 | round_direction = RoundDirection::Up; | |
| 1170 | } else { | |
| 1171 | round_direction = RoundDirection::Down; | |
| 1172 | } | |
| 1173 | break; | |
| 1174 | case FE_DOWNWARD: | |
| 1175 | if (sign == '+') { | |
| 1176 | round_direction = RoundDirection::Down; | |
| 1177 | } else { | |
| 1178 | round_direction = RoundDirection::Up; | |
| 1179 | } | |
| 1180 | break; | |
| 1181 | case FE_TOWARDZERO: | |
| 1182 | round_direction = RoundDirection::Down; | |
| 1183 | break; | |
| 1184 | } | |
| 1185 | ||
| 1186 | StrToNumResult<ExpandedFloat<T>> parse_result({0, 0}); | |
| 1187 | if (base == 16) { | |
| 1188 | parse_result = hexadecimal_string_to_float<T>(src + index, DECIMAL_POINT, | |
| 1189 | round_direction); | |
| 1190 | } else { // base is 10 | |
| 1191 | parse_result = decimal_string_to_float<T>(src + index, DECIMAL_POINT, | |
| 1192 | round_direction); | |
| 1193 | } | |
| 1194 | seen_digit = parse_result.parsed_len != 0; | |
| 1195 | result.set_mantissa(parse_result.value.mantissa); | |
| 1196 | result.set_biased_exponent(parse_result.value.exponent); | |
| 1197 | index += parse_result.parsed_len; | |
| 1198 | error = parse_result.error; | |
| 1199 | } else if (tolower(src[index]) == 'n') { // NaN | |
| 1200 | if (tolower(src[index + 1]) == nan_string[1] && | |
| 1201 | tolower(src[index + 2]) == nan_string[2]) { | |
| 1202 | seen_digit = true; | |
| 1203 | index += 3; | |
| 1204 | StorageType nan_mantissa = 0; | |
| 1205 | // this handles the case of `NaN(n-character-sequence)`, where the | |
| 1206 | // n-character-sequence is made of 0 or more letters, numbers, or | |
| 1207 | // underscore characters in any order. | |
| 1208 | if (src[index] == '(') { | |
| 1209 | size_t left_paren = index; | |
| 1210 | ++index; | |
| 1211 | while (isalnum(src[index]) || src[index] == '_') | |
| 1212 | ++index; | |
| 1213 | if (src[index] == ')') { | |
| 1214 | ++index; | |
| 1215 | nan_mantissa = nan_mantissa_from_ncharseq<T>( | |
| 1216 | cpp::string_view(src + (left_paren + 1), index - left_paren - 2)); | |
| 1217 | } else { | |
| 1218 | index = left_paren; | |
| 1219 | } | |
| 1220 | } | |
| 1221 | result = FPBits(result.quiet_nan(result.sign(), nan_mantissa)); | |
| 1222 | } | |
| 1223 | } else if (tolower(src[index]) == 'i') { // INF | |
| 1224 | if (tolower(src[index + 1]) == inf_string[1] && | |
| 1225 | tolower(src[index + 2]) == inf_string[2]) { | |
| 1226 | seen_digit = true; | |
| 1227 | result = FPBits(result.inf(result.sign())); | |
| 1228 | if (tolower(src[index + 3]) == inf_string[3] && | |
| 1229 | tolower(src[index + 4]) == inf_string[4] && | |
| 1230 | tolower(src[index + 5]) == inf_string[5] && | |
| 1231 | tolower(src[index + 6]) == inf_string[6] && | |
| 1232 | tolower(src[index + 7]) == inf_string[7]) { | |
| 1233 | // if the string is "INFINITY" then consume 8 characters. | |
| 1234 | index += 8; | |
| 1235 | } else { | |
| 1236 | index += 3; | |
| 1237 | } | |
| 1238 | } | |
| 1239 | } | |
| 1240 | if (!seen_digit) { // If there is nothing to actually parse, then return 0. | |
| 1241 | return {T(0), 0, error}; | |
| 1242 | } | |
| 1243 | ||
| 1244 | // This function only does something if T is long double and the platform uses | |
| 1245 | // special 80 bit long doubles. Otherwise it should be inlined out. | |
| 1246 | set_implicit_bit<T>(result); | |
| 1247 | ||
| 1248 | return {result.get_val(), index, error}; | |
| 1249 | } | |
| 1250 | ||
| 1251 | template <class T> LIBC_INLINE StrToNumResult<T> strtonan(const char *arg) { | |
| 1252 | using FPBits = typename fputil::FPBits<T>; | |
| 1253 | using StorageType = typename FPBits::StorageType; | |
| 1254 | ||
| 1255 | LIBC_CRASH_ON_NULLPTR(arg); | |
| 1256 | ||
| 1257 | FPBits result; | |
| 1258 | int error = 0; | |
| 1259 | StorageType nan_mantissa = 0; | |
| 1260 | ||
| 1261 | ptrdiff_t index = 0; | |
| 1262 | while (isalnum(arg[index]) || arg[index] == '_') | |
| 1263 | ++index; | |
| 1264 | ||
| 1265 | if (arg[index] == '\0') | |
| 1266 | nan_mantissa = nan_mantissa_from_ncharseq<T>(cpp::string_view(arg, index)); | |
| 1267 | ||
| 1268 | result = FPBits::quiet_nan(Sign::POS, nan_mantissa); | |
| 1269 | return {result.get_val(), 0, error}; | |
| 1270 | } | |
| 1271 | ||
| 1272 | } // namespace internal | |
| 1273 | } // namespace LIBC_NAMESPACE_DECL | |
| 1274 | ||
| 1275 | #endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_FLOAT_H |
lib/libcxx/libc/src/__support/str_to_integer.h created+169| ... | ... | @@ -0,0 +1,169 @@ |
| 1 | //===-- String to integer conversion utils ----------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // ----------------------------------------------------------------------------- | |
| 10 | // **** WARNING **** | |
| 11 | // This file is shared with libc++. You should also be careful when adding | |
| 12 | // dependencies to this file, since it needs to build for all libc++ targets. | |
| 13 | // ----------------------------------------------------------------------------- | |
| 14 | ||
| 15 | #ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H | |
| 16 | #define LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H | |
| 17 | ||
| 18 | #include "src/__support/CPP/limits.h" | |
| 19 | #include "src/__support/CPP/type_traits.h" | |
| 20 | #include "src/__support/CPP/type_traits/make_unsigned.h" | |
| 21 | #include "src/__support/big_int.h" | |
| 22 | #include "src/__support/common.h" | |
| 23 | #include "src/__support/ctype_utils.h" | |
| 24 | #include "src/__support/macros/config.h" | |
| 25 | #include "src/__support/str_to_num_result.h" | |
| 26 | #include "src/__support/uint128.h" | |
| 27 | #include "src/errno/libc_errno.h" // For ERANGE | |
| 28 | ||
| 29 | namespace LIBC_NAMESPACE_DECL { | |
| 30 | namespace internal { | |
| 31 | ||
| 32 | // Returns a pointer to the first character in src that is not a whitespace | |
| 33 | // character (as determined by isspace()) | |
| 34 | // TODO: Change from returning a pointer to returning a length. | |
| 35 | LIBC_INLINE const char * | |
| 36 | first_non_whitespace(const char *__restrict src, | |
| 37 | size_t src_len = cpp::numeric_limits<size_t>::max()) { | |
| 38 | size_t src_cur = 0; | |
| 39 | while (src_cur < src_len && internal::isspace(src[src_cur])) { | |
| 40 | ++src_cur; | |
| 41 | } | |
| 42 | return src + src_cur; | |
| 43 | } | |
| 44 | ||
| 45 | // checks if the next 3 characters of the string pointer are the start of a | |
| 46 | // hexadecimal number. Does not advance the string pointer. | |
| 47 | LIBC_INLINE bool | |
| 48 | is_hex_start(const char *__restrict src, | |
| 49 | size_t src_len = cpp::numeric_limits<size_t>::max()) { | |
| 50 | if (src_len < 3) | |
| 51 | return false; | |
| 52 | return *src == '0' && tolower(*(src + 1)) == 'x' && isalnum(*(src + 2)) && | |
| 53 | b36_char_to_int(*(src + 2)) < 16; | |
| 54 | } | |
| 55 | ||
| 56 | // Takes the address of the string pointer and parses the base from the start of | |
| 57 | // it. | |
| 58 | LIBC_INLINE int infer_base(const char *__restrict src, size_t src_len) { | |
| 59 | // A hexadecimal number is defined as "the prefix 0x or 0X followed by a | |
| 60 | // sequence of the decimal digits and the letters a (or A) through f (or F) | |
| 61 | // with values 10 through 15 respectively." (C standard 6.4.4.1) | |
| 62 | if (is_hex_start(src, src_len)) | |
| 63 | return 16; | |
| 64 | // An octal number is defined as "the prefix 0 optionally followed by a | |
| 65 | // sequence of the digits 0 through 7 only" (C standard 6.4.4.1) and so any | |
| 66 | // number that starts with 0, including just 0, is an octal number. | |
| 67 | if (src_len > 0 && src[0] == '0') | |
| 68 | return 8; | |
| 69 | // A decimal number is defined as beginning "with a nonzero digit and | |
| 70 | // consist[ing] of a sequence of decimal digits." (C standard 6.4.4.1) | |
| 71 | return 10; | |
| 72 | } | |
| 73 | ||
| 74 | // ----------------------------------------------------------------------------- | |
| 75 | // **** WARNING **** | |
| 76 | // This interface is shared with libc++, if you change this interface you need | |
| 77 | // to update it in both libc and libc++. | |
| 78 | // ----------------------------------------------------------------------------- | |
| 79 | // Takes a pointer to a string and the base to convert to. This function is used | |
| 80 | // as the backend for all of the string to int functions. | |
| 81 | template <class T> | |
| 82 | LIBC_INLINE StrToNumResult<T> | |
| 83 | strtointeger(const char *__restrict src, int base, | |
| 84 | const size_t src_len = cpp::numeric_limits<size_t>::max()) { | |
| 85 | using ResultType = make_integral_or_big_int_unsigned_t<T>; | |
| 86 | ||
| 87 | ResultType result = 0; | |
| 88 | ||
| 89 | bool is_number = false; | |
| 90 | size_t src_cur = 0; | |
| 91 | int error_val = 0; | |
| 92 | ||
| 93 | if (src_len == 0) | |
| 94 | return {0, 0, 0}; | |
| 95 | ||
| 96 | if (base < 0 || base == 1 || base > 36) | |
| 97 | return {0, 0, EINVAL}; | |
| 98 | ||
| 99 | src_cur = first_non_whitespace(src, src_len) - src; | |
| 100 | ||
| 101 | char result_sign = '+'; | |
| 102 | if (src[src_cur] == '+' || src[src_cur] == '-') { | |
| 103 | result_sign = src[src_cur]; | |
| 104 | ++src_cur; | |
| 105 | } | |
| 106 | ||
| 107 | if (base == 0) | |
| 108 | base = infer_base(src + src_cur, src_len - src_cur); | |
| 109 | ||
| 110 | if (base == 16 && is_hex_start(src + src_cur, src_len - src_cur)) | |
| 111 | src_cur = src_cur + 2; | |
| 112 | ||
| 113 | constexpr bool IS_UNSIGNED = cpp::is_unsigned_v<T>; | |
| 114 | const bool is_positive = (result_sign == '+'); | |
| 115 | ||
| 116 | ResultType constexpr NEGATIVE_MAX = | |
| 117 | !IS_UNSIGNED ? static_cast<ResultType>(cpp::numeric_limits<T>::max()) + 1 | |
| 118 | : cpp::numeric_limits<T>::max(); | |
| 119 | ResultType const abs_max = | |
| 120 | (is_positive ? cpp::numeric_limits<T>::max() : NEGATIVE_MAX); | |
| 121 | ResultType const abs_max_div_by_base = | |
| 122 | static_cast<ResultType>(abs_max / base); | |
| 123 | ||
| 124 | while (src_cur < src_len && isalnum(src[src_cur])) { | |
| 125 | int cur_digit = b36_char_to_int(src[src_cur]); | |
| 126 | if (cur_digit >= base) | |
| 127 | break; | |
| 128 | ||
| 129 | is_number = true; | |
| 130 | ++src_cur; | |
| 131 | ||
| 132 | // If the number has already hit the maximum value for the current type then | |
| 133 | // the result cannot change, but we still need to advance src to the end of | |
| 134 | // the number. | |
| 135 | if (result == abs_max) { | |
| 136 | error_val = ERANGE; | |
| 137 | continue; | |
| 138 | } | |
| 139 | ||
| 140 | if (result > abs_max_div_by_base) { | |
| 141 | result = abs_max; | |
| 142 | error_val = ERANGE; | |
| 143 | } else { | |
| 144 | result = static_cast<ResultType>(result * base); | |
| 145 | } | |
| 146 | if (result > abs_max - cur_digit) { | |
| 147 | result = abs_max; | |
| 148 | error_val = ERANGE; | |
| 149 | } else { | |
| 150 | result = static_cast<ResultType>(result + cur_digit); | |
| 151 | } | |
| 152 | } | |
| 153 | ||
| 154 | ptrdiff_t str_len = is_number ? (src_cur) : 0; | |
| 155 | ||
| 156 | if (error_val == ERANGE) { | |
| 157 | if (is_positive || IS_UNSIGNED) | |
| 158 | return {cpp::numeric_limits<T>::max(), str_len, error_val}; | |
| 159 | else // T is signed and there is a negative overflow | |
| 160 | return {cpp::numeric_limits<T>::min(), str_len, error_val}; | |
| 161 | } | |
| 162 | ||
| 163 | return {static_cast<T>(is_positive ? result : -result), str_len, error_val}; | |
| 164 | } | |
| 165 | ||
| 166 | } // namespace internal | |
| 167 | } // namespace LIBC_NAMESPACE_DECL | |
| 168 | ||
| 169 | #endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H |
lib/libcxx/libc/src/__support/str_to_num_result.h created+48| ... | ... | @@ -0,0 +1,48 @@ |
| 1 | //===-- A data structure for str_to_number to return ------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // ----------------------------------------------------------------------------- | |
| 10 | // **** WARNING **** | |
| 11 | // This file is shared with libc++. You should also be careful when adding | |
| 12 | // dependencies to this file, since it needs to build for all libc++ targets. | |
| 13 | // ----------------------------------------------------------------------------- | |
| 14 | ||
| 15 | #ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H | |
| 16 | #define LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H | |
| 17 | ||
| 18 | #include "src/__support/macros/attributes.h" // LIBC_INLINE | |
| 19 | #include "src/__support/macros/config.h" | |
| 20 | ||
| 21 | #include <stddef.h> | |
| 22 | ||
| 23 | namespace LIBC_NAMESPACE_DECL { | |
| 24 | ||
| 25 | // ----------------------------------------------------------------------------- | |
| 26 | // **** WARNING **** | |
| 27 | // This interface is shared with libc++, if you change this interface you need | |
| 28 | // to update it in both libc and libc++. | |
| 29 | // ----------------------------------------------------------------------------- | |
| 30 | template <typename T> struct StrToNumResult { | |
| 31 | T value; | |
| 32 | int error; | |
| 33 | ptrdiff_t parsed_len; | |
| 34 | ||
| 35 | LIBC_INLINE constexpr StrToNumResult(T value) | |
| 36 | : value(value), error(0), parsed_len(0) {} | |
| 37 | LIBC_INLINE constexpr StrToNumResult(T value, ptrdiff_t parsed_len) | |
| 38 | : value(value), error(0), parsed_len(parsed_len) {} | |
| 39 | LIBC_INLINE constexpr StrToNumResult(T value, ptrdiff_t parsed_len, int error) | |
| 40 | : value(value), error(error), parsed_len(parsed_len) {} | |
| 41 | ||
| 42 | LIBC_INLINE constexpr bool has_error() { return error != 0; } | |
| 43 | ||
| 44 | LIBC_INLINE constexpr operator T() { return value; } | |
| 45 | }; | |
| 46 | } // namespace LIBC_NAMESPACE_DECL | |
| 47 | ||
| 48 | #endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_NUM_RESULT_H |
lib/libcxx/libc/src/__support/uint128.h created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | //===-- 128-bit signed and unsigned int types -------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC___SUPPORT_UINT128_H | |
| 10 | #define LLVM_LIBC_SRC___SUPPORT_UINT128_H | |
| 11 | ||
| 12 | #include "big_int.h" | |
| 13 | #include "src/__support/macros/properties/types.h" // LIBC_TYPES_HAS_INT128 | |
| 14 | ||
| 15 | #ifdef LIBC_TYPES_HAS_INT128 | |
| 16 | using UInt128 = __uint128_t; | |
| 17 | using Int128 = __int128_t; | |
| 18 | #else | |
| 19 | using UInt128 = LIBC_NAMESPACE::UInt<128>; | |
| 20 | using Int128 = LIBC_NAMESPACE::Int<128>; | |
| 21 | #endif // LIBC_TYPES_HAS_INT128 | |
| 22 | ||
| 23 | #endif // LLVM_LIBC_SRC___SUPPORT_UINT128_H |
lib/libcxx/libc/src/errno/libc_errno.h created+47| ... | ... | @@ -0,0 +1,47 @@ |
| 1 | //===-- Implementation header for libc_errno --------------------*- C++ -*-===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H | |
| 10 | #define LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H | |
| 11 | ||
| 12 | #include "src/__support/macros/attributes.h" | |
| 13 | #include "src/__support/macros/config.h" | |
| 14 | #include "src/__support/macros/properties/architectures.h" | |
| 15 | ||
| 16 | #include "hdr/errno_macros.h" | |
| 17 | ||
| 18 | // This header is to be consumed by internal implementations, in which all of | |
| 19 | // them should refer to `libc_errno` instead of using `errno` directly from | |
| 20 | // <errno.h> header. | |
| 21 | ||
| 22 | // Unit and hermetic tests should: | |
| 23 | // - #include "src/errno/libc_errno.h" | |
| 24 | // - NOT #include <errno.h> | |
| 25 | // - Only use `libc_errno` in the code | |
| 26 | // - Depend on libc.src.errno.errno | |
| 27 | ||
| 28 | // Integration tests should: | |
| 29 | // - NOT #include "src/errno/libc_errno.h" | |
| 30 | // - #include <errno.h> | |
| 31 | // - Use regular `errno` in the code | |
| 32 | // - Still depend on libc.src.errno.errno | |
| 33 | ||
| 34 | namespace LIBC_NAMESPACE_DECL { | |
| 35 | ||
| 36 | extern "C" int *__llvm_libc_errno() noexcept; | |
| 37 | ||
| 38 | struct Errno { | |
| 39 | void operator=(int); | |
| 40 | operator int(); | |
| 41 | }; | |
| 42 | ||
| 43 | extern Errno libc_errno; | |
| 44 | ||
| 45 | } // namespace LIBC_NAMESPACE_DECL | |
| 46 | ||
| 47 | #endif // LLVM_LIBC_SRC_ERRNO_LIBC_ERRNO_H |
lib/libcxx/src/algorithm.cpp+2-3| ... | ... | @@ -21,13 +21,12 @@ void __sort(RandomAccessIterator first, RandomAccessIterator last, Comp comp) { |
| 21 | 21 | std::__introsort<_ClassicAlgPolicy, |
| 22 | 22 | ranges::less, |
| 23 | 23 | RandomAccessIterator, |
| 24 | __use_branchless_sort<ranges::less, RandomAccessIterator>::value>( | |
| 25 | first, last, ranges::less{}, depth_limit); | |
| 24 | __use_branchless_sort<ranges::less, RandomAccessIterator>>(first, last, ranges::less{}, depth_limit); | |
| 26 | 25 | } |
| 27 | 26 | |
| 28 | 27 | // clang-format off |
| 29 | 28 | template void __sort<__less<char>&, char*>(char*, char*, __less<char>&); |
| 30 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 29 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 31 | 30 | template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); |
| 32 | 31 | #endif |
| 33 | 32 | template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); |
lib/libcxx/src/any.cpp+1-1| ... | ... | @@ -12,7 +12,7 @@ namespace std { |
| 12 | 12 | const char* bad_any_cast::what() const noexcept { return "bad any cast"; } |
| 13 | 13 | } // namespace std |
| 14 | 14 | |
| 15 | #include <experimental/__config> | |
| 15 | #include <__config> | |
| 16 | 16 | |
| 17 | 17 | // Preserve std::experimental::any_bad_cast for ABI compatibility |
| 18 | 18 | // Even though it no longer exists in a header file |
lib/libcxx/src/atomic.cpp+2-2| ... | ... | @@ -94,11 +94,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo |
| 94 | 94 | |
| 95 | 95 | static void |
| 96 | 96 | __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) { |
| 97 | _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, NULL, NULL); | |
| 97 | _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, nullptr, nullptr); | |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) { |
| 101 | _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL); | |
| 101 | _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, nullptr, nullptr); | |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | #else // <- Add other operating systems here |
lib/libcxx/src/barrier.cpp+1-5| ... | ... | @@ -11,13 +11,11 @@ |
| 11 | 11 | |
| 12 | 12 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 13 | 13 | |
| 14 | #if !defined(_LIBCPP_HAS_NO_TREE_BARRIER) | |
| 15 | ||
| 16 | 14 | class __barrier_algorithm_base { |
| 17 | 15 | public: |
| 18 | 16 | struct alignas(64) /* naturally-align the heap state */ __state_t { |
| 19 | 17 | struct { |
| 20 | __atomic_base<__barrier_phase_t> __phase{0}; | |
| 18 | atomic<__barrier_phase_t> __phase{0}; | |
| 21 | 19 | } __tickets[64]; |
| 22 | 20 | }; |
| 23 | 21 | |
| ... | ... | @@ -70,6 +68,4 @@ _LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algori |
| 70 | 68 | delete __barrier; |
| 71 | 69 | } |
| 72 | 70 | |
| 73 | #endif // !defined(_LIBCPP_HAS_NO_TREE_BARRIER) | |
| 74 | ||
| 75 | 71 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/call_once.cpp+5-5| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | #include <__mutex/once_flag.h> |
| 10 | 10 | #include <__utility/exception_guard.h> |
| 11 | 11 | |
| 12 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 12 | #if _LIBCPP_HAS_THREADS | |
| 13 | 13 | # include <__thread/support.h> |
| 14 | 14 | #endif |
| 15 | 15 | |
| ... | ... | @@ -23,13 +23,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | // call into dispatch_once_f instead of here. Relevant radar this code needs to |
| 24 | 24 | // keep in sync with: 7741191. |
| 25 | 25 | |
| 26 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 26 | #if _LIBCPP_HAS_THREADS | |
| 27 | 27 | static constinit __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER; |
| 28 | 28 | static constinit __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER; |
| 29 | 29 | #endif |
| 30 | 30 | |
| 31 | 31 | void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)(void*)) { |
| 32 | #if defined(_LIBCPP_HAS_NO_THREADS) | |
| 32 | #if !_LIBCPP_HAS_THREADS | |
| 33 | 33 | |
| 34 | 34 | if (flag == once_flag::_Unset) { |
| 35 | 35 | auto guard = std::__make_exception_guard([&flag] { flag = once_flag::_Unset; }); |
| ... | ... | @@ -39,7 +39,7 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)( |
| 39 | 39 | guard.__complete(); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | #else // !_LIBCPP_HAS_NO_THREADS | |
| 42 | #else // !_LIBCPP_HAS_THREADS | |
| 43 | 43 | |
| 44 | 44 | __libcpp_mutex_lock(&mut); |
| 45 | 45 | while (flag == once_flag::_Pending) |
| ... | ... | @@ -64,7 +64,7 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)( |
| 64 | 64 | __libcpp_mutex_unlock(&mut); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | #endif // !_LIBCPP_HAS_NO_THREADS | |
| 67 | #endif // !_LIBCPP_HAS_THREADS | |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/charconv.cpp+12| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | #include <charconv> |
| 10 | 10 | #include <string.h> |
| 11 | 11 | |
| 12 | #include "include/from_chars_floating_point.h" | |
| 12 | 13 | #include "include/to_chars_floating_point.h" |
| 13 | 14 | |
| 14 | 15 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -74,4 +75,15 @@ to_chars_result to_chars(char* __first, char* __last, long double __value, chars |
| 74 | 75 | __first, __last, static_cast<double>(__value), __fmt, __precision); |
| 75 | 76 | } |
| 76 | 77 | |
| 78 | template <class _Fp> | |
| 79 | __from_chars_result<_Fp> __from_chars_floating_point( | |
| 80 | _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt) { | |
| 81 | return std::__from_chars_floating_point_impl<_Fp>(__first, __last, __fmt); | |
| 82 | } | |
| 83 | ||
| 84 | template __from_chars_result<float> __from_chars_floating_point( | |
| 85 | _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt); | |
| 86 | ||
| 87 | template __from_chars_result<double> __from_chars_floating_point( | |
| 88 | _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt); | |
| 77 | 89 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/chrono.cpp+34-5| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | # define _LARGE_TIME_API |
| 13 | 13 | #endif |
| 14 | 14 | |
| 15 | #include <__system_error/system_error.h> | |
| 15 | #include <__system_error/throw_system_error.h> | |
| 16 | 16 | #include <cerrno> // errno |
| 17 | 17 | #include <chrono> |
| 18 | 18 | |
| ... | ... | @@ -31,9 +31,14 @@ |
| 31 | 31 | # include <sys/time.h> // for gettimeofday and timeval |
| 32 | 32 | #endif |
| 33 | 33 | |
| 34 | // OpenBSD does not have a fully conformant suite of POSIX timers, but | |
| 34 | #if defined(__LLVM_LIBC__) | |
| 35 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 36 | #endif | |
| 37 | ||
| 38 | // OpenBSD and GPU do not have a fully conformant suite of POSIX timers, but | |
| 35 | 39 | // it does have clock_gettime and CLOCK_MONOTONIC which is all we need. |
| 36 | #if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) | |
| 40 | #if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || defined(__AMDGPU__) || \ | |
| 41 | defined(__NVPTX__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) | |
| 37 | 42 | # define _LIBCPP_HAS_CLOCK_GETTIME |
| 38 | 43 | #endif |
| 39 | 44 | |
| ... | ... | @@ -114,6 +119,15 @@ static system_clock::time_point __libcpp_system_clock_now() { |
| 114 | 119 | return system_clock::time_point(duration_cast<system_clock::duration>(d - nt_to_unix_epoch)); |
| 115 | 120 | } |
| 116 | 121 | |
| 122 | #elif defined(_LIBCPP_HAS_TIMESPEC_GET) | |
| 123 | ||
| 124 | static system_clock::time_point __libcpp_system_clock_now() { | |
| 125 | struct timespec ts; | |
| 126 | if (timespec_get(&ts, TIME_UTC) != TIME_UTC) | |
| 127 | __throw_system_error(errno, "timespec_get(TIME_UTC) failed"); | |
| 128 | return system_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000)); | |
| 129 | } | |
| 130 | ||
| 117 | 131 | #elif defined(_LIBCPP_HAS_CLOCK_GETTIME) |
| 118 | 132 | |
| 119 | 133 | static system_clock::time_point __libcpp_system_clock_now() { |
| ... | ... | @@ -133,7 +147,10 @@ static system_clock::time_point __libcpp_system_clock_now() { |
| 133 | 147 | |
| 134 | 148 | #endif |
| 135 | 149 | |
| 150 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 151 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") | |
| 136 | 152 | const bool system_clock::is_steady; |
| 153 | _LIBCPP_DIAGNOSTIC_POP | |
| 137 | 154 | |
| 138 | 155 | system_clock::time_point system_clock::now() noexcept { return __libcpp_system_clock_now(); } |
| 139 | 156 | |
| ... | ... | @@ -151,7 +168,7 @@ system_clock::time_point system_clock::from_time_t(time_t t) noexcept { return s |
| 151 | 168 | // instead. |
| 152 | 169 | // |
| 153 | 170 | |
| 154 | #ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK | |
| 171 | #if _LIBCPP_HAS_MONOTONIC_CLOCK | |
| 155 | 172 | |
| 156 | 173 | # if defined(__APPLE__) |
| 157 | 174 | |
| ... | ... | @@ -212,6 +229,15 @@ static steady_clock::time_point __libcpp_steady_clock_now() noexcept { |
| 212 | 229 | return steady_clock::time_point(nanoseconds(_zx_clock_get_monotonic())); |
| 213 | 230 | } |
| 214 | 231 | |
| 232 | # elif defined(_LIBCPP_HAS_TIMESPEC_GET) | |
| 233 | ||
| 234 | static steady_clock::time_point __libcpp_steady_clock_now() { | |
| 235 | struct timespec ts; | |
| 236 | if (timespec_get(&ts, TIME_MONOTONIC) != TIME_MONOTONIC) | |
| 237 | __throw_system_error(errno, "timespec_get(TIME_MONOTONIC) failed"); | |
| 238 | return steady_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000)); | |
| 239 | } | |
| 240 | ||
| 215 | 241 | # elif defined(_LIBCPP_HAS_CLOCK_GETTIME) |
| 216 | 242 | |
| 217 | 243 | static steady_clock::time_point __libcpp_steady_clock_now() { |
| ... | ... | @@ -225,11 +251,14 @@ static steady_clock::time_point __libcpp_steady_clock_now() { |
| 225 | 251 | # error "Monotonic clock not implemented on this platform" |
| 226 | 252 | # endif |
| 227 | 253 | |
| 254 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 255 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") | |
| 228 | 256 | const bool steady_clock::is_steady; |
| 257 | _LIBCPP_DIAGNOSTIC_POP | |
| 229 | 258 | |
| 230 | 259 | steady_clock::time_point steady_clock::now() noexcept { return __libcpp_steady_clock_now(); } |
| 231 | 260 | |
| 232 | #endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK | |
| 261 | #endif // _LIBCPP_HAS_MONOTONIC_CLOCK | |
| 233 | 262 | |
| 234 | 263 | } // namespace chrono |
| 235 | 264 |
lib/libcxx/src/condition_variable_destructor.cpp+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__config> |
| 15 | 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 || !_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION | |
| 18 | 18 | # define NEEDS_CONDVAR_DESTRUCTOR |
| 19 | 19 | #endif |
| 20 | 20 |
lib/libcxx/src/exception.cpp+3| ... | ... | @@ -6,6 +6,9 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #define _LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION | |
| 10 | #define _LIBCPP_DISABLE_DEPRECATION_WARNINGS | |
| 11 | ||
| 9 | 12 | #include <exception> |
| 10 | 13 | #include <new> |
| 11 | 14 | #include <typeinfo> |
lib/libcxx/src/experimental/include/tzdb/tzdb_list_private.h+6-6| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | // When threads are available, we use std::mutex over std::shared_mutex |
| 19 | 19 | // due to the increased overhead of std::shared_mutex. |
| 20 | 20 | // See shared_mutex_vs_mutex.bench.cpp |
| 21 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 21 | #if _LIBCPP_HAS_THREADS | |
| 22 | 22 | # include <mutex> |
| 23 | 23 | #endif |
| 24 | 24 | |
| ... | ... | @@ -48,7 +48,7 @@ public: |
| 48 | 48 | __impl() { __load_no_lock(); } |
| 49 | 49 | |
| 50 | 50 | [[nodiscard]] const tzdb& __load() { |
| 51 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 51 | #if _LIBCPP_HAS_THREADS | |
| 52 | 52 | unique_lock __lock{__mutex_}; |
| 53 | 53 | #endif |
| 54 | 54 | __load_no_lock(); |
| ... | ... | @@ -58,14 +58,14 @@ public: |
| 58 | 58 | using const_iterator = tzdb_list::const_iterator; |
| 59 | 59 | |
| 60 | 60 | const tzdb& __front() const noexcept { |
| 61 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 61 | #if _LIBCPP_HAS_THREADS | |
| 62 | 62 | unique_lock __lock{__mutex_}; |
| 63 | 63 | #endif |
| 64 | 64 | return __tzdb_.front(); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | const_iterator __erase_after(const_iterator __p) { |
| 68 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 68 | #if _LIBCPP_HAS_THREADS | |
| 69 | 69 | unique_lock __lock{__mutex_}; |
| 70 | 70 | #endif |
| 71 | 71 | |
| ... | ... | @@ -74,7 +74,7 @@ public: |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | const_iterator __begin() const noexcept { |
| 77 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 77 | #if _LIBCPP_HAS_THREADS | |
| 78 | 78 | unique_lock __lock{__mutex_}; |
| 79 | 79 | #endif |
| 80 | 80 | return __tzdb_.begin(); |
| ... | ... | @@ -89,7 +89,7 @@ private: |
| 89 | 89 | // pre: The caller ensures the locking, if needed, is done. |
| 90 | 90 | void __load_no_lock() { chrono::__init_tzdb(__tzdb_.emplace_front(), __rules_.emplace_front()); } |
| 91 | 91 | |
| 92 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 92 | #if _LIBCPP_HAS_THREADS | |
| 93 | 93 | mutable mutex __mutex_; |
| 94 | 94 | #endif |
| 95 | 95 | forward_list<tzdb> __tzdb_; |
lib/libcxx/src/experimental/time_zone.cpp+4-4| ... | ... | @@ -199,7 +199,7 @@ __format(const __tz::__continuation& __continuation, const string& __letters, se |
| 199 | 199 | // active at the end. This should be determined separately. |
| 200 | 200 | return chrono::seconds{0}; |
| 201 | 201 | else |
| 202 | static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support | |
| 202 | static_assert(false); | |
| 203 | 203 | |
| 204 | 204 | std::__libcpp_unreachable(); |
| 205 | 205 | }, |
| ... | ... | @@ -225,7 +225,7 @@ __format(const __tz::__continuation& __continuation, const string& __letters, se |
| 225 | 225 | else if constexpr (same_as<_Tp, __tz::__constrained_weekday>) |
| 226 | 226 | return __value(__year, __month); |
| 227 | 227 | else |
| 228 | static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support | |
| 228 | static_assert(false); | |
| 229 | 229 | |
| 230 | 230 | std::__libcpp_unreachable(); |
| 231 | 231 | }, |
| ... | ... | @@ -668,7 +668,7 @@ __first_rule(seconds __stdoff, const vector<__tz::__rule>& __rules) { |
| 668 | 668 | __continuation_end, |
| 669 | 669 | __continuation.__stdoff + __save, |
| 670 | 670 | chrono::duration_cast<minutes>(__save), |
| 671 | __continuation.__format}, | |
| 671 | chrono::__format(__continuation, __continuation.__format, __save)}, | |
| 672 | 672 | true}; |
| 673 | 673 | } |
| 674 | 674 | |
| ... | ... | @@ -688,7 +688,7 @@ __get_sys_info(sys_seconds __time, |
| 688 | 688 | else if constexpr (same_as<_Tp, __tz::__save>) |
| 689 | 689 | return chrono::__get_sys_info_basic(__time, __continuation_begin, __continuation, __value.__time); |
| 690 | 690 | else |
| 691 | static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support | |
| 691 | static_assert(false); | |
| 692 | 692 | |
| 693 | 693 | std::__libcpp_unreachable(); |
| 694 | 694 | }, |
lib/libcxx/src/experimental/tzdb.cpp+19-7| ... | ... | @@ -8,12 +8,16 @@ |
| 8 | 8 | |
| 9 | 9 | // For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html |
| 10 | 10 | |
| 11 | #include <__assert> | |
| 11 | 12 | #include <algorithm> |
| 13 | #include <cctype> | |
| 12 | 14 | #include <chrono> |
| 13 | 15 | #include <filesystem> |
| 14 | 16 | #include <fstream> |
| 15 | 17 | #include <stdexcept> |
| 16 | 18 | #include <string> |
| 19 | #include <string_view> | |
| 20 | #include <vector> | |
| 17 | 21 | |
| 18 | 22 | #include "include/tzdb/time_zone_private.h" |
| 19 | 23 | #include "include/tzdb/types_private.h" |
| ... | ... | @@ -51,8 +55,7 @@ _LIBCPP_WEAK string_view __libcpp_tzdb_directory() { |
| 51 | 55 | #if defined(__linux__) |
| 52 | 56 | return "/usr/share/zoneinfo/"; |
| 53 | 57 | #else |
| 54 | // Zig patch: change this compilation error into a runtime crash. | |
| 55 | //# error "unknown path to the IANA Time Zone Database" | |
| 58 | // zig patch: change this compilation error into a runtime crash | |
| 56 | 59 | abort(); |
| 57 | 60 | #endif |
| 58 | 61 | } |
| ... | ... | @@ -96,14 +99,23 @@ static void __skip(istream& __input, string_view __suffix) { |
| 96 | 99 | } |
| 97 | 100 | |
| 98 | 101 | 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()); | |
| 102 | _LIBCPP_ASSERT_INTERNAL(!std::isalpha(__expected) || std::islower(__expected), "lowercase characters only here!"); | |
| 103 | char __c = __input.get(); | |
| 104 | if (std::tolower(__c) != __expected) | |
| 105 | std::__throw_runtime_error( | |
| 106 | (string("corrupt tzdb: expected character '") + __expected + "', got '" + __c + "' instead").c_str()); | |
| 101 | 107 | } |
| 102 | 108 | |
| 103 | 109 | 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()); | |
| 110 | for (auto __c : __expected) { | |
| 111 | _LIBCPP_ASSERT_INTERNAL(!std::isalpha(__c) || std::islower(__c), "lowercase strings only here!"); | |
| 112 | char __actual = __input.get(); | |
| 113 | if (std::tolower(__actual) != __c) | |
| 114 | std::__throw_runtime_error( | |
| 115 | (string("corrupt tzdb: expected character '") + __c + "' from string '" + string(__expected) + "', got '" + | |
| 116 | __actual + "' instead") | |
| 117 | .c_str()); | |
| 118 | } | |
| 107 | 119 | } |
| 108 | 120 | |
| 109 | 121 | [[nodiscard]] static string __parse_string(istream& __input) { |
lib/libcxx/src/filesystem/directory_iterator.cpp+11-11| ... | ... | @@ -47,9 +47,9 @@ public: |
| 47 | 47 | } |
| 48 | 48 | __stream_ = ::FindFirstFileW((root / "*").c_str(), &__data_); |
| 49 | 49 | if (__stream_ == INVALID_HANDLE_VALUE) { |
| 50 | ec = detail::make_windows_error(GetLastError()); | |
| 50 | ec = detail::get_last_error(); | |
| 51 | 51 | const bool ignore_permission_denied = bool(opts & directory_options::skip_permission_denied); |
| 52 | if (ignore_permission_denied && ec.value() == static_cast<int>(errc::permission_denied)) | |
| 52 | if (ignore_permission_denied && ec == errc::permission_denied) | |
| 53 | 53 | ec.clear(); |
| 54 | 54 | return; |
| 55 | 55 | } |
| ... | ... | @@ -77,13 +77,13 @@ public: |
| 77 | 77 | bool assign() { |
| 78 | 78 | if (!wcscmp(__data_.cFileName, L".") || !wcscmp(__data_.cFileName, L"..")) |
| 79 | 79 | return false; |
| 80 | // FIXME: Cache more of this | |
| 81 | // directory_entry::__cached_data cdata; | |
| 82 | // cdata.__type_ = get_file_type(__data_); | |
| 83 | // cdata.__size_ = get_file_size(__data_); | |
| 84 | // cdata.__write_time_ = get_write_time(__data_); | |
| 85 | 80 | __entry_.__assign_iter_entry( |
| 86 | __root_ / __data_.cFileName, directory_entry::__create_iter_result(detail::get_file_type(__data_))); | |
| 81 | __root_ / __data_.cFileName, | |
| 82 | directory_entry::__create_iter_cached_result( | |
| 83 | detail::get_file_type(__data_), | |
| 84 | detail::get_file_size(__data_), | |
| 85 | detail::get_file_perm(__data_), | |
| 86 | detail::get_write_time(__data_))); | |
| 87 | 87 | return true; |
| 88 | 88 | } |
| 89 | 89 | |
| ... | ... | @@ -91,7 +91,7 @@ private: |
| 91 | 91 | error_code close() noexcept { |
| 92 | 92 | error_code ec; |
| 93 | 93 | if (!::FindClose(__stream_)) |
| 94 | ec = detail::make_windows_error(GetLastError()); | |
| 94 | ec = detail::get_last_error(); | |
| 95 | 95 | __stream_ = INVALID_HANDLE_VALUE; |
| 96 | 96 | return ec; |
| 97 | 97 | } |
| ... | ... | @@ -118,7 +118,7 @@ public: |
| 118 | 118 | if ((__stream_ = ::opendir(root.c_str())) == nullptr) { |
| 119 | 119 | ec = detail::capture_errno(); |
| 120 | 120 | const bool allow_eacces = bool(opts & directory_options::skip_permission_denied); |
| 121 | if (allow_eacces && ec.value() == EACCES) | |
| 121 | if (allow_eacces && ec == errc::permission_denied) | |
| 122 | 122 | ec.clear(); |
| 123 | 123 | return; |
| 124 | 124 | } |
| ... | ... | @@ -307,7 +307,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) { |
| 307 | 307 | } |
| 308 | 308 | if (m_ec) { |
| 309 | 309 | const bool allow_eacess = bool(__imp_->__options_ & directory_options::skip_permission_denied); |
| 310 | if (m_ec.value() == EACCES && allow_eacess) { | |
| 310 | if (m_ec == errc::permission_denied && allow_eacess) { | |
| 311 | 311 | if (ec) |
| 312 | 312 | ec->clear(); |
| 313 | 313 | } else { |
lib/libcxx/src/filesystem/error.h+16-75| ... | ... | @@ -32,80 +32,21 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 32 | 32 | |
| 33 | 33 | namespace detail { |
| 34 | 34 | |
| 35 | #if defined(_LIBCPP_WIN32API) | |
| 36 | ||
| 37 | inline errc __win_err_to_errc(int err) { | |
| 38 | constexpr struct { | |
| 39 | DWORD win; | |
| 40 | errc errc; | |
| 41 | } win_error_mapping[] = { | |
| 42 | {ERROR_ACCESS_DENIED, errc::permission_denied}, | |
| 43 | {ERROR_ALREADY_EXISTS, errc::file_exists}, | |
| 44 | {ERROR_BAD_NETPATH, errc::no_such_file_or_directory}, | |
| 45 | {ERROR_BAD_PATHNAME, errc::no_such_file_or_directory}, | |
| 46 | {ERROR_BAD_UNIT, errc::no_such_device}, | |
| 47 | {ERROR_BROKEN_PIPE, errc::broken_pipe}, | |
| 48 | {ERROR_BUFFER_OVERFLOW, errc::filename_too_long}, | |
| 49 | {ERROR_BUSY, errc::device_or_resource_busy}, | |
| 50 | {ERROR_BUSY_DRIVE, errc::device_or_resource_busy}, | |
| 51 | {ERROR_CANNOT_MAKE, errc::permission_denied}, | |
| 52 | {ERROR_CANTOPEN, errc::io_error}, | |
| 53 | {ERROR_CANTREAD, errc::io_error}, | |
| 54 | {ERROR_CANTWRITE, errc::io_error}, | |
| 55 | {ERROR_CURRENT_DIRECTORY, errc::permission_denied}, | |
| 56 | {ERROR_DEV_NOT_EXIST, errc::no_such_device}, | |
| 57 | {ERROR_DEVICE_IN_USE, errc::device_or_resource_busy}, | |
| 58 | {ERROR_DIR_NOT_EMPTY, errc::directory_not_empty}, | |
| 59 | {ERROR_DIRECTORY, errc::invalid_argument}, | |
| 60 | {ERROR_DISK_FULL, errc::no_space_on_device}, | |
| 61 | {ERROR_FILE_EXISTS, errc::file_exists}, | |
| 62 | {ERROR_FILE_NOT_FOUND, errc::no_such_file_or_directory}, | |
| 63 | {ERROR_HANDLE_DISK_FULL, errc::no_space_on_device}, | |
| 64 | {ERROR_INVALID_ACCESS, errc::permission_denied}, | |
| 65 | {ERROR_INVALID_DRIVE, errc::no_such_device}, | |
| 66 | {ERROR_INVALID_FUNCTION, errc::function_not_supported}, | |
| 67 | {ERROR_INVALID_HANDLE, errc::invalid_argument}, | |
| 68 | {ERROR_INVALID_NAME, errc::no_such_file_or_directory}, | |
| 69 | {ERROR_INVALID_PARAMETER, errc::invalid_argument}, | |
| 70 | {ERROR_LOCK_VIOLATION, errc::no_lock_available}, | |
| 71 | {ERROR_LOCKED, errc::no_lock_available}, | |
| 72 | {ERROR_NEGATIVE_SEEK, errc::invalid_argument}, | |
| 73 | {ERROR_NOACCESS, errc::permission_denied}, | |
| 74 | {ERROR_NOT_ENOUGH_MEMORY, errc::not_enough_memory}, | |
| 75 | {ERROR_NOT_READY, errc::resource_unavailable_try_again}, | |
| 76 | {ERROR_NOT_SAME_DEVICE, errc::cross_device_link}, | |
| 77 | {ERROR_NOT_SUPPORTED, errc::not_supported}, | |
| 78 | {ERROR_OPEN_FAILED, errc::io_error}, | |
| 79 | {ERROR_OPEN_FILES, errc::device_or_resource_busy}, | |
| 80 | {ERROR_OPERATION_ABORTED, errc::operation_canceled}, | |
| 81 | {ERROR_OUTOFMEMORY, errc::not_enough_memory}, | |
| 82 | {ERROR_PATH_NOT_FOUND, errc::no_such_file_or_directory}, | |
| 83 | {ERROR_READ_FAULT, errc::io_error}, | |
| 84 | {ERROR_REPARSE_TAG_INVALID, errc::invalid_argument}, | |
| 85 | {ERROR_RETRY, errc::resource_unavailable_try_again}, | |
| 86 | {ERROR_SEEK, errc::io_error}, | |
| 87 | {ERROR_SHARING_VIOLATION, errc::permission_denied}, | |
| 88 | {ERROR_TOO_MANY_OPEN_FILES, errc::too_many_files_open}, | |
| 89 | {ERROR_WRITE_FAULT, errc::io_error}, | |
| 90 | {ERROR_WRITE_PROTECT, errc::permission_denied}, | |
| 91 | }; | |
| 92 | ||
| 93 | for (const auto& pair : win_error_mapping) | |
| 94 | if (pair.win == static_cast<DWORD>(err)) | |
| 95 | return pair.errc; | |
| 96 | return errc::invalid_argument; | |
| 97 | } | |
| 98 | ||
| 99 | #endif // _LIBCPP_WIN32API | |
| 35 | // On windows, libc functions use errno, but system functions use GetLastError. | |
| 36 | // So, callers need to be careful which of these next functions they call! | |
| 100 | 37 | |
| 101 | 38 | inline error_code capture_errno() { |
| 102 | 39 | _LIBCPP_ASSERT_INTERNAL(errno != 0, "Expected errno to be non-zero"); |
| 103 | 40 | return error_code(errno, generic_category()); |
| 104 | 41 | } |
| 105 | 42 | |
| 43 | inline error_code get_last_error() { | |
| 106 | 44 | #if defined(_LIBCPP_WIN32API) |
| 107 | inline error_code make_windows_error(int err) { return make_error_code(__win_err_to_errc(err)); } | |
| 45 | return std::error_code(GetLastError(), std::system_category()); | |
| 46 | #else | |
| 47 | return capture_errno(); | |
| 108 | 48 | #endif |
| 49 | } | |
| 109 | 50 | |
| 110 | 51 | template <class T> |
| 111 | 52 | T error_value(); |
| ... | ... | @@ -186,16 +127,16 @@ struct ErrorHandler { |
| 186 | 127 | T report(const error_code& ec, const char* msg, ...) const { |
| 187 | 128 | va_list ap; |
| 188 | 129 | va_start(ap, msg); |
| 189 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 130 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 190 | 131 | try { |
| 191 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 132 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 192 | 133 | report_impl(ec, msg, ap); |
| 193 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 134 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 194 | 135 | } catch (...) { |
| 195 | 136 | va_end(ap); |
| 196 | 137 | throw; |
| 197 | 138 | } |
| 198 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 139 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 199 | 140 | va_end(ap); |
| 200 | 141 | return error_value<T>(); |
| 201 | 142 | } |
| ... | ... | @@ -206,16 +147,16 @@ struct ErrorHandler { |
| 206 | 147 | T report(errc const& err, const char* msg, ...) const { |
| 207 | 148 | va_list ap; |
| 208 | 149 | va_start(ap, msg); |
| 209 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 150 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 210 | 151 | try { |
| 211 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 152 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 212 | 153 | report_impl(make_error_code(err), msg, ap); |
| 213 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 154 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 214 | 155 | } catch (...) { |
| 215 | 156 | va_end(ap); |
| 216 | 157 | throw; |
| 217 | 158 | } |
| 218 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 159 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 219 | 160 | va_end(ap); |
| 220 | 161 | return error_value<T>(); |
| 221 | 162 | } |
| ... | ... | @@ -225,7 +166,7 @@ private: |
| 225 | 166 | ErrorHandler& operator=(ErrorHandler const&) = delete; |
| 226 | 167 | }; |
| 227 | 168 | |
| 228 | } // end namespace detail | |
| 169 | } // namespace detail | |
| 229 | 170 | |
| 230 | 171 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 231 | 172 |
lib/libcxx/src/filesystem/file_descriptor.h+18-11| ... | ... | @@ -97,11 +97,18 @@ inline uintmax_t get_file_size(const WIN32_FIND_DATAW& data) { |
| 97 | 97 | return (static_cast<uint64_t>(data.nFileSizeHigh) << 32) + data.nFileSizeLow; |
| 98 | 98 | } |
| 99 | 99 | inline file_time_type get_write_time(const WIN32_FIND_DATAW& data) { |
| 100 | ULARGE_INTEGER tmp; | |
| 100 | using detail::fs_time; | |
| 101 | 101 | const FILETIME& time = data.ftLastWriteTime; |
| 102 | tmp.u.LowPart = time.dwLowDateTime; | |
| 103 | tmp.u.HighPart = time.dwHighDateTime; | |
| 104 | return file_time_type(file_time_type::duration(tmp.QuadPart)); | |
| 102 | auto ts = filetime_to_timespec(time); | |
| 103 | if (!fs_time::is_representable(ts)) | |
| 104 | return file_time_type::min(); | |
| 105 | return fs_time::convert_from_timespec(ts); | |
| 106 | } | |
| 107 | inline perms get_file_perm(const WIN32_FIND_DATAW& data) { | |
| 108 | unsigned st_mode = 0555; // Read-only | |
| 109 | if (!(data.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) | |
| 110 | st_mode |= 0222; // Write | |
| 111 | return static_cast<perms>(st_mode) & perms::mask; | |
| 105 | 112 | } |
| 106 | 113 | |
| 107 | 114 | #endif // !_LIBCPP_WIN32API |
| ... | ... | @@ -194,7 +201,7 @@ inline perms posix_get_perms(const StatT& st) noexcept { return static_cast<perm |
| 194 | 201 | inline file_status create_file_status(error_code& m_ec, path const& p, const StatT& path_stat, error_code* ec) { |
| 195 | 202 | if (ec) |
| 196 | 203 | *ec = m_ec; |
| 197 | if (m_ec && (m_ec.value() == ENOENT || m_ec.value() == ENOTDIR)) { | |
| 204 | if (m_ec && (m_ec == errc::no_such_file_or_directory || m_ec == errc::not_a_directory)) { | |
| 198 | 205 | return file_status(file_type::not_found); |
| 199 | 206 | } else if (m_ec) { |
| 200 | 207 | ErrorHandler<void> err("posix_stat", ec, &p); |
| ... | ... | @@ -229,7 +236,7 @@ inline file_status create_file_status(error_code& m_ec, path const& p, const Sta |
| 229 | 236 | inline file_status posix_stat(path const& p, StatT& path_stat, error_code* ec) { |
| 230 | 237 | error_code m_ec; |
| 231 | 238 | if (detail::stat(p.c_str(), &path_stat) == -1) |
| 232 | m_ec = detail::capture_errno(); | |
| 239 | m_ec = detail::get_last_error(); | |
| 233 | 240 | return create_file_status(m_ec, p, path_stat, ec); |
| 234 | 241 | } |
| 235 | 242 | |
| ... | ... | @@ -241,7 +248,7 @@ inline file_status posix_stat(path const& p, error_code* ec) { |
| 241 | 248 | inline file_status posix_lstat(path const& p, StatT& path_stat, error_code* ec) { |
| 242 | 249 | error_code m_ec; |
| 243 | 250 | if (detail::lstat(p.c_str(), &path_stat) == -1) |
| 244 | m_ec = detail::capture_errno(); | |
| 251 | m_ec = detail::get_last_error(); | |
| 245 | 252 | return create_file_status(m_ec, p, path_stat, ec); |
| 246 | 253 | } |
| 247 | 254 | |
| ... | ... | @@ -253,7 +260,7 @@ inline file_status posix_lstat(path const& p, error_code* ec) { |
| 253 | 260 | // http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html |
| 254 | 261 | inline bool posix_ftruncate(const FileDescriptor& fd, off_t to_size, error_code& ec) { |
| 255 | 262 | if (detail::ftruncate(fd.fd, to_size) == -1) { |
| 256 | ec = capture_errno(); | |
| 263 | ec = get_last_error(); | |
| 257 | 264 | return true; |
| 258 | 265 | } |
| 259 | 266 | ec.clear(); |
| ... | ... | @@ -262,7 +269,7 @@ inline bool posix_ftruncate(const FileDescriptor& fd, off_t to_size, error_code& |
| 262 | 269 | |
| 263 | 270 | inline bool posix_fchmod(const FileDescriptor& fd, const StatT& st, error_code& ec) { |
| 264 | 271 | if (detail::fchmod(fd.fd, st.st_mode) == -1) { |
| 265 | ec = capture_errno(); | |
| 272 | ec = get_last_error(); | |
| 266 | 273 | return true; |
| 267 | 274 | } |
| 268 | 275 | ec.clear(); |
| ... | ... | @@ -279,12 +286,12 @@ inline file_status FileDescriptor::refresh_status(error_code& ec) { |
| 279 | 286 | m_stat = {}; |
| 280 | 287 | error_code m_ec; |
| 281 | 288 | if (detail::fstat(fd, &m_stat) == -1) |
| 282 | m_ec = capture_errno(); | |
| 289 | m_ec = get_last_error(); | |
| 283 | 290 | m_status = create_file_status(m_ec, name, m_stat, &ec); |
| 284 | 291 | return m_status; |
| 285 | 292 | } |
| 286 | 293 | |
| 287 | } // end namespace detail | |
| 294 | } // namespace detail | |
| 288 | 295 | |
| 289 | 296 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 290 | 297 |
lib/libcxx/src/filesystem/filesystem_clock.cpp+16-1| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | 9 | #include <__config> |
| 10 | #include <__system_error/throw_system_error.h> | |
| 10 | 11 | #include <chrono> |
| 11 | 12 | #include <filesystem> |
| 12 | 13 | #include <time.h> |
| ... | ... | @@ -29,13 +30,21 @@ |
| 29 | 30 | # include <sys/time.h> // for gettimeofday and timeval |
| 30 | 31 | #endif |
| 31 | 32 | |
| 32 | #if defined(__APPLE__) || defined(__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) | |
| 33 | #if defined(__LLVM_LIBC__) | |
| 34 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 35 | #endif | |
| 36 | ||
| 37 | #if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__AMDGPU__) || defined(__NVPTX__) || \ | |
| 38 | (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) | |
| 33 | 39 | # define _LIBCPP_HAS_CLOCK_GETTIME |
| 34 | 40 | #endif |
| 35 | 41 | |
| 36 | 42 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 37 | 43 | |
| 44 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 45 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") | |
| 38 | 46 | const bool _FilesystemClock::is_steady; |
| 47 | _LIBCPP_DIAGNOSTIC_POP | |
| 39 | 48 | |
| 40 | 49 | _FilesystemClock::time_point _FilesystemClock::now() noexcept { |
| 41 | 50 | typedef chrono::duration<rep> __secs; |
| ... | ... | @@ -45,6 +54,12 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept { |
| 45 | 54 | GetSystemTimeAsFileTime(&time); |
| 46 | 55 | detail::TimeSpec tp = detail::filetime_to_timespec(time); |
| 47 | 56 | return time_point(__secs(tp.tv_sec) + chrono::duration_cast<duration>(__nsecs(tp.tv_nsec))); |
| 57 | #elif defined(_LIBCPP_HAS_TIMESPEC_GET) | |
| 58 | typedef chrono::duration<rep, nano> __nsecs; | |
| 59 | struct timespec ts; | |
| 60 | if (timespec_get(&ts, TIME_UTC) != TIME_UTC) | |
| 61 | __throw_system_error(errno, "timespec_get(TIME_UTC) failed"); | |
| 62 | return time_point(__secs(ts.tv_sec) + chrono::duration_cast<duration>(__nsecs(ts.tv_nsec))); | |
| 48 | 63 | #elif defined(_LIBCPP_HAS_CLOCK_GETTIME) |
| 49 | 64 | typedef chrono::duration<rep, nano> __nsecs; |
| 50 | 65 | struct timespec tp; |
lib/libcxx/src/filesystem/format_string.h+5-5| ... | ... | @@ -56,21 +56,21 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) string format_string(const cha |
| 56 | 56 | string ret; |
| 57 | 57 | va_list ap; |
| 58 | 58 | va_start(ap, msg); |
| 59 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 59 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 60 | 60 | try { |
| 61 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 61 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 62 | 62 | ret = detail::vformat_string(msg, ap); |
| 63 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 63 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 64 | 64 | } catch (...) { |
| 65 | 65 | va_end(ap); |
| 66 | 66 | throw; |
| 67 | 67 | } |
| 68 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 68 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 69 | 69 | va_end(ap); |
| 70 | 70 | return ret; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | } // end namespace detail | |
| 73 | } // namespace detail | |
| 74 | 74 | |
| 75 | 75 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 76 | 76 |
lib/libcxx/src/filesystem/int128_builtins.cpp+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <__config> |
| 17 | 17 | #include <climits> |
| 18 | 18 | |
| 19 | #if !defined(_LIBCPP_HAS_NO_INT128) | |
| 19 | #if _LIBCPP_HAS_INT128 | |
| 20 | 20 | |
| 21 | 21 | extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI __int128_t |
| 22 | 22 | __muloti4(__int128_t a, __int128_t b, int* overflow) { |
lib/libcxx/src/filesystem/operations.cpp+181-60| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | #include <filesystem> |
| 16 | 16 | #include <iterator> |
| 17 | 17 | #include <string_view> |
| 18 | #include <system_error> | |
| 18 | 19 | #include <type_traits> |
| 19 | 20 | #include <vector> |
| 20 | 21 | |
| ... | ... | @@ -32,11 +33,24 @@ |
| 32 | 33 | # include <dirent.h> |
| 33 | 34 | # include <sys/stat.h> |
| 34 | 35 | # include <sys/statvfs.h> |
| 36 | # include <sys/types.h> | |
| 35 | 37 | # include <unistd.h> |
| 36 | 38 | #endif |
| 37 | 39 | #include <fcntl.h> /* values for fchmodat */ |
| 38 | 40 | #include <time.h> |
| 39 | 41 | |
| 42 | // since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl | |
| 43 | #if defined(__linux__) | |
| 44 | # if defined(_LIBCPP_GLIBC_PREREQ) | |
| 45 | # if _LIBCPP_GLIBC_PREREQ(2, 27) | |
| 46 | # define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE | |
| 47 | # endif | |
| 48 | # elif _LIBCPP_HAS_MUSL_LIBC | |
| 49 | # define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE | |
| 50 | # endif | |
| 51 | #elif defined(__FreeBSD__) | |
| 52 | # define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE | |
| 53 | #endif | |
| 40 | 54 | #if __has_include(<sys/sendfile.h>) |
| 41 | 55 | # include <sys/sendfile.h> |
| 42 | 56 | # define _LIBCPP_FILESYSTEM_USE_SENDFILE |
| ... | ... | @@ -44,10 +58,18 @@ |
| 44 | 58 | # include <copyfile.h> |
| 45 | 59 | # define _LIBCPP_FILESYSTEM_USE_COPYFILE |
| 46 | 60 | #else |
| 47 | # include <fstream> | |
| 48 | 61 | # define _LIBCPP_FILESYSTEM_USE_FSTREAM |
| 49 | 62 | #endif |
| 50 | 63 | |
| 64 | // sendfile and copy_file_range need to fall back | |
| 65 | // to the fstream implementation for special files | |
| 66 | #if (defined(_LIBCPP_FILESYSTEM_USE_SENDFILE) || defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE) || \ | |
| 67 | defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)) && \ | |
| 68 | _LIBCPP_HAS_LOCALIZATION | |
| 69 | # include <fstream> | |
| 70 | # define _LIBCPP_FILESYSTEM_NEED_FSTREAM | |
| 71 | #endif | |
| 72 | ||
| 51 | 73 | #if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB) |
| 52 | 74 | # pragma comment(lib, "rt") |
| 53 | 75 | #endif |
| ... | ... | @@ -86,7 +108,7 @@ path __canonical(path const& orig_p, error_code* ec) { |
| 86 | 108 | #if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112) || defined(_LIBCPP_WIN32API) |
| 87 | 109 | std::unique_ptr<path::value_type, decltype(&::free)> hold(detail::realpath(p.c_str(), nullptr), &::free); |
| 88 | 110 | if (hold.get() == nullptr) |
| 89 | return err.report(capture_errno()); | |
| 111 | return err.report(detail::get_last_error()); | |
| 90 | 112 | return {hold.get()}; |
| 91 | 113 | #else |
| 92 | 114 | # if defined(__MVS__) && !defined(PATH_MAX) |
| ... | ... | @@ -96,7 +118,7 @@ path __canonical(path const& orig_p, error_code* ec) { |
| 96 | 118 | # endif |
| 97 | 119 | path::value_type* ret; |
| 98 | 120 | if ((ret = detail::realpath(p.c_str(), buff)) == nullptr) |
| 99 | return err.report(capture_errno()); | |
| 121 | return err.report(detail::get_last_error()); | |
| 100 | 122 | return {ret}; |
| 101 | 123 | #endif |
| 102 | 124 | } |
| ... | ... | @@ -178,9 +200,89 @@ void __copy(const path& from, const path& to, copy_options options, error_code* |
| 178 | 200 | namespace detail { |
| 179 | 201 | namespace { |
| 180 | 202 | |
| 203 | #if defined(_LIBCPP_FILESYSTEM_NEED_FSTREAM) | |
| 204 | bool copy_file_impl_fstream(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) { | |
| 205 | ifstream in; | |
| 206 | in.__open(read_fd.fd, ios::binary); | |
| 207 | if (!in.is_open()) { | |
| 208 | // This assumes that __open didn't reset the error code. | |
| 209 | ec = capture_errno(); | |
| 210 | return false; | |
| 211 | } | |
| 212 | read_fd.fd = -1; | |
| 213 | ofstream out; | |
| 214 | out.__open(write_fd.fd, ios::binary); | |
| 215 | if (!out.is_open()) { | |
| 216 | ec = capture_errno(); | |
| 217 | return false; | |
| 218 | } | |
| 219 | write_fd.fd = -1; | |
| 220 | ||
| 221 | if (in.good() && out.good()) { | |
| 222 | using InIt = istreambuf_iterator<char>; | |
| 223 | using OutIt = ostreambuf_iterator<char>; | |
| 224 | InIt bin(in); | |
| 225 | InIt ein; | |
| 226 | OutIt bout(out); | |
| 227 | copy(bin, ein, bout); | |
| 228 | } | |
| 229 | if (out.fail() || in.fail()) { | |
| 230 | ec = make_error_code(errc::io_error); | |
| 231 | return false; | |
| 232 | } | |
| 233 | ||
| 234 | ec.clear(); | |
| 235 | return true; | |
| 236 | } | |
| 237 | #endif | |
| 238 | ||
| 239 | #if defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE) | |
| 240 | bool copy_file_impl_copy_file_range(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) { | |
| 241 | size_t count = read_fd.get_stat().st_size; | |
| 242 | // a zero-length file is either empty, or not copyable by this syscall | |
| 243 | // return early to avoid the syscall cost | |
| 244 | if (count == 0) { | |
| 245 | ec = {EINVAL, generic_category()}; | |
| 246 | return false; | |
| 247 | } | |
| 248 | // do not modify the fd positions as copy_file_impl_sendfile may be called after a partial copy | |
| 249 | # if defined(__linux__) | |
| 250 | loff_t off_in = 0; | |
| 251 | loff_t off_out = 0; | |
| 252 | # else | |
| 253 | off_t off_in = 0; | |
| 254 | off_t off_out = 0; | |
| 255 | # endif | |
| 256 | ||
| 257 | do { | |
| 258 | ssize_t res; | |
| 259 | ||
| 260 | if ((res = ::copy_file_range(read_fd.fd, &off_in, write_fd.fd, &off_out, count, 0)) == -1) { | |
| 261 | ec = capture_errno(); | |
| 262 | return false; | |
| 263 | } | |
| 264 | count -= res; | |
| 265 | } while (count > 0); | |
| 266 | ||
| 267 | ec.clear(); | |
| 268 | ||
| 269 | return true; | |
| 270 | } | |
| 271 | #endif | |
| 272 | ||
| 181 | 273 | #if defined(_LIBCPP_FILESYSTEM_USE_SENDFILE) |
| 182 | bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) { | |
| 274 | bool copy_file_impl_sendfile(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) { | |
| 183 | 275 | size_t count = read_fd.get_stat().st_size; |
| 276 | // a zero-length file is either empty, or not copyable by this syscall | |
| 277 | // return early to avoid the syscall cost | |
| 278 | // however, we can't afford this luxury in the no-locale build, | |
| 279 | // as we can't utilize the fstream impl to copy empty files | |
| 280 | # if _LIBCPP_HAS_LOCALIZATION | |
| 281 | if (count == 0) { | |
| 282 | ec = {EINVAL, generic_category()}; | |
| 283 | return false; | |
| 284 | } | |
| 285 | # endif | |
| 184 | 286 | do { |
| 185 | 287 | ssize_t res; |
| 186 | 288 | if ((res = ::sendfile(write_fd.fd, read_fd.fd, nullptr, count)) == -1) { |
| ... | ... | @@ -194,6 +296,54 @@ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_cod |
| 194 | 296 | |
| 195 | 297 | return true; |
| 196 | 298 | } |
| 299 | #endif | |
| 300 | ||
| 301 | #if defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE) || defined(_LIBCPP_FILESYSTEM_USE_SENDFILE) | |
| 302 | // If we have copy_file_range or sendfile, try both in succession (if available). | |
| 303 | // If both fail, fall back to using fstream. | |
| 304 | bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) { | |
| 305 | # if defined(_LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE) | |
| 306 | if (copy_file_impl_copy_file_range(read_fd, write_fd, ec)) { | |
| 307 | return true; | |
| 308 | } | |
| 309 | // EINVAL: src and dst are the same file (this is not cheaply | |
| 310 | // detectable from userspace) | |
| 311 | // EINVAL: copy_file_range is unsupported for this file type by the | |
| 312 | // underlying filesystem | |
| 313 | // ENOTSUP: undocumented, can arise with old kernels and NFS | |
| 314 | // EOPNOTSUPP: filesystem does not implement copy_file_range | |
| 315 | // ETXTBSY: src or dst is an active swapfile (nonsensical, but allowed | |
| 316 | // with normal copying) | |
| 317 | // EXDEV: src and dst are on different filesystems that do not support | |
| 318 | // cross-fs copy_file_range | |
| 319 | // ENOENT: undocumented, can arise with CIFS | |
| 320 | // ENOSYS: unsupported by kernel or blocked by seccomp | |
| 321 | if (ec.value() != EINVAL && ec.value() != ENOTSUP && ec.value() != EOPNOTSUPP && ec.value() != ETXTBSY && | |
| 322 | ec.value() != EXDEV && ec.value() != ENOENT && ec.value() != ENOSYS) { | |
| 323 | return false; | |
| 324 | } | |
| 325 | ec.clear(); | |
| 326 | # endif | |
| 327 | ||
| 328 | # if defined(_LIBCPP_FILESYSTEM_USE_SENDFILE) | |
| 329 | if (copy_file_impl_sendfile(read_fd, write_fd, ec)) { | |
| 330 | return true; | |
| 331 | } | |
| 332 | // EINVAL: unsupported file type | |
| 333 | if (ec.value() != EINVAL) { | |
| 334 | return false; | |
| 335 | } | |
| 336 | ec.clear(); | |
| 337 | # endif | |
| 338 | ||
| 339 | # if defined(_LIBCPP_FILESYSTEM_NEED_FSTREAM) | |
| 340 | return copy_file_impl_fstream(read_fd, write_fd, ec); | |
| 341 | # else | |
| 342 | // since iostreams are unavailable in the no-locale build, just fail after a failed sendfile | |
| 343 | ec.assign(EINVAL, std::system_category()); | |
| 344 | return false; | |
| 345 | # endif | |
| 346 | } | |
| 197 | 347 | #elif defined(_LIBCPP_FILESYSTEM_USE_COPYFILE) |
| 198 | 348 | bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) { |
| 199 | 349 | struct CopyFileState { |
| ... | ... | @@ -217,44 +367,14 @@ bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_cod |
| 217 | 367 | } |
| 218 | 368 | #elif defined(_LIBCPP_FILESYSTEM_USE_FSTREAM) |
| 219 | 369 | bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) { |
| 220 | ifstream in; | |
| 221 | in.__open(read_fd.fd, ios::binary); | |
| 222 | if (!in.is_open()) { | |
| 223 | // This assumes that __open didn't reset the error code. | |
| 224 | ec = capture_errno(); | |
| 225 | return false; | |
| 226 | } | |
| 227 | read_fd.fd = -1; | |
| 228 | ofstream out; | |
| 229 | out.__open(write_fd.fd, ios::binary); | |
| 230 | if (!out.is_open()) { | |
| 231 | ec = capture_errno(); | |
| 232 | return false; | |
| 233 | } | |
| 234 | write_fd.fd = -1; | |
| 235 | ||
| 236 | if (in.good() && out.good()) { | |
| 237 | using InIt = istreambuf_iterator<char>; | |
| 238 | using OutIt = ostreambuf_iterator<char>; | |
| 239 | InIt bin(in); | |
| 240 | InIt ein; | |
| 241 | OutIt bout(out); | |
| 242 | copy(bin, ein, bout); | |
| 243 | } | |
| 244 | if (out.fail() || in.fail()) { | |
| 245 | ec = make_error_code(errc::io_error); | |
| 246 | return false; | |
| 247 | } | |
| 248 | ||
| 249 | ec.clear(); | |
| 250 | return true; | |
| 370 | return copy_file_impl_fstream(read_fd, write_fd, ec); | |
| 251 | 371 | } |
| 252 | 372 | #else |
| 253 | 373 | # error "Unknown implementation for copy_file_impl" |
| 254 | 374 | #endif // copy_file_impl implementation |
| 255 | 375 | |
| 256 | 376 | } // end anonymous namespace |
| 257 | } // end namespace detail | |
| 377 | } // namespace detail | |
| 258 | 378 | |
| 259 | 379 | bool __copy_file(const path& from, const path& to, copy_options options, error_code* ec) { |
| 260 | 380 | using detail::FileDescriptor; |
| ... | ... | @@ -393,9 +513,9 @@ bool __create_directory(const path& p, error_code* ec) { |
| 393 | 513 | if (detail::mkdir(p.c_str(), static_cast<int>(perms::all)) == 0) |
| 394 | 514 | return true; |
| 395 | 515 | |
| 396 | if (errno != EEXIST) | |
| 397 | return err.report(capture_errno()); | |
| 398 | error_code mec = capture_errno(); | |
| 516 | error_code mec = detail::get_last_error(); | |
| 517 | if (mec != errc::file_exists) | |
| 518 | return err.report(mec); | |
| 399 | 519 | error_code ignored_ec; |
| 400 | 520 | const file_status st = status(p, ignored_ec); |
| 401 | 521 | if (!is_directory(st)) |
| ... | ... | @@ -417,10 +537,10 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) { |
| 417 | 537 | if (detail::mkdir(p.c_str(), attr_stat.st_mode) == 0) |
| 418 | 538 | return true; |
| 419 | 539 | |
| 420 | if (errno != EEXIST) | |
| 421 | return err.report(capture_errno()); | |
| 540 | mec = detail::get_last_error(); | |
| 541 | if (mec != errc::file_exists) | |
| 542 | return err.report(mec); | |
| 422 | 543 | |
| 423 | mec = capture_errno(); | |
| 424 | 544 | error_code ignored_ec; |
| 425 | 545 | st = status(p, ignored_ec); |
| 426 | 546 | if (!is_directory(st)) |
| ... | ... | @@ -431,19 +551,19 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) { |
| 431 | 551 | void __create_directory_symlink(path const& from, path const& to, error_code* ec) { |
| 432 | 552 | ErrorHandler<void> err("create_directory_symlink", ec, &from, &to); |
| 433 | 553 | if (detail::symlink_dir(from.c_str(), to.c_str()) == -1) |
| 434 | return err.report(capture_errno()); | |
| 554 | return err.report(detail::get_last_error()); | |
| 435 | 555 | } |
| 436 | 556 | |
| 437 | 557 | void __create_hard_link(const path& from, const path& to, error_code* ec) { |
| 438 | 558 | ErrorHandler<void> err("create_hard_link", ec, &from, &to); |
| 439 | 559 | if (detail::link(from.c_str(), to.c_str()) == -1) |
| 440 | return err.report(capture_errno()); | |
| 560 | return err.report(detail::get_last_error()); | |
| 441 | 561 | } |
| 442 | 562 | |
| 443 | 563 | void __create_symlink(path const& from, path const& to, error_code* ec) { |
| 444 | 564 | ErrorHandler<void> err("create_symlink", ec, &from, &to); |
| 445 | 565 | if (detail::symlink_file(from.c_str(), to.c_str()) == -1) |
| 446 | return err.report(capture_errno()); | |
| 566 | return err.report(detail::get_last_error()); | |
| 447 | 567 | } |
| 448 | 568 | |
| 449 | 569 | path __current_path(error_code* ec) { |
| ... | ... | @@ -486,7 +606,7 @@ path __current_path(error_code* ec) { |
| 486 | 606 | |
| 487 | 607 | unique_ptr<path::value_type, Deleter> hold(detail::getcwd(ptr, size), deleter); |
| 488 | 608 | if (hold.get() == nullptr) |
| 489 | return err.report(capture_errno(), "call to getcwd failed"); | |
| 609 | return err.report(detail::get_last_error(), "call to getcwd failed"); | |
| 490 | 610 | |
| 491 | 611 | return {hold.get()}; |
| 492 | 612 | } |
| ... | ... | @@ -494,7 +614,7 @@ path __current_path(error_code* ec) { |
| 494 | 614 | void __current_path(const path& p, error_code* ec) { |
| 495 | 615 | ErrorHandler<void> err("current_path", ec, &p); |
| 496 | 616 | if (detail::chdir(p.c_str()) == -1) |
| 497 | err.report(capture_errno()); | |
| 617 | err.report(detail::get_last_error()); | |
| 498 | 618 | } |
| 499 | 619 | |
| 500 | 620 | bool __equivalent(const path& p1, const path& p2, error_code* ec) { |
| ... | ... | @@ -582,10 +702,10 @@ void __last_write_time(const path& p, file_time_type new_time, error_code* ec) { |
| 582 | 702 | return err.report(errc::value_too_large); |
| 583 | 703 | detail::WinHandle h(p.c_str(), FILE_WRITE_ATTRIBUTES, 0); |
| 584 | 704 | if (!h) |
| 585 | return err.report(detail::make_windows_error(GetLastError())); | |
| 705 | return err.report(detail::get_last_error()); | |
| 586 | 706 | FILETIME last_write = timespec_to_filetime(ts); |
| 587 | 707 | if (!SetFileTime(h, nullptr, nullptr, &last_write)) |
| 588 | return err.report(detail::make_windows_error(GetLastError())); | |
| 708 | return err.report(detail::get_last_error()); | |
| 589 | 709 | #else |
| 590 | 710 | error_code m_ec; |
| 591 | 711 | array<TimeSpec, 2> tbuf; |
| ... | ... | @@ -643,7 +763,7 @@ void __permissions(const path& p, perms prms, perm_options opts, error_code* ec) |
| 643 | 763 | #if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_FDCWD) |
| 644 | 764 | const int flags = set_sym_perms ? AT_SYMLINK_NOFOLLOW : 0; |
| 645 | 765 | if (detail::fchmodat(AT_FDCWD, p.c_str(), real_perms, flags) == -1) { |
| 646 | return err.report(capture_errno()); | |
| 766 | return err.report(detail::get_last_error()); | |
| 647 | 767 | } |
| 648 | 768 | #else |
| 649 | 769 | if (set_sym_perms) |
| ... | ... | @@ -671,14 +791,14 @@ path __read_symlink(const path& p, error_code* ec) { |
| 671 | 791 | #else |
| 672 | 792 | StatT sb; |
| 673 | 793 | if (detail::lstat(p.c_str(), &sb) == -1) { |
| 674 | return err.report(capture_errno()); | |
| 794 | return err.report(detail::get_last_error()); | |
| 675 | 795 | } |
| 676 | 796 | const size_t size = sb.st_size + 1; |
| 677 | 797 | auto buff = unique_ptr<path::value_type[]>(new path::value_type[size]); |
| 678 | 798 | #endif |
| 679 | 799 | detail::SSizeT ret; |
| 680 | 800 | if ((ret = detail::readlink(p.c_str(), buff.get(), size)) == -1) |
| 681 | return err.report(capture_errno()); | |
| 801 | return err.report(detail::get_last_error()); | |
| 682 | 802 | // Note that `ret` returning `0` would work, resulting in a valid empty string being returned. |
| 683 | 803 | if (static_cast<size_t>(ret) >= size) |
| 684 | 804 | return err.report(errc::value_too_large); |
| ... | ... | @@ -689,8 +809,9 @@ path __read_symlink(const path& p, error_code* ec) { |
| 689 | 809 | bool __remove(const path& p, error_code* ec) { |
| 690 | 810 | ErrorHandler<bool> err("remove", ec, &p); |
| 691 | 811 | if (detail::remove(p.c_str()) == -1) { |
| 692 | if (errno != ENOENT) | |
| 693 | err.report(capture_errno()); | |
| 812 | error_code mec = detail::get_last_error(); | |
| 813 | if (mec != errc::no_such_file_or_directory) | |
| 814 | err.report(mec); | |
| 694 | 815 | return false; |
| 695 | 816 | } |
| 696 | 817 | return true; |
| ... | ... | @@ -732,7 +853,7 @@ uintmax_t remove_all_impl(path const& p, error_code& ec) { |
| 732 | 853 | return count; |
| 733 | 854 | } |
| 734 | 855 | |
| 735 | } // end namespace | |
| 856 | } // namespace | |
| 736 | 857 | |
| 737 | 858 | uintmax_t __remove_all(const path& p, error_code* ec) { |
| 738 | 859 | ErrorHandler<uintmax_t> err("remove_all", ec, &p); |
| ... | ... | @@ -827,7 +948,7 @@ uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) { |
| 827 | 948 | return 0; |
| 828 | 949 | } |
| 829 | 950 | |
| 830 | } // end namespace | |
| 951 | } // namespace | |
| 831 | 952 | |
| 832 | 953 | uintmax_t __remove_all(const path& p, error_code* ec) { |
| 833 | 954 | ErrorHandler<uintmax_t> err("remove_all", ec, &p); |
| ... | ... | @@ -843,13 +964,13 @@ uintmax_t __remove_all(const path& p, error_code* ec) { |
| 843 | 964 | void __rename(const path& from, const path& to, error_code* ec) { |
| 844 | 965 | ErrorHandler<void> err("rename", ec, &from, &to); |
| 845 | 966 | if (detail::rename(from.c_str(), to.c_str()) == -1) |
| 846 | err.report(capture_errno()); | |
| 967 | err.report(detail::get_last_error()); | |
| 847 | 968 | } |
| 848 | 969 | |
| 849 | 970 | void __resize_file(const path& p, uintmax_t size, error_code* ec) { |
| 850 | 971 | ErrorHandler<void> err("resize_file", ec, &p); |
| 851 | 972 | if (detail::truncate(p.c_str(), static_cast< ::off_t>(size)) == -1) |
| 852 | return err.report(capture_errno()); | |
| 973 | return err.report(detail::get_last_error()); | |
| 853 | 974 | } |
| 854 | 975 | |
| 855 | 976 | space_info __space(const path& p, error_code* ec) { |
| ... | ... | @@ -857,7 +978,7 @@ space_info __space(const path& p, error_code* ec) { |
| 857 | 978 | space_info si; |
| 858 | 979 | detail::StatVFS m_svfs = {}; |
| 859 | 980 | if (detail::statvfs(p.c_str(), &m_svfs) == -1) { |
| 860 | err.report(capture_errno()); | |
| 981 | err.report(detail::get_last_error()); | |
| 861 | 982 | si.capacity = si.free = si.available = static_cast<uintmax_t>(-1); |
| 862 | 983 | return si; |
| 863 | 984 | } |
| ... | ... | @@ -884,7 +1005,7 @@ path __temp_directory_path(error_code* ec) { |
| 884 | 1005 | wchar_t buf[MAX_PATH]; |
| 885 | 1006 | DWORD retval = GetTempPathW(MAX_PATH, buf); |
| 886 | 1007 | if (!retval) |
| 887 | return err.report(detail::make_windows_error(GetLastError())); | |
| 1008 | return err.report(detail::get_last_error()); | |
| 888 | 1009 | if (retval > MAX_PATH) |
| 889 | 1010 | return err.report(errc::filename_too_long); |
| 890 | 1011 | // GetTempPathW returns a path with a trailing slash, which we |
lib/libcxx/src/filesystem/path.cpp+6-2| ... | ... | @@ -24,7 +24,10 @@ using parser::string_view_t; |
| 24 | 24 | // path definitions |
| 25 | 25 | /////////////////////////////////////////////////////////////////////////////// |
| 26 | 26 | |
| 27 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 28 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") | |
| 27 | 29 | constexpr path::value_type path::preferred_separator; |
| 30 | _LIBCPP_DIAGNOSTIC_POP | |
| 28 | 31 | |
| 29 | 32 | path& path::replace_extension(path const& replacement) { |
| 30 | 33 | path p = extension(); |
| ... | ... | @@ -267,7 +270,7 @@ path path::lexically_relative(const path& base) const { |
| 267 | 270 | // Find the first mismatching element |
| 268 | 271 | auto PP = PathParser::CreateBegin(__pn_); |
| 269 | 272 | auto PPBase = PathParser::CreateBegin(base.__pn_); |
| 270 | while (PP && PPBase && PP.State_ == PPBase.State_ && *PP == *PPBase) { | |
| 273 | while (PP && PPBase && PP.State_ == PPBase.State_ && (*PP == *PPBase || PP.inRootDir())) { | |
| 271 | 274 | ++PP; |
| 272 | 275 | ++PPBase; |
| 273 | 276 | } |
| ... | ... | @@ -368,7 +371,8 @@ size_t hash_value(const path& __p) noexcept { |
| 368 | 371 | size_t hash_value = 0; |
| 369 | 372 | hash<string_view_t> hasher; |
| 370 | 373 | while (PP) { |
| 371 | hash_value = __hash_combine(hash_value, hasher(*PP)); | |
| 374 | string_view_t Part = PP.inRootDir() ? PATHSTR("/") : *PP; | |
| 375 | hash_value = __hash_combine(hash_value, hasher(Part)); | |
| 372 | 376 | ++PP; |
| 373 | 377 | } |
| 374 | 378 | return hash_value; |
lib/libcxx/src/filesystem/posix_compat.h+34-41| ... | ... | @@ -11,9 +11,10 @@ |
| 11 | 11 | // |
| 12 | 12 | // These generally behave like the proper posix functions, with these |
| 13 | 13 | // exceptions: |
| 14 | // On Windows, they take paths in wchar_t* form, instead of char* form. | |
| 15 | // The symlink() function is split into two frontends, symlink_file() | |
| 16 | // and symlink_dir(). | |
| 14 | // - On Windows, they take paths in wchar_t* form, instead of char* form. | |
| 15 | // - The symlink() function is split into two frontends, symlink_file() | |
| 16 | // and symlink_dir(). | |
| 17 | // - Errors should be retrieved with get_last_error, not errno. | |
| 17 | 18 | // |
| 18 | 19 | // These are provided within an anonymous namespace within the detail |
| 19 | 20 | // namespace - callers need to include this header and call them as |
| ... | ... | @@ -122,11 +123,6 @@ namespace detail { |
| 122 | 123 | |
| 123 | 124 | # define O_NONBLOCK 0 |
| 124 | 125 | |
| 125 | inline int set_errno(int e = GetLastError()) { | |
| 126 | errno = static_cast<int>(__win_err_to_errc(e)); | |
| 127 | return -1; | |
| 128 | } | |
| 129 | ||
| 130 | 126 | class WinHandle { |
| 131 | 127 | public: |
| 132 | 128 | WinHandle(const wchar_t* p, DWORD access, DWORD flags) { |
| ... | ... | @@ -153,7 +149,7 @@ private: |
| 153 | 149 | inline int stat_handle(HANDLE h, StatT* buf) { |
| 154 | 150 | FILE_BASIC_INFO basic; |
| 155 | 151 | if (!GetFileInformationByHandleEx(h, FileBasicInfo, &basic, sizeof(basic))) |
| 156 | return set_errno(); | |
| 152 | return -1; | |
| 157 | 153 | memset(buf, 0, sizeof(*buf)); |
| 158 | 154 | buf->st_mtim = filetime_to_timespec(basic.LastWriteTime); |
| 159 | 155 | buf->st_atim = filetime_to_timespec(basic.LastAccessTime); |
| ... | ... | @@ -168,18 +164,18 @@ inline int stat_handle(HANDLE h, StatT* buf) { |
| 168 | 164 | if (basic.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { |
| 169 | 165 | FILE_ATTRIBUTE_TAG_INFO tag; |
| 170 | 166 | if (!GetFileInformationByHandleEx(h, FileAttributeTagInfo, &tag, sizeof(tag))) |
| 171 | return set_errno(); | |
| 167 | return -1; | |
| 172 | 168 | if (tag.ReparseTag == IO_REPARSE_TAG_SYMLINK) |
| 173 | 169 | buf->st_mode = (buf->st_mode & ~_S_IFMT) | _S_IFLNK; |
| 174 | 170 | } |
| 175 | 171 | FILE_STANDARD_INFO standard; |
| 176 | 172 | if (!GetFileInformationByHandleEx(h, FileStandardInfo, &standard, sizeof(standard))) |
| 177 | return set_errno(); | |
| 173 | return -1; | |
| 178 | 174 | buf->st_nlink = standard.NumberOfLinks; |
| 179 | 175 | buf->st_size = standard.EndOfFile.QuadPart; |
| 180 | 176 | BY_HANDLE_FILE_INFORMATION info; |
| 181 | 177 | if (!GetFileInformationByHandle(h, &info)) |
| 182 | return set_errno(); | |
| 178 | return -1; | |
| 183 | 179 | buf->st_dev = info.dwVolumeSerialNumber; |
| 184 | 180 | memcpy(&buf->st_ino.id[0], &info.nFileIndexHigh, 4); |
| 185 | 181 | memcpy(&buf->st_ino.id[4], &info.nFileIndexLow, 4); |
| ... | ... | @@ -189,7 +185,7 @@ inline int stat_handle(HANDLE h, StatT* buf) { |
| 189 | 185 | inline int stat_file(const wchar_t* path, StatT* buf, DWORD flags) { |
| 190 | 186 | WinHandle h(path, FILE_READ_ATTRIBUTES, flags); |
| 191 | 187 | if (!h) |
| 192 | return set_errno(); | |
| 188 | return -1; | |
| 193 | 189 | int ret = stat_handle(h, buf); |
| 194 | 190 | return ret; |
| 195 | 191 | } |
| ... | ... | @@ -206,7 +202,7 @@ inline int fstat(int fd, StatT* buf) { |
| 206 | 202 | inline int mkdir(const wchar_t* path, int permissions) { |
| 207 | 203 | (void)permissions; |
| 208 | 204 | if (!CreateDirectoryW(path, nullptr)) |
| 209 | return set_errno(); | |
| 205 | return -1; | |
| 210 | 206 | return 0; |
| 211 | 207 | } |
| 212 | 208 | |
| ... | ... | @@ -219,10 +215,10 @@ inline int symlink_file_dir(const wchar_t* oldname, const wchar_t* newname, bool |
| 219 | 215 | return 0; |
| 220 | 216 | int e = GetLastError(); |
| 221 | 217 | if (e != ERROR_INVALID_PARAMETER) |
| 222 | return set_errno(e); | |
| 218 | return -1; | |
| 223 | 219 | if (CreateSymbolicLinkW(newname, oldname, flags)) |
| 224 | 220 | return 0; |
| 225 | return set_errno(); | |
| 221 | return -1; | |
| 226 | 222 | } |
| 227 | 223 | |
| 228 | 224 | inline int symlink_file(const wchar_t* oldname, const wchar_t* newname) { |
| ... | ... | @@ -236,17 +232,17 @@ inline int symlink_dir(const wchar_t* oldname, const wchar_t* newname) { |
| 236 | 232 | inline int link(const wchar_t* oldname, const wchar_t* newname) { |
| 237 | 233 | if (CreateHardLinkW(newname, oldname, nullptr)) |
| 238 | 234 | return 0; |
| 239 | return set_errno(); | |
| 235 | return -1; | |
| 240 | 236 | } |
| 241 | 237 | |
| 242 | 238 | inline int remove(const wchar_t* path) { |
| 243 | 239 | detail::WinHandle h(path, DELETE, FILE_FLAG_OPEN_REPARSE_POINT); |
| 244 | 240 | if (!h) |
| 245 | return set_errno(); | |
| 241 | return -1; | |
| 246 | 242 | FILE_DISPOSITION_INFO info; |
| 247 | 243 | info.DeleteFile = TRUE; |
| 248 | 244 | if (!SetFileInformationByHandle(h, FileDispositionInfo, &info, sizeof(info))) |
| 249 | return set_errno(); | |
| 245 | return -1; | |
| 250 | 246 | return 0; |
| 251 | 247 | } |
| 252 | 248 | |
| ... | ... | @@ -254,9 +250,9 @@ inline int truncate_handle(HANDLE h, off_t length) { |
| 254 | 250 | LARGE_INTEGER size_param; |
| 255 | 251 | size_param.QuadPart = length; |
| 256 | 252 | if (!SetFilePointerEx(h, size_param, 0, FILE_BEGIN)) |
| 257 | return set_errno(); | |
| 253 | return -1; | |
| 258 | 254 | if (!SetEndOfFile(h)) |
| 259 | return set_errno(); | |
| 255 | return -1; | |
| 260 | 256 | return 0; |
| 261 | 257 | } |
| 262 | 258 | |
| ... | ... | @@ -268,19 +264,19 @@ inline int ftruncate(int fd, off_t length) { |
| 268 | 264 | inline int truncate(const wchar_t* path, off_t length) { |
| 269 | 265 | detail::WinHandle h(path, GENERIC_WRITE, 0); |
| 270 | 266 | if (!h) |
| 271 | return set_errno(); | |
| 267 | return -1; | |
| 272 | 268 | return truncate_handle(h, length); |
| 273 | 269 | } |
| 274 | 270 | |
| 275 | 271 | inline int rename(const wchar_t* from, const wchar_t* to) { |
| 276 | 272 | if (!(MoveFileExW(from, to, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH))) |
| 277 | return set_errno(); | |
| 273 | return -1; | |
| 278 | 274 | return 0; |
| 279 | 275 | } |
| 280 | 276 | |
| 281 | 277 | inline int chdir(const wchar_t* path) { |
| 282 | 278 | if (!SetCurrentDirectoryW(path)) |
| 283 | return set_errno(); | |
| 279 | return -1; | |
| 284 | 280 | return 0; |
| 285 | 281 | } |
| 286 | 282 | |
| ... | ... | @@ -300,7 +296,7 @@ inline int statvfs(const wchar_t* p, StatVFS* buf) { |
| 300 | 296 | break; |
| 301 | 297 | path parent = dir.parent_path(); |
| 302 | 298 | if (parent == dir) { |
| 303 | errno = ENOENT; | |
| 299 | SetLastError(ERROR_PATH_NOT_FOUND); | |
| 304 | 300 | return -1; |
| 305 | 301 | } |
| 306 | 302 | dir = parent; |
| ... | ... | @@ -308,7 +304,7 @@ inline int statvfs(const wchar_t* p, StatVFS* buf) { |
| 308 | 304 | ULARGE_INTEGER free_bytes_available_to_caller, total_number_of_bytes, total_number_of_free_bytes; |
| 309 | 305 | if (!GetDiskFreeSpaceExW( |
| 310 | 306 | dir.c_str(), &free_bytes_available_to_caller, &total_number_of_bytes, &total_number_of_free_bytes)) |
| 311 | return set_errno(); | |
| 307 | return -1; | |
| 312 | 308 | buf->f_frsize = 1; |
| 313 | 309 | buf->f_blocks = total_number_of_bytes.QuadPart; |
| 314 | 310 | buf->f_bfree = total_number_of_free_bytes.QuadPart; |
| ... | ... | @@ -330,7 +326,6 @@ inline wchar_t* getcwd([[maybe_unused]] wchar_t* in_buf, [[maybe_unused]] size_t |
| 330 | 326 | retval = GetCurrentDirectoryW(buff_size, buff.get()); |
| 331 | 327 | } |
| 332 | 328 | if (!retval) { |
| 333 | set_errno(); | |
| 334 | 329 | return nullptr; |
| 335 | 330 | } |
| 336 | 331 | return buff.release(); |
| ... | ... | @@ -342,7 +337,6 @@ inline wchar_t* realpath(const wchar_t* path, [[maybe_unused]] wchar_t* resolved |
| 342 | 337 | |
| 343 | 338 | WinHandle h(path, FILE_READ_ATTRIBUTES, 0); |
| 344 | 339 | if (!h) { |
| 345 | set_errno(); | |
| 346 | 340 | return nullptr; |
| 347 | 341 | } |
| 348 | 342 | size_t buff_size = MAX_PATH + 10; |
| ... | ... | @@ -354,7 +348,6 @@ inline wchar_t* realpath(const wchar_t* path, [[maybe_unused]] wchar_t* resolved |
| 354 | 348 | retval = GetFinalPathNameByHandleW(h, buff.get(), buff_size, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS); |
| 355 | 349 | } |
| 356 | 350 | if (!retval) { |
| 357 | set_errno(); | |
| 358 | 351 | return nullptr; |
| 359 | 352 | } |
| 360 | 353 | wchar_t* ptr = buff.get(); |
| ... | ... | @@ -376,20 +369,20 @@ using ModeT = int; |
| 376 | 369 | inline int fchmod_handle(HANDLE h, int perms) { |
| 377 | 370 | FILE_BASIC_INFO basic; |
| 378 | 371 | if (!GetFileInformationByHandleEx(h, FileBasicInfo, &basic, sizeof(basic))) |
| 379 | return set_errno(); | |
| 372 | return -1; | |
| 380 | 373 | DWORD orig_attributes = basic.FileAttributes; |
| 381 | 374 | basic.FileAttributes &= ~FILE_ATTRIBUTE_READONLY; |
| 382 | 375 | if ((perms & 0222) == 0) |
| 383 | 376 | basic.FileAttributes |= FILE_ATTRIBUTE_READONLY; |
| 384 | 377 | if (basic.FileAttributes != orig_attributes && !SetFileInformationByHandle(h, FileBasicInfo, &basic, sizeof(basic))) |
| 385 | return set_errno(); | |
| 378 | return -1; | |
| 386 | 379 | return 0; |
| 387 | 380 | } |
| 388 | 381 | |
| 389 | 382 | inline int fchmodat(int /*fd*/, const wchar_t* path, int perms, int flag) { |
| 390 | 383 | DWORD attributes = GetFileAttributesW(path); |
| 391 | 384 | if (attributes == INVALID_FILE_ATTRIBUTES) |
| 392 | return set_errno(); | |
| 385 | return -1; | |
| 393 | 386 | if (attributes & FILE_ATTRIBUTE_REPARSE_POINT && !(flag & AT_SYMLINK_NOFOLLOW)) { |
| 394 | 387 | // If the file is a symlink, and we are supposed to operate on the target |
| 395 | 388 | // of the symlink, we need to open a handle to it, without the |
| ... | ... | @@ -397,7 +390,7 @@ inline int fchmodat(int /*fd*/, const wchar_t* path, int perms, int flag) { |
| 397 | 390 | // symlink, and operate on it via the handle. |
| 398 | 391 | detail::WinHandle h(path, FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, 0); |
| 399 | 392 | if (!h) |
| 400 | return set_errno(); | |
| 393 | return -1; | |
| 401 | 394 | return fchmod_handle(h, perms); |
| 402 | 395 | } else { |
| 403 | 396 | // For a non-symlink, or if operating on the symlink itself instead of |
| ... | ... | @@ -407,7 +400,7 @@ inline int fchmodat(int /*fd*/, const wchar_t* path, int perms, int flag) { |
| 407 | 400 | if ((perms & 0222) == 0) |
| 408 | 401 | attributes |= FILE_ATTRIBUTE_READONLY; |
| 409 | 402 | if (attributes != orig_attributes && !SetFileAttributesW(path, attributes)) |
| 410 | return set_errno(); | |
| 403 | return -1; | |
| 411 | 404 | } |
| 412 | 405 | return 0; |
| 413 | 406 | } |
| ... | ... | @@ -424,18 +417,18 @@ inline SSizeT readlink(const wchar_t* path, wchar_t* ret_buf, size_t bufsize) { |
| 424 | 417 | uint8_t buf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; |
| 425 | 418 | detail::WinHandle h(path, FILE_READ_ATTRIBUTES, FILE_FLAG_OPEN_REPARSE_POINT); |
| 426 | 419 | if (!h) |
| 427 | return set_errno(); | |
| 420 | return -1; | |
| 428 | 421 | DWORD out; |
| 429 | 422 | if (!DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, nullptr, 0, buf, sizeof(buf), &out, 0)) |
| 430 | return set_errno(); | |
| 423 | return -1; | |
| 431 | 424 | const auto* reparse = reinterpret_cast<LIBCPP_REPARSE_DATA_BUFFER*>(buf); |
| 432 | 425 | size_t path_buf_offset = offsetof(LIBCPP_REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer[0]); |
| 433 | 426 | if (out < path_buf_offset) { |
| 434 | errno = EINVAL; | |
| 427 | SetLastError(ERROR_REPARSE_TAG_INVALID); | |
| 435 | 428 | return -1; |
| 436 | 429 | } |
| 437 | 430 | if (reparse->ReparseTag != IO_REPARSE_TAG_SYMLINK) { |
| 438 | errno = EINVAL; | |
| 431 | SetLastError(ERROR_REPARSE_TAG_INVALID); | |
| 439 | 432 | return -1; |
| 440 | 433 | } |
| 441 | 434 | const auto& symlink = reparse->SymbolicLinkReparseBuffer; |
| ... | ... | @@ -449,11 +442,11 @@ inline SSizeT readlink(const wchar_t* path, wchar_t* ret_buf, size_t bufsize) { |
| 449 | 442 | } |
| 450 | 443 | // name_offset/length are expressed in bytes, not in wchar_t |
| 451 | 444 | if (path_buf_offset + name_offset + name_length > out) { |
| 452 | errno = EINVAL; | |
| 445 | SetLastError(ERROR_REPARSE_TAG_INVALID); | |
| 453 | 446 | return -1; |
| 454 | 447 | } |
| 455 | 448 | if (name_length / sizeof(wchar_t) > bufsize) { |
| 456 | errno = ENOMEM; | |
| 449 | SetLastError(ERROR_NOT_ENOUGH_MEMORY); | |
| 457 | 450 | return -1; |
| 458 | 451 | } |
| 459 | 452 | memcpy(ret_buf, &symlink.PathBuffer[name_offset / sizeof(wchar_t)], name_length); |
| ... | ... | @@ -490,7 +483,7 @@ using SSizeT = ::ssize_t; |
| 490 | 483 | |
| 491 | 484 | #endif |
| 492 | 485 | |
| 493 | } // end namespace detail | |
| 486 | } // namespace detail | |
| 494 | 487 | |
| 495 | 488 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 496 | 489 |
lib/libcxx/src/filesystem/time_utils.h+3-3| ... | ... | @@ -299,7 +299,7 @@ inline TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; } |
| 299 | 299 | inline TimeSpec extract_atime(StatT const& st) { return st.st_atim; } |
| 300 | 300 | #endif |
| 301 | 301 | |
| 302 | #ifndef _LIBCPP_HAS_NO_FILESYSTEM | |
| 302 | #if _LIBCPP_HAS_FILESYSTEM | |
| 303 | 303 | |
| 304 | 304 | # if !defined(_LIBCPP_WIN32API) |
| 305 | 305 | inline bool posix_utimes(const path& p, std::array<TimeSpec, 2> const& TS, error_code& ec) { |
| ... | ... | @@ -342,9 +342,9 @@ inline file_time_type __extract_last_write_time(const path& p, const StatT& st, |
| 342 | 342 | return fs_time::convert_from_timespec(ts); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | #endif // !_LIBCPP_HAS_NO_FILESYSTEM | |
| 345 | #endif // _LIBCPP_HAS_FILESYSTEM | |
| 346 | 346 | |
| 347 | } // end namespace detail | |
| 347 | } // namespace detail | |
| 348 | 348 | |
| 349 | 349 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 350 | 350 |
lib/libcxx/src/future.cpp+2-2| ... | ... | @@ -142,10 +142,10 @@ promise<void>::promise() : __state_(new __assoc_sub_state) {} |
| 142 | 142 | |
| 143 | 143 | promise<void>::~promise() { |
| 144 | 144 | if (__state_) { |
| 145 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 145 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 146 | 146 | if (!__state_->__has_value() && __state_->use_count() > 1) |
| 147 | 147 | __state_->set_exception(make_exception_ptr(future_error(future_errc::broken_promise))); |
| 148 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 148 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 149 | 149 | __state_->__release_shared(); |
| 150 | 150 | } |
| 151 | 151 | } |
lib/libcxx/src/include/atomic_support.h+5-5| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | # define _LIBCPP_HAS_ATOMIC_BUILTINS |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | #if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 24 | #if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && _LIBCPP_HAS_THREADS | |
| 25 | 25 | # if defined(_LIBCPP_WARNING) |
| 26 | 26 | _LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported") |
| 27 | 27 | # else |
| ... | ... | @@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | 34 | namespace { |
| 35 | 35 | |
| 36 | #if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 36 | #if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && _LIBCPP_HAS_THREADS | |
| 37 | 37 | |
| 38 | 38 | enum __libcpp_atomic_order { |
| 39 | 39 | _AO_Relaxed = __ATOMIC_RELAXED, |
| ... | ... | @@ -80,7 +80,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_atomic_compare_exchange( |
| 80 | 80 | return __atomic_compare_exchange_n(__val, __expected, __after, true, __success_order, __fail_order); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | #else // _LIBCPP_HAS_NO_THREADS | |
| 83 | #else // _LIBCPP_HAS_THREADS | |
| 84 | 84 | |
| 85 | 85 | enum __libcpp_atomic_order { _AO_Relaxed, _AO_Consume, _AO_Acquire, _AO_Release, _AO_Acq_Rel, _AO_Seq }; |
| 86 | 86 | |
| ... | ... | @@ -123,9 +123,9 @@ __libcpp_atomic_compare_exchange(_ValueType* __val, _ValueType* __expected, _Val |
| 123 | 123 | return false; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | #endif // _LIBCPP_HAS_NO_THREADS | |
| 126 | #endif // _LIBCPP_HAS_THREADS | |
| 127 | 127 | |
| 128 | } // end namespace | |
| 128 | } // namespace | |
| 129 | 129 | |
| 130 | 130 | _LIBCPP_END_NAMESPACE_STD |
| 131 | 131 |
lib/libcxx/src/include/config_elast.h+3-1| ... | ... | @@ -21,6 +21,8 @@ |
| 21 | 21 | // where strerror/strerror_r can't handle out-of-range errno values. |
| 22 | 22 | #if defined(ELAST) |
| 23 | 23 | # define _LIBCPP_ELAST ELAST |
| 24 | #elif defined(__LLVM_LIBC__) | |
| 25 | // No _LIBCPP_ELAST needed for LLVM libc | |
| 24 | 26 | #elif defined(_NEWLIB_VERSION) |
| 25 | 27 | # define _LIBCPP_ELAST __ELASTERROR |
| 26 | 28 | #elif defined(__NuttX__) |
| ... | ... | @@ -31,7 +33,7 @@ |
| 31 | 33 | // No _LIBCPP_ELAST needed on WASI |
| 32 | 34 | #elif defined(__EMSCRIPTEN__) |
| 33 | 35 | // No _LIBCPP_ELAST needed on Emscripten |
| 34 | #elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC) | |
| 36 | #elif defined(__linux__) || _LIBCPP_HAS_MUSL_LIBC | |
| 35 | 37 | # define _LIBCPP_ELAST 4095 |
| 36 | 38 | #elif defined(__APPLE__) |
| 37 | 39 | // No _LIBCPP_ELAST needed on Apple |
lib/libcxx/src/include/from_chars_floating_point.h created+457| ... | ... | @@ -0,0 +1,457 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H | |
| 10 | #define _LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H | |
| 11 | ||
| 12 | // These headers are in the shared LLVM-libc header library. | |
| 13 | #include "shared/fp_bits.h" | |
| 14 | #include "shared/str_to_float.h" | |
| 15 | #include "shared/str_to_integer.h" | |
| 16 | ||
| 17 | #include <__assert> | |
| 18 | #include <__config> | |
| 19 | #include <cctype> | |
| 20 | #include <charconv> | |
| 21 | #include <concepts> | |
| 22 | #include <limits> | |
| 23 | ||
| 24 | // Included for the _Floating_type_traits class | |
| 25 | #include "to_chars_floating_point.h" | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | // Parses an infinity string. | |
| 30 | // Valid strings are case insensitive and contain INF or INFINITY. | |
| 31 | // | |
| 32 | // - __first is the first argument to std::from_chars. When the string is invalid | |
| 33 | // this value is returned as ptr in the result. | |
| 34 | // - __last is the last argument of std::from_chars. | |
| 35 | // - __value is the value argument of std::from_chars, | |
| 36 | // - __ptr is the current position is the input string. This is points beyond | |
| 37 | // the initial I character. | |
| 38 | // - __negative whether a valid string represents -inf or +inf. | |
| 39 | template <floating_point _Fp> | |
| 40 | __from_chars_result<_Fp> | |
| 41 | __from_chars_floating_point_inf(const char* const __first, const char* __last, const char* __ptr, bool __negative) { | |
| 42 | if (__last - __ptr < 2) [[unlikely]] | |
| 43 | return {_Fp{0}, 0, errc::invalid_argument}; | |
| 44 | ||
| 45 | if (std::tolower(__ptr[0]) != 'n' || std::tolower(__ptr[1]) != 'f') [[unlikely]] | |
| 46 | return {_Fp{0}, 0, errc::invalid_argument}; | |
| 47 | ||
| 48 | __ptr += 2; | |
| 49 | ||
| 50 | // At this point the result is valid and contains INF. | |
| 51 | // When the remaining part contains INITY this will be consumed. Otherwise | |
| 52 | // only INF is consumed. For example INFINITZ will consume INF and ignore | |
| 53 | // INITZ. | |
| 54 | ||
| 55 | if (__last - __ptr >= 5 // | |
| 56 | && std::tolower(__ptr[0]) == 'i' // | |
| 57 | && std::tolower(__ptr[1]) == 'n' // | |
| 58 | && std::tolower(__ptr[2]) == 'i' // | |
| 59 | && std::tolower(__ptr[3]) == 't' // | |
| 60 | && std::tolower(__ptr[4]) == 'y') | |
| 61 | __ptr += 5; | |
| 62 | ||
| 63 | if constexpr (numeric_limits<_Fp>::has_infinity) { | |
| 64 | if (__negative) | |
| 65 | return {-std::numeric_limits<_Fp>::infinity(), __ptr - __first, std::errc{}}; | |
| 66 | ||
| 67 | return {std::numeric_limits<_Fp>::infinity(), __ptr - __first, std::errc{}}; | |
| 68 | } else { | |
| 69 | return {_Fp{0}, __ptr - __first, errc::result_out_of_range}; | |
| 70 | } | |
| 71 | } | |
| 72 | ||
| 73 | // Parses a nan string. | |
| 74 | // Valid strings are case insensitive and contain INF or INFINITY. | |
| 75 | // | |
| 76 | // - __first is the first argument to std::from_chars. When the string is invalid | |
| 77 | // this value is returned as ptr in the result. | |
| 78 | // - __last is the last argument of std::from_chars. | |
| 79 | // - __value is the value argument of std::from_chars, | |
| 80 | // - __ptr is the current position is the input string. This is points beyond | |
| 81 | // the initial N character. | |
| 82 | // - __negative whether a valid string represents -nan or +nan. | |
| 83 | template <floating_point _Fp> | |
| 84 | __from_chars_result<_Fp> | |
| 85 | __from_chars_floating_point_nan(const char* const __first, const char* __last, const char* __ptr, bool __negative) { | |
| 86 | if (__last - __ptr < 2) [[unlikely]] | |
| 87 | return {_Fp{0}, 0, errc::invalid_argument}; | |
| 88 | ||
| 89 | if (std::tolower(__ptr[0]) != 'a' || std::tolower(__ptr[1]) != 'n') [[unlikely]] | |
| 90 | return {_Fp{0}, 0, errc::invalid_argument}; | |
| 91 | ||
| 92 | __ptr += 2; | |
| 93 | ||
| 94 | // At this point the result is valid and contains NAN. When the remaining | |
| 95 | // part contains ( n-char-sequence_opt ) this will be consumed. Otherwise | |
| 96 | // only NAN is consumed. For example NAN(abcd will consume NAN and ignore | |
| 97 | // (abcd. | |
| 98 | if (__last - __ptr >= 2 && __ptr[0] == '(') { | |
| 99 | size_t __offset = 1; | |
| 100 | do { | |
| 101 | if (__ptr[__offset] == ')') { | |
| 102 | __ptr += __offset + 1; | |
| 103 | break; | |
| 104 | } | |
| 105 | if (__ptr[__offset] != '_' && !std::isalnum(__ptr[__offset])) | |
| 106 | break; | |
| 107 | ++__offset; | |
| 108 | } while (__ptr + __offset != __last); | |
| 109 | } | |
| 110 | ||
| 111 | if (__negative) | |
| 112 | return {-std::numeric_limits<_Fp>::quiet_NaN(), __ptr - __first, std::errc{}}; | |
| 113 | ||
| 114 | return {std::numeric_limits<_Fp>::quiet_NaN(), __ptr - __first, std::errc{}}; | |
| 115 | } | |
| 116 | ||
| 117 | template <class _Tp> | |
| 118 | struct __fractional_constant_result { | |
| 119 | size_t __offset{size_t(-1)}; | |
| 120 | _Tp __mantissa{0}; | |
| 121 | int __exponent{0}; | |
| 122 | bool __truncated{false}; | |
| 123 | bool __is_valid{false}; | |
| 124 | }; | |
| 125 | ||
| 126 | // Parses the hex constant part of the hexadecimal floating-point value. | |
| 127 | // - input start of buffer given to from_chars | |
| 128 | // - __n the number of elements in the buffer | |
| 129 | // - __offset where to start parsing. The input can have an optional sign, the | |
| 130 | // offset starts after this sign. | |
| 131 | template <class _Tp> | |
| 132 | __fractional_constant_result<_Tp> __parse_fractional_hex_constant(const char* __input, size_t __n, size_t __offset) { | |
| 133 | __fractional_constant_result<_Tp> __result; | |
| 134 | ||
| 135 | const _Tp __mantissa_truncate_threshold = numeric_limits<_Tp>::max() / 16; | |
| 136 | bool __fraction = false; | |
| 137 | for (; __offset < __n; ++__offset) { | |
| 138 | if (std::isxdigit(__input[__offset])) { | |
| 139 | __result.__is_valid = true; | |
| 140 | ||
| 141 | uint32_t __digit = __input[__offset] - '0'; | |
| 142 | switch (std::tolower(__input[__offset])) { | |
| 143 | case 'a': | |
| 144 | __digit = 10; | |
| 145 | break; | |
| 146 | case 'b': | |
| 147 | __digit = 11; | |
| 148 | break; | |
| 149 | case 'c': | |
| 150 | __digit = 12; | |
| 151 | break; | |
| 152 | case 'd': | |
| 153 | __digit = 13; | |
| 154 | break; | |
| 155 | case 'e': | |
| 156 | __digit = 14; | |
| 157 | break; | |
| 158 | case 'f': | |
| 159 | __digit = 15; | |
| 160 | break; | |
| 161 | } | |
| 162 | ||
| 163 | if (__result.__mantissa < __mantissa_truncate_threshold) { | |
| 164 | __result.__mantissa = (__result.__mantissa * 16) + __digit; | |
| 165 | if (__fraction) | |
| 166 | __result.__exponent -= 4; | |
| 167 | } else { | |
| 168 | if (__digit > 0) | |
| 169 | __result.__truncated = true; | |
| 170 | if (!__fraction) | |
| 171 | __result.__exponent += 4; | |
| 172 | } | |
| 173 | } else if (__input[__offset] == '.') { | |
| 174 | if (__fraction) | |
| 175 | break; // this means that __input[__offset] points to a second decimal point, ending the number. | |
| 176 | ||
| 177 | __fraction = true; | |
| 178 | } else | |
| 179 | break; | |
| 180 | } | |
| 181 | ||
| 182 | __result.__offset = __offset; | |
| 183 | return __result; | |
| 184 | } | |
| 185 | ||
| 186 | struct __exponent_result { | |
| 187 | size_t __offset{size_t(-1)}; | |
| 188 | int __value{0}; | |
| 189 | bool __present{false}; | |
| 190 | }; | |
| 191 | ||
| 192 | // When the exponent is not present the result of the struct contains | |
| 193 | // __offset, 0, false. This allows using the results unconditionally, the | |
| 194 | // __present is important for the scientific notation, where the value is | |
| 195 | // mandatory. | |
| 196 | __exponent_result __parse_exponent(const char* __input, size_t __n, size_t __offset, char __marker) { | |
| 197 | if (__offset + 1 < __n && // an exponent always needs at least one digit. | |
| 198 | std::tolower(__input[__offset]) == __marker && // | |
| 199 | !std::isspace(__input[__offset + 1]) // leading whitespace is not allowed. | |
| 200 | ) { | |
| 201 | ++__offset; | |
| 202 | LIBC_NAMESPACE::shared::StrToNumResult<int32_t> __e = | |
| 203 | LIBC_NAMESPACE::shared::strtointeger<int32_t>(__input + __offset, 10, __n - __offset); | |
| 204 | // __result.error contains the errno value, 0 or ERANGE these are not interesting. | |
| 205 | // If the number of characters parsed is 0 it means there was no number. | |
| 206 | if (__e.parsed_len != 0) | |
| 207 | return {__offset + __e.parsed_len, __e.value, true}; | |
| 208 | else | |
| 209 | --__offset; // the assumption of a valid exponent was not true, undo eating the exponent character. | |
| 210 | } | |
| 211 | ||
| 212 | return {__offset, 0, false}; | |
| 213 | } | |
| 214 | ||
| 215 | // Here we do this operation as int64 to avoid overflow. | |
| 216 | int32_t __merge_exponents(int64_t __fractional, int64_t __exponent, int __max_biased_exponent) { | |
| 217 | int64_t __sum = __fractional + __exponent; | |
| 218 | ||
| 219 | if (__sum > __max_biased_exponent) | |
| 220 | return __max_biased_exponent; | |
| 221 | ||
| 222 | if (__sum < -__max_biased_exponent) | |
| 223 | return -__max_biased_exponent; | |
| 224 | ||
| 225 | return __sum; | |
| 226 | } | |
| 227 | ||
| 228 | template <class _Fp, class _Tp> | |
| 229 | __from_chars_result<_Fp> | |
| 230 | __calculate_result(_Tp __mantissa, int __exponent, bool __negative, __from_chars_result<_Fp> __result) { | |
| 231 | auto __r = LIBC_NAMESPACE::shared::FPBits<_Fp>(); | |
| 232 | __r.set_mantissa(__mantissa); | |
| 233 | __r.set_biased_exponent(__exponent); | |
| 234 | ||
| 235 | // C17 7.12.1/6 | |
| 236 | // The result underflows if the magnitude of the mathematical result is so | |
| 237 | // small that the mathematical result cannot be represented, without | |
| 238 | // extraordinary roundoff error, in an object of the specified type.237) If | |
| 239 | // the result underflows, the function returns an implementation-defined | |
| 240 | // value whose magnitude is no greater than the smallest normalized positive | |
| 241 | // number in the specified type; if the integer expression math_errhandling | |
| 242 | // & MATH_ERRNO is nonzero, whether errno acquires the value ERANGE is | |
| 243 | // implementation-defined; if the integer expression math_errhandling & | |
| 244 | // MATH_ERREXCEPT is nonzero, whether the "underflow" floating-point | |
| 245 | // exception is raised is implementation-defined. | |
| 246 | // | |
| 247 | // LLVM-LIBC sets ERAGNE for subnormal values | |
| 248 | // | |
| 249 | // [charconv.from.chars]/1 | |
| 250 | // ... If the parsed value is not in the range representable by the type of | |
| 251 | // value, value is unmodified and the member ec of the return value is | |
| 252 | // equal to errc::result_out_of_range. ... | |
| 253 | // | |
| 254 | // Undo the ERANGE for subnormal values. | |
| 255 | if (__result.__ec == errc::result_out_of_range && __r.is_subnormal() && !__r.is_zero()) | |
| 256 | __result.__ec = errc{}; | |
| 257 | ||
| 258 | if (__negative) | |
| 259 | __result.__value = -__r.get_val(); | |
| 260 | else | |
| 261 | __result.__value = __r.get_val(); | |
| 262 | ||
| 263 | return __result; | |
| 264 | } | |
| 265 | ||
| 266 | // Implements from_chars for decimal floating-point values. | |
| 267 | // __first forwarded from from_chars | |
| 268 | // __last forwarded from from_chars | |
| 269 | // __value forwarded from from_chars | |
| 270 | // __fmt forwarded from from_chars | |
| 271 | // __ptr the start of the buffer to parse. This is after the optional sign character. | |
| 272 | // __negative should __value be set to a negative value? | |
| 273 | // | |
| 274 | // This function and __from_chars_floating_point_decimal are similar. However | |
| 275 | // the similar parts are all in helper functions. So the amount of code | |
| 276 | // duplication is minimal. | |
| 277 | template <floating_point _Fp> | |
| 278 | __from_chars_result<_Fp> | |
| 279 | __from_chars_floating_point_hex(const char* const __first, const char* __last, const char* __ptr, bool __negative) { | |
| 280 | size_t __n = __last - __first; | |
| 281 | ptrdiff_t __offset = __ptr - __first; | |
| 282 | ||
| 283 | auto __fractional = | |
| 284 | std::__parse_fractional_hex_constant<typename _Floating_type_traits<_Fp>::_Uint_type>(__first, __n, __offset); | |
| 285 | if (!__fractional.__is_valid) | |
| 286 | return {_Fp{0}, 0, errc::invalid_argument}; | |
| 287 | ||
| 288 | auto __parsed_exponent = std::__parse_exponent(__first, __n, __fractional.__offset, 'p'); | |
| 289 | __offset = __parsed_exponent.__offset; | |
| 290 | int __exponent = std::__merge_exponents( | |
| 291 | __fractional.__exponent, __parsed_exponent.__value, LIBC_NAMESPACE::shared::FPBits<_Fp>::MAX_BIASED_EXPONENT); | |
| 292 | ||
| 293 | __from_chars_result<_Fp> __result{_Fp{0}, __offset, {}}; | |
| 294 | LIBC_NAMESPACE::shared::ExpandedFloat<_Fp> __expanded_float = {0, 0}; | |
| 295 | if (__fractional.__mantissa != 0) { | |
| 296 | auto __temp = LIBC_NAMESPACE::shared::binary_exp_to_float<_Fp>( | |
| 297 | {__fractional.__mantissa, __exponent}, | |
| 298 | __fractional.__truncated, | |
| 299 | LIBC_NAMESPACE::shared::RoundDirection::Nearest); | |
| 300 | __expanded_float = __temp.num; | |
| 301 | if (__temp.error == ERANGE) { | |
| 302 | __result.__ec = errc::result_out_of_range; | |
| 303 | } | |
| 304 | } | |
| 305 | ||
| 306 | return std::__calculate_result<_Fp>(__expanded_float.mantissa, __expanded_float.exponent, __negative, __result); | |
| 307 | } | |
| 308 | ||
| 309 | // Parses the hex constant part of the decimal float value. | |
| 310 | // - input start of buffer given to from_chars | |
| 311 | // - __n the number of elements in the buffer | |
| 312 | // - __offset where to start parsing. The input can have an optional sign, the | |
| 313 | // offset starts after this sign. | |
| 314 | template <class _Tp> | |
| 315 | __fractional_constant_result<_Tp> | |
| 316 | __parse_fractional_decimal_constant(const char* __input, ptrdiff_t __n, ptrdiff_t __offset) { | |
| 317 | __fractional_constant_result<_Tp> __result; | |
| 318 | ||
| 319 | const _Tp __mantissa_truncate_threshold = numeric_limits<_Tp>::max() / 10; | |
| 320 | bool __fraction = false; | |
| 321 | for (; __offset < __n; ++__offset) { | |
| 322 | if (std::isdigit(__input[__offset])) { | |
| 323 | __result.__is_valid = true; | |
| 324 | ||
| 325 | uint32_t __digit = __input[__offset] - '0'; | |
| 326 | if (__result.__mantissa < __mantissa_truncate_threshold) { | |
| 327 | __result.__mantissa = (__result.__mantissa * 10) + __digit; | |
| 328 | if (__fraction) | |
| 329 | --__result.__exponent; | |
| 330 | } else { | |
| 331 | if (__digit > 0) | |
| 332 | __result.__truncated = true; | |
| 333 | if (!__fraction) | |
| 334 | ++__result.__exponent; | |
| 335 | } | |
| 336 | } else if (__input[__offset] == '.') { | |
| 337 | if (__fraction) | |
| 338 | break; // this means that __input[__offset] points to a second decimal point, ending the number. | |
| 339 | ||
| 340 | __fraction = true; | |
| 341 | } else | |
| 342 | break; | |
| 343 | } | |
| 344 | ||
| 345 | __result.__offset = __offset; | |
| 346 | return __result; | |
| 347 | } | |
| 348 | ||
| 349 | // Implements from_chars for decimal floating-point values. | |
| 350 | // __first forwarded from from_chars | |
| 351 | // __last forwarded from from_chars | |
| 352 | // __value forwarded from from_chars | |
| 353 | // __fmt forwarded from from_chars | |
| 354 | // __ptr the start of the buffer to parse. This is after the optional sign character. | |
| 355 | // __negative should __value be set to a negative value? | |
| 356 | template <floating_point _Fp> | |
| 357 | __from_chars_result<_Fp> __from_chars_floating_point_decimal( | |
| 358 | const char* const __first, const char* __last, chars_format __fmt, const char* __ptr, bool __negative) { | |
| 359 | ptrdiff_t __n = __last - __first; | |
| 360 | ptrdiff_t __offset = __ptr - __first; | |
| 361 | ||
| 362 | auto __fractional = | |
| 363 | std::__parse_fractional_decimal_constant<typename _Floating_type_traits<_Fp>::_Uint_type>(__first, __n, __offset); | |
| 364 | if (!__fractional.__is_valid) | |
| 365 | return {_Fp{0}, 0, errc::invalid_argument}; | |
| 366 | ||
| 367 | __offset = __fractional.__offset; | |
| 368 | ||
| 369 | // LWG3456 Pattern used by std::from_chars is underspecified | |
| 370 | // This changes fixed to ignore a possible exponent instead of making its | |
| 371 | // existance an error. | |
| 372 | int __exponent; | |
| 373 | if (__fmt == chars_format::fixed) { | |
| 374 | __exponent = | |
| 375 | std::__merge_exponents(__fractional.__exponent, 0, LIBC_NAMESPACE::shared::FPBits<_Fp>::MAX_BIASED_EXPONENT); | |
| 376 | } else { | |
| 377 | auto __parsed_exponent = std::__parse_exponent(__first, __n, __offset, 'e'); | |
| 378 | if (__fmt == chars_format::scientific && !__parsed_exponent.__present) { | |
| 379 | // [charconv.from.chars]/6.2 if fmt has chars_format::scientific set but not chars_format::fixed, | |
| 380 | // the otherwise optional exponent part shall appear; | |
| 381 | return {_Fp{0}, 0, errc::invalid_argument}; | |
| 382 | } | |
| 383 | ||
| 384 | __offset = __parsed_exponent.__offset; | |
| 385 | __exponent = std::__merge_exponents( | |
| 386 | __fractional.__exponent, __parsed_exponent.__value, LIBC_NAMESPACE::shared::FPBits<_Fp>::MAX_BIASED_EXPONENT); | |
| 387 | } | |
| 388 | ||
| 389 | __from_chars_result<_Fp> __result{_Fp{0}, __offset, {}}; | |
| 390 | LIBC_NAMESPACE::shared::ExpandedFloat<_Fp> __expanded_float = {0, 0}; | |
| 391 | if (__fractional.__mantissa != 0) { | |
| 392 | // This function expects to parse a positive value. This means it does not | |
| 393 | // take a __first, __n as arguments, since __first points to '-' for | |
| 394 | // negative values. | |
| 395 | auto __temp = LIBC_NAMESPACE::shared::decimal_exp_to_float<_Fp>( | |
| 396 | {__fractional.__mantissa, __exponent}, | |
| 397 | __fractional.__truncated, | |
| 398 | LIBC_NAMESPACE::shared::RoundDirection::Nearest, | |
| 399 | __ptr, | |
| 400 | __last - __ptr); | |
| 401 | __expanded_float = __temp.num; | |
| 402 | if (__temp.error == ERANGE) { | |
| 403 | __result.__ec = errc::result_out_of_range; | |
| 404 | } | |
| 405 | } | |
| 406 | ||
| 407 | return std::__calculate_result(__expanded_float.mantissa, __expanded_float.exponent, __negative, __result); | |
| 408 | } | |
| 409 | ||
| 410 | template <floating_point _Fp> | |
| 411 | __from_chars_result<_Fp> | |
| 412 | __from_chars_floating_point_impl(const char* const __first, const char* __last, chars_format __fmt) { | |
| 413 | if (__first == __last) [[unlikely]] | |
| 414 | return {_Fp{0}, 0, errc::invalid_argument}; | |
| 415 | ||
| 416 | const char* __ptr = __first; | |
| 417 | bool __negative = *__ptr == '-'; | |
| 418 | if (__negative) { | |
| 419 | ++__ptr; | |
| 420 | if (__ptr == __last) [[unlikely]] | |
| 421 | return {_Fp{0}, 0, errc::invalid_argument}; | |
| 422 | } | |
| 423 | ||
| 424 | // [charconv.from.chars] | |
| 425 | // [Note 1: If the pattern allows for an optional sign, but the string has | |
| 426 | // no digit characters following the sign, no characters match the pattern. | |
| 427 | // -- end note] | |
| 428 | // This is true for integrals, floating point allows -.0 | |
| 429 | ||
| 430 | // [charconv.from.chars]/6.2 | |
| 431 | // if fmt has chars_format::scientific set but not chars_format::fixed, the | |
| 432 | // otherwise optional exponent part shall appear; | |
| 433 | // Since INF/NAN do not have an exponent this value is not valid. | |
| 434 | // | |
| 435 | // LWG3456 Pattern used by std::from_chars is underspecified | |
| 436 | // Does not address this point, but proposed option B does solve this issue, | |
| 437 | // Both MSVC STL and libstdc++ implement this this behaviour. | |
| 438 | switch (std::tolower(*__ptr)) { | |
| 439 | case 'i': | |
| 440 | return std::__from_chars_floating_point_inf<_Fp>(__first, __last, __ptr + 1, __negative); | |
| 441 | case 'n': | |
| 442 | if constexpr (numeric_limits<_Fp>::has_quiet_NaN) | |
| 443 | // NOTE: The pointer passed here will be parsed in the default C locale. | |
| 444 | // This is standard behavior (see https://eel.is/c++draft/charconv.from.chars), but may be unexpected. | |
| 445 | return std::__from_chars_floating_point_nan<_Fp>(__first, __last, __ptr + 1, __negative); | |
| 446 | return {_Fp{0}, 0, errc::invalid_argument}; | |
| 447 | } | |
| 448 | ||
| 449 | if (__fmt == chars_format::hex) | |
| 450 | return std::__from_chars_floating_point_hex<_Fp>(__first, __last, __ptr, __negative); | |
| 451 | ||
| 452 | return std::__from_chars_floating_point_decimal<_Fp>(__first, __last, __fmt, __ptr, __negative); | |
| 453 | } | |
| 454 | ||
| 455 | _LIBCPP_END_NAMESPACE_STD | |
| 456 | ||
| 457 | #endif //_LIBCPP_SRC_INCLUDE_FROM_CHARS_FLOATING_POINT_H |
lib/libcxx/src/include/overridable_function.h+7-1| ... | ... | @@ -96,7 +96,8 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no |
| 96 | 96 | } |
| 97 | 97 | _LIBCPP_END_NAMESPACE_STD |
| 98 | 98 | |
| 99 | #elif defined(_LIBCPP_OBJECT_FORMAT_ELF) | |
| 99 | // The NVPTX linker cannot create '__start/__stop' sections. | |
| 100 | #elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__) | |
| 100 | 101 | |
| 101 | 102 | # define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1 |
| 102 | 103 | # define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE __attribute__((__section__("__lcxx_override"))) |
| ... | ... | @@ -115,6 +116,11 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no |
| 115 | 116 | uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override); |
| 116 | 117 | uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr); |
| 117 | 118 | |
| 119 | # if __has_feature(ptrauth_calls) | |
| 120 | // We must pass a void* to ptrauth_strip since it only accepts a pointer type. See full explanation above. | |
| 121 | __ptr = reinterpret_cast<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer)); | |
| 122 | # endif | |
| 123 | ||
| 118 | 124 | return __ptr < __start || __ptr > __end; |
| 119 | 125 | } |
| 120 | 126 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/include/refstring.h+1-1| ... | ... | @@ -124,4 +124,4 @@ inline bool __libcpp_refstring::__uses_refcount() const { |
| 124 | 124 | |
| 125 | 125 | _LIBCPP_END_NAMESPACE_STD |
| 126 | 126 | |
| 127 | #endif //_LIBCPP_REFSTRING_H | |
| 127 | #endif // _LIBCPP_REFSTRING_H |
lib/libcxx/src/ios.cpp+5-5| ... | ... | @@ -116,7 +116,7 @@ locale ios_base::getloc() const { |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // xalloc |
| 119 | #if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 119 | #if _LIBCPP_HAS_C_ATOMIC_IMP && _LIBCPP_HAS_THREADS | |
| 120 | 120 | atomic<int> ios_base::__xindex_{0}; |
| 121 | 121 | #else |
| 122 | 122 | int ios_base::__xindex_ = 0; |
| ... | ... | @@ -361,18 +361,18 @@ void ios_base::swap(ios_base& rhs) noexcept { |
| 361 | 361 | |
| 362 | 362 | void ios_base::__set_badbit_and_consider_rethrow() { |
| 363 | 363 | __rdstate_ |= badbit; |
| 364 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 364 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 365 | 365 | if (__exceptions_ & badbit) |
| 366 | 366 | throw; |
| 367 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 367 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | void ios_base::__set_failbit_and_consider_rethrow() { |
| 371 | 371 | __rdstate_ |= failbit; |
| 372 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 372 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 373 | 373 | if (__exceptions_ & failbit) |
| 374 | 374 | throw; |
| 375 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 375 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | bool ios_base::sync_with_stdio(bool sync) { |
lib/libcxx/src/ios.instantiations.cpp+2-2| ... | ... | @@ -23,7 +23,7 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<char>; |
| 23 | 23 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<char>; |
| 24 | 24 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_iostream<char>; |
| 25 | 25 | |
| 26 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 26 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 27 | 27 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<wchar_t>; |
| 28 | 28 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<wchar_t>; |
| 29 | 29 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<wchar_t>; |
| ... | ... | @@ -37,7 +37,7 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringstream<char> |
| 37 | 37 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostringstream<char>; |
| 38 | 38 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istringstream<char>; |
| 39 | 39 | |
| 40 | #ifndef _LIBCPP_HAS_NO_FILESYSTEM | |
| 40 | #if _LIBCPP_HAS_FILESYSTEM | |
| 41 | 41 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ifstream<char>; |
| 42 | 42 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ofstream<char>; |
| 43 | 43 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>; |
lib/libcxx/src/iostream.cpp+13-17| ... | ... | @@ -11,10 +11,6 @@ |
| 11 | 11 | #include <new> |
| 12 | 12 | #include <string> |
| 13 | 13 | |
| 14 | #ifdef _LIBCPP_MSVCRT_LIKE | |
| 15 | # include <__locale_dir/locale_base_api/locale_guard.h> | |
| 16 | #endif | |
| 17 | ||
| 18 | 14 | #define _str(s) #s |
| 19 | 15 | #define str(s) _str(s) |
| 20 | 16 | #define _LIBCPP_ABI_NAMESPACE_STR str(_LIBCPP_ABI_NAMESPACE) |
| ... | ... | @@ -30,7 +26,7 @@ alignas(istream) _LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)] |
| 30 | 26 | alignas(__stdinbuf<char>) static char __cin[sizeof(__stdinbuf<char>)]; |
| 31 | 27 | static mbstate_t mb_cin; |
| 32 | 28 | |
| 33 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 29 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 34 | 30 | alignas(wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)] |
| 35 | 31 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 36 | 32 | __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR |
| ... | ... | @@ -39,7 +35,7 @@ alignas(wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)] |
| 39 | 35 | ; |
| 40 | 36 | alignas(__stdinbuf<wchar_t>) static char __wcin[sizeof(__stdinbuf<wchar_t>)]; |
| 41 | 37 | static mbstate_t mb_wcin; |
| 42 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 38 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 43 | 39 | |
| 44 | 40 | alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)] |
| 45 | 41 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| ... | ... | @@ -50,7 +46,7 @@ alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)] |
| 50 | 46 | alignas(__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)]; |
| 51 | 47 | static mbstate_t mb_cout; |
| 52 | 48 | |
| 53 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 49 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 54 | 50 | alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)] |
| 55 | 51 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 56 | 52 | __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR |
| ... | ... | @@ -59,7 +55,7 @@ alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)] |
| 59 | 55 | ; |
| 60 | 56 | alignas(__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)]; |
| 61 | 57 | static mbstate_t mb_wcout; |
| 62 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 58 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 63 | 59 | |
| 64 | 60 | alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)] |
| 65 | 61 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| ... | ... | @@ -70,7 +66,7 @@ alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)] |
| 70 | 66 | alignas(__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)]; |
| 71 | 67 | static mbstate_t mb_cerr; |
| 72 | 68 | |
| 73 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 69 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 74 | 70 | alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)] |
| 75 | 71 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 76 | 72 | __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR |
| ... | ... | @@ -79,7 +75,7 @@ alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)] |
| 79 | 75 | ; |
| 80 | 76 | alignas(__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)]; |
| 81 | 77 | static mbstate_t mb_wcerr; |
| 82 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 78 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 83 | 79 | |
| 84 | 80 | alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)] |
| 85 | 81 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| ... | ... | @@ -88,14 +84,14 @@ alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)] |
| 88 | 84 | #endif |
| 89 | 85 | ; |
| 90 | 86 | |
| 91 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 87 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 92 | 88 | alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)] |
| 93 | 89 | # if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 94 | 90 | __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR |
| 95 | 91 | "@std@@@12@A") |
| 96 | 92 | # endif |
| 97 | 93 | ; |
| 98 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 94 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 99 | 95 | |
| 100 | 96 | // Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority |
| 101 | 97 | // attribute with a value that's reserved for the implementation (we're the implementation). |
| ... | ... | @@ -107,12 +103,12 @@ alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)] |
| 107 | 103 | static void force_locale_initialization() { |
| 108 | 104 | #if defined(_LIBCPP_MSVCRT_LIKE) |
| 109 | 105 | static bool once = []() { |
| 110 | auto loc = newlocale(LC_ALL_MASK, "C", 0); | |
| 106 | auto loc = __locale::__newlocale(_LIBCPP_ALL_MASK, "C", 0); | |
| 111 | 107 | { |
| 112 | __libcpp_locale_guard g(loc); // forces initialization of locale TLS | |
| 108 | __locale::__locale_guard g(loc); // forces initialization of locale TLS | |
| 113 | 109 | ((void)g); |
| 114 | 110 | } |
| 115 | freelocale(loc); | |
| 111 | __locale::__freelocale(loc); | |
| 116 | 112 | return true; |
| 117 | 113 | }(); |
| 118 | 114 | ((void)once); |
| ... | ... | @@ -136,7 +132,7 @@ DoIOSInit::DoIOSInit() { |
| 136 | 132 | std::unitbuf(*cerr_ptr); |
| 137 | 133 | cerr_ptr->tie(cout_ptr); |
| 138 | 134 | |
| 139 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 135 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 140 | 136 | wistream* wcin_ptr = ::new (wcin) wistream(::new (__wcin) __stdinbuf<wchar_t>(stdin, &mb_wcin)); |
| 141 | 137 | wostream* wcout_ptr = ::new (wcout) wostream(::new (__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout)); |
| 142 | 138 | wostream* wcerr_ptr = ::new (wcerr) wostream(::new (__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr)); |
| ... | ... | @@ -154,7 +150,7 @@ DoIOSInit::~DoIOSInit() { |
| 154 | 150 | ostream* clog_ptr = reinterpret_cast<ostream*>(clog); |
| 155 | 151 | clog_ptr->flush(); |
| 156 | 152 | |
| 157 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 153 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 158 | 154 | wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout); |
| 159 | 155 | wcout_ptr->flush(); |
| 160 | 156 | wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog); |
lib/libcxx/src/legacy_pointer_safety.cpp deleted-23| ... | ... | @@ -1,23 +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 | #include <__config> | |
| 10 | #include <memory> | |
| 11 | ||
| 12 | // Support for garbage collection was removed in C++23 by https://wg21.link/P2186R2. Libc++ implements | |
| 13 | // that removal as an extension in all Standard versions. However, we still define the functions that | |
| 14 | // were once part of the library's ABI for backwards compatibility. | |
| 15 | ||
| 16 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 17 | ||
| 18 | _LIBCPP_EXPORTED_FROM_ABI void declare_reachable(void*) {} | |
| 19 | _LIBCPP_EXPORTED_FROM_ABI void declare_no_pointers(char*, size_t) {} | |
| 20 | _LIBCPP_EXPORTED_FROM_ABI void undeclare_no_pointers(char*, size_t) {} | |
| 21 | _LIBCPP_EXPORTED_FROM_ABI void* __undeclare_reachable(void* p) { return p; } | |
| 22 | ||
| 23 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/locale.cpp+294-289| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | #include <utility> |
| 23 | 23 | #include <vector> |
| 24 | 24 | |
| 25 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 25 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 26 | 26 | # include <cwctype> |
| 27 | 27 | #endif |
| 28 | 28 | |
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | # define _CTYPE_DISABLE_MACROS |
| 35 | 35 | #endif |
| 36 | 36 | |
| 37 | #if !defined(_LIBCPP_MSVCRT) && !defined(__MINGW32__) && !defined(__BIONIC__) && !defined(__NuttX__) | |
| 37 | #if __has_include("<langinfo.h>") | |
| 38 | 38 | # include <langinfo.h> |
| 39 | 39 | #endif |
| 40 | 40 | |
| ... | ... | @@ -51,18 +51,18 @@ _LIBCPP_PUSH_MACROS |
| 51 | 51 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 52 | 52 | |
| 53 | 53 | struct __libcpp_unique_locale { |
| 54 | __libcpp_unique_locale(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {} | |
| 54 | __libcpp_unique_locale(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {} | |
| 55 | 55 | |
| 56 | 56 | ~__libcpp_unique_locale() { |
| 57 | 57 | if (__loc_) |
| 58 | freelocale(__loc_); | |
| 58 | __locale::__freelocale(__loc_); | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | explicit operator bool() const { return __loc_; } |
| 62 | 62 | |
| 63 | locale_t& get() { return __loc_; } | |
| 63 | __locale::__locale_t& get() { return __loc_; } | |
| 64 | 64 | |
| 65 | locale_t __loc_; | |
| 65 | __locale::__locale_t __loc_; | |
| 66 | 66 | |
| 67 | 67 | private: |
| 68 | 68 | __libcpp_unique_locale(__libcpp_unique_locale const&); |
| ... | ... | @@ -70,11 +70,11 @@ private: |
| 70 | 70 | }; |
| 71 | 71 | |
| 72 | 72 | #ifdef __cloc_defined |
| 73 | locale_t __cloc() { | |
| 73 | __locale::__locale_t __cloc() { | |
| 74 | 74 | // In theory this could create a race condition. In practice |
| 75 | 75 | // the race condition is non-fatal since it will just create |
| 76 | 76 | // a little resource leak. Better approach would be appreciated. |
| 77 | static locale_t result = newlocale(LC_ALL_MASK, "C", 0); | |
| 77 | static __locale::__locale_t result = __locale::__newlocale(_LIBCPP_ALL_MASK, "C", 0); | |
| 78 | 78 | return result; |
| 79 | 79 | } |
| 80 | 80 | #endif // __cloc_defined |
| ... | ... | @@ -159,123 +159,123 @@ private: |
| 159 | 159 | locale::__imp::__imp(size_t refs) : facet(refs), facets_(N), name_("C") { |
| 160 | 160 | facets_.clear(); |
| 161 | 161 | install(&make<std::collate<char> >(1u)); |
| 162 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 162 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 163 | 163 | install(&make<std::collate<wchar_t> >(1u)); |
| 164 | 164 | #endif |
| 165 | 165 | install(&make<std::ctype<char> >(nullptr, false, 1u)); |
| 166 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 166 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 167 | 167 | install(&make<std::ctype<wchar_t> >(1u)); |
| 168 | 168 | #endif |
| 169 | 169 | install(&make<codecvt<char, char, mbstate_t> >(1u)); |
| 170 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 170 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 171 | 171 | install(&make<codecvt<wchar_t, char, mbstate_t> >(1u)); |
| 172 | 172 | #endif |
| 173 | 173 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 174 | 174 | install(&make<codecvt<char16_t, char, mbstate_t> >(1u)); |
| 175 | 175 | install(&make<codecvt<char32_t, char, mbstate_t> >(1u)); |
| 176 | 176 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 177 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 177 | #if _LIBCPP_HAS_CHAR8_T | |
| 178 | 178 | install(&make<codecvt<char16_t, char8_t, mbstate_t> >(1u)); |
| 179 | 179 | install(&make<codecvt<char32_t, char8_t, mbstate_t> >(1u)); |
| 180 | 180 | #endif |
| 181 | 181 | install(&make<numpunct<char> >(1u)); |
| 182 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 182 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 183 | 183 | install(&make<numpunct<wchar_t> >(1u)); |
| 184 | 184 | #endif |
| 185 | 185 | install(&make<num_get<char> >(1u)); |
| 186 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 186 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 187 | 187 | install(&make<num_get<wchar_t> >(1u)); |
| 188 | 188 | #endif |
| 189 | 189 | install(&make<num_put<char> >(1u)); |
| 190 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 190 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 191 | 191 | install(&make<num_put<wchar_t> >(1u)); |
| 192 | 192 | #endif |
| 193 | 193 | install(&make<moneypunct<char, false> >(1u)); |
| 194 | 194 | install(&make<moneypunct<char, true> >(1u)); |
| 195 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 195 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 196 | 196 | install(&make<moneypunct<wchar_t, false> >(1u)); |
| 197 | 197 | install(&make<moneypunct<wchar_t, true> >(1u)); |
| 198 | 198 | #endif |
| 199 | 199 | install(&make<money_get<char> >(1u)); |
| 200 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 200 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 201 | 201 | install(&make<money_get<wchar_t> >(1u)); |
| 202 | 202 | #endif |
| 203 | 203 | install(&make<money_put<char> >(1u)); |
| 204 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 204 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 205 | 205 | install(&make<money_put<wchar_t> >(1u)); |
| 206 | 206 | #endif |
| 207 | 207 | install(&make<time_get<char> >(1u)); |
| 208 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 208 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 209 | 209 | install(&make<time_get<wchar_t> >(1u)); |
| 210 | 210 | #endif |
| 211 | 211 | install(&make<time_put<char> >(1u)); |
| 212 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 212 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 213 | 213 | install(&make<time_put<wchar_t> >(1u)); |
| 214 | 214 | #endif |
| 215 | 215 | install(&make<std::messages<char> >(1u)); |
| 216 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 216 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 217 | 217 | install(&make<std::messages<wchar_t> >(1u)); |
| 218 | 218 | #endif |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), name_(name) { |
| 222 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 222 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 223 | 223 | try { |
| 224 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 224 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 225 | 225 | facets_ = locale::classic().__locale_->facets_; |
| 226 | 226 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 227 | 227 | if (facets_[i]) |
| 228 | 228 | facets_[i]->__add_shared(); |
| 229 | 229 | install(new collate_byname<char>(name_)); |
| 230 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 230 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 231 | 231 | install(new collate_byname<wchar_t>(name_)); |
| 232 | 232 | #endif |
| 233 | 233 | install(new ctype_byname<char>(name_)); |
| 234 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 234 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 235 | 235 | install(new ctype_byname<wchar_t>(name_)); |
| 236 | 236 | #endif |
| 237 | 237 | install(new codecvt_byname<char, char, mbstate_t>(name_)); |
| 238 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 238 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 239 | 239 | install(new codecvt_byname<wchar_t, char, mbstate_t>(name_)); |
| 240 | 240 | #endif |
| 241 | 241 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 242 | 242 | install(new codecvt_byname<char16_t, char, mbstate_t>(name_)); |
| 243 | 243 | install(new codecvt_byname<char32_t, char, mbstate_t>(name_)); |
| 244 | 244 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 245 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 245 | #if _LIBCPP_HAS_CHAR8_T | |
| 246 | 246 | install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_)); |
| 247 | 247 | install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_)); |
| 248 | 248 | #endif |
| 249 | 249 | install(new numpunct_byname<char>(name_)); |
| 250 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 250 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 251 | 251 | install(new numpunct_byname<wchar_t>(name_)); |
| 252 | 252 | #endif |
| 253 | 253 | install(new moneypunct_byname<char, false>(name_)); |
| 254 | 254 | install(new moneypunct_byname<char, true>(name_)); |
| 255 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 255 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 256 | 256 | install(new moneypunct_byname<wchar_t, false>(name_)); |
| 257 | 257 | install(new moneypunct_byname<wchar_t, true>(name_)); |
| 258 | 258 | #endif |
| 259 | 259 | install(new time_get_byname<char>(name_)); |
| 260 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 260 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 261 | 261 | install(new time_get_byname<wchar_t>(name_)); |
| 262 | 262 | #endif |
| 263 | 263 | install(new time_put_byname<char>(name_)); |
| 264 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 264 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 265 | 265 | install(new time_put_byname<wchar_t>(name_)); |
| 266 | 266 | #endif |
| 267 | 267 | install(new messages_byname<char>(name_)); |
| 268 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 268 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 269 | 269 | install(new messages_byname<wchar_t>(name_)); |
| 270 | 270 | #endif |
| 271 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 271 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 272 | 272 | } catch (...) { |
| 273 | 273 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 274 | 274 | if (facets_[i]) |
| 275 | 275 | facets_[i]->__release_shared(); |
| 276 | 276 | throw; |
| 277 | 277 | } |
| 278 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 278 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | locale::__imp::__imp(const __imp& other) : facets_(max<size_t>(N, other.facets_.size())), name_(other.name_) { |
| ... | ... | @@ -291,29 +291,29 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) |
| 291 | 291 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 292 | 292 | if (facets_[i]) |
| 293 | 293 | facets_[i]->__add_shared(); |
| 294 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 294 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 295 | 295 | try { |
| 296 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 296 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 297 | 297 | if (c & locale::collate) { |
| 298 | 298 | install(new collate_byname<char>(name)); |
| 299 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 299 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 300 | 300 | install(new collate_byname<wchar_t>(name)); |
| 301 | 301 | #endif |
| 302 | 302 | } |
| 303 | 303 | if (c & locale::ctype) { |
| 304 | 304 | install(new ctype_byname<char>(name)); |
| 305 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 305 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 306 | 306 | install(new ctype_byname<wchar_t>(name)); |
| 307 | 307 | #endif |
| 308 | 308 | install(new codecvt_byname<char, char, mbstate_t>(name)); |
| 309 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 309 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 310 | 310 | install(new codecvt_byname<wchar_t, char, mbstate_t>(name)); |
| 311 | 311 | #endif |
| 312 | 312 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 313 | 313 | install(new codecvt_byname<char16_t, char, mbstate_t>(name)); |
| 314 | 314 | install(new codecvt_byname<char32_t, char, mbstate_t>(name)); |
| 315 | 315 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 316 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 316 | #if _LIBCPP_HAS_CHAR8_T | |
| 317 | 317 | install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name)); |
| 318 | 318 | install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name)); |
| 319 | 319 | #endif |
| ... | ... | @@ -321,41 +321,41 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) |
| 321 | 321 | if (c & locale::monetary) { |
| 322 | 322 | install(new moneypunct_byname<char, false>(name)); |
| 323 | 323 | install(new moneypunct_byname<char, true>(name)); |
| 324 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 324 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 325 | 325 | install(new moneypunct_byname<wchar_t, false>(name)); |
| 326 | 326 | install(new moneypunct_byname<wchar_t, true>(name)); |
| 327 | 327 | #endif |
| 328 | 328 | } |
| 329 | 329 | if (c & locale::numeric) { |
| 330 | 330 | install(new numpunct_byname<char>(name)); |
| 331 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 331 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 332 | 332 | install(new numpunct_byname<wchar_t>(name)); |
| 333 | 333 | #endif |
| 334 | 334 | } |
| 335 | 335 | if (c & locale::time) { |
| 336 | 336 | install(new time_get_byname<char>(name)); |
| 337 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 337 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 338 | 338 | install(new time_get_byname<wchar_t>(name)); |
| 339 | 339 | #endif |
| 340 | 340 | install(new time_put_byname<char>(name)); |
| 341 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 341 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 342 | 342 | install(new time_put_byname<wchar_t>(name)); |
| 343 | 343 | #endif |
| 344 | 344 | } |
| 345 | 345 | if (c & locale::messages) { |
| 346 | 346 | install(new messages_byname<char>(name)); |
| 347 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 347 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 348 | 348 | install(new messages_byname<wchar_t>(name)); |
| 349 | 349 | #endif |
| 350 | 350 | } |
| 351 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 351 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 352 | 352 | } catch (...) { |
| 353 | 353 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 354 | 354 | if (facets_[i]) |
| 355 | 355 | facets_[i]->__release_shared(); |
| 356 | 356 | throw; |
| 357 | 357 | } |
| 358 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 358 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | template <class F> |
| ... | ... | @@ -370,18 +370,18 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) |
| 370 | 370 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 371 | 371 | if (facets_[i]) |
| 372 | 372 | facets_[i]->__add_shared(); |
| 373 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 373 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 374 | 374 | try { |
| 375 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 375 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 376 | 376 | if (c & locale::collate) { |
| 377 | 377 | install_from<std::collate<char> >(one); |
| 378 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 378 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 379 | 379 | install_from<std::collate<wchar_t> >(one); |
| 380 | 380 | #endif |
| 381 | 381 | } |
| 382 | 382 | if (c & locale::ctype) { |
| 383 | 383 | install_from<std::ctype<char> >(one); |
| 384 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 384 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 385 | 385 | install_from<std::ctype<wchar_t> >(one); |
| 386 | 386 | #endif |
| 387 | 387 | install_from<std::codecvt<char, char, mbstate_t> >(one); |
| ... | ... | @@ -389,68 +389,68 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) |
| 389 | 389 | install_from<std::codecvt<char16_t, char, mbstate_t> >(one); |
| 390 | 390 | install_from<std::codecvt<char32_t, char, mbstate_t> >(one); |
| 391 | 391 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 392 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 392 | #if _LIBCPP_HAS_CHAR8_T | |
| 393 | 393 | install_from<std::codecvt<char16_t, char8_t, mbstate_t> >(one); |
| 394 | 394 | install_from<std::codecvt<char32_t, char8_t, mbstate_t> >(one); |
| 395 | 395 | #endif |
| 396 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 396 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 397 | 397 | install_from<std::codecvt<wchar_t, char, mbstate_t> >(one); |
| 398 | 398 | #endif |
| 399 | 399 | } |
| 400 | 400 | if (c & locale::monetary) { |
| 401 | 401 | install_from<moneypunct<char, false> >(one); |
| 402 | 402 | install_from<moneypunct<char, true> >(one); |
| 403 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 403 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 404 | 404 | install_from<moneypunct<wchar_t, false> >(one); |
| 405 | 405 | install_from<moneypunct<wchar_t, true> >(one); |
| 406 | 406 | #endif |
| 407 | 407 | install_from<money_get<char> >(one); |
| 408 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 408 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 409 | 409 | install_from<money_get<wchar_t> >(one); |
| 410 | 410 | #endif |
| 411 | 411 | install_from<money_put<char> >(one); |
| 412 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 412 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 413 | 413 | install_from<money_put<wchar_t> >(one); |
| 414 | 414 | #endif |
| 415 | 415 | } |
| 416 | 416 | if (c & locale::numeric) { |
| 417 | 417 | install_from<numpunct<char> >(one); |
| 418 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 418 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 419 | 419 | install_from<numpunct<wchar_t> >(one); |
| 420 | 420 | #endif |
| 421 | 421 | install_from<num_get<char> >(one); |
| 422 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 422 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 423 | 423 | install_from<num_get<wchar_t> >(one); |
| 424 | 424 | #endif |
| 425 | 425 | install_from<num_put<char> >(one); |
| 426 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 426 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 427 | 427 | install_from<num_put<wchar_t> >(one); |
| 428 | 428 | #endif |
| 429 | 429 | } |
| 430 | 430 | if (c & locale::time) { |
| 431 | 431 | install_from<time_get<char> >(one); |
| 432 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 432 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 433 | 433 | install_from<time_get<wchar_t> >(one); |
| 434 | 434 | #endif |
| 435 | 435 | install_from<time_put<char> >(one); |
| 436 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 436 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 437 | 437 | install_from<time_put<wchar_t> >(one); |
| 438 | 438 | #endif |
| 439 | 439 | } |
| 440 | 440 | if (c & locale::messages) { |
| 441 | 441 | install_from<std::messages<char> >(one); |
| 442 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 442 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 443 | 443 | install_from<std::messages<wchar_t> >(one); |
| 444 | 444 | #endif |
| 445 | 445 | } |
| 446 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 446 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 447 | 447 | } catch (...) { |
| 448 | 448 | for (unsigned i = 0; i < facets_.size(); ++i) |
| 449 | 449 | if (facets_[i]) |
| 450 | 450 | facets_[i]->__release_shared(); |
| 451 | 451 | throw; |
| 452 | 452 | } |
| 453 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 453 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | locale::__imp::__imp(const __imp& other, facet* f, long id) |
| ... | ... | @@ -570,7 +570,7 @@ locale locale::global(const locale& loc) { |
| 570 | 570 | locale r = g; |
| 571 | 571 | g = loc; |
| 572 | 572 | if (g.name() != "*") |
| 573 | setlocale(LC_ALL, g.name().c_str()); | |
| 573 | __locale::__setlocale(_LIBCPP_LC_ALL, g.name().c_str()); | |
| 574 | 574 | return r; |
| 575 | 575 | } |
| 576 | 576 | |
| ... | ... | @@ -600,7 +600,7 @@ long locale::id::__get() { |
| 600 | 600 | // template <> class collate_byname<char> |
| 601 | 601 | |
| 602 | 602 | collate_byname<char>::collate_byname(const char* n, size_t refs) |
| 603 | : collate<char>(refs), __l_(newlocale(LC_ALL_MASK, n, 0)) { | |
| 603 | : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) { | |
| 604 | 604 | if (__l_ == 0) |
| 605 | 605 | __throw_runtime_error( |
| 606 | 606 | ("collate_byname<char>::collate_byname" |
| ... | ... | @@ -610,7 +610,7 @@ collate_byname<char>::collate_byname(const char* n, size_t refs) |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | collate_byname<char>::collate_byname(const string& name, size_t refs) |
| 613 | : collate<char>(refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { | |
| 613 | : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { | |
| 614 | 614 | if (__l_ == 0) |
| 615 | 615 | __throw_runtime_error( |
| 616 | 616 | ("collate_byname<char>::collate_byname" |
| ... | ... | @@ -619,13 +619,13 @@ collate_byname<char>::collate_byname(const string& name, size_t refs) |
| 619 | 619 | .c_str()); |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | collate_byname<char>::~collate_byname() { freelocale(__l_); } | |
| 622 | collate_byname<char>::~collate_byname() { __locale::__freelocale(__l_); } | |
| 623 | 623 | |
| 624 | 624 | int collate_byname<char>::do_compare( |
| 625 | 625 | const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const { |
| 626 | 626 | string_type lhs(__lo1, __hi1); |
| 627 | 627 | string_type rhs(__lo2, __hi2); |
| 628 | int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l_); | |
| 628 | int r = __locale::__strcoll(lhs.c_str(), rhs.c_str(), __l_); | |
| 629 | 629 | if (r < 0) |
| 630 | 630 | return -1; |
| 631 | 631 | if (r > 0) |
| ... | ... | @@ -635,16 +635,16 @@ int collate_byname<char>::do_compare( |
| 635 | 635 | |
| 636 | 636 | collate_byname<char>::string_type collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const { |
| 637 | 637 | const string_type in(lo, hi); |
| 638 | string_type out(strxfrm_l(0, in.c_str(), 0, __l_), char()); | |
| 639 | strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size() + 1, __l_); | |
| 638 | string_type out(__locale::__strxfrm(0, in.c_str(), 0, __l_), char()); | |
| 639 | __locale::__strxfrm(const_cast<char*>(out.c_str()), in.c_str(), out.size() + 1, __l_); | |
| 640 | 640 | return out; |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | // template <> class collate_byname<wchar_t> |
| 644 | 644 | |
| 645 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 645 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 646 | 646 | collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) |
| 647 | : collate<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, n, 0)) { | |
| 647 | : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) { | |
| 648 | 648 | if (__l_ == 0) |
| 649 | 649 | __throw_runtime_error( |
| 650 | 650 | ("collate_byname<wchar_t>::collate_byname(size_t refs)" |
| ... | ... | @@ -654,7 +654,7 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) |
| 657 | : collate<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { | |
| 657 | : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { | |
| 658 | 658 | if (__l_ == 0) |
| 659 | 659 | __throw_runtime_error( |
| 660 | 660 | ("collate_byname<wchar_t>::collate_byname(size_t refs)" |
| ... | ... | @@ -663,13 +663,13 @@ collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) |
| 663 | 663 | .c_str()); |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | collate_byname<wchar_t>::~collate_byname() { freelocale(__l_); } | |
| 666 | collate_byname<wchar_t>::~collate_byname() { __locale::__freelocale(__l_); } | |
| 667 | 667 | |
| 668 | 668 | int collate_byname<wchar_t>::do_compare( |
| 669 | 669 | const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const { |
| 670 | 670 | string_type lhs(__lo1, __hi1); |
| 671 | 671 | string_type rhs(__lo2, __hi2); |
| 672 | int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l_); | |
| 672 | int r = __locale::__wcscoll(lhs.c_str(), rhs.c_str(), __l_); | |
| 673 | 673 | if (r < 0) |
| 674 | 674 | return -1; |
| 675 | 675 | if (r > 0) |
| ... | ... | @@ -680,11 +680,11 @@ int collate_byname<wchar_t>::do_compare( |
| 680 | 680 | collate_byname<wchar_t>::string_type |
| 681 | 681 | collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const { |
| 682 | 682 | const string_type in(lo, hi); |
| 683 | string_type out(wcsxfrm_l(0, in.c_str(), 0, __l_), wchar_t()); | |
| 684 | wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size() + 1, __l_); | |
| 683 | string_type out(__locale::__wcsxfrm(0, in.c_str(), 0, __l_), wchar_t()); | |
| 684 | __locale::__wcsxfrm(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size() + 1, __l_); | |
| 685 | 685 | return out; |
| 686 | 686 | } |
| 687 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 687 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 688 | 688 | |
| 689 | 689 | const ctype_base::mask ctype_base::space; |
| 690 | 690 | const ctype_base::mask ctype_base::print; |
| ... | ... | @@ -701,75 +701,76 @@ const ctype_base::mask ctype_base::graph; |
| 701 | 701 | |
| 702 | 702 | // template <> class ctype<wchar_t>; |
| 703 | 703 | |
| 704 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 704 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 705 | 705 | constinit locale::id ctype<wchar_t>::id; |
| 706 | 706 | |
| 707 | 707 | ctype<wchar_t>::~ctype() {} |
| 708 | 708 | |
| 709 | 709 | bool ctype<wchar_t>::do_is(mask m, char_type c) const { |
| 710 | return isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false; | |
| 710 | return std::__libcpp_isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false; | |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | const wchar_t* ctype<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const { |
| 714 | 714 | for (; low != high; ++low, ++vec) |
| 715 | *vec = static_cast<mask>(isascii(*low) ? ctype<char>::classic_table()[*low] : 0); | |
| 715 | *vec = static_cast<mask>(std::__libcpp_isascii(*low) ? ctype<char>::classic_table()[*low] : 0); | |
| 716 | 716 | return low; |
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | const wchar_t* ctype<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const { |
| 720 | 720 | for (; low != high; ++low) |
| 721 | if (isascii(*low) && (ctype<char>::classic_table()[*low] & m)) | |
| 721 | if (std::__libcpp_isascii(*low) && (ctype<char>::classic_table()[*low] & m)) | |
| 722 | 722 | break; |
| 723 | 723 | return low; |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | const wchar_t* ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const { |
| 727 | 727 | for (; low != high; ++low) |
| 728 | if (!(isascii(*low) && (ctype<char>::classic_table()[*low] & m))) | |
| 728 | if (!(std::__libcpp_isascii(*low) && (ctype<char>::classic_table()[*low] & m))) | |
| 729 | 729 | break; |
| 730 | 730 | return low; |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | wchar_t ctype<wchar_t>::do_toupper(char_type c) const { |
| 734 | 734 | # ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 735 | return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c; | |
| 735 | return std::__libcpp_isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c; | |
| 736 | 736 | # elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__) |
| 737 | return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c; | |
| 737 | return std::__libcpp_isascii(c) ? ctype<char>::__classic_upper_table()[c] : c; | |
| 738 | 738 | # else |
| 739 | return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c - L'a' + L'A' : c; | |
| 739 | return (std::__libcpp_isascii(c) && __locale::__iswlower(c, _LIBCPP_GET_C_LOCALE)) ? c - L'a' + L'A' : c; | |
| 740 | 740 | # endif |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | const wchar_t* ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const { |
| 744 | 744 | for (; low != high; ++low) |
| 745 | 745 | # ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 746 | *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low; | |
| 746 | *low = std::__libcpp_isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low; | |
| 747 | 747 | # elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__) |
| 748 | *low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low] : *low; | |
| 748 | *low = std::__libcpp_isascii(*low) ? ctype<char>::__classic_upper_table()[*low] : *low; | |
| 749 | 749 | # else |
| 750 | *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? (*low - L'a' + L'A') : *low; | |
| 750 | *low = | |
| 751 | (std::__libcpp_isascii(*low) && __locale::__islower(*low, _LIBCPP_GET_C_LOCALE)) ? (*low - L'a' + L'A') : *low; | |
| 751 | 752 | # endif |
| 752 | 753 | return low; |
| 753 | 754 | } |
| 754 | 755 | |
| 755 | 756 | wchar_t ctype<wchar_t>::do_tolower(char_type c) const { |
| 756 | 757 | # ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 757 | return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c; | |
| 758 | return std::__libcpp_isascii(c) ? _DefaultRuneLocale.__maplower[c] : c; | |
| 758 | 759 | # elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__) |
| 759 | return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c; | |
| 760 | return std::__libcpp_isascii(c) ? ctype<char>::__classic_lower_table()[c] : c; | |
| 760 | 761 | # else |
| 761 | return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c - L'A' + 'a' : c; | |
| 762 | return (std::__libcpp_isascii(c) && __locale::__isupper(c, _LIBCPP_GET_C_LOCALE)) ? c - L'A' + 'a' : c; | |
| 762 | 763 | # endif |
| 763 | 764 | } |
| 764 | 765 | |
| 765 | 766 | const wchar_t* ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const { |
| 766 | 767 | for (; low != high; ++low) |
| 767 | 768 | # ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 768 | *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low; | |
| 769 | *low = std::__libcpp_isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low; | |
| 769 | 770 | # elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__) |
| 770 | *low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low] : *low; | |
| 771 | *low = std::__libcpp_isascii(*low) ? ctype<char>::__classic_lower_table()[*low] : *low; | |
| 771 | 772 | # else |
| 772 | *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low - L'A' + L'a' : *low; | |
| 773 | *low = (std::__libcpp_isascii(*low) && __locale::__isupper(*low, _LIBCPP_GET_C_LOCALE)) ? *low - L'A' + L'a' : *low; | |
| 773 | 774 | # endif |
| 774 | 775 | return low; |
| 775 | 776 | } |
| ... | ... | @@ -783,20 +784,20 @@ const char* ctype<wchar_t>::do_widen(const char* low, const char* high, char_typ |
| 783 | 784 | } |
| 784 | 785 | |
| 785 | 786 | char ctype<wchar_t>::do_narrow(char_type c, char dfault) const { |
| 786 | if (isascii(c)) | |
| 787 | if (std::__libcpp_isascii(c)) | |
| 787 | 788 | return static_cast<char>(c); |
| 788 | 789 | return dfault; |
| 789 | 790 | } |
| 790 | 791 | |
| 791 | 792 | const wchar_t* ctype<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const { |
| 792 | 793 | for (; low != high; ++low, ++dest) |
| 793 | if (isascii(*low)) | |
| 794 | if (std::__libcpp_isascii(*low)) | |
| 794 | 795 | *dest = static_cast<char>(*low); |
| 795 | 796 | else |
| 796 | 797 | *dest = dfault; |
| 797 | 798 | return low; |
| 798 | 799 | } |
| 799 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 800 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 800 | 801 | |
| 801 | 802 | // template <> class ctype<char>; |
| 802 | 803 | |
| ... | ... | @@ -816,52 +817,56 @@ ctype<char>::~ctype() { |
| 816 | 817 | |
| 817 | 818 | char ctype<char>::do_toupper(char_type c) const { |
| 818 | 819 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 819 | return isascii(c) ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c; | |
| 820 | return std::__libcpp_isascii(c) ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c; | |
| 820 | 821 | #elif defined(__NetBSD__) |
| 821 | 822 | return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]); |
| 822 | 823 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) |
| 823 | return isascii(c) ? static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c; | |
| 824 | return std::__libcpp_isascii(c) ? static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c; | |
| 824 | 825 | #else |
| 825 | return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c - 'a' + 'A' : c; | |
| 826 | return (std::__libcpp_isascii(c) && __locale::__islower(c, _LIBCPP_GET_C_LOCALE)) ? c - 'a' + 'A' : c; | |
| 826 | 827 | #endif |
| 827 | 828 | } |
| 828 | 829 | |
| 829 | 830 | const char* ctype<char>::do_toupper(char_type* low, const char_type* high) const { |
| 830 | 831 | for (; low != high; ++low) |
| 831 | 832 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 832 | *low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) : *low; | |
| 833 | *low = std::__libcpp_isascii(*low) | |
| 834 | ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) | |
| 835 | : *low; | |
| 833 | 836 | #elif defined(__NetBSD__) |
| 834 | 837 | *low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]); |
| 835 | 838 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) |
| 836 | *low = isascii(*low) ? static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low; | |
| 839 | *low = std::__libcpp_isascii(*low) ? static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low; | |
| 837 | 840 | #else |
| 838 | *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'a' + 'A' : *low; | |
| 841 | *low = (std::__libcpp_isascii(*low) && __locale::__islower(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'a' + 'A' : *low; | |
| 839 | 842 | #endif |
| 840 | 843 | return low; |
| 841 | 844 | } |
| 842 | 845 | |
| 843 | 846 | char ctype<char>::do_tolower(char_type c) const { |
| 844 | 847 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 845 | return isascii(c) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c; | |
| 848 | return std::__libcpp_isascii(c) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c; | |
| 846 | 849 | #elif defined(__NetBSD__) |
| 847 | 850 | return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]); |
| 848 | 851 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) |
| 849 | return isascii(c) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c; | |
| 852 | return std::__libcpp_isascii(c) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c; | |
| 850 | 853 | #else |
| 851 | return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c - 'A' + 'a' : c; | |
| 854 | return (std::__libcpp_isascii(c) && __locale::__isupper(c, _LIBCPP_GET_C_LOCALE)) ? c - 'A' + 'a' : c; | |
| 852 | 855 | #endif |
| 853 | 856 | } |
| 854 | 857 | |
| 855 | 858 | const char* ctype<char>::do_tolower(char_type* low, const char_type* high) const { |
| 856 | 859 | for (; low != high; ++low) |
| 857 | 860 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 858 | *low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) : *low; | |
| 861 | *low = std::__libcpp_isascii(*low) | |
| 862 | ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) | |
| 863 | : *low; | |
| 859 | 864 | #elif defined(__NetBSD__) |
| 860 | 865 | *low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]); |
| 861 | 866 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) |
| 862 | *low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low; | |
| 867 | *low = std::__libcpp_isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low; | |
| 863 | 868 | #else |
| 864 | *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'A' + 'a' : *low; | |
| 869 | *low = (std::__libcpp_isascii(*low) && __locale::__isupper(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'A' + 'a' : *low; | |
| 865 | 870 | #endif |
| 866 | 871 | return low; |
| 867 | 872 | } |
| ... | ... | @@ -875,14 +880,14 @@ const char* ctype<char>::do_widen(const char* low, const char* high, char_type* |
| 875 | 880 | } |
| 876 | 881 | |
| 877 | 882 | char ctype<char>::do_narrow(char_type c, char dfault) const { |
| 878 | if (isascii(c)) | |
| 883 | if (std::__libcpp_isascii(c)) | |
| 879 | 884 | return static_cast<char>(c); |
| 880 | 885 | return dfault; |
| 881 | 886 | } |
| 882 | 887 | |
| 883 | 888 | const char* ctype<char>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const { |
| 884 | 889 | for (; low != high; ++low, ++dest) |
| 885 | if (isascii(*low)) | |
| 890 | if (std::__libcpp_isascii(*low)) | |
| 886 | 891 | *dest = *low; |
| 887 | 892 | else |
| 888 | 893 | *dest = dfault; |
| ... | ... | @@ -1004,7 +1009,7 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept { |
| 1004 | 1009 | # warning ctype<char>::classic_table() is not implemented |
| 1005 | 1010 | printf("ctype<char>::classic_table() is not implemented\n"); |
| 1006 | 1011 | abort(); |
| 1007 | return NULL; | |
| 1012 | return nullptr; | |
| 1008 | 1013 | # endif |
| 1009 | 1014 | } |
| 1010 | 1015 | #endif |
| ... | ... | @@ -1042,7 +1047,7 @@ const unsigned short* ctype<char>::__classic_upper_table() _NOEXCEPT { |
| 1042 | 1047 | // template <> class ctype_byname<char> |
| 1043 | 1048 | |
| 1044 | 1049 | ctype_byname<char>::ctype_byname(const char* name, size_t refs) |
| 1045 | : ctype<char>(0, false, refs), __l_(newlocale(LC_ALL_MASK, name, 0)) { | |
| 1050 | : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) { | |
| 1046 | 1051 | if (__l_ == 0) |
| 1047 | 1052 | __throw_runtime_error( |
| 1048 | 1053 | ("ctype_byname<char>::ctype_byname" |
| ... | ... | @@ -1052,7 +1057,7 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs) |
| 1052 | 1057 | } |
| 1053 | 1058 | |
| 1054 | 1059 | ctype_byname<char>::ctype_byname(const string& name, size_t refs) |
| 1055 | : ctype<char>(0, false, refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { | |
| 1060 | : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { | |
| 1056 | 1061 | if (__l_ == 0) |
| 1057 | 1062 | __throw_runtime_error( |
| 1058 | 1063 | ("ctype_byname<char>::ctype_byname" |
| ... | ... | @@ -1061,33 +1066,33 @@ ctype_byname<char>::ctype_byname(const string& name, size_t refs) |
| 1061 | 1066 | .c_str()); |
| 1062 | 1067 | } |
| 1063 | 1068 | |
| 1064 | ctype_byname<char>::~ctype_byname() { freelocale(__l_); } | |
| 1069 | ctype_byname<char>::~ctype_byname() { __locale::__freelocale(__l_); } | |
| 1065 | 1070 | |
| 1066 | 1071 | char ctype_byname<char>::do_toupper(char_type c) const { |
| 1067 | return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l_)); | |
| 1072 | return static_cast<char>(__locale::__toupper(static_cast<unsigned char>(c), __l_)); | |
| 1068 | 1073 | } |
| 1069 | 1074 | |
| 1070 | 1075 | const char* ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const { |
| 1071 | 1076 | for (; low != high; ++low) |
| 1072 | *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l_)); | |
| 1077 | *low = static_cast<char>(__locale::__toupper(static_cast<unsigned char>(*low), __l_)); | |
| 1073 | 1078 | return low; |
| 1074 | 1079 | } |
| 1075 | 1080 | |
| 1076 | 1081 | char ctype_byname<char>::do_tolower(char_type c) const { |
| 1077 | return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l_)); | |
| 1082 | return static_cast<char>(__locale::__tolower(static_cast<unsigned char>(c), __l_)); | |
| 1078 | 1083 | } |
| 1079 | 1084 | |
| 1080 | 1085 | const char* ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const { |
| 1081 | 1086 | for (; low != high; ++low) |
| 1082 | *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l_)); | |
| 1087 | *low = static_cast<char>(__locale::__tolower(static_cast<unsigned char>(*low), __l_)); | |
| 1083 | 1088 | return low; |
| 1084 | 1089 | } |
| 1085 | 1090 | |
| 1086 | 1091 | // template <> class ctype_byname<wchar_t> |
| 1087 | 1092 | |
| 1088 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1093 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1089 | 1094 | ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) |
| 1090 | : ctype<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, name, 0)) { | |
| 1095 | : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) { | |
| 1091 | 1096 | if (__l_ == 0) |
| 1092 | 1097 | __throw_runtime_error( |
| 1093 | 1098 | ("ctype_byname<wchar_t>::ctype_byname" |
| ... | ... | @@ -1097,7 +1102,7 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) |
| 1097 | 1102 | } |
| 1098 | 1103 | |
| 1099 | 1104 | ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) |
| 1100 | : ctype<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { | |
| 1105 | : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) { | |
| 1101 | 1106 | if (__l_ == 0) |
| 1102 | 1107 | __throw_runtime_error( |
| 1103 | 1108 | ("ctype_byname<wchar_t>::ctype_byname" |
| ... | ... | @@ -1106,70 +1111,70 @@ ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) |
| 1106 | 1111 | .c_str()); |
| 1107 | 1112 | } |
| 1108 | 1113 | |
| 1109 | ctype_byname<wchar_t>::~ctype_byname() { freelocale(__l_); } | |
| 1114 | ctype_byname<wchar_t>::~ctype_byname() { __locale::__freelocale(__l_); } | |
| 1110 | 1115 | |
| 1111 | 1116 | bool ctype_byname<wchar_t>::do_is(mask m, char_type c) const { |
| 1117 | wint_t ch = static_cast<wint_t>(c); | |
| 1112 | 1118 | # ifdef _LIBCPP_WCTYPE_IS_MASK |
| 1113 | return static_cast<bool>(iswctype_l(c, m, __l_)); | |
| 1119 | return static_cast<bool>(__locale::__iswctype(ch, m, __l_)); | |
| 1114 | 1120 | # else |
| 1115 | 1121 | bool result = false; |
| 1116 | wint_t ch = static_cast<wint_t>(c); | |
| 1117 | 1122 | if ((m & space) == space) |
| 1118 | result |= (iswspace_l(ch, __l_) != 0); | |
| 1123 | result |= (__locale::__iswspace(ch, __l_) != 0); | |
| 1119 | 1124 | if ((m & print) == print) |
| 1120 | result |= (iswprint_l(ch, __l_) != 0); | |
| 1125 | result |= (__locale::__iswprint(ch, __l_) != 0); | |
| 1121 | 1126 | if ((m & cntrl) == cntrl) |
| 1122 | result |= (iswcntrl_l(ch, __l_) != 0); | |
| 1127 | result |= (__locale::__iswcntrl(ch, __l_) != 0); | |
| 1123 | 1128 | if ((m & upper) == upper) |
| 1124 | result |= (iswupper_l(ch, __l_) != 0); | |
| 1129 | result |= (__locale::__iswupper(ch, __l_) != 0); | |
| 1125 | 1130 | if ((m & lower) == lower) |
| 1126 | result |= (iswlower_l(ch, __l_) != 0); | |
| 1131 | result |= (__locale::__iswlower(ch, __l_) != 0); | |
| 1127 | 1132 | if ((m & alpha) == alpha) |
| 1128 | result |= (iswalpha_l(ch, __l_) != 0); | |
| 1133 | result |= (__locale::__iswalpha(ch, __l_) != 0); | |
| 1129 | 1134 | if ((m & digit) == digit) |
| 1130 | result |= (iswdigit_l(ch, __l_) != 0); | |
| 1135 | result |= (__locale::__iswdigit(ch, __l_) != 0); | |
| 1131 | 1136 | if ((m & punct) == punct) |
| 1132 | result |= (iswpunct_l(ch, __l_) != 0); | |
| 1137 | result |= (__locale::__iswpunct(ch, __l_) != 0); | |
| 1133 | 1138 | if ((m & xdigit) == xdigit) |
| 1134 | result |= (iswxdigit_l(ch, __l_) != 0); | |
| 1139 | result |= (__locale::__iswxdigit(ch, __l_) != 0); | |
| 1135 | 1140 | if ((m & blank) == blank) |
| 1136 | result |= (iswblank_l(ch, __l_) != 0); | |
| 1141 | result |= (__locale::__iswblank(ch, __l_) != 0); | |
| 1137 | 1142 | return result; |
| 1138 | 1143 | # endif |
| 1139 | 1144 | } |
| 1140 | 1145 | |
| 1141 | 1146 | const wchar_t* ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const { |
| 1142 | 1147 | for (; low != high; ++low, ++vec) { |
| 1143 | if (isascii(*low)) | |
| 1148 | if (std::__libcpp_isascii(*low)) | |
| 1144 | 1149 | *vec = static_cast<mask>(ctype<char>::classic_table()[*low]); |
| 1145 | 1150 | else { |
| 1146 | 1151 | *vec = 0; |
| 1147 | 1152 | wint_t ch = static_cast<wint_t>(*low); |
| 1148 | if (iswspace_l(ch, __l_)) | |
| 1153 | if (__locale::__iswspace(ch, __l_)) | |
| 1149 | 1154 | *vec |= space; |
| 1150 | 1155 | # ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT |
| 1151 | if (iswprint_l(ch, __l_)) | |
| 1156 | if (__locale::__iswprint(ch, __l_)) | |
| 1152 | 1157 | *vec |= print; |
| 1153 | 1158 | # endif |
| 1154 | if (iswcntrl_l(ch, __l_)) | |
| 1159 | if (__locale::__iswcntrl(ch, __l_)) | |
| 1155 | 1160 | *vec |= cntrl; |
| 1156 | if (iswupper_l(ch, __l_)) | |
| 1161 | if (__locale::__iswupper(ch, __l_)) | |
| 1157 | 1162 | *vec |= upper; |
| 1158 | if (iswlower_l(ch, __l_)) | |
| 1163 | if (__locale::__iswlower(ch, __l_)) | |
| 1159 | 1164 | *vec |= lower; |
| 1160 | 1165 | # ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA |
| 1161 | if (iswalpha_l(ch, __l_)) | |
| 1166 | if (__locale::__iswalpha(ch, __l_)) | |
| 1162 | 1167 | *vec |= alpha; |
| 1163 | 1168 | # endif |
| 1164 | if (iswdigit_l(ch, __l_)) | |
| 1169 | if (__locale::__iswdigit(ch, __l_)) | |
| 1165 | 1170 | *vec |= digit; |
| 1166 | if (iswpunct_l(ch, __l_)) | |
| 1171 | if (__locale::__iswpunct(ch, __l_)) | |
| 1167 | 1172 | *vec |= punct; |
| 1168 | 1173 | # ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT |
| 1169 | if (iswxdigit_l(ch, __l_)) | |
| 1174 | if (__locale::__iswxdigit(ch, __l_)) | |
| 1170 | 1175 | *vec |= xdigit; |
| 1171 | 1176 | # endif |
| 1172 | if (iswblank_l(ch, __l_)) | |
| 1177 | if (__locale::__iswblank(ch, __l_)) | |
| 1173 | 1178 | *vec |= blank; |
| 1174 | 1179 | } |
| 1175 | 1180 | } |
| ... | ... | @@ -1179,29 +1184,29 @@ const wchar_t* ctype_byname<wchar_t>::do_is(const char_type* low, const char_typ |
| 1179 | 1184 | const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const { |
| 1180 | 1185 | for (; low != high; ++low) { |
| 1181 | 1186 | # ifdef _LIBCPP_WCTYPE_IS_MASK |
| 1182 | if (iswctype_l(*low, m, __l_)) | |
| 1187 | if (__locale::__iswctype(static_cast<wint_t>(*low), m, __l_)) | |
| 1183 | 1188 | break; |
| 1184 | 1189 | # else |
| 1185 | 1190 | wint_t ch = static_cast<wint_t>(*low); |
| 1186 | if ((m & space) == space && iswspace_l(ch, __l_)) | |
| 1191 | if ((m & space) == space && __locale::__iswspace(ch, __l_)) | |
| 1187 | 1192 | break; |
| 1188 | if ((m & print) == print && iswprint_l(ch, __l_)) | |
| 1193 | if ((m & print) == print && __locale::__iswprint(ch, __l_)) | |
| 1189 | 1194 | break; |
| 1190 | if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) | |
| 1195 | if ((m & cntrl) == cntrl && __locale::__iswcntrl(ch, __l_)) | |
| 1191 | 1196 | break; |
| 1192 | if ((m & upper) == upper && iswupper_l(ch, __l_)) | |
| 1197 | if ((m & upper) == upper && __locale::__iswupper(ch, __l_)) | |
| 1193 | 1198 | break; |
| 1194 | if ((m & lower) == lower && iswlower_l(ch, __l_)) | |
| 1199 | if ((m & lower) == lower && __locale::__iswlower(ch, __l_)) | |
| 1195 | 1200 | break; |
| 1196 | if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) | |
| 1201 | if ((m & alpha) == alpha && __locale::__iswalpha(ch, __l_)) | |
| 1197 | 1202 | break; |
| 1198 | if ((m & digit) == digit && iswdigit_l(ch, __l_)) | |
| 1203 | if ((m & digit) == digit && __locale::__iswdigit(ch, __l_)) | |
| 1199 | 1204 | break; |
| 1200 | if ((m & punct) == punct && iswpunct_l(ch, __l_)) | |
| 1205 | if ((m & punct) == punct && __locale::__iswpunct(ch, __l_)) | |
| 1201 | 1206 | break; |
| 1202 | if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) | |
| 1207 | if ((m & xdigit) == xdigit && __locale::__iswxdigit(ch, __l_)) | |
| 1203 | 1208 | break; |
| 1204 | if ((m & blank) == blank && iswblank_l(ch, __l_)) | |
| 1209 | if ((m & blank) == blank && __locale::__iswblank(ch, __l_)) | |
| 1205 | 1210 | break; |
| 1206 | 1211 | # endif |
| 1207 | 1212 | } |
| ... | ... | @@ -1210,30 +1215,30 @@ const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, c |
| 1210 | 1215 | |
| 1211 | 1216 | const wchar_t* ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const { |
| 1212 | 1217 | for (; low != high; ++low) { |
| 1218 | wint_t ch = static_cast<wint_t>(*low); | |
| 1213 | 1219 | # ifdef _LIBCPP_WCTYPE_IS_MASK |
| 1214 | if (!iswctype_l(*low, m, __l_)) | |
| 1220 | if (!__locale::__iswctype(ch, m, __l_)) | |
| 1215 | 1221 | break; |
| 1216 | 1222 | # else |
| 1217 | wint_t ch = static_cast<wint_t>(*low); | |
| 1218 | if ((m & space) == space && iswspace_l(ch, __l_)) | |
| 1223 | if ((m & space) == space && __locale::__iswspace(ch, __l_)) | |
| 1219 | 1224 | continue; |
| 1220 | if ((m & print) == print && iswprint_l(ch, __l_)) | |
| 1225 | if ((m & print) == print && __locale::__iswprint(ch, __l_)) | |
| 1221 | 1226 | continue; |
| 1222 | if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) | |
| 1227 | if ((m & cntrl) == cntrl && __locale::__iswcntrl(ch, __l_)) | |
| 1223 | 1228 | continue; |
| 1224 | if ((m & upper) == upper && iswupper_l(ch, __l_)) | |
| 1229 | if ((m & upper) == upper && __locale::__iswupper(ch, __l_)) | |
| 1225 | 1230 | continue; |
| 1226 | if ((m & lower) == lower && iswlower_l(ch, __l_)) | |
| 1231 | if ((m & lower) == lower && __locale::__iswlower(ch, __l_)) | |
| 1227 | 1232 | continue; |
| 1228 | if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) | |
| 1233 | if ((m & alpha) == alpha && __locale::__iswalpha(ch, __l_)) | |
| 1229 | 1234 | continue; |
| 1230 | if ((m & digit) == digit && iswdigit_l(ch, __l_)) | |
| 1235 | if ((m & digit) == digit && __locale::__iswdigit(ch, __l_)) | |
| 1231 | 1236 | continue; |
| 1232 | if ((m & punct) == punct && iswpunct_l(ch, __l_)) | |
| 1237 | if ((m & punct) == punct && __locale::__iswpunct(ch, __l_)) | |
| 1233 | 1238 | continue; |
| 1234 | if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) | |
| 1239 | if ((m & xdigit) == xdigit && __locale::__iswxdigit(ch, __l_)) | |
| 1235 | 1240 | continue; |
| 1236 | if ((m & blank) == blank && iswblank_l(ch, __l_)) | |
| 1241 | if ((m & blank) == blank && __locale::__iswblank(ch, __l_)) | |
| 1237 | 1242 | continue; |
| 1238 | 1243 | break; |
| 1239 | 1244 | # endif |
| ... | ... | @@ -1241,44 +1246,44 @@ const wchar_t* ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, |
| 1241 | 1246 | return low; |
| 1242 | 1247 | } |
| 1243 | 1248 | |
| 1244 | wchar_t ctype_byname<wchar_t>::do_toupper(char_type c) const { return towupper_l(c, __l_); } | |
| 1249 | wchar_t ctype_byname<wchar_t>::do_toupper(char_type c) const { return __locale::__towupper(c, __l_); } | |
| 1245 | 1250 | |
| 1246 | 1251 | const wchar_t* ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const { |
| 1247 | 1252 | for (; low != high; ++low) |
| 1248 | *low = towupper_l(*low, __l_); | |
| 1253 | *low = __locale::__towupper(*low, __l_); | |
| 1249 | 1254 | return low; |
| 1250 | 1255 | } |
| 1251 | 1256 | |
| 1252 | wchar_t ctype_byname<wchar_t>::do_tolower(char_type c) const { return towlower_l(c, __l_); } | |
| 1257 | wchar_t ctype_byname<wchar_t>::do_tolower(char_type c) const { return __locale::__towlower(c, __l_); } | |
| 1253 | 1258 | |
| 1254 | 1259 | const wchar_t* ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const { |
| 1255 | 1260 | for (; low != high; ++low) |
| 1256 | *low = towlower_l(*low, __l_); | |
| 1261 | *low = __locale::__towlower(*low, __l_); | |
| 1257 | 1262 | return low; |
| 1258 | 1263 | } |
| 1259 | 1264 | |
| 1260 | wchar_t ctype_byname<wchar_t>::do_widen(char c) const { return __libcpp_btowc_l(c, __l_); } | |
| 1265 | wchar_t ctype_byname<wchar_t>::do_widen(char c) const { return __locale::__btowc(c, __l_); } | |
| 1261 | 1266 | |
| 1262 | 1267 | const char* ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const { |
| 1263 | 1268 | for (; low != high; ++low, ++dest) |
| 1264 | *dest = __libcpp_btowc_l(*low, __l_); | |
| 1269 | *dest = __locale::__btowc(*low, __l_); | |
| 1265 | 1270 | return low; |
| 1266 | 1271 | } |
| 1267 | 1272 | |
| 1268 | 1273 | char ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const { |
| 1269 | int r = __libcpp_wctob_l(c, __l_); | |
| 1274 | int r = __locale::__wctob(c, __l_); | |
| 1270 | 1275 | return (r != EOF) ? static_cast<char>(r) : dfault; |
| 1271 | 1276 | } |
| 1272 | 1277 | |
| 1273 | 1278 | const wchar_t* |
| 1274 | 1279 | ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const { |
| 1275 | 1280 | for (; low != high; ++low, ++dest) { |
| 1276 | int r = __libcpp_wctob_l(*low, __l_); | |
| 1281 | int r = __locale::__wctob(*low, __l_); | |
| 1277 | 1282 | *dest = (r != EOF) ? static_cast<char>(r) : dfault; |
| 1278 | 1283 | } |
| 1279 | 1284 | return low; |
| 1280 | 1285 | } |
| 1281 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1286 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1282 | 1287 | |
| 1283 | 1288 | // template <> class codecvt<char, char, mbstate_t> |
| 1284 | 1289 | |
| ... | ... | @@ -1331,13 +1336,13 @@ int codecvt<char, char, mbstate_t>::do_max_length() const noexcept { return 1; } |
| 1331 | 1336 | |
| 1332 | 1337 | // template <> class codecvt<wchar_t, char, mbstate_t> |
| 1333 | 1338 | |
| 1334 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1339 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1335 | 1340 | constinit locale::id codecvt<wchar_t, char, mbstate_t>::id; |
| 1336 | 1341 | |
| 1337 | 1342 | codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) : locale::facet(refs), __l_(_LIBCPP_GET_C_LOCALE) {} |
| 1338 | 1343 | |
| 1339 | 1344 | codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs) |
| 1340 | : locale::facet(refs), __l_(newlocale(LC_ALL_MASK, nm, 0)) { | |
| 1345 | : locale::facet(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) { | |
| 1341 | 1346 | if (__l_ == 0) |
| 1342 | 1347 | __throw_runtime_error( |
| 1343 | 1348 | ("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" |
| ... | ... | @@ -1348,7 +1353,7 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs) |
| 1348 | 1353 | |
| 1349 | 1354 | codecvt<wchar_t, char, mbstate_t>::~codecvt() { |
| 1350 | 1355 | if (__l_ != _LIBCPP_GET_C_LOCALE) |
| 1351 | freelocale(__l_); | |
| 1356 | __locale::__freelocale(__l_); | |
| 1352 | 1357 | } |
| 1353 | 1358 | |
| 1354 | 1359 | codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_out( |
| ... | ... | @@ -1369,12 +1374,12 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_ |
| 1369 | 1374 | for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt) { |
| 1370 | 1375 | // save state in case it is needed to recover to_nxt on error |
| 1371 | 1376 | mbstate_t save_state = st; |
| 1372 | size_t n = __libcpp_wcsnrtombs_l( | |
| 1377 | size_t n = __locale::__wcsnrtombs( | |
| 1373 | 1378 | to, &frm_nxt, static_cast<size_t>(fend - frm), static_cast<size_t>(to_end - to), &st, __l_); |
| 1374 | 1379 | if (n == size_t(-1)) { |
| 1375 | 1380 | // need to recover to_nxt |
| 1376 | 1381 | for (to_nxt = to; frm != frm_nxt; ++frm) { |
| 1377 | n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l_); | |
| 1382 | n = __locale::__wcrtomb(to_nxt, *frm, &save_state, __l_); | |
| 1378 | 1383 | if (n == size_t(-1)) |
| 1379 | 1384 | break; |
| 1380 | 1385 | to_nxt += n; |
| ... | ... | @@ -1391,7 +1396,7 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_ |
| 1391 | 1396 | { |
| 1392 | 1397 | // Try to write the terminating null |
| 1393 | 1398 | extern_type tmp[MB_LEN_MAX]; |
| 1394 | n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_); | |
| 1399 | n = __locale::__wcrtomb(tmp, intern_type(), &st, __l_); | |
| 1395 | 1400 | if (n == size_t(-1)) // on error |
| 1396 | 1401 | return error; |
| 1397 | 1402 | if (n > static_cast<size_t>(to_end - to_nxt)) // is there room? |
| ... | ... | @@ -1426,12 +1431,12 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_ |
| 1426 | 1431 | for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt) { |
| 1427 | 1432 | // save state in case it is needed to recover to_nxt on error |
| 1428 | 1433 | mbstate_t save_state = st; |
| 1429 | size_t n = __libcpp_mbsnrtowcs_l( | |
| 1434 | size_t n = __locale::__mbsnrtowcs( | |
| 1430 | 1435 | to, &frm_nxt, static_cast<size_t>(fend - frm), static_cast<size_t>(to_end - to), &st, __l_); |
| 1431 | 1436 | if (n == size_t(-1)) { |
| 1432 | 1437 | // need to recover to_nxt |
| 1433 | 1438 | for (to_nxt = to; frm != frm_nxt; ++to_nxt) { |
| 1434 | n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend - frm), &save_state, __l_); | |
| 1439 | n = __locale::__mbrtowc(to_nxt, frm, static_cast<size_t>(fend - frm), &save_state, __l_); | |
| 1435 | 1440 | switch (n) { |
| 1436 | 1441 | case 0: |
| 1437 | 1442 | ++frm; |
| ... | ... | @@ -1458,7 +1463,7 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_ |
| 1458 | 1463 | if (fend != frm_end) // set up next null terminated sequence |
| 1459 | 1464 | { |
| 1460 | 1465 | // Try to write the terminating null |
| 1461 | n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l_); | |
| 1466 | n = __locale::__mbrtowc(to_nxt, frm_nxt, 1, &st, __l_); | |
| 1462 | 1467 | if (n != 0) // on error |
| 1463 | 1468 | return error; |
| 1464 | 1469 | ++to_nxt; |
| ... | ... | @@ -1476,7 +1481,7 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_ |
| 1476 | 1481 | state_type& st, extern_type* to, extern_type* to_end, extern_type*& to_nxt) const { |
| 1477 | 1482 | to_nxt = to; |
| 1478 | 1483 | extern_type tmp[MB_LEN_MAX]; |
| 1479 | size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_); | |
| 1484 | size_t n = __locale::__wcrtomb(tmp, intern_type(), &st, __l_); | |
| 1480 | 1485 | if (n == size_t(-1) || n == 0) // on error |
| 1481 | 1486 | return error; |
| 1482 | 1487 | --n; |
| ... | ... | @@ -1488,12 +1493,12 @@ codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_ |
| 1488 | 1493 | } |
| 1489 | 1494 | |
| 1490 | 1495 | int codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept { |
| 1491 | if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l_) != 0) | |
| 1496 | if (__locale::__mbtowc(nullptr, nullptr, MB_LEN_MAX, __l_) != 0) | |
| 1492 | 1497 | return -1; |
| 1493 | 1498 | |
| 1494 | 1499 | // stateless encoding |
| 1495 | if (__l_ == 0 || __libcpp_mb_cur_max_l(__l_) == 1) // there are no known constant length encodings | |
| 1496 | return 1; // which take more than 1 char to form a wchar_t | |
| 1500 | if (__l_ == 0 || __locale::__mb_len_max(__l_) == 1) // there are no known constant length encodings | |
| 1501 | return 1; // which take more than 1 char to form a wchar_t | |
| 1497 | 1502 | return 0; |
| 1498 | 1503 | } |
| 1499 | 1504 | |
| ... | ... | @@ -1503,7 +1508,7 @@ int codecvt<wchar_t, char, mbstate_t>::do_length( |
| 1503 | 1508 | state_type& st, const extern_type* frm, const extern_type* frm_end, size_t mx) const { |
| 1504 | 1509 | int nbytes = 0; |
| 1505 | 1510 | for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t) { |
| 1506 | size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end - frm), &st, __l_); | |
| 1511 | size_t n = __locale::__mbrlen(frm, static_cast<size_t>(frm_end - frm), &st, __l_); | |
| 1507 | 1512 | switch (n) { |
| 1508 | 1513 | case 0: |
| 1509 | 1514 | ++nbytes; |
| ... | ... | @@ -1522,9 +1527,9 @@ int codecvt<wchar_t, char, mbstate_t>::do_length( |
| 1522 | 1527 | } |
| 1523 | 1528 | |
| 1524 | 1529 | int codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept { |
| 1525 | return __l_ == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l_)); | |
| 1530 | return __l_ == 0 ? 1 : static_cast<int>(__locale::__mb_len_max(__l_)); | |
| 1526 | 1531 | } |
| 1527 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1532 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 1528 | 1533 | |
| 1529 | 1534 | // Valid UTF ranges |
| 1530 | 1535 | // UTF-32 UTF-16 UTF-8 # of code points |
| ... | ... | @@ -2815,7 +2820,7 @@ int codecvt<char16_t, char, mbstate_t>::do_length( |
| 2815 | 2820 | |
| 2816 | 2821 | int codecvt<char16_t, char, mbstate_t>::do_max_length() const noexcept { return 4; } |
| 2817 | 2822 | |
| 2818 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 2823 | #if _LIBCPP_HAS_CHAR8_T | |
| 2819 | 2824 | |
| 2820 | 2825 | // template <> class codecvt<char16_t, char8_t, mbstate_t> |
| 2821 | 2826 | |
| ... | ... | @@ -2949,7 +2954,7 @@ int codecvt<char32_t, char, mbstate_t>::do_length( |
| 2949 | 2954 | |
| 2950 | 2955 | int codecvt<char32_t, char, mbstate_t>::do_max_length() const noexcept { return 4; } |
| 2951 | 2956 | |
| 2952 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 2957 | #if _LIBCPP_HAS_CHAR8_T | |
| 2953 | 2958 | |
| 2954 | 2959 | // template <> class codecvt<char32_t, char8_t, mbstate_t> |
| 2955 | 2960 | |
| ... | ... | @@ -3020,7 +3025,7 @@ int codecvt<char32_t, char8_t, mbstate_t>::do_max_length() const noexcept { retu |
| 3020 | 3025 | |
| 3021 | 3026 | // __codecvt_utf8<wchar_t> |
| 3022 | 3027 | |
| 3023 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3028 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3024 | 3029 | __codecvt_utf8<wchar_t>::result __codecvt_utf8<wchar_t>::do_out( |
| 3025 | 3030 | state_type&, |
| 3026 | 3031 | const intern_type* frm, |
| ... | ... | @@ -3111,7 +3116,7 @@ int __codecvt_utf8<wchar_t>::do_max_length() const noexcept { |
| 3111 | 3116 | return 4; |
| 3112 | 3117 | # endif |
| 3113 | 3118 | } |
| 3114 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3119 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3115 | 3120 | |
| 3116 | 3121 | // __codecvt_utf8<char16_t> |
| 3117 | 3122 | |
| ... | ... | @@ -3249,7 +3254,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 3249 | 3254 | |
| 3250 | 3255 | // __codecvt_utf16<wchar_t, false> |
| 3251 | 3256 | |
| 3252 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3257 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3253 | 3258 | __codecvt_utf16<wchar_t, false>::result __codecvt_utf16<wchar_t, false>::do_out( |
| 3254 | 3259 | state_type&, |
| 3255 | 3260 | const intern_type* frm, |
| ... | ... | @@ -3431,7 +3436,7 @@ int __codecvt_utf16<wchar_t, true>::do_max_length() const noexcept { |
| 3431 | 3436 | return 4; |
| 3432 | 3437 | # endif |
| 3433 | 3438 | } |
| 3434 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3439 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3435 | 3440 | |
| 3436 | 3441 | // __codecvt_utf16<char16_t, false> |
| 3437 | 3442 | |
| ... | ... | @@ -3703,7 +3708,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 3703 | 3708 | |
| 3704 | 3709 | // __codecvt_utf8_utf16<wchar_t> |
| 3705 | 3710 | |
| 3706 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3711 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3707 | 3712 | __codecvt_utf8_utf16<wchar_t>::result __codecvt_utf8_utf16<wchar_t>::do_out( |
| 3708 | 3713 | state_type&, |
| 3709 | 3714 | const intern_type* frm, |
| ... | ... | @@ -3778,7 +3783,7 @@ int __codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept { |
| 3778 | 3783 | return 7; |
| 3779 | 3784 | return 4; |
| 3780 | 3785 | } |
| 3781 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3786 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3782 | 3787 | |
| 3783 | 3788 | // __codecvt_utf8_utf16<char16_t> |
| 3784 | 3789 | |
| ... | ... | @@ -3930,22 +3935,22 @@ __widen_from_utf8<16>::~__widen_from_utf8() {} |
| 3930 | 3935 | |
| 3931 | 3936 | __widen_from_utf8<32>::~__widen_from_utf8() {} |
| 3932 | 3937 | |
| 3933 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3934 | static bool checked_string_to_wchar_convert(wchar_t& dest, const char* ptr, locale_t loc) { | |
| 3938 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3939 | static bool checked_string_to_wchar_convert(wchar_t& dest, const char* ptr, __locale::__locale_t loc) { | |
| 3935 | 3940 | if (*ptr == '\0') |
| 3936 | 3941 | return false; |
| 3937 | 3942 | mbstate_t mb = {}; |
| 3938 | 3943 | wchar_t out; |
| 3939 | size_t ret = __libcpp_mbrtowc_l(&out, ptr, strlen(ptr), &mb, loc); | |
| 3944 | size_t ret = __locale::__mbrtowc(&out, ptr, strlen(ptr), &mb, loc); | |
| 3940 | 3945 | if (ret == static_cast<size_t>(-1) || ret == static_cast<size_t>(-2)) { |
| 3941 | 3946 | return false; |
| 3942 | 3947 | } |
| 3943 | 3948 | dest = out; |
| 3944 | 3949 | return true; |
| 3945 | 3950 | } |
| 3946 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3951 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3947 | 3952 | |
| 3948 | #ifdef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3953 | #if !_LIBCPP_HAS_WIDE_CHARACTERS | |
| 3949 | 3954 | static bool is_narrow_non_breaking_space(const char* ptr) { |
| 3950 | 3955 | // https://www.fileformat.info/info/unicode/char/202f/index.htm |
| 3951 | 3956 | return ptr[0] == '\xe2' && ptr[1] == '\x80' && ptr[2] == '\xaf'; |
| ... | ... | @@ -3955,9 +3960,9 @@ static bool is_non_breaking_space(const char* ptr) { |
| 3955 | 3960 | // https://www.fileformat.info/info/unicode/char/0a/index.htm |
| 3956 | 3961 | return ptr[0] == '\xc2' && ptr[1] == '\xa0'; |
| 3957 | 3962 | } |
| 3958 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3963 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3959 | 3964 | |
| 3960 | static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t __loc) { | |
| 3965 | static bool checked_string_to_char_convert(char& dest, const char* ptr, __locale::__locale_t __loc) { | |
| 3961 | 3966 | if (*ptr == '\0') |
| 3962 | 3967 | return false; |
| 3963 | 3968 | if (!ptr[1]) { |
| ... | ... | @@ -3965,14 +3970,14 @@ static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t |
| 3965 | 3970 | return true; |
| 3966 | 3971 | } |
| 3967 | 3972 | |
| 3968 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3973 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3969 | 3974 | // First convert the MBS into a wide char then attempt to narrow it using |
| 3970 | 3975 | // wctob_l. |
| 3971 | 3976 | wchar_t wout; |
| 3972 | 3977 | if (!checked_string_to_wchar_convert(wout, ptr, __loc)) |
| 3973 | 3978 | return false; |
| 3974 | 3979 | int res; |
| 3975 | if ((res = __libcpp_wctob_l(wout, __loc)) != char_traits<char>::eof()) { | |
| 3980 | if ((res = __locale::__wctob(wout, __loc)) != char_traits<char>::eof()) { | |
| 3976 | 3981 | dest = res; |
| 3977 | 3982 | return true; |
| 3978 | 3983 | } |
| ... | ... | @@ -3986,7 +3991,7 @@ static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t |
| 3986 | 3991 | default: |
| 3987 | 3992 | return false; |
| 3988 | 3993 | } |
| 3989 | #else // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3994 | #else // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3990 | 3995 | // FIXME: Work around specific multibyte sequences that we can reasonably |
| 3991 | 3996 | // translate into a different single byte. |
| 3992 | 3997 | if (is_narrow_non_breaking_space(ptr) || is_non_breaking_space(ptr)) { |
| ... | ... | @@ -3995,51 +4000,51 @@ static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t |
| 3995 | 4000 | } |
| 3996 | 4001 | |
| 3997 | 4002 | return false; |
| 3998 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4003 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 3999 | 4004 | __libcpp_unreachable(); |
| 4000 | 4005 | } |
| 4001 | 4006 | |
| 4002 | 4007 | // numpunct<char> && numpunct<wchar_t> |
| 4003 | 4008 | |
| 4004 | 4009 | constinit locale::id numpunct<char>::id; |
| 4005 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4010 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4006 | 4011 | constinit locale::id numpunct<wchar_t>::id; |
| 4007 | 4012 | #endif |
| 4008 | 4013 | |
| 4009 | 4014 | numpunct<char>::numpunct(size_t refs) : locale::facet(refs), __decimal_point_('.'), __thousands_sep_(',') {} |
| 4010 | 4015 | |
| 4011 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4016 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4012 | 4017 | numpunct<wchar_t>::numpunct(size_t refs) : locale::facet(refs), __decimal_point_(L'.'), __thousands_sep_(L',') {} |
| 4013 | 4018 | #endif |
| 4014 | 4019 | |
| 4015 | 4020 | numpunct<char>::~numpunct() {} |
| 4016 | 4021 | |
| 4017 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4022 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4018 | 4023 | numpunct<wchar_t>::~numpunct() {} |
| 4019 | 4024 | #endif |
| 4020 | 4025 | |
| 4021 | 4026 | char numpunct< char >::do_decimal_point() const { return __decimal_point_; } |
| 4022 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4027 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4023 | 4028 | wchar_t numpunct<wchar_t>::do_decimal_point() const { return __decimal_point_; } |
| 4024 | 4029 | #endif |
| 4025 | 4030 | |
| 4026 | 4031 | char numpunct< char >::do_thousands_sep() const { return __thousands_sep_; } |
| 4027 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4032 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4028 | 4033 | wchar_t numpunct<wchar_t>::do_thousands_sep() const { return __thousands_sep_; } |
| 4029 | 4034 | #endif |
| 4030 | 4035 | |
| 4031 | 4036 | string numpunct< char >::do_grouping() const { return __grouping_; } |
| 4032 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4037 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4033 | 4038 | string numpunct<wchar_t>::do_grouping() const { return __grouping_; } |
| 4034 | 4039 | #endif |
| 4035 | 4040 | |
| 4036 | 4041 | string numpunct< char >::do_truename() const { return "true"; } |
| 4037 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4042 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4038 | 4043 | wstring numpunct<wchar_t>::do_truename() const { return L"true"; } |
| 4039 | 4044 | #endif |
| 4040 | 4045 | |
| 4041 | 4046 | string numpunct< char >::do_falsename() const { return "false"; } |
| 4042 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4047 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4043 | 4048 | wstring numpunct<wchar_t>::do_falsename() const { return L"false"; } |
| 4044 | 4049 | #endif |
| 4045 | 4050 | |
| ... | ... | @@ -4062,7 +4067,7 @@ void numpunct_byname<char>::__init(const char* nm) { |
| 4062 | 4067 | string(nm)) |
| 4063 | 4068 | .c_str()); |
| 4064 | 4069 | |
| 4065 | lconv* lc = __libcpp_localeconv_l(loc.get()); | |
| 4070 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); | |
| 4066 | 4071 | if (!checked_string_to_char_convert(__decimal_point_, lc->decimal_point, loc.get())) |
| 4067 | 4072 | __decimal_point_ = base::do_decimal_point(); |
| 4068 | 4073 | if (!checked_string_to_char_convert(__thousands_sep_, lc->thousands_sep, loc.get())) |
| ... | ... | @@ -4074,7 +4079,7 @@ void numpunct_byname<char>::__init(const char* nm) { |
| 4074 | 4079 | |
| 4075 | 4080 | // numpunct_byname<wchar_t> |
| 4076 | 4081 | |
| 4077 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4082 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4078 | 4083 | numpunct_byname<wchar_t>::numpunct_byname(const char* nm, size_t refs) : numpunct<wchar_t>(refs) { __init(nm); } |
| 4079 | 4084 | |
| 4080 | 4085 | numpunct_byname<wchar_t>::numpunct_byname(const string& nm, size_t refs) : numpunct<wchar_t>(refs) { |
| ... | ... | @@ -4093,14 +4098,14 @@ void numpunct_byname<wchar_t>::__init(const char* nm) { |
| 4093 | 4098 | string(nm)) |
| 4094 | 4099 | .c_str()); |
| 4095 | 4100 | |
| 4096 | lconv* lc = __libcpp_localeconv_l(loc.get()); | |
| 4101 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); | |
| 4097 | 4102 | checked_string_to_wchar_convert(__decimal_point_, lc->decimal_point, loc.get()); |
| 4098 | 4103 | checked_string_to_wchar_convert(__thousands_sep_, lc->thousands_sep, loc.get()); |
| 4099 | 4104 | __grouping_ = lc->grouping; |
| 4100 | 4105 | // localization for truename and falsename is not available |
| 4101 | 4106 | } |
| 4102 | 4107 | } |
| 4103 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4108 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4104 | 4109 | |
| 4105 | 4110 | // num_get helpers |
| 4106 | 4111 | |
| ... | ... | @@ -4240,7 +4245,7 @@ static string* init_weeks() { |
| 4240 | 4245 | return weeks; |
| 4241 | 4246 | } |
| 4242 | 4247 | |
| 4243 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4248 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4244 | 4249 | static wstring* init_wweeks() { |
| 4245 | 4250 | static wstring weeks[14]; |
| 4246 | 4251 | weeks[0] = L"Sunday"; |
| ... | ... | @@ -4267,7 +4272,7 @@ const string* __time_get_c_storage<char>::__weeks() const { |
| 4267 | 4272 | return weeks; |
| 4268 | 4273 | } |
| 4269 | 4274 | |
| 4270 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4275 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4271 | 4276 | template <> |
| 4272 | 4277 | const wstring* __time_get_c_storage<wchar_t>::__weeks() const { |
| 4273 | 4278 | static const wstring* weeks = init_wweeks(); |
| ... | ... | @@ -4304,7 +4309,7 @@ static string* init_months() { |
| 4304 | 4309 | return months; |
| 4305 | 4310 | } |
| 4306 | 4311 | |
| 4307 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4312 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4308 | 4313 | static wstring* init_wmonths() { |
| 4309 | 4314 | static wstring months[24]; |
| 4310 | 4315 | months[0] = L"January"; |
| ... | ... | @@ -4341,7 +4346,7 @@ const string* __time_get_c_storage<char>::__months() const { |
| 4341 | 4346 | return months; |
| 4342 | 4347 | } |
| 4343 | 4348 | |
| 4344 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4349 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4345 | 4350 | template <> |
| 4346 | 4351 | const wstring* __time_get_c_storage<wchar_t>::__months() const { |
| 4347 | 4352 | static const wstring* months = init_wmonths(); |
| ... | ... | @@ -4356,7 +4361,7 @@ static string* init_am_pm() { |
| 4356 | 4361 | return am_pm; |
| 4357 | 4362 | } |
| 4358 | 4363 | |
| 4359 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4364 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4360 | 4365 | static wstring* init_wam_pm() { |
| 4361 | 4366 | static wstring am_pm[2]; |
| 4362 | 4367 | am_pm[0] = L"AM"; |
| ... | ... | @@ -4371,7 +4376,7 @@ const string* __time_get_c_storage<char>::__am_pm() const { |
| 4371 | 4376 | return am_pm; |
| 4372 | 4377 | } |
| 4373 | 4378 | |
| 4374 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4379 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4375 | 4380 | template <> |
| 4376 | 4381 | const wstring* __time_get_c_storage<wchar_t>::__am_pm() const { |
| 4377 | 4382 | static const wstring* am_pm = init_wam_pm(); |
| ... | ... | @@ -4385,7 +4390,7 @@ const string& __time_get_c_storage<char>::__x() const { |
| 4385 | 4390 | return s; |
| 4386 | 4391 | } |
| 4387 | 4392 | |
| 4388 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4393 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4389 | 4394 | template <> |
| 4390 | 4395 | const wstring& __time_get_c_storage<wchar_t>::__x() const { |
| 4391 | 4396 | static wstring s(L"%m/%d/%y"); |
| ... | ... | @@ -4399,7 +4404,7 @@ const string& __time_get_c_storage<char>::__X() const { |
| 4399 | 4404 | return s; |
| 4400 | 4405 | } |
| 4401 | 4406 | |
| 4402 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4407 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4403 | 4408 | template <> |
| 4404 | 4409 | const wstring& __time_get_c_storage<wchar_t>::__X() const { |
| 4405 | 4410 | static wstring s(L"%H:%M:%S"); |
| ... | ... | @@ -4413,7 +4418,7 @@ const string& __time_get_c_storage<char>::__c() const { |
| 4413 | 4418 | return s; |
| 4414 | 4419 | } |
| 4415 | 4420 | |
| 4416 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4421 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4417 | 4422 | template <> |
| 4418 | 4423 | const wstring& __time_get_c_storage<wchar_t>::__c() const { |
| 4419 | 4424 | static wstring s(L"%a %b %d %H:%M:%S %Y"); |
| ... | ... | @@ -4427,7 +4432,7 @@ const string& __time_get_c_storage<char>::__r() const { |
| 4427 | 4432 | return s; |
| 4428 | 4433 | } |
| 4429 | 4434 | |
| 4430 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4435 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4431 | 4436 | template <> |
| 4432 | 4437 | const wstring& __time_get_c_storage<wchar_t>::__r() const { |
| 4433 | 4438 | static wstring s(L"%I:%M:%S %p"); |
| ... | ... | @@ -4437,17 +4442,17 @@ const wstring& __time_get_c_storage<wchar_t>::__r() const { |
| 4437 | 4442 | |
| 4438 | 4443 | // time_get_byname |
| 4439 | 4444 | |
| 4440 | __time_get::__time_get(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) { | |
| 4445 | __time_get::__time_get(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) { | |
| 4441 | 4446 | if (__loc_ == 0) |
| 4442 | 4447 | __throw_runtime_error(("time_get_byname failed to construct for " + string(nm)).c_str()); |
| 4443 | 4448 | } |
| 4444 | 4449 | |
| 4445 | __time_get::__time_get(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) { | |
| 4450 | __time_get::__time_get(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) { | |
| 4446 | 4451 | if (__loc_ == 0) |
| 4447 | 4452 | __throw_runtime_error(("time_get_byname failed to construct for " + nm).c_str()); |
| 4448 | 4453 | } |
| 4449 | 4454 | |
| 4450 | __time_get::~__time_get() { freelocale(__loc_); } | |
| 4455 | __time_get::~__time_get() { __locale::__freelocale(__loc_); } | |
| 4451 | 4456 | |
| 4452 | 4457 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers") |
| 4453 | 4458 | |
| ... | ... | @@ -4467,7 +4472,7 @@ string __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) { |
| 4467 | 4472 | char f[3] = {0}; |
| 4468 | 4473 | f[0] = '%'; |
| 4469 | 4474 | f[1] = fmt; |
| 4470 | size_t n = strftime_l(buf, countof(buf), f, &t, __loc_); | |
| 4475 | size_t n = __locale::__strftime(buf, countof(buf), f, &t, __loc_); | |
| 4471 | 4476 | char* bb = buf; |
| 4472 | 4477 | char* be = buf + n; |
| 4473 | 4478 | string result; |
| ... | ... | @@ -4581,7 +4586,7 @@ string __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) { |
| 4581 | 4586 | |
| 4582 | 4587 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-braces") |
| 4583 | 4588 | |
| 4584 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4589 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4585 | 4590 | template <> |
| 4586 | 4591 | wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct) { |
| 4587 | 4592 | tm t = {0}; |
| ... | ... | @@ -4598,12 +4603,12 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c |
| 4598 | 4603 | char f[3] = {0}; |
| 4599 | 4604 | f[0] = '%'; |
| 4600 | 4605 | f[1] = fmt; |
| 4601 | strftime_l(buf, countof(buf), f, &t, __loc_); | |
| 4606 | __locale::__strftime(buf, countof(buf), f, &t, __loc_); | |
| 4602 | 4607 | wchar_t wbuf[100]; |
| 4603 | 4608 | wchar_t* wbb = wbuf; |
| 4604 | 4609 | mbstate_t mb = {0}; |
| 4605 | 4610 | const char* bb = buf; |
| 4606 | size_t j = __libcpp_mbsrtowcs_l(wbb, &bb, countof(wbuf), &mb, __loc_); | |
| 4611 | size_t j = __locale::__mbsrtowcs(wbb, &bb, countof(wbuf), &mb, __loc_); | |
| 4607 | 4612 | if (j == size_t(-1)) |
| 4608 | 4613 | __throw_runtime_error("locale not supported"); |
| 4609 | 4614 | wchar_t* wbe = wbb + j; |
| ... | ... | @@ -4715,7 +4720,7 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c |
| 4715 | 4720 | } |
| 4716 | 4721 | return result; |
| 4717 | 4722 | } |
| 4718 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4723 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4719 | 4724 | |
| 4720 | 4725 | template <> |
| 4721 | 4726 | void __time_get_storage<char>::init(const ctype<char>& ct) { |
| ... | ... | @@ -4724,25 +4729,25 @@ void __time_get_storage<char>::init(const ctype<char>& ct) { |
| 4724 | 4729 | // __weeks_ |
| 4725 | 4730 | for (int i = 0; i < 7; ++i) { |
| 4726 | 4731 | t.tm_wday = i; |
| 4727 | strftime_l(buf, countof(buf), "%A", &t, __loc_); | |
| 4732 | __locale::__strftime(buf, countof(buf), "%A", &t, __loc_); | |
| 4728 | 4733 | __weeks_[i] = buf; |
| 4729 | strftime_l(buf, countof(buf), "%a", &t, __loc_); | |
| 4734 | __locale::__strftime(buf, countof(buf), "%a", &t, __loc_); | |
| 4730 | 4735 | __weeks_[i + 7] = buf; |
| 4731 | 4736 | } |
| 4732 | 4737 | // __months_ |
| 4733 | 4738 | for (int i = 0; i < 12; ++i) { |
| 4734 | 4739 | t.tm_mon = i; |
| 4735 | strftime_l(buf, countof(buf), "%B", &t, __loc_); | |
| 4740 | __locale::__strftime(buf, countof(buf), "%B", &t, __loc_); | |
| 4736 | 4741 | __months_[i] = buf; |
| 4737 | strftime_l(buf, countof(buf), "%b", &t, __loc_); | |
| 4742 | __locale::__strftime(buf, countof(buf), "%b", &t, __loc_); | |
| 4738 | 4743 | __months_[i + 12] = buf; |
| 4739 | 4744 | } |
| 4740 | 4745 | // __am_pm_ |
| 4741 | 4746 | t.tm_hour = 1; |
| 4742 | strftime_l(buf, countof(buf), "%p", &t, __loc_); | |
| 4747 | __locale::__strftime(buf, countof(buf), "%p", &t, __loc_); | |
| 4743 | 4748 | __am_pm_[0] = buf; |
| 4744 | 4749 | t.tm_hour = 13; |
| 4745 | strftime_l(buf, countof(buf), "%p", &t, __loc_); | |
| 4750 | __locale::__strftime(buf, countof(buf), "%p", &t, __loc_); | |
| 4746 | 4751 | __am_pm_[1] = buf; |
| 4747 | 4752 | __c_ = __analyze('c', ct); |
| 4748 | 4753 | __r_ = __analyze('r', ct); |
| ... | ... | @@ -4750,7 +4755,7 @@ void __time_get_storage<char>::init(const ctype<char>& ct) { |
| 4750 | 4755 | __X_ = __analyze('X', ct); |
| 4751 | 4756 | } |
| 4752 | 4757 | |
| 4753 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4758 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4754 | 4759 | template <> |
| 4755 | 4760 | void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4756 | 4761 | tm t = {0}; |
| ... | ... | @@ -4761,18 +4766,18 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4761 | 4766 | // __weeks_ |
| 4762 | 4767 | for (int i = 0; i < 7; ++i) { |
| 4763 | 4768 | t.tm_wday = i; |
| 4764 | strftime_l(buf, countof(buf), "%A", &t, __loc_); | |
| 4769 | __locale::__strftime(buf, countof(buf), "%A", &t, __loc_); | |
| 4765 | 4770 | mb = mbstate_t(); |
| 4766 | 4771 | const char* bb = buf; |
| 4767 | size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4772 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4768 | 4773 | if (j == size_t(-1) || j == 0) |
| 4769 | 4774 | __throw_runtime_error("locale not supported"); |
| 4770 | 4775 | wbe = wbuf + j; |
| 4771 | 4776 | __weeks_[i].assign(wbuf, wbe); |
| 4772 | strftime_l(buf, countof(buf), "%a", &t, __loc_); | |
| 4777 | __locale::__strftime(buf, countof(buf), "%a", &t, __loc_); | |
| 4773 | 4778 | mb = mbstate_t(); |
| 4774 | 4779 | bb = buf; |
| 4775 | j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4780 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4776 | 4781 | if (j == size_t(-1) || j == 0) |
| 4777 | 4782 | __throw_runtime_error("locale not supported"); |
| 4778 | 4783 | wbe = wbuf + j; |
| ... | ... | @@ -4781,18 +4786,18 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4781 | 4786 | // __months_ |
| 4782 | 4787 | for (int i = 0; i < 12; ++i) { |
| 4783 | 4788 | t.tm_mon = i; |
| 4784 | strftime_l(buf, countof(buf), "%B", &t, __loc_); | |
| 4789 | __locale::__strftime(buf, countof(buf), "%B", &t, __loc_); | |
| 4785 | 4790 | mb = mbstate_t(); |
| 4786 | 4791 | const char* bb = buf; |
| 4787 | size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4792 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4788 | 4793 | if (j == size_t(-1) || j == 0) |
| 4789 | 4794 | __throw_runtime_error("locale not supported"); |
| 4790 | 4795 | wbe = wbuf + j; |
| 4791 | 4796 | __months_[i].assign(wbuf, wbe); |
| 4792 | strftime_l(buf, countof(buf), "%b", &t, __loc_); | |
| 4797 | __locale::__strftime(buf, countof(buf), "%b", &t, __loc_); | |
| 4793 | 4798 | mb = mbstate_t(); |
| 4794 | 4799 | bb = buf; |
| 4795 | j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4800 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4796 | 4801 | if (j == size_t(-1) || j == 0) |
| 4797 | 4802 | __throw_runtime_error("locale not supported"); |
| 4798 | 4803 | wbe = wbuf + j; |
| ... | ... | @@ -4800,19 +4805,19 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4800 | 4805 | } |
| 4801 | 4806 | // __am_pm_ |
| 4802 | 4807 | t.tm_hour = 1; |
| 4803 | strftime_l(buf, countof(buf), "%p", &t, __loc_); | |
| 4808 | __locale::__strftime(buf, countof(buf), "%p", &t, __loc_); | |
| 4804 | 4809 | mb = mbstate_t(); |
| 4805 | 4810 | const char* bb = buf; |
| 4806 | size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4811 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4807 | 4812 | if (j == size_t(-1)) |
| 4808 | 4813 | __throw_runtime_error("locale not supported"); |
| 4809 | 4814 | wbe = wbuf + j; |
| 4810 | 4815 | __am_pm_[0].assign(wbuf, wbe); |
| 4811 | 4816 | t.tm_hour = 13; |
| 4812 | strftime_l(buf, countof(buf), "%p", &t, __loc_); | |
| 4817 | __locale::__strftime(buf, countof(buf), "%p", &t, __loc_); | |
| 4813 | 4818 | mb = mbstate_t(); |
| 4814 | 4819 | bb = buf; |
| 4815 | j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4820 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_); | |
| 4816 | 4821 | if (j == size_t(-1)) |
| 4817 | 4822 | __throw_runtime_error("locale not supported"); |
| 4818 | 4823 | wbe = wbuf + j; |
| ... | ... | @@ -4822,7 +4827,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) { |
| 4822 | 4827 | __x_ = __analyze('x', ct); |
| 4823 | 4828 | __X_ = __analyze('X', ct); |
| 4824 | 4829 | } |
| 4825 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4830 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4826 | 4831 | |
| 4827 | 4832 | template <class CharT> |
| 4828 | 4833 | struct _LIBCPP_HIDDEN __time_get_temp : public ctype_byname<CharT> { |
| ... | ... | @@ -4842,7 +4847,7 @@ __time_get_storage<char>::__time_get_storage(const string& __nm) : __time_get(__ |
| 4842 | 4847 | init(ct); |
| 4843 | 4848 | } |
| 4844 | 4849 | |
| 4845 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4850 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4846 | 4851 | template <> |
| 4847 | 4852 | __time_get_storage<wchar_t>::__time_get_storage(const char* __nm) : __time_get(__nm) { |
| 4848 | 4853 | const __time_get_temp<wchar_t> ct(__nm); |
| ... | ... | @@ -4854,7 +4859,7 @@ __time_get_storage<wchar_t>::__time_get_storage(const string& __nm) : __time_get |
| 4854 | 4859 | const __time_get_temp<wchar_t> ct(__nm); |
| 4855 | 4860 | init(ct); |
| 4856 | 4861 | } |
| 4857 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4862 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4858 | 4863 | |
| 4859 | 4864 | template <> |
| 4860 | 4865 | time_base::dateorder __time_get_storage<char>::__do_date_order() const { |
| ... | ... | @@ -4937,7 +4942,7 @@ time_base::dateorder __time_get_storage<char>::__do_date_order() const { |
| 4937 | 4942 | return time_base::no_order; |
| 4938 | 4943 | } |
| 4939 | 4944 | |
| 4940 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4945 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 4941 | 4946 | template <> |
| 4942 | 4947 | time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const { |
| 4943 | 4948 | unsigned i; |
| ... | ... | @@ -5018,46 +5023,46 @@ time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const { |
| 5018 | 5023 | } |
| 5019 | 5024 | return time_base::no_order; |
| 5020 | 5025 | } |
| 5021 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5026 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 5022 | 5027 | |
| 5023 | 5028 | // time_put |
| 5024 | 5029 | |
| 5025 | __time_put::__time_put(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) { | |
| 5030 | __time_put::__time_put(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) { | |
| 5026 | 5031 | if (__loc_ == 0) |
| 5027 | 5032 | __throw_runtime_error(("time_put_byname failed to construct for " + string(nm)).c_str()); |
| 5028 | 5033 | } |
| 5029 | 5034 | |
| 5030 | __time_put::__time_put(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) { | |
| 5035 | __time_put::__time_put(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) { | |
| 5031 | 5036 | if (__loc_ == 0) |
| 5032 | 5037 | __throw_runtime_error(("time_put_byname failed to construct for " + nm).c_str()); |
| 5033 | 5038 | } |
| 5034 | 5039 | |
| 5035 | 5040 | __time_put::~__time_put() { |
| 5036 | 5041 | if (__loc_ != _LIBCPP_GET_C_LOCALE) |
| 5037 | freelocale(__loc_); | |
| 5042 | __locale::__freelocale(__loc_); | |
| 5038 | 5043 | } |
| 5039 | 5044 | |
| 5040 | 5045 | void __time_put::__do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const { |
| 5041 | 5046 | char fmt[] = {'%', __fmt, __mod, 0}; |
| 5042 | 5047 | if (__mod != 0) |
| 5043 | 5048 | swap(fmt[1], fmt[2]); |
| 5044 | size_t n = strftime_l(__nb, countof(__nb, __ne), fmt, __tm, __loc_); | |
| 5049 | size_t n = __locale::__strftime(__nb, countof(__nb, __ne), fmt, __tm, __loc_); | |
| 5045 | 5050 | __ne = __nb + n; |
| 5046 | 5051 | } |
| 5047 | 5052 | |
| 5048 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5053 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 5049 | 5054 | void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const { |
| 5050 | 5055 | char __nar[100]; |
| 5051 | 5056 | char* __ne = __nar + 100; |
| 5052 | 5057 | __do_put(__nar, __ne, __tm, __fmt, __mod); |
| 5053 | 5058 | mbstate_t mb = {0}; |
| 5054 | 5059 | const char* __nb = __nar; |
| 5055 | size_t j = __libcpp_mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_); | |
| 5060 | size_t j = __locale::__mbsrtowcs(__wb, &__nb, countof(__wb, __we), &mb, __loc_); | |
| 5056 | 5061 | if (j == size_t(-1)) |
| 5057 | 5062 | __throw_runtime_error("locale not supported"); |
| 5058 | 5063 | __we = __wb + j; |
| 5059 | 5064 | } |
| 5060 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5065 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 5061 | 5066 | |
| 5062 | 5067 | // moneypunct_byname |
| 5063 | 5068 | |
| ... | ... | @@ -5428,7 +5433,7 @@ void moneypunct_byname<char, false>::init(const char* nm) { |
| 5428 | 5433 | if (!loc) |
| 5429 | 5434 | __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); |
| 5430 | 5435 | |
| 5431 | lconv* lc = __libcpp_localeconv_l(loc.get()); | |
| 5436 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); | |
| 5432 | 5437 | if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) |
| 5433 | 5438 | __decimal_point_ = base::do_decimal_point(); |
| 5434 | 5439 | if (!checked_string_to_char_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get())) |
| ... | ... | @@ -5463,7 +5468,7 @@ void moneypunct_byname<char, true>::init(const char* nm) { |
| 5463 | 5468 | if (!loc) |
| 5464 | 5469 | __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); |
| 5465 | 5470 | |
| 5466 | lconv* lc = __libcpp_localeconv_l(loc.get()); | |
| 5471 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); | |
| 5467 | 5472 | if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) |
| 5468 | 5473 | __decimal_point_ = base::do_decimal_point(); |
| 5469 | 5474 | if (!checked_string_to_char_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get())) |
| ... | ... | @@ -5511,14 +5516,14 @@ void moneypunct_byname<char, true>::init(const char* nm) { |
| 5511 | 5516 | #endif // !_LIBCPP_MSVCRT |
| 5512 | 5517 | } |
| 5513 | 5518 | |
| 5514 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5519 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 5515 | 5520 | template <> |
| 5516 | 5521 | void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5517 | 5522 | typedef moneypunct<wchar_t, false> base; |
| 5518 | 5523 | __libcpp_unique_locale loc(nm); |
| 5519 | 5524 | if (!loc) |
| 5520 | 5525 | __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); |
| 5521 | lconv* lc = __libcpp_localeconv_l(loc.get()); | |
| 5526 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); | |
| 5522 | 5527 | if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) |
| 5523 | 5528 | __decimal_point_ = base::do_decimal_point(); |
| 5524 | 5529 | if (!checked_string_to_wchar_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get())) |
| ... | ... | @@ -5527,7 +5532,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5527 | 5532 | wchar_t wbuf[100]; |
| 5528 | 5533 | mbstate_t mb = {0}; |
| 5529 | 5534 | const char* bb = lc->currency_symbol; |
| 5530 | size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5535 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5531 | 5536 | if (j == size_t(-1)) |
| 5532 | 5537 | __throw_runtime_error("locale not supported"); |
| 5533 | 5538 | wchar_t* wbe = wbuf + j; |
| ... | ... | @@ -5541,7 +5546,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5541 | 5546 | else { |
| 5542 | 5547 | mb = mbstate_t(); |
| 5543 | 5548 | bb = lc->positive_sign; |
| 5544 | j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5549 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5545 | 5550 | if (j == size_t(-1)) |
| 5546 | 5551 | __throw_runtime_error("locale not supported"); |
| 5547 | 5552 | wbe = wbuf + j; |
| ... | ... | @@ -5552,7 +5557,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) { |
| 5552 | 5557 | else { |
| 5553 | 5558 | mb = mbstate_t(); |
| 5554 | 5559 | bb = lc->negative_sign; |
| 5555 | j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5560 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5556 | 5561 | if (j == size_t(-1)) |
| 5557 | 5562 | __throw_runtime_error("locale not supported"); |
| 5558 | 5563 | wbe = wbuf + j; |
| ... | ... | @@ -5573,7 +5578,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5573 | 5578 | if (!loc) |
| 5574 | 5579 | __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); |
| 5575 | 5580 | |
| 5576 | lconv* lc = __libcpp_localeconv_l(loc.get()); | |
| 5581 | __locale::__lconv_t* lc = __locale::__localeconv(loc.get()); | |
| 5577 | 5582 | if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get())) |
| 5578 | 5583 | __decimal_point_ = base::do_decimal_point(); |
| 5579 | 5584 | if (!checked_string_to_wchar_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get())) |
| ... | ... | @@ -5582,7 +5587,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5582 | 5587 | wchar_t wbuf[100]; |
| 5583 | 5588 | mbstate_t mb = {0}; |
| 5584 | 5589 | const char* bb = lc->int_curr_symbol; |
| 5585 | size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5590 | size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5586 | 5591 | if (j == size_t(-1)) |
| 5587 | 5592 | __throw_runtime_error("locale not supported"); |
| 5588 | 5593 | wchar_t* wbe = wbuf + j; |
| ... | ... | @@ -5600,7 +5605,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5600 | 5605 | else { |
| 5601 | 5606 | mb = mbstate_t(); |
| 5602 | 5607 | bb = lc->positive_sign; |
| 5603 | j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5608 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5604 | 5609 | if (j == size_t(-1)) |
| 5605 | 5610 | __throw_runtime_error("locale not supported"); |
| 5606 | 5611 | wbe = wbuf + j; |
| ... | ... | @@ -5615,7 +5620,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5615 | 5620 | else { |
| 5616 | 5621 | mb = mbstate_t(); |
| 5617 | 5622 | bb = lc->negative_sign; |
| 5618 | j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5623 | j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get()); | |
| 5619 | 5624 | if (j == size_t(-1)) |
| 5620 | 5625 | __throw_runtime_error("locale not supported"); |
| 5621 | 5626 | wbe = wbuf + j; |
| ... | ... | @@ -5641,7 +5646,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) { |
| 5641 | 5646 | __neg_format_, __curr_symbol_, true, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn, L' '); |
| 5642 | 5647 | # endif // !_LIBCPP_MSVCRT |
| 5643 | 5648 | } |
| 5644 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5649 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 5645 | 5650 | |
| 5646 | 5651 | void __do_nothing(void*) {} |
| 5647 | 5652 | |
| ... | ... | @@ -5707,7 +5712,7 @@ template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_ |
| 5707 | 5712 | codecvt_byname<char16_t, char, mbstate_t>; |
| 5708 | 5713 | template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
| 5709 | 5714 | codecvt_byname<char32_t, char, mbstate_t>; |
| 5710 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 5715 | #if _LIBCPP_HAS_CHAR8_T | |
| 5711 | 5716 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; |
| 5712 | 5717 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; |
| 5713 | 5718 | #endif |
lib/libcxx/src/memory.cpp+3-3| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | |
| 14 | 14 | #include <memory> |
| 15 | 15 | |
| 16 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 16 | #if _LIBCPP_HAS_THREADS | |
| 17 | 17 | # include <mutex> |
| 18 | 18 | # include <thread> |
| 19 | 19 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) |
| ... | ... | @@ -96,7 +96,7 @@ __shared_weak_count* __shared_weak_count::lock() noexcept { |
| 96 | 96 | |
| 97 | 97 | const void* __shared_weak_count::__get_deleter(const type_info&) const noexcept { return nullptr; } |
| 98 | 98 | |
| 99 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 99 | #if _LIBCPP_HAS_THREADS | |
| 100 | 100 | |
| 101 | 101 | static constexpr std::size_t __sp_mut_count = 32; |
| 102 | 102 | static constinit __libcpp_mutex_t mut_back[__sp_mut_count] = { |
| ... | ... | @@ -128,7 +128,7 @@ __sp_mut& __get_sp_mut(const void* p) { |
| 128 | 128 | return muts[hash<const void*>()(p) & (__sp_mut_count - 1)]; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 131 | #endif // _LIBCPP_HAS_THREADS | |
| 132 | 132 | |
| 133 | 133 | void* align(size_t alignment, size_t size, void*& ptr, size_t& space) { |
| 134 | 134 | void* r = nullptr; |
lib/libcxx/src/memory_resource.cpp+32-30| ... | ... | @@ -6,12 +6,13 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include <cstddef> | |
| 9 | 10 | #include <memory> |
| 10 | 11 | #include <memory_resource> |
| 11 | 12 | |
| 12 | #ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER | |
| 13 | #if _LIBCPP_HAS_ATOMIC_HEADER | |
| 13 | 14 | # include <atomic> |
| 14 | #elif !defined(_LIBCPP_HAS_NO_THREADS) | |
| 15 | #elif _LIBCPP_HAS_THREADS | |
| 15 | 16 | # include <mutex> |
| 16 | 17 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) |
| 17 | 18 | # pragma comment(lib, "pthread") |
| ... | ... | @@ -28,7 +29,7 @@ memory_resource::~memory_resource() = default; |
| 28 | 29 | |
| 29 | 30 | // new_delete_resource() |
| 30 | 31 | |
| 31 | #ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION | |
| 32 | #if !_LIBCPP_HAS_ALIGNED_ALLOCATION | |
| 32 | 33 | static bool is_aligned_to(void* ptr, size_t align) { |
| 33 | 34 | void* p2 = ptr; |
| 34 | 35 | size_t space = 1; |
| ... | ... | @@ -39,21 +40,23 @@ static bool is_aligned_to(void* ptr, size_t align) { |
| 39 | 40 | |
| 40 | 41 | class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory_resource { |
| 41 | 42 | void* do_allocate(size_t bytes, size_t align) override { |
| 42 | #ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION | |
| 43 | return std::__libcpp_allocate(bytes, align); | |
| 43 | #if _LIBCPP_HAS_ALIGNED_ALLOCATION | |
| 44 | return std::__libcpp_allocate<std::byte>(__element_count(bytes), align); | |
| 44 | 45 | #else |
| 45 | 46 | if (bytes == 0) |
| 46 | 47 | bytes = 1; |
| 47 | void* result = std::__libcpp_allocate(bytes, align); | |
| 48 | std::byte* result = std::__libcpp_allocate<std::byte>(__element_count(bytes), align); | |
| 48 | 49 | if (!is_aligned_to(result, align)) { |
| 49 | std::__libcpp_deallocate(result, bytes, align); | |
| 50 | std::__libcpp_deallocate<std::byte>(result, __element_count(bytes), align); | |
| 50 | 51 | __throw_bad_alloc(); |
| 51 | 52 | } |
| 52 | 53 | return result; |
| 53 | 54 | #endif |
| 54 | 55 | } |
| 55 | 56 | |
| 56 | void do_deallocate(void* p, size_t bytes, size_t align) override { std::__libcpp_deallocate(p, bytes, align); } | |
| 57 | void do_deallocate(void* p, size_t bytes, size_t align) override { | |
| 58 | std::__libcpp_deallocate<std::byte>(static_cast<std::byte*>(p), __element_count(bytes), align); | |
| 59 | } | |
| 57 | 60 | |
| 58 | 61 | bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; } |
| 59 | 62 | }; |
| ... | ... | @@ -82,7 +85,7 @@ union ResourceInitHelper { |
| 82 | 85 | // attribute with a value that's reserved for the implementation (we're the implementation). |
| 83 | 86 | #include "memory_resource_init_helper.h" |
| 84 | 87 | |
| 85 | } // end namespace | |
| 88 | } // namespace | |
| 86 | 89 | |
| 87 | 90 | memory_resource* new_delete_resource() noexcept { return &res_init.resources.new_delete_res; } |
| 88 | 91 | |
| ... | ... | @@ -91,7 +94,7 @@ memory_resource* null_memory_resource() noexcept { return &res_init.resources.nu |
| 91 | 94 | // default_memory_resource() |
| 92 | 95 | |
| 93 | 96 | static memory_resource* __default_memory_resource(bool set = false, memory_resource* new_res = nullptr) noexcept { |
| 94 | #ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER | |
| 97 | #if _LIBCPP_HAS_ATOMIC_HEADER | |
| 95 | 98 | static constinit atomic<memory_resource*> __res{&res_init.resources.new_delete_res}; |
| 96 | 99 | if (set) { |
| 97 | 100 | new_res = new_res ? new_res : new_delete_resource(); |
| ... | ... | @@ -100,7 +103,7 @@ static memory_resource* __default_memory_resource(bool set = false, memory_resou |
| 100 | 103 | } else { |
| 101 | 104 | return std::atomic_load_explicit(&__res, memory_order_acquire); |
| 102 | 105 | } |
| 103 | #elif !defined(_LIBCPP_HAS_NO_THREADS) | |
| 106 | #elif _LIBCPP_HAS_THREADS | |
| 104 | 107 | static constinit memory_resource* res = &res_init.resources.new_delete_res; |
| 105 | 108 | static mutex res_lock; |
| 106 | 109 | if (set) { |
| ... | ... | @@ -412,6 +415,8 @@ bool synchronized_pool_resource::do_is_equal(const memory_resource& other) const |
| 412 | 415 | |
| 413 | 416 | // 23.12.6, mem.res.monotonic.buffer |
| 414 | 417 | |
| 418 | constexpr size_t __default_growth_factor = 2; | |
| 419 | ||
| 415 | 420 | static void* align_down(size_t align, size_t size, void*& ptr, size_t& space) { |
| 416 | 421 | if (size > space) |
| 417 | 422 | return nullptr; |
| ... | ... | @@ -428,23 +433,20 @@ static void* align_down(size_t align, size_t size, void*& ptr, size_t& space) { |
| 428 | 433 | return ptr; |
| 429 | 434 | } |
| 430 | 435 | |
| 431 | void* monotonic_buffer_resource::__initial_descriptor::__try_allocate_from_chunk(size_t bytes, size_t align) { | |
| 432 | if (!__cur_) | |
| 433 | return nullptr; | |
| 434 | void* new_ptr = static_cast<void*>(__cur_); | |
| 435 | size_t new_capacity = (__cur_ - __start_); | |
| 436 | void* aligned_ptr = align_down(align, bytes, new_ptr, new_capacity); | |
| 437 | if (aligned_ptr != nullptr) | |
| 438 | __cur_ = static_cast<char*>(new_ptr); | |
| 439 | return aligned_ptr; | |
| 440 | } | |
| 441 | ||
| 442 | void* monotonic_buffer_resource::__chunk_footer::__try_allocate_from_chunk(size_t bytes, size_t align) { | |
| 443 | void* new_ptr = static_cast<void*>(__cur_); | |
| 444 | size_t new_capacity = (__cur_ - __start_); | |
| 436 | template <bool is_initial, typename Chunk> | |
| 437 | void* __try_allocate_from_chunk(Chunk& self, size_t bytes, size_t align) { | |
| 438 | if constexpr (is_initial) { | |
| 439 | // only for __initial_descriptor. | |
| 440 | // if __initial_descriptor.__cur_ equals nullptr, means no available buffer given when ctor. | |
| 441 | // here we just return nullptr, let the caller do the next handling. | |
| 442 | if (!self.__cur_) | |
| 443 | return nullptr; | |
| 444 | } | |
| 445 | void* new_ptr = static_cast<void*>(self.__cur_); | |
| 446 | size_t new_capacity = (self.__cur_ - self.__start_); | |
| 445 | 447 | void* aligned_ptr = align_down(align, bytes, new_ptr, new_capacity); |
| 446 | 448 | if (aligned_ptr != nullptr) |
| 447 | __cur_ = static_cast<char*>(new_ptr); | |
| 449 | self.__cur_ = static_cast<char*>(new_ptr); | |
| 448 | 450 | return aligned_ptr; |
| 449 | 451 | } |
| 450 | 452 | |
| ... | ... | @@ -461,10 +463,10 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) { |
| 461 | 463 | return roundup(newsize, footer_align) + footer_size; |
| 462 | 464 | }; |
| 463 | 465 | |
| 464 | if (void* result = __initial_.__try_allocate_from_chunk(bytes, align)) | |
| 466 | if (void* result = __try_allocate_from_chunk<true, __initial_descriptor>(__initial_, bytes, align)) | |
| 465 | 467 | return result; |
| 466 | 468 | if (__chunks_ != nullptr) { |
| 467 | if (void* result = __chunks_->__try_allocate_from_chunk(bytes, align)) | |
| 469 | if (void* result = __try_allocate_from_chunk<false, __chunk_footer>(*__chunks_, bytes, align)) | |
| 468 | 470 | return result; |
| 469 | 471 | } |
| 470 | 472 | |
| ... | ... | @@ -477,7 +479,7 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) { |
| 477 | 479 | size_t previous_capacity = previous_allocation_size(); |
| 478 | 480 | |
| 479 | 481 | if (aligned_capacity <= previous_capacity) { |
| 480 | size_t newsize = 2 * (previous_capacity - footer_size); | |
| 482 | size_t newsize = __default_growth_factor * (previous_capacity - footer_size); | |
| 481 | 483 | aligned_capacity = roundup(newsize, footer_align) + footer_size; |
| 482 | 484 | } |
| 483 | 485 | |
| ... | ... | @@ -490,7 +492,7 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) { |
| 490 | 492 | footer->__align_ = align; |
| 491 | 493 | __chunks_ = footer; |
| 492 | 494 | |
| 493 | return __chunks_->__try_allocate_from_chunk(bytes, align); | |
| 495 | return __try_allocate_from_chunk<false, __chunk_footer>(*__chunks_, bytes, align); | |
| 494 | 496 | } |
| 495 | 497 | |
| 496 | 498 | } // namespace pmr |
lib/libcxx/src/mutex_destructor.cpp+1-1| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | #include <__config> |
| 20 | 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 || !_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION | |
| 23 | 23 | # define NEEDS_MUTEX_DESTRUCTOR |
| 24 | 24 | #endif |
| 25 | 25 |
lib/libcxx/src/new.cpp+6-6| ... | ... | @@ -51,7 +51,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { |
| 54 | # ifdef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 54 | # if !_LIBCPP_HAS_EXCEPTIONS | |
| 55 | 55 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION |
| 56 | 56 | _LIBCPP_ASSERT_SHIM( |
| 57 | 57 | !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)), |
| ... | ... | @@ -79,7 +79,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](s |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | _LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { |
| 82 | # ifdef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 82 | # if !_LIBCPP_HAS_EXCEPTIONS | |
| 83 | 83 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION |
| 84 | 84 | _LIBCPP_ASSERT_SHIM( |
| 85 | 85 | !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new[])), |
| ... | ... | @@ -114,7 +114,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept { |
| 114 | 114 | |
| 115 | 115 | _LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); } |
| 116 | 116 | |
| 117 | # if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) | |
| 117 | # if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION | |
| 118 | 118 | |
| 119 | 119 | static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) { |
| 120 | 120 | if (size == 0) |
| ... | ... | @@ -145,7 +145,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { |
| 148 | # ifdef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 148 | # if !_LIBCPP_HAS_EXCEPTIONS | |
| 149 | 149 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION |
| 150 | 150 | _LIBCPP_ASSERT_SHIM( |
| 151 | 151 | !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new)), |
| ... | ... | @@ -174,7 +174,7 @@ operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { |
| 177 | # ifdef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 177 | # if !_LIBCPP_HAS_EXCEPTIONS | |
| 178 | 178 | # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION |
| 179 | 179 | _LIBCPP_ASSERT_SHIM( |
| 180 | 180 | !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new[])), |
| ... | ... | @@ -220,7 +220,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignmen |
| 220 | 220 | ::operator delete[](ptr, alignment); |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | # endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 223 | # endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION | |
| 224 | 224 | // ------------------ END COPY ------------------ |
| 225 | 225 | |
| 226 | 226 | #endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME |
lib/libcxx/src/new_helpers.cpp+1-1| ... | ... | @@ -18,7 +18,7 @@ const nothrow_t nothrow{}; |
| 18 | 18 | #ifndef LIBSTDCXX |
| 19 | 19 | |
| 20 | 20 | void __throw_bad_alloc() { |
| 21 | # ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 21 | # if _LIBCPP_HAS_EXCEPTIONS | |
| 22 | 22 | throw bad_alloc(); |
| 23 | 23 | # else |
| 24 | 24 | _LIBCPP_VERBOSE_ABORT("bad_alloc was thrown in -fno-exceptions mode"); |
lib/libcxx/src/optional.cpp+1-1| ... | ... | @@ -17,7 +17,7 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac |
| 17 | 17 | |
| 18 | 18 | } // namespace std |
| 19 | 19 | |
| 20 | #include <experimental/__config> | |
| 20 | #include <__config> | |
| 21 | 21 | |
| 22 | 22 | // Preserve std::experimental::bad_optional_access for ABI compatibility |
| 23 | 23 | // Even though it no longer exists in a header file |
lib/libcxx/src/ostream.cpp+4-4| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | 9 | #include <__config> |
| 10 | #ifndef _LIBCPP_HAS_NO_FILESYSTEM | |
| 10 | #if _LIBCPP_HAS_FILESYSTEM | |
| 11 | 11 | # include <fstream> |
| 12 | 12 | #endif |
| 13 | 13 | #include <ostream> |
| ... | ... | @@ -24,16 +24,16 @@ _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) { |
| 24 | 24 | // Returning a nullptr means the stream is not considered a terminal and the |
| 25 | 25 | // special terminal handling is not done. The terminal handling is mainly of |
| 26 | 26 | // importance on Windows. |
| 27 | #ifndef _LIBCPP_HAS_NO_RTTI | |
| 27 | #if _LIBCPP_HAS_RTTI | |
| 28 | 28 | auto* __rdbuf = __os.rdbuf(); |
| 29 | # ifndef _LIBCPP_HAS_NO_FILESYSTEM | |
| 29 | # if _LIBCPP_HAS_FILESYSTEM | |
| 30 | 30 | if (auto* __buffer = dynamic_cast<filebuf*>(__rdbuf)) |
| 31 | 31 | return __buffer->__file_; |
| 32 | 32 | # endif |
| 33 | 33 | |
| 34 | 34 | if (auto* __buffer = dynamic_cast<__stdoutbuf<char>*>(__rdbuf)) |
| 35 | 35 | return __buffer->__file_; |
| 36 | #endif // _LIBCPP_HAS_NO_RTTI | |
| 36 | #endif // _LIBCPP_HAS_RTTI | |
| 37 | 37 | |
| 38 | 38 | return nullptr; |
| 39 | 39 | } |
lib/libcxx/src/print.cpp+3-3| ... | ... | @@ -42,7 +42,7 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream) { |
| 42 | 42 | return GetConsoleMode(reinterpret_cast<void*>(__handle), &__mode); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 45 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 46 | 46 | _LIBCPP_EXPORTED_FROM_ABI void |
| 47 | 47 | __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wstring_view __view) { |
| 48 | 48 | // https://learn.microsoft.com/en-us/windows/console/writeconsole |
| ... | ... | @@ -51,10 +51,10 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst |
| 51 | 51 | __view.size(), |
| 52 | 52 | nullptr, |
| 53 | 53 | nullptr) == 0) { |
| 54 | __throw_system_error(filesystem::detail::make_windows_error(GetLastError()), "failed to write formatted output"); | |
| 54 | __throw_system_error(filesystem::detail::get_last_error(), "failed to write formatted output"); | |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 57 | # endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 58 | 58 | |
| 59 | 59 | #elif __has_include(<unistd.h>) // !_LIBCPP_WIN32API |
| 60 | 60 |
lib/libcxx/src/random.cpp+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | # define _CRT_RAND_S |
| 14 | 14 | #endif // defined(_LIBCPP_USING_WIN32_RANDOM) |
| 15 | 15 | |
| 16 | #include <__system_error/system_error.h> | |
| 16 | #include <__system_error/throw_system_error.h> | |
| 17 | 17 | #include <limits> |
| 18 | 18 | #include <random> |
| 19 | 19 |
lib/libcxx/src/random_shuffle.cpp+4-4| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | #include <algorithm> |
| 10 | 10 | #include <random> |
| 11 | 11 | |
| 12 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 12 | #if _LIBCPP_HAS_THREADS | |
| 13 | 13 | # include <mutex> |
| 14 | 14 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) |
| 15 | 15 | # pragma comment(lib, "pthread") |
| ... | ... | @@ -18,13 +18,13 @@ |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 21 | #if _LIBCPP_HAS_THREADS | |
| 22 | 22 | static constinit __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER; |
| 23 | 23 | #endif |
| 24 | 24 | unsigned __rs_default::__c_ = 0; |
| 25 | 25 | |
| 26 | 26 | __rs_default::__rs_default() { |
| 27 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 27 | #if _LIBCPP_HAS_THREADS | |
| 28 | 28 | __libcpp_mutex_lock(&__rs_mut); |
| 29 | 29 | #endif |
| 30 | 30 | __c_ = 1; |
| ... | ... | @@ -33,7 +33,7 @@ __rs_default::__rs_default() { |
| 33 | 33 | __rs_default::__rs_default(const __rs_default&) { ++__c_; } |
| 34 | 34 | |
| 35 | 35 | __rs_default::~__rs_default() { |
| 36 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 36 | #if _LIBCPP_HAS_THREADS | |
| 37 | 37 | if (--__c_ == 0) |
| 38 | 38 | __libcpp_mutex_unlock(&__rs_mut); |
| 39 | 39 | #else |
lib/libcxx/src/regex.cpp+2-2| ... | ... | @@ -323,8 +323,8 @@ const classnames ClassNames[] = { |
| 323 | 323 | {"xdigit", ctype_base::xdigit}}; |
| 324 | 324 | |
| 325 | 325 | struct use_strcmp { |
| 326 | bool operator()(const collationnames& x, const char* y) { return strcmp(x.elem_, y) < 0; } | |
| 327 | bool operator()(const classnames& x, const char* y) { return strcmp(x.elem_, y) < 0; } | |
| 326 | bool operator()(const collationnames& x, const char* y) const { return strcmp(x.elem_, y) < 0; } | |
| 327 | bool operator()(const classnames& x, const char* y) const { return strcmp(x.elem_, y) < 0; } | |
| 328 | 328 | }; |
| 329 | 329 | |
| 330 | 330 | } // namespace |
lib/libcxx/src/ryu/d2s.cpp+1-1| ... | ... | @@ -478,7 +478,7 @@ struct __floating_decimal_64 { |
| 478 | 478 | 36893488u, 7378697u, 1475739u, 295147u, 59029u, 11805u, 2361u, 472u, 94u, 18u, 3u }; |
| 479 | 479 | |
| 480 | 480 | unsigned long _Trailing_zero_bits; |
| 481 | #ifdef _LIBCPP_HAS_BITSCAN64 | |
| 481 | #if _LIBCPP_HAS_BITSCAN64 | |
| 482 | 482 | (void) _BitScanForward64(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero |
| 483 | 483 | #else // ^^^ 64-bit ^^^ / vvv 32-bit vvv |
| 484 | 484 | const uint32_t _Low_mantissa = static_cast<uint32_t>(__v.__mantissa); |
lib/libcxx/src/shared_mutex.cpp+11-5| ... | ... | @@ -38,8 +38,10 @@ bool __shared_mutex_base::try_lock() { |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | void __shared_mutex_base::unlock() { |
| 41 | lock_guard<mutex> _(__mut_); | |
| 42 | __state_ = 0; | |
| 41 | { | |
| 42 | lock_guard<mutex> _(__mut_); | |
| 43 | __state_ = 0; | |
| 44 | } | |
| 43 | 45 | __gate1_.notify_all(); |
| 44 | 46 | } |
| 45 | 47 | |
| ... | ... | @@ -67,16 +69,20 @@ bool __shared_mutex_base::try_lock_shared() { |
| 67 | 69 | } |
| 68 | 70 | |
| 69 | 71 | void __shared_mutex_base::unlock_shared() { |
| 70 | lock_guard<mutex> _(__mut_); | |
| 72 | unique_lock<mutex> lk(__mut_); | |
| 71 | 73 | unsigned num_readers = (__state_ & __n_readers_) - 1; |
| 72 | 74 | __state_ &= ~__n_readers_; |
| 73 | 75 | __state_ |= num_readers; |
| 74 | 76 | if (__state_ & __write_entered_) { |
| 75 | if (num_readers == 0) | |
| 77 | if (num_readers == 0) { | |
| 78 | lk.unlock(); | |
| 76 | 79 | __gate2_.notify_one(); |
| 80 | } | |
| 77 | 81 | } else { |
| 78 | if (num_readers == __n_readers_ - 1) | |
| 82 | if (num_readers == __n_readers_ - 1) { | |
| 83 | lk.unlock(); | |
| 79 | 84 | __gate1_.notify_one(); |
| 85 | } | |
| 80 | 86 | } |
| 81 | 87 | } |
| 82 | 88 |
lib/libcxx/src/std_stream.h+3-3| ... | ... | @@ -106,7 +106,7 @@ inline bool __do_getc(FILE* __fp, char* __pbuf) { |
| 106 | 106 | *__pbuf = static_cast<char>(__c); |
| 107 | 107 | return true; |
| 108 | 108 | } |
| 109 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 109 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 110 | 110 | inline bool __do_getc(FILE* __fp, wchar_t* __pbuf) { |
| 111 | 111 | wint_t __c = getwc(__fp); |
| 112 | 112 | if (__c == WEOF) |
| ... | ... | @@ -121,7 +121,7 @@ inline bool __do_ungetc(int __c, FILE* __fp, char __dummy) { |
| 121 | 121 | return false; |
| 122 | 122 | return true; |
| 123 | 123 | } |
| 124 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 124 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 125 | 125 | inline bool __do_ungetc(std::wint_t __c, FILE* __fp, wchar_t __dummy) { |
| 126 | 126 | if (ungetwc(__c, __fp) == WEOF) |
| 127 | 127 | return false; |
| ... | ... | @@ -293,7 +293,7 @@ inline bool __do_fputc(char __c, FILE* __fp) { |
| 293 | 293 | return false; |
| 294 | 294 | return true; |
| 295 | 295 | } |
| 296 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 296 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 297 | 297 | inline bool __do_fputc(wchar_t __c, FILE* __fp) { |
| 298 | 298 | // fputwc works regardless of wide/narrow mode of stdout, while |
| 299 | 299 | // fwrite of wchar_t only works if the stream actually has been set |
lib/libcxx/src/stdexcept.cpp+2-2| ... | ... | @@ -19,8 +19,8 @@ |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | _LIBCPP_NORETURN void __throw_runtime_error(const char* msg) { | |
| 23 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 22 | void __throw_runtime_error(const char* msg) { | |
| 23 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 24 | 24 | throw runtime_error(msg); |
| 25 | 25 | #else |
| 26 | 26 | _LIBCPP_VERBOSE_ABORT("runtime_error was thrown in -fno-exceptions mode with message \"%s\"", msg); |
lib/libcxx/src/string.cpp+15-15| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <stdexcept> |
| 15 | 15 | #include <string> |
| 16 | 16 | |
| 17 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 17 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 18 | 18 | # include <cwchar> |
| 19 | 19 | #endif |
| 20 | 20 | |
| ... | ... | @@ -28,8 +28,8 @@ struct __basic_string_common; |
| 28 | 28 | // The struct isn't declared anymore in the headers. It's only here for ABI compatibility. |
| 29 | 29 | template <> |
| 30 | 30 | struct __basic_string_common<true> { |
| 31 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; | |
| 32 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; | |
| 31 | [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; | |
| 32 | [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; | |
| 33 | 33 | }; |
| 34 | 34 | |
| 35 | 35 | void __basic_string_common<true>::__throw_length_error() const { std::__throw_length_error("basic_string"); } |
| ... | ... | @@ -40,12 +40,12 @@ void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_ou |
| 40 | 40 | #define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__; |
| 41 | 41 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
| 42 | 42 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char) |
| 43 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 43 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 44 | 44 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t) |
| 45 | 45 | # endif |
| 46 | 46 | #else |
| 47 | 47 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char) |
| 48 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 48 | # if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 49 | 49 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t) |
| 50 | 50 | # endif |
| 51 | 51 | #endif |
| ... | ... | @@ -115,7 +115,7 @@ inline unsigned long long as_integer(const string& func, const string& s, size_t |
| 115 | 115 | return as_integer_helper<unsigned long long>(func, s, idx, base, strtoull); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 118 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 119 | 119 | // wstring |
| 120 | 120 | template <> |
| 121 | 121 | inline int as_integer(const string& func, const wstring& s, size_t* idx, int base) { |
| ... | ... | @@ -145,7 +145,7 @@ template <> |
| 145 | 145 | inline unsigned long long as_integer(const string& func, const wstring& s, size_t* idx, int base) { |
| 146 | 146 | return as_integer_helper<unsigned long long>(func, s, idx, base, wcstoull); |
| 147 | 147 | } |
| 148 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 148 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 149 | 149 | |
| 150 | 150 | // as_float |
| 151 | 151 | |
| ... | ... | @@ -184,7 +184,7 @@ inline long double as_float(const string& func, const string& s, size_t* idx) { |
| 184 | 184 | return as_float_helper<long double>(func, s, idx, strtold); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 187 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 188 | 188 | template <> |
| 189 | 189 | inline float as_float(const string& func, const wstring& s, size_t* idx) { |
| 190 | 190 | return as_float_helper<float>(func, s, idx, wcstof); |
| ... | ... | @@ -199,7 +199,7 @@ template <> |
| 199 | 199 | inline long double as_float(const string& func, const wstring& s, size_t* idx) { |
| 200 | 200 | return as_float_helper<long double>(func, s, idx, wcstold); |
| 201 | 201 | } |
| 202 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 202 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 203 | 203 | |
| 204 | 204 | } // unnamed namespace |
| 205 | 205 | |
| ... | ... | @@ -223,7 +223,7 @@ double stod(const string& str, size_t* idx) { return as_float<double>("stod", st |
| 223 | 223 | |
| 224 | 224 | long double stold(const string& str, size_t* idx) { return as_float<long double>("stold", str, idx); } |
| 225 | 225 | |
| 226 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 226 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 227 | 227 | int stoi(const wstring& str, size_t* idx, int base) { return as_integer<int>("stoi", str, idx, base); } |
| 228 | 228 | |
| 229 | 229 | long stol(const wstring& str, size_t* idx, int base) { return as_integer<long>("stol", str, idx, base); } |
| ... | ... | @@ -243,7 +243,7 @@ float stof(const wstring& str, size_t* idx) { return as_float<float>("stof", str |
| 243 | 243 | double stod(const wstring& str, size_t* idx) { return as_float<double>("stod", str, idx); } |
| 244 | 244 | |
| 245 | 245 | long double stold(const wstring& str, size_t* idx) { return as_float<long double>("stold", str, idx); } |
| 246 | #endif // !_LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 246 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 247 | 247 | |
| 248 | 248 | // to_string |
| 249 | 249 | |
| ... | ... | @@ -283,7 +283,7 @@ struct initial_string<string> { |
| 283 | 283 | } |
| 284 | 284 | }; |
| 285 | 285 | |
| 286 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 286 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 287 | 287 | template <> |
| 288 | 288 | struct initial_string<wstring> { |
| 289 | 289 | wstring operator()() const { |
| ... | ... | @@ -302,7 +302,7 @@ inline wide_printf get_swprintf() { |
| 302 | 302 | return static_cast<int(__cdecl*)(wchar_t* __restrict, size_t, const wchar_t* __restrict, ...)>(_snwprintf); |
| 303 | 303 | # endif |
| 304 | 304 | } |
| 305 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 305 | #endif // _LIBCPP_HAS_WIDE_CHARACTERS | |
| 306 | 306 | |
| 307 | 307 | template <typename S, typename V> |
| 308 | 308 | S i_to_string(V v) { |
| ... | ... | @@ -325,7 +325,7 @@ string to_string(unsigned val) { return i_to_string< string>(val); } |
| 325 | 325 | string to_string(unsigned long val) { return i_to_string< string>(val); } |
| 326 | 326 | string to_string(unsigned long long val) { return i_to_string< string>(val); } |
| 327 | 327 | |
| 328 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 328 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 329 | 329 | wstring to_wstring(int val) { return i_to_string<wstring>(val); } |
| 330 | 330 | wstring to_wstring(long val) { return i_to_string<wstring>(val); } |
| 331 | 331 | wstring to_wstring(long long val) { return i_to_string<wstring>(val); } |
| ... | ... | @@ -338,7 +338,7 @@ string to_string(float val) { return as_string(snprintf, initial_string< string> |
| 338 | 338 | string to_string(double val) { return as_string(snprintf, initial_string< string>()(), "%f", val); } |
| 339 | 339 | string to_string(long double val) { return as_string(snprintf, initial_string< string>()(), "%Lf", val); } |
| 340 | 340 | |
| 341 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 341 | #if _LIBCPP_HAS_WIDE_CHARACTERS | |
| 342 | 342 | wstring to_wstring(float val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); } |
| 343 | 343 | wstring to_wstring(double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); } |
| 344 | 344 | wstring to_wstring(long double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%Lf", val); } |
lib/libcxx/src/support/ibm/mbsnrtowcs.cpp+2-2| ... | ... | @@ -48,7 +48,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs( |
| 48 | 48 | size_t dest_remaining = max_dest_chars - dest_converted; |
| 49 | 49 | |
| 50 | 50 | if (dst == nullptr) { |
| 51 | result = mbrtowc(NULL, *src + source_converted, source_remaining, ps); | |
| 51 | result = mbrtowc(nullptr, *src + source_converted, source_remaining, ps); | |
| 52 | 52 | } else if (dest_remaining >= source_remaining) { |
| 53 | 53 | // dst has enough space to translate in-place. |
| 54 | 54 | result = mbrtowc(dst + dest_converted, *src + source_converted, source_remaining, ps); |
| ... | ... | @@ -86,7 +86,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs( |
| 86 | 86 | |
| 87 | 87 | if (dst) { |
| 88 | 88 | if (result == terminated_sequence) |
| 89 | *src = NULL; | |
| 89 | *src = nullptr; | |
| 90 | 90 | else |
| 91 | 91 | *src += source_converted; |
| 92 | 92 | } |
lib/libcxx/src/support/ibm/wcsnrtombs.cpp+2-2| ... | ... | @@ -41,7 +41,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs( |
| 41 | 41 | size_t dest_remaining = dst_size_bytes - dest_converted; |
| 42 | 42 | |
| 43 | 43 | if (dst == nullptr) { |
| 44 | result = wcrtomb(NULL, c, ps); | |
| 44 | result = wcrtomb(nullptr, c, ps); | |
| 45 | 45 | } else if (dest_remaining >= static_cast<size_t>(MB_CUR_MAX)) { |
| 46 | 46 | // dst has enough space to translate in-place. |
| 47 | 47 | result = wcrtomb(dst + dest_converted, c, ps); |
| ... | ... | @@ -82,7 +82,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs( |
| 82 | 82 | |
| 83 | 83 | if (c == L'\0') { |
| 84 | 84 | if (dst) |
| 85 | *src = NULL; | |
| 85 | *src = nullptr; | |
| 86 | 86 | return dest_converted; |
| 87 | 87 | } |
| 88 | 88 | } |
lib/libcxx/src/support/ibm/xlocale_zos.cpp+8-8| ... | ... | @@ -20,12 +20,12 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) { |
| 20 | 20 | std::string current_loc_name(setlocale(LC_ALL, 0)); |
| 21 | 21 | |
| 22 | 22 | // Check for errors. |
| 23 | if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == NULL) { | |
| 23 | if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == nullptr) { | |
| 24 | 24 | errno = EINVAL; |
| 25 | 25 | return (locale_t)0; |
| 26 | 26 | } else { |
| 27 | 27 | for (int _Cat = 0; _Cat <= _LC_MAX; ++_Cat) { |
| 28 | if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == NULL) { | |
| 28 | if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == nullptr) { | |
| 29 | 29 | setlocale(LC_ALL, current_loc_name.c_str()); |
| 30 | 30 | errno = EINVAL; |
| 31 | 31 | return (locale_t)0; |
| ... | ... | @@ -74,12 +74,12 @@ locale_t uselocale(locale_t newloc) { |
| 74 | 74 | if (newloc) { |
| 75 | 75 | // Set locales and check for errors. |
| 76 | 76 | bool is_error = |
| 77 | (newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) || | |
| 78 | (newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) || | |
| 79 | (newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) || | |
| 80 | (newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) || | |
| 81 | (newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) || | |
| 82 | (newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL); | |
| 77 | (newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == nullptr) || | |
| 78 | (newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == nullptr) || | |
| 79 | (newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == nullptr) || | |
| 80 | (newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == nullptr) || | |
| 81 | (newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == nullptr) || | |
| 82 | (newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == nullptr); | |
| 83 | 83 | |
| 84 | 84 | if (is_error) { |
| 85 | 85 | setlocale(LC_ALL, current_loc_name.c_str()); |
lib/libcxx/src/support/runtime/exception_fallback.ipp+10-13| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #include <cstdio> | |
| 10 | #include <__verbose_abort> | |
| 11 | 11 | |
| 12 | 12 | namespace std { |
| 13 | 13 | |
| ... | ... | @@ -21,7 +21,7 @@ unexpected_handler set_unexpected(unexpected_handler func) noexcept { |
| 21 | 21 | |
| 22 | 22 | unexpected_handler get_unexpected() noexcept { return __libcpp_atomic_load(&__unexpected_handler); } |
| 23 | 23 | |
| 24 | _LIBCPP_NORETURN void unexpected() { | |
| 24 | [[noreturn]] void unexpected() { | |
| 25 | 25 | (*get_unexpected())(); |
| 26 | 26 | // unexpected handler should not return |
| 27 | 27 | terminate(); |
| ... | ... | @@ -33,29 +33,26 @@ terminate_handler set_terminate(terminate_handler func) noexcept { |
| 33 | 33 | |
| 34 | 34 | terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__terminate_handler); } |
| 35 | 35 | |
| 36 | _LIBCPP_NORETURN void terminate() noexcept { | |
| 37 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 36 | [[noreturn]] void terminate() noexcept { | |
| 37 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 38 | 38 | try { |
| 39 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 39 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 40 | 40 | (*get_terminate())(); |
| 41 | 41 | // handler should not return |
| 42 | fprintf(stderr, "terminate_handler unexpectedly returned\n"); | |
| 43 | ::abort(); | |
| 44 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 42 | __libcpp_verbose_abort("terminate_handler unexpectedly returned\n"); | |
| 43 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 45 | 44 | } catch (...) { |
| 46 | 45 | // handler should not throw exception |
| 47 | fprintf(stderr, "terminate_handler unexpectedly threw an exception\n"); | |
| 48 | ::abort(); | |
| 46 | __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n"); | |
| 49 | 47 | } |
| 50 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 48 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 51 | 49 | } |
| 52 | 50 | |
| 53 | 51 | bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } |
| 54 | 52 | |
| 55 | 53 | int uncaught_exceptions() noexcept { |
| 56 | 54 | #warning uncaught_exception not yet implemented |
| 57 | fprintf(stderr, "uncaught_exceptions not yet implemented\n"); | |
| 58 | ::abort(); | |
| 55 | __libcpp_verbose_abort("uncaught_exceptions not yet implemented\n"); | |
| 59 | 56 | } |
| 60 | 57 | |
| 61 | 58 | exception::~exception() noexcept {} |
lib/libcxx/src/support/runtime/exception_msvc.ipp+9-12| ... | ... | @@ -11,8 +11,7 @@ |
| 11 | 11 | # error this header can only be used when targeting the MSVC ABI |
| 12 | 12 | #endif |
| 13 | 13 | |
| 14 | #include <stdio.h> | |
| 15 | #include <stdlib.h> | |
| 14 | #include <__verbose_abort> | |
| 16 | 15 | |
| 17 | 16 | extern "C" { |
| 18 | 17 | typedef void(__cdecl* terminate_handler)(); |
| ... | ... | @@ -32,7 +31,7 @@ unexpected_handler set_unexpected(unexpected_handler func) noexcept { return ::s |
| 32 | 31 | |
| 33 | 32 | unexpected_handler get_unexpected() noexcept { return ::_get_unexpected(); } |
| 34 | 33 | |
| 35 | _LIBCPP_NORETURN void unexpected() { | |
| 34 | [[noreturn]] void unexpected() { | |
| 36 | 35 | (*get_unexpected())(); |
| 37 | 36 | // unexpected handler should not return |
| 38 | 37 | terminate(); |
| ... | ... | @@ -42,21 +41,19 @@ terminate_handler set_terminate(terminate_handler func) noexcept { return ::set_ |
| 42 | 41 | |
| 43 | 42 | terminate_handler get_terminate() noexcept { return ::_get_terminate(); } |
| 44 | 43 | |
| 45 | _LIBCPP_NORETURN void terminate() noexcept { | |
| 46 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 44 | [[noreturn]] void terminate() noexcept { | |
| 45 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 47 | 46 | try { |
| 48 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 47 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 49 | 48 | (*get_terminate())(); |
| 50 | 49 | // handler should not return |
| 51 | fprintf(stderr, "terminate_handler unexpectedly returned\n"); | |
| 52 | ::abort(); | |
| 53 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 50 | __libcpp_verbose_abort("terminate_handler unexpectedly returned\n"); | |
| 51 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 54 | 52 | } catch (...) { |
| 55 | 53 | // handler should not throw exception |
| 56 | fprintf(stderr, "terminate_handler unexpectedly threw an exception\n"); | |
| 57 | ::abort(); | |
| 54 | __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n"); | |
| 58 | 55 | } |
| 59 | #endif // _LIBCPP_HAS_NO_EXCEPTIONS | |
| 56 | #endif // _LIBCPP_HAS_EXCEPTIONS | |
| 60 | 57 | } |
| 61 | 58 | |
| 62 | 59 | bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } |
lib/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp+2-2| ... | ... | @@ -40,7 +40,7 @@ nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {} |
| 40 | 40 | |
| 41 | 41 | nested_exception::~nested_exception() noexcept {} |
| 42 | 42 | |
| 43 | _LIBCPP_NORETURN void nested_exception::rethrow_nested() const { | |
| 43 | void nested_exception::rethrow_nested() const { | |
| 44 | 44 | if (__ptr_ == nullptr) |
| 45 | 45 | terminate(); |
| 46 | 46 | rethrow_exception(__ptr_); |
| ... | ... | @@ -55,7 +55,7 @@ exception_ptr current_exception() noexcept { |
| 55 | 55 | return ptr; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | _LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { | |
| 58 | void rethrow_exception(exception_ptr p) { | |
| 59 | 59 | __cxa_rethrow_primary_exception(p.__ptr_); |
| 60 | 60 | // if p.__ptr_ is NULL, above returns so we terminate |
| 61 | 61 | terminate(); |
lib/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp+3-3| ... | ... | @@ -31,7 +31,7 @@ struct exception_ptr { |
| 31 | 31 | |
| 32 | 32 | } // namespace __exception_ptr |
| 33 | 33 | |
| 34 | _LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr); | |
| 34 | [[noreturn]] void rethrow_exception(__exception_ptr::exception_ptr); | |
| 35 | 35 | |
| 36 | 36 | exception_ptr::~exception_ptr() noexcept { reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); } |
| 37 | 37 | |
| ... | ... | @@ -55,13 +55,13 @@ exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept |
| 55 | 55 | |
| 56 | 56 | nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {} |
| 57 | 57 | |
| 58 | _LIBCPP_NORETURN void nested_exception::rethrow_nested() const { | |
| 58 | [[noreturn]] void nested_exception::rethrow_nested() const { | |
| 59 | 59 | if (__ptr_ == nullptr) |
| 60 | 60 | terminate(); |
| 61 | 61 | rethrow_exception(__ptr_); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | _LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { | |
| 64 | [[noreturn]] void rethrow_exception(exception_ptr p) { | |
| 65 | 65 | rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p)); |
| 66 | 66 | } |
| 67 | 67 |
lib/libcxx/src/support/runtime/exception_pointer_msvc.ipp+2-2| ... | ... | @@ -61,13 +61,13 @@ exception_ptr current_exception() noexcept { |
| 61 | 61 | return __ret; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | _LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); } | |
| 64 | [[noreturn]] void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); } | |
| 65 | 65 | |
| 66 | 66 | nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {} |
| 67 | 67 | |
| 68 | 68 | nested_exception::~nested_exception() noexcept {} |
| 69 | 69 | |
| 70 | _LIBCPP_NORETURN void nested_exception::rethrow_nested() const { | |
| 70 | [[noreturn]] void nested_exception::rethrow_nested() const { | |
| 71 | 71 | if (__ptr_ == nullptr) |
| 72 | 72 | terminate(); |
| 73 | 73 | rethrow_exception(__ptr_); |
lib/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp+10-18| ... | ... | @@ -7,33 +7,28 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #include <stdio.h> | |
| 11 | #include <stdlib.h> | |
| 10 | #include <__verbose_abort> | |
| 12 | 11 | |
| 13 | 12 | namespace std { |
| 14 | 13 | |
| 15 | 14 | exception_ptr::~exception_ptr() noexcept { |
| 16 | 15 | #warning exception_ptr not yet implemented |
| 17 | fprintf(stderr, "exception_ptr not yet implemented\n"); | |
| 18 | ::abort(); | |
| 16 | __libcpp_verbose_abort("exception_ptr not yet implemented\n"); | |
| 19 | 17 | } |
| 20 | 18 | |
| 21 | 19 | exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) { |
| 22 | 20 | #warning exception_ptr not yet implemented |
| 23 | fprintf(stderr, "exception_ptr not yet implemented\n"); | |
| 24 | ::abort(); | |
| 21 | __libcpp_verbose_abort("exception_ptr not yet implemented\n"); | |
| 25 | 22 | } |
| 26 | 23 | |
| 27 | 24 | exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept { |
| 28 | 25 | #warning exception_ptr not yet implemented |
| 29 | fprintf(stderr, "exception_ptr not yet implemented\n"); | |
| 30 | ::abort(); | |
| 26 | __libcpp_verbose_abort("exception_ptr not yet implemented\n"); | |
| 31 | 27 | } |
| 32 | 28 | |
| 33 | 29 | exception_ptr exception_ptr::__from_native_exception_pointer(void *__e) noexcept { |
| 34 | 30 | #warning exception_ptr not yet implemented |
| 35 | fprintf(stderr, "exception_ptr not yet implemented\n"); | |
| 36 | ::abort(); | |
| 31 | __libcpp_verbose_abort("exception_ptr not yet implemented\n"); | |
| 37 | 32 | } |
| 38 | 33 | |
| 39 | 34 | nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {} |
| ... | ... | @@ -44,10 +39,9 @@ nested_exception::~nested_exception() noexcept {} |
| 44 | 39 | |
| 45 | 40 | #endif |
| 46 | 41 | |
| 47 | _LIBCPP_NORETURN void nested_exception::rethrow_nested() const { | |
| 42 | [[noreturn]] void nested_exception::rethrow_nested() const { | |
| 48 | 43 | #warning exception_ptr not yet implemented |
| 49 | fprintf(stderr, "exception_ptr not yet implemented\n"); | |
| 50 | ::abort(); | |
| 44 | __libcpp_verbose_abort("exception_ptr not yet implemented\n"); | |
| 51 | 45 | #if 0 |
| 52 | 46 | if (__ptr_ == nullptr) |
| 53 | 47 | terminate(); |
| ... | ... | @@ -57,14 +51,12 @@ _LIBCPP_NORETURN void nested_exception::rethrow_nested() const { |
| 57 | 51 | |
| 58 | 52 | exception_ptr current_exception() noexcept { |
| 59 | 53 | #warning exception_ptr not yet implemented |
| 60 | fprintf(stderr, "exception_ptr not yet implemented\n"); | |
| 61 | ::abort(); | |
| 54 | __libcpp_verbose_abort("exception_ptr not yet implemented\n"); | |
| 62 | 55 | } |
| 63 | 56 | |
| 64 | _LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { | |
| 57 | [[noreturn]] void rethrow_exception(exception_ptr p) { | |
| 65 | 58 | #warning exception_ptr not yet implemented |
| 66 | fprintf(stderr, "exception_ptr not yet implemented\n"); | |
| 67 | ::abort(); | |
| 59 | __libcpp_verbose_abort("exception_ptr not yet implemented\n"); | |
| 68 | 60 | } |
| 69 | 61 | |
| 70 | 62 | } // namespace std |
lib/libcxx/src/support/win32/locale_win32.cpp+133-80| ... | ... | @@ -6,127 +6,180 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include <cstdarg> // va_start, va_end | |
| 10 | #include <locale> | |
| 11 | #include <memory> | |
| 12 | #include <type_traits> | |
| 9 | #include <__locale_dir/support/windows.h> | |
| 10 | #include <clocale> // std::localeconv() & friends | |
| 11 | #include <cstdarg> // va_start & friends | |
| 12 | #include <cstddef> | |
| 13 | #include <cstdio> // std::vsnprintf & friends | |
| 14 | #include <cstdlib> // std::strtof & friends | |
| 15 | #include <ctime> // std::strftime | |
| 16 | #include <cwchar> // wide char manipulation | |
| 13 | 17 | |
| 14 | #include <__locale_dir/locale_base_api/locale_guard.h> | |
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | namespace __locale { | |
| 15 | 20 | |
| 16 | int __libcpp_vasprintf(char** sptr, const char* __restrict fmt, va_list ap); | |
| 21 | // | |
| 22 | // Locale management | |
| 23 | // | |
| 24 | // FIXME: base and mask currently unused. Needs manual work to construct the new locale | |
| 25 | __locale_t __newlocale(int /*mask*/, const char* locale, __locale_t /*base*/) { | |
| 26 | return {::_create_locale(LC_ALL, locale), locale}; | |
| 27 | } | |
| 28 | ||
| 29 | __lconv_t* __localeconv(__locale_t& loc) { | |
| 30 | __locale_guard __current(loc); | |
| 31 | lconv* lc = std::localeconv(); | |
| 32 | if (!lc) | |
| 33 | return lc; | |
| 34 | return loc.__store_lconv(lc); | |
| 35 | } | |
| 17 | 36 | |
| 18 | using std::__libcpp_locale_guard; | |
| 37 | // | |
| 38 | // Strtonum functions | |
| 39 | // | |
| 40 | #if !defined(_LIBCPP_MSVCRT) | |
| 41 | float __strtof(const char* nptr, char** endptr, __locale_t loc) { | |
| 42 | __locale_guard __current(loc); | |
| 43 | return std::strtof(nptr, endptr); | |
| 44 | } | |
| 19 | 45 | |
| 20 | // FIXME: base and mask currently unused. Needs manual work to construct the new locale | |
| 21 | locale_t newlocale(int /*mask*/, const char* locale, locale_t /*base*/) { | |
| 22 | return {_create_locale(LC_ALL, locale), locale}; | |
| 46 | long double __strtold(const char* nptr, char** endptr, __locale_t loc) { | |
| 47 | __locale_guard __current(loc); | |
| 48 | return std::strtold(nptr, endptr); | |
| 49 | } | |
| 50 | #endif | |
| 51 | ||
| 52 | // | |
| 53 | // Character manipulation functions | |
| 54 | // | |
| 55 | #if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800 | |
| 56 | size_t __strftime(char* ret, size_t n, const char* format, const struct tm* tm, __locale_t loc) { | |
| 57 | __locale_guard __current(loc); | |
| 58 | return std::strftime(ret, n, format, tm); | |
| 23 | 59 | } |
| 60 | #endif | |
| 24 | 61 | |
| 25 | decltype(MB_CUR_MAX) MB_CUR_MAX_L(locale_t __l) { | |
| 62 | // | |
| 63 | // Other functions | |
| 64 | // | |
| 65 | decltype(MB_CUR_MAX) __mb_len_max(__locale_t __l) { | |
| 26 | 66 | #if defined(_LIBCPP_MSVCRT) |
| 27 | return ___mb_cur_max_l_func(__l); | |
| 67 | return ::___mb_cur_max_l_func(__l); | |
| 28 | 68 | #else |
| 29 | __libcpp_locale_guard __current(__l); | |
| 69 | __locale_guard __current(__l); | |
| 30 | 70 | return MB_CUR_MAX; |
| 31 | 71 | #endif |
| 32 | 72 | } |
| 33 | 73 | |
| 34 | lconv* localeconv_l(locale_t& loc) { | |
| 35 | __libcpp_locale_guard __current(loc); | |
| 36 | lconv* lc = localeconv(); | |
| 37 | if (!lc) | |
| 38 | return lc; | |
| 39 | return loc.__store_lconv(lc); | |
| 74 | wint_t __btowc(int c, __locale_t loc) { | |
| 75 | __locale_guard __current(loc); | |
| 76 | return std::btowc(c); | |
| 40 | 77 | } |
| 41 | size_t mbrlen_l(const char* __restrict s, size_t n, mbstate_t* __restrict ps, locale_t loc) { | |
| 42 | __libcpp_locale_guard __current(loc); | |
| 43 | return mbrlen(s, n, ps); | |
| 44 | } | |
| 45 | size_t | |
| 46 | mbsrtowcs_l(wchar_t* __restrict dst, const char** __restrict src, size_t len, mbstate_t* __restrict ps, locale_t loc) { | |
| 47 | __libcpp_locale_guard __current(loc); | |
| 48 | return mbsrtowcs(dst, src, len, ps); | |
| 78 | ||
| 79 | int __wctob(wint_t c, __locale_t loc) { | |
| 80 | __locale_guard __current(loc); | |
| 81 | return std::wctob(c); | |
| 49 | 82 | } |
| 50 | size_t wcrtomb_l(char* __restrict s, wchar_t wc, mbstate_t* __restrict ps, locale_t loc) { | |
| 51 | __libcpp_locale_guard __current(loc); | |
| 52 | return wcrtomb(s, wc, ps); | |
| 83 | ||
| 84 | size_t __wcsnrtombs(char* __restrict dst, | |
| 85 | const wchar_t** __restrict src, | |
| 86 | size_t nwc, | |
| 87 | size_t len, | |
| 88 | mbstate_t* __restrict ps, | |
| 89 | __locale_t loc) { | |
| 90 | __locale_guard __current(loc); | |
| 91 | return ::wcsnrtombs(dst, src, nwc, len, ps); | |
| 53 | 92 | } |
| 54 | size_t mbrtowc_l(wchar_t* __restrict pwc, const char* __restrict s, size_t n, mbstate_t* __restrict ps, locale_t loc) { | |
| 55 | __libcpp_locale_guard __current(loc); | |
| 56 | return mbrtowc(pwc, s, n, ps); | |
| 93 | ||
| 94 | size_t __wcrtomb(char* __restrict s, wchar_t wc, mbstate_t* __restrict ps, __locale_t loc) { | |
| 95 | __locale_guard __current(loc); | |
| 96 | return std::wcrtomb(s, wc, ps); | |
| 57 | 97 | } |
| 58 | size_t mbsnrtowcs_l(wchar_t* __restrict dst, | |
| 98 | ||
| 99 | size_t __mbsnrtowcs(wchar_t* __restrict dst, | |
| 59 | 100 | const char** __restrict src, |
| 60 | 101 | size_t nms, |
| 61 | 102 | size_t len, |
| 62 | 103 | mbstate_t* __restrict ps, |
| 63 | locale_t loc) { | |
| 64 | __libcpp_locale_guard __current(loc); | |
| 65 | return mbsnrtowcs(dst, src, nms, len, ps); | |
| 104 | __locale_t loc) { | |
| 105 | __locale_guard __current(loc); | |
| 106 | return ::mbsnrtowcs(dst, src, nms, len, ps); | |
| 66 | 107 | } |
| 67 | size_t wcsnrtombs_l(char* __restrict dst, | |
| 68 | const wchar_t** __restrict src, | |
| 69 | size_t nwc, | |
| 70 | size_t len, | |
| 71 | mbstate_t* __restrict ps, | |
| 72 | locale_t loc) { | |
| 73 | __libcpp_locale_guard __current(loc); | |
| 74 | return wcsnrtombs(dst, src, nwc, len, ps); | |
| 108 | ||
| 109 | size_t | |
| 110 | __mbrtowc(wchar_t* __restrict pwc, const char* __restrict s, size_t n, mbstate_t* __restrict ps, __locale_t loc) { | |
| 111 | __locale_guard __current(loc); | |
| 112 | return std::mbrtowc(pwc, s, n, ps); | |
| 75 | 113 | } |
| 76 | wint_t btowc_l(int c, locale_t loc) { | |
| 77 | __libcpp_locale_guard __current(loc); | |
| 78 | return btowc(c); | |
| 114 | ||
| 115 | size_t __mbrlen(const char* __restrict s, size_t n, mbstate_t* __restrict ps, __locale_t loc) { | |
| 116 | __locale_guard __current(loc); | |
| 117 | return std::mbrlen(s, n, ps); | |
| 79 | 118 | } |
| 80 | int wctob_l(wint_t c, locale_t loc) { | |
| 81 | __libcpp_locale_guard __current(loc); | |
| 82 | return wctob(c); | |
| 119 | ||
| 120 | size_t __mbsrtowcs( | |
| 121 | wchar_t* __restrict dst, const char** __restrict src, size_t len, mbstate_t* __restrict ps, __locale_t loc) { | |
| 122 | __locale_guard __current(loc); | |
| 123 | return std::mbsrtowcs(dst, src, len, ps); | |
| 83 | 124 | } |
| 84 | 125 | |
| 85 | int snprintf_l(char* ret, size_t n, locale_t loc, const char* format, ...) { | |
| 126 | int __snprintf(char* ret, size_t n, __locale_t loc, const char* format, ...) { | |
| 86 | 127 | va_list ap; |
| 87 | 128 | va_start(ap, format); |
| 88 | 129 | #if defined(_LIBCPP_MSVCRT) |
| 89 | 130 | // FIXME: Remove usage of internal CRT function and globals. |
| 90 | int result = __stdio_common_vsprintf( | |
| 131 | int result = ::__stdio_common_vsprintf( | |
| 91 | 132 | _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, ret, n, format, loc, ap); |
| 92 | 133 | #else |
| 93 | __libcpp_locale_guard __current(loc); | |
| 134 | __locale_guard __current(loc); | |
| 94 | 135 | _LIBCPP_DIAGNOSTIC_PUSH |
| 95 | 136 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") |
| 96 | int result = vsnprintf(ret, n, format, ap); | |
| 137 | int result = std::vsnprintf(ret, n, format, ap); | |
| 97 | 138 | _LIBCPP_DIAGNOSTIC_POP |
| 98 | 139 | #endif |
| 99 | 140 | va_end(ap); |
| 100 | 141 | return result; |
| 101 | 142 | } |
| 102 | 143 | |
| 103 | int asprintf_l(char** ret, locale_t loc, const char* format, ...) { | |
| 144 | // Like sprintf, but when return value >= 0 it returns | |
| 145 | // a pointer to a malloc'd string in *sptr. | |
| 146 | // If return >= 0, use free to delete *sptr. | |
| 147 | int __libcpp_vasprintf(char** sptr, const char* __restrict format, va_list ap) { | |
| 148 | *sptr = nullptr; | |
| 149 | // Query the count required. | |
| 150 | va_list ap_copy; | |
| 151 | va_copy(ap_copy, ap); | |
| 152 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 153 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 154 | int count = vsnprintf(nullptr, 0, format, ap_copy); | |
| 155 | _LIBCPP_DIAGNOSTIC_POP | |
| 156 | va_end(ap_copy); | |
| 157 | if (count < 0) | |
| 158 | return count; | |
| 159 | size_t buffer_size = static_cast<size_t>(count) + 1; | |
| 160 | char* p = static_cast<char*>(malloc(buffer_size)); | |
| 161 | if (!p) | |
| 162 | return -1; | |
| 163 | // If we haven't used exactly what was required, something is wrong. | |
| 164 | // Maybe bug in vsnprintf. Report the error and return. | |
| 165 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 166 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 167 | if (vsnprintf(p, buffer_size, format, ap) != count) { | |
| 168 | _LIBCPP_DIAGNOSTIC_POP | |
| 169 | free(p); | |
| 170 | return -1; | |
| 171 | } | |
| 172 | // All good. This is returning memory to the caller not freeing it. | |
| 173 | *sptr = p; | |
| 174 | return count; | |
| 175 | } | |
| 176 | ||
| 177 | int __asprintf(char** ret, __locale_t loc, const char* format, ...) { | |
| 104 | 178 | va_list ap; |
| 105 | 179 | va_start(ap, format); |
| 106 | int result = vasprintf_l(ret, loc, format, ap); | |
| 107 | va_end(ap); | |
| 108 | return result; | |
| 109 | } | |
| 110 | int vasprintf_l(char** ret, locale_t loc, const char* format, va_list ap) { | |
| 111 | __libcpp_locale_guard __current(loc); | |
| 180 | __locale_guard __current(loc); | |
| 112 | 181 | return __libcpp_vasprintf(ret, format, ap); |
| 113 | 182 | } |
| 114 | 183 | |
| 115 | #if !defined(_LIBCPP_MSVCRT) | |
| 116 | float strtof_l(const char* nptr, char** endptr, locale_t loc) { | |
| 117 | __libcpp_locale_guard __current(loc); | |
| 118 | return strtof(nptr, endptr); | |
| 119 | } | |
| 120 | ||
| 121 | long double strtold_l(const char* nptr, char** endptr, locale_t loc) { | |
| 122 | __libcpp_locale_guard __current(loc); | |
| 123 | return strtold(nptr, endptr); | |
| 124 | } | |
| 125 | #endif | |
| 126 | ||
| 127 | #if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800 | |
| 128 | size_t strftime_l(char* ret, size_t n, const char* format, const struct tm* tm, locale_t loc) { | |
| 129 | __libcpp_locale_guard __current(loc); | |
| 130 | return strftime(ret, n, format, tm); | |
| 131 | } | |
| 132 | #endif | |
| 184 | } // namespace __locale | |
| 185 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/support/win32/support.cpp+4-37| ... | ... | @@ -13,39 +13,6 @@ |
| 13 | 13 | #include <cstring> // strcpy, wcsncpy |
| 14 | 14 | #include <cwchar> // mbstate_t |
| 15 | 15 | |
| 16 | // Like sprintf, but when return value >= 0 it returns | |
| 17 | // a pointer to a malloc'd string in *sptr. | |
| 18 | // If return >= 0, use free to delete *sptr. | |
| 19 | int __libcpp_vasprintf(char** sptr, const char* __restrict format, va_list ap) { | |
| 20 | *sptr = NULL; | |
| 21 | // Query the count required. | |
| 22 | va_list ap_copy; | |
| 23 | va_copy(ap_copy, ap); | |
| 24 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 25 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 26 | int count = vsnprintf(NULL, 0, format, ap_copy); | |
| 27 | _LIBCPP_DIAGNOSTIC_POP | |
| 28 | va_end(ap_copy); | |
| 29 | if (count < 0) | |
| 30 | return count; | |
| 31 | size_t buffer_size = static_cast<size_t>(count) + 1; | |
| 32 | char* p = static_cast<char*>(malloc(buffer_size)); | |
| 33 | if (!p) | |
| 34 | return -1; | |
| 35 | // If we haven't used exactly what was required, something is wrong. | |
| 36 | // Maybe bug in vsnprintf. Report the error and return. | |
| 37 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 38 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 39 | if (vsnprintf(p, buffer_size, format, ap) != count) { | |
| 40 | _LIBCPP_DIAGNOSTIC_POP | |
| 41 | free(p); | |
| 42 | return -1; | |
| 43 | } | |
| 44 | // All good. This is returning memory to the caller not freeing it. | |
| 45 | *sptr = p; | |
| 46 | return count; | |
| 47 | } | |
| 48 | ||
| 49 | 16 | // Returns >= 0: the number of wide characters found in the |
| 50 | 17 | // multi byte sequence src (of src_size_bytes), that fit in the buffer dst |
| 51 | 18 | // (of max_dest_chars elements size). The count returned excludes the |
| ... | ... | @@ -81,7 +48,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst, |
| 81 | 48 | // if result > 0, it's the size in bytes of that character. |
| 82 | 49 | // othewise if result is zero it indicates the null character has been found. |
| 83 | 50 | // otherwise it's an error and errno may be set. |
| 84 | size_t char_size = mbrtowc(dst ? dst + dest_converted : NULL, *src + source_converted, source_remaining, ps); | |
| 51 | size_t char_size = mbrtowc(dst ? dst + dest_converted : nullptr, *src + source_converted, source_remaining, ps); | |
| 85 | 52 | // Don't do anything to change errno from here on. |
| 86 | 53 | if (char_size > 0) { |
| 87 | 54 | source_remaining -= char_size; |
| ... | ... | @@ -95,7 +62,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst, |
| 95 | 62 | } |
| 96 | 63 | if (dst) { |
| 97 | 64 | if (have_result && result == terminated_sequence) |
| 98 | *src = NULL; | |
| 65 | *src = nullptr; | |
| 99 | 66 | else |
| 100 | 67 | *src += source_converted; |
| 101 | 68 | } |
| ... | ... | @@ -141,7 +108,7 @@ size_t wcsnrtombs(char* __restrict dst, |
| 141 | 108 | if (dst) |
| 142 | 109 | result = wcrtomb_s(&char_size, dst + dest_converted, dest_remaining, c, ps); |
| 143 | 110 | else |
| 144 | result = wcrtomb_s(&char_size, NULL, 0, c, ps); | |
| 111 | result = wcrtomb_s(&char_size, nullptr, 0, c, ps); | |
| 145 | 112 | // If result is zero there is no error and char_size contains the |
| 146 | 113 | // size of the multi-byte-sequence converted. |
| 147 | 114 | // Otherwise result indicates an errno type error. |
| ... | ... | @@ -161,7 +128,7 @@ size_t wcsnrtombs(char* __restrict dst, |
| 161 | 128 | } |
| 162 | 129 | if (dst) { |
| 163 | 130 | if (terminator_found) |
| 164 | *src = NULL; | |
| 131 | *src = nullptr; | |
| 165 | 132 | else |
| 166 | 133 | *src = *src + source_converted; |
| 167 | 134 | } |
lib/libcxx/src/support/win32/thread_win32.cpp+1-1| ... | ... | @@ -129,7 +129,7 @@ __libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter, |
| 129 | 129 | |
| 130 | 130 | int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)(void)) { |
| 131 | 131 | if (!InitOnceExecuteOnce( |
| 132 | (PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), NULL)) | |
| 132 | (PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), nullptr)) | |
| 133 | 133 | return GetLastError(); |
| 134 | 134 | return 0; |
| 135 | 135 | } |
lib/libcxx/src/system_error.cpp+158-12| ... | ... | @@ -8,25 +8,138 @@ |
| 8 | 8 | |
| 9 | 9 | #include <__assert> |
| 10 | 10 | #include <__config> |
| 11 | #include <__system_error/throw_system_error.h> | |
| 11 | 12 | #include <__verbose_abort> |
| 12 | 13 | #include <cerrno> |
| 13 | 14 | #include <cstdio> |
| 14 | 15 | #include <cstdlib> |
| 15 | 16 | #include <cstring> |
| 17 | #include <optional> | |
| 16 | 18 | #include <string.h> |
| 17 | 19 | #include <string> |
| 18 | 20 | #include <system_error> |
| 19 | 21 | |
| 20 | 22 | #include "include/config_elast.h" |
| 21 | 23 | |
| 22 | #if defined(__ANDROID__) | |
| 23 | # include <android/api-level.h> | |
| 24 | #if defined(_LIBCPP_WIN32API) | |
| 25 | # include <windows.h> | |
| 26 | # include <winerror.h> | |
| 24 | 27 | #endif |
| 25 | 28 | |
| 26 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 30 | |
| 31 | #if defined(_LIBCPP_WIN32API) | |
| 32 | ||
| 28 | 33 | namespace { |
| 29 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 34 | std::optional<errc> __win_err_to_errc(int err) { | |
| 35 | switch (err) { | |
| 36 | case ERROR_ACCESS_DENIED: | |
| 37 | return errc::permission_denied; | |
| 38 | case ERROR_ALREADY_EXISTS: | |
| 39 | return errc::file_exists; | |
| 40 | case ERROR_BAD_NETPATH: | |
| 41 | return errc::no_such_file_or_directory; | |
| 42 | case ERROR_BAD_PATHNAME: | |
| 43 | return errc::no_such_file_or_directory; | |
| 44 | case ERROR_BAD_UNIT: | |
| 45 | return errc::no_such_device; | |
| 46 | case ERROR_BROKEN_PIPE: | |
| 47 | return errc::broken_pipe; | |
| 48 | case ERROR_BUFFER_OVERFLOW: | |
| 49 | return errc::filename_too_long; | |
| 50 | case ERROR_BUSY: | |
| 51 | return errc::device_or_resource_busy; | |
| 52 | case ERROR_BUSY_DRIVE: | |
| 53 | return errc::device_or_resource_busy; | |
| 54 | case ERROR_CANNOT_MAKE: | |
| 55 | return errc::permission_denied; | |
| 56 | case ERROR_CANTOPEN: | |
| 57 | return errc::io_error; | |
| 58 | case ERROR_CANTREAD: | |
| 59 | return errc::io_error; | |
| 60 | case ERROR_CANTWRITE: | |
| 61 | return errc::io_error; | |
| 62 | case ERROR_CURRENT_DIRECTORY: | |
| 63 | return errc::permission_denied; | |
| 64 | case ERROR_DEV_NOT_EXIST: | |
| 65 | return errc::no_such_device; | |
| 66 | case ERROR_DEVICE_IN_USE: | |
| 67 | return errc::device_or_resource_busy; | |
| 68 | case ERROR_DIR_NOT_EMPTY: | |
| 69 | return errc::directory_not_empty; | |
| 70 | case ERROR_DIRECTORY: | |
| 71 | return errc::invalid_argument; | |
| 72 | case ERROR_DISK_FULL: | |
| 73 | return errc::no_space_on_device; | |
| 74 | case ERROR_FILE_EXISTS: | |
| 75 | return errc::file_exists; | |
| 76 | case ERROR_FILE_NOT_FOUND: | |
| 77 | return errc::no_such_file_or_directory; | |
| 78 | case ERROR_HANDLE_DISK_FULL: | |
| 79 | return errc::no_space_on_device; | |
| 80 | case ERROR_INVALID_ACCESS: | |
| 81 | return errc::permission_denied; | |
| 82 | case ERROR_INVALID_DRIVE: | |
| 83 | return errc::no_such_device; | |
| 84 | case ERROR_INVALID_FUNCTION: | |
| 85 | return errc::function_not_supported; | |
| 86 | case ERROR_INVALID_HANDLE: | |
| 87 | return errc::invalid_argument; | |
| 88 | case ERROR_INVALID_NAME: | |
| 89 | return errc::no_such_file_or_directory; | |
| 90 | case ERROR_INVALID_PARAMETER: | |
| 91 | return errc::invalid_argument; | |
| 92 | case ERROR_LOCK_VIOLATION: | |
| 93 | return errc::no_lock_available; | |
| 94 | case ERROR_LOCKED: | |
| 95 | return errc::no_lock_available; | |
| 96 | case ERROR_NEGATIVE_SEEK: | |
| 97 | return errc::invalid_argument; | |
| 98 | case ERROR_NOACCESS: | |
| 99 | return errc::permission_denied; | |
| 100 | case ERROR_NOT_ENOUGH_MEMORY: | |
| 101 | return errc::not_enough_memory; | |
| 102 | case ERROR_NOT_READY: | |
| 103 | return errc::resource_unavailable_try_again; | |
| 104 | case ERROR_NOT_SAME_DEVICE: | |
| 105 | return errc::cross_device_link; | |
| 106 | case ERROR_NOT_SUPPORTED: | |
| 107 | return errc::not_supported; | |
| 108 | case ERROR_OPEN_FAILED: | |
| 109 | return errc::io_error; | |
| 110 | case ERROR_OPEN_FILES: | |
| 111 | return errc::device_or_resource_busy; | |
| 112 | case ERROR_OPERATION_ABORTED: | |
| 113 | return errc::operation_canceled; | |
| 114 | case ERROR_OUTOFMEMORY: | |
| 115 | return errc::not_enough_memory; | |
| 116 | case ERROR_PATH_NOT_FOUND: | |
| 117 | return errc::no_such_file_or_directory; | |
| 118 | case ERROR_READ_FAULT: | |
| 119 | return errc::io_error; | |
| 120 | case ERROR_REPARSE_TAG_INVALID: | |
| 121 | return errc::invalid_argument; | |
| 122 | case ERROR_RETRY: | |
| 123 | return errc::resource_unavailable_try_again; | |
| 124 | case ERROR_SEEK: | |
| 125 | return errc::io_error; | |
| 126 | case ERROR_SHARING_VIOLATION: | |
| 127 | return errc::permission_denied; | |
| 128 | case ERROR_TOO_MANY_OPEN_FILES: | |
| 129 | return errc::too_many_files_open; | |
| 130 | case ERROR_WRITE_FAULT: | |
| 131 | return errc::io_error; | |
| 132 | case ERROR_WRITE_PROTECT: | |
| 133 | return errc::permission_denied; | |
| 134 | default: | |
| 135 | return {}; | |
| 136 | } | |
| 137 | } | |
| 138 | } // namespace | |
| 139 | #endif | |
| 140 | ||
| 141 | namespace { | |
| 142 | #if _LIBCPP_HAS_THREADS | |
| 30 | 143 | |
| 31 | 144 | // GLIBC also uses 1024 as the maximum buffer size internally. |
| 32 | 145 | constexpr size_t strerror_buff_size = 1024; |
| ... | ... | @@ -92,7 +205,7 @@ string do_strerror_r(int ev) { |
| 92 | 205 | } |
| 93 | 206 | # endif |
| 94 | 207 | |
| 95 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 208 | #endif // _LIBCPP_HAS_THREADS | |
| 96 | 209 | |
| 97 | 210 | string make_error_str(const error_code& ec, string what_arg) { |
| 98 | 211 | if (ec) { |
| ... | ... | @@ -110,10 +223,10 @@ string make_error_str(const error_code& ec) { |
| 110 | 223 | } |
| 111 | 224 | return string(); |
| 112 | 225 | } |
| 113 | } // end namespace | |
| 226 | } // namespace | |
| 114 | 227 | |
| 115 | 228 | string __do_message::message(int ev) const { |
| 116 | #if defined(_LIBCPP_HAS_NO_THREADS) | |
| 229 | #if !_LIBCPP_HAS_THREADS | |
| 117 | 230 | return string(::strerror(ev)); |
| 118 | 231 | #else |
| 119 | 232 | return do_strerror_r(ev); |
| ... | ... | @@ -156,19 +269,52 @@ public: |
| 156 | 269 | const char* __system_error_category::name() const noexcept { return "system"; } |
| 157 | 270 | |
| 158 | 271 | string __system_error_category::message(int ev) const { |
| 159 | #ifdef _LIBCPP_ELAST | |
| 272 | #ifdef _LIBCPP_WIN32API | |
| 273 | std::string result; | |
| 274 | char* str = nullptr; | |
| 275 | unsigned long num_chars = ::FormatMessageA( | |
| 276 | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, | |
| 277 | nullptr, | |
| 278 | ev, | |
| 279 | 0, | |
| 280 | reinterpret_cast<char*>(&str), | |
| 281 | 0, | |
| 282 | nullptr); | |
| 283 | auto is_whitespace = [](char ch) { return ch == '\n' || ch == '\r' || ch == ' '; }; | |
| 284 | while (num_chars > 0 && is_whitespace(str[num_chars - 1])) | |
| 285 | --num_chars; | |
| 286 | ||
| 287 | if (num_chars) | |
| 288 | result = std::string(str, num_chars); | |
| 289 | else | |
| 290 | result = "Unknown error"; | |
| 291 | ||
| 292 | LocalFree(str); | |
| 293 | return result; | |
| 294 | #else | |
| 295 | # ifdef _LIBCPP_ELAST | |
| 160 | 296 | if (ev > _LIBCPP_ELAST) |
| 161 | 297 | return string("unspecified system_category error"); |
| 162 | #endif // _LIBCPP_ELAST | |
| 298 | # endif // _LIBCPP_ELAST | |
| 163 | 299 | return __do_message::message(ev); |
| 300 | #endif | |
| 164 | 301 | } |
| 165 | 302 | |
| 166 | 303 | error_condition __system_error_category::default_error_condition(int ev) const noexcept { |
| 167 | #ifdef _LIBCPP_ELAST | |
| 304 | #ifdef _LIBCPP_WIN32API | |
| 305 | // Remap windows error codes to generic error codes if possible. | |
| 306 | if (ev == 0) | |
| 307 | return error_condition(0, generic_category()); | |
| 308 | if (auto maybe_errc = __win_err_to_errc(ev)) | |
| 309 | return error_condition(static_cast<int>(*maybe_errc), generic_category()); | |
| 310 | return error_condition(ev, system_category()); | |
| 311 | #else | |
| 312 | # ifdef _LIBCPP_ELAST | |
| 168 | 313 | if (ev > _LIBCPP_ELAST) |
| 169 | 314 | return error_condition(ev, system_category()); |
| 170 | #endif // _LIBCPP_ELAST | |
| 315 | # endif // _LIBCPP_ELAST | |
| 171 | 316 | return error_condition(ev, generic_category()); |
| 317 | #endif | |
| 172 | 318 | } |
| 173 | 319 | |
| 174 | 320 | const error_category& system_category() noexcept { |
| ... | ... | @@ -211,8 +357,8 @@ system_error::system_error(int ev, const error_category& ecat) |
| 211 | 357 | system_error::~system_error() noexcept {} |
| 212 | 358 | |
| 213 | 359 | void __throw_system_error(int ev, const char* what_arg) { |
| 214 | #ifndef _LIBCPP_HAS_NO_EXCEPTIONS | |
| 215 | std::__throw_system_error(error_code(ev, system_category()), what_arg); | |
| 360 | #if _LIBCPP_HAS_EXCEPTIONS | |
| 361 | std::__throw_system_error(error_code(ev, generic_category()), what_arg); | |
| 216 | 362 | #else |
| 217 | 363 | // The above could also handle the no-exception case, but for size, avoid referencing system_category() unnecessarily. |
| 218 | 364 | _LIBCPP_VERBOSE_ABORT( |
lib/libcxx/src/vector.cpp+2-2| ... | ... | @@ -17,8 +17,8 @@ struct __vector_base_common; |
| 17 | 17 | |
| 18 | 18 | template <> |
| 19 | 19 | struct __vector_base_common<true> { |
| 20 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; | |
| 21 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; | |
| 20 | [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; | |
| 21 | [[noreturn]] _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; | |
| 22 | 22 | }; |
| 23 | 23 | |
| 24 | 24 | void __vector_base_common<true>::__throw_length_error() const { std::__throw_length_error("vector"); } |
lib/libcxx/src/verbose_abort.cpp+2-14| ... | ... | @@ -13,13 +13,8 @@ |
| 13 | 13 | #include <cstdlib> |
| 14 | 14 | |
| 15 | 15 | #ifdef __BIONIC__ |
| 16 | # include <android/api-level.h> | |
| 17 | # if __ANDROID_API__ >= 21 | |
| 18 | # include <syslog.h> | |
| 16 | # include <syslog.h> | |
| 19 | 17 | extern "C" void android_set_abort_message(const char* msg); |
| 20 | # else | |
| 21 | # include <assert.h> | |
| 22 | # endif // __ANDROID_API__ >= 21 | |
| 23 | 18 | #endif // __BIONIC__ |
| 24 | 19 | |
| 25 | 20 | #if defined(__APPLE__) && __has_include(<CrashReporterClient.h>) |
| ... | ... | @@ -28,7 +23,7 @@ extern "C" void android_set_abort_message(const char* msg); |
| 28 | 23 | |
| 29 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 25 | |
| 31 | _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) { | |
| 26 | _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT { | |
| 32 | 27 | // Write message to stderr. We do this before formatting into a |
| 33 | 28 | // buffer so that we still get some information out if that fails. |
| 34 | 29 | { |
| ... | ... | @@ -54,7 +49,6 @@ _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) { |
| 54 | 49 | #elif defined(__BIONIC__) |
| 55 | 50 | vasprintf(&buffer, format, list); |
| 56 | 51 | |
| 57 | # if __ANDROID_API__ >= 21 | |
| 58 | 52 | // Show error in tombstone. |
| 59 | 53 | android_set_abort_message(buffer); |
| 60 | 54 | |
| ... | ... | @@ -62,12 +56,6 @@ _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) { |
| 62 | 56 | openlog("libc++", 0, 0); |
| 63 | 57 | syslog(LOG_CRIT, "%s", buffer); |
| 64 | 58 | closelog(); |
| 65 | # else | |
| 66 | // The good error reporting wasn't available in Android until L. Since we're | |
| 67 | // about to abort anyway, just call __assert2, which will log _somewhere_ | |
| 68 | // (tombstone and/or logcat) in older releases. | |
| 69 | __assert2(__FILE__, __LINE__, __func__, buffer); | |
| 70 | # endif // __ANDROID_API__ >= 21 | |
| 71 | 59 | #endif |
| 72 | 60 | va_end(list); |
| 73 | 61 |
src/Compilation.zig+1-23| ... | ... | @@ -5776,29 +5776,7 @@ pub fn addCCArgs( |
| 5776 | 5776 | comp.zig_lib_directory.path.?, "libcxxabi", "include", |
| 5777 | 5777 | })); |
| 5778 | 5778 | |
| 5779 | if (target.abi.isMusl()) { | |
| 5780 | try argv.append("-D_LIBCPP_HAS_MUSL_LIBC"); | |
| 5781 | } | |
| 5782 | ||
| 5783 | try argv.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); | |
| 5784 | try argv.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS"); | |
| 5785 | try argv.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); | |
| 5786 | ||
| 5787 | if (!comp.config.any_non_single_threaded) { | |
| 5788 | try argv.append("-D_LIBCPP_HAS_NO_THREADS"); | |
| 5789 | } | |
| 5790 | ||
| 5791 | // See the comment in libcxx.zig for more details about this. | |
| 5792 | try argv.append("-D_LIBCPP_PSTL_BACKEND_SERIAL"); | |
| 5793 | ||
| 5794 | try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{ | |
| 5795 | @intFromEnum(comp.libcxx_abi_version), | |
| 5796 | })); | |
| 5797 | try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{ | |
| 5798 | @intFromEnum(comp.libcxx_abi_version), | |
| 5799 | })); | |
| 5800 | ||
| 5801 | try argv.append(libcxx.hardeningModeFlag(mod.optimize_mode)); | |
| 5779 | try libcxx.addCxxArgs(comp, arena, argv); | |
| 5802 | 5780 | } |
| 5803 | 5781 | |
| 5804 | 5782 | // According to Rich Felker libc headers are supposed to go before C language headers. |
src/libcxx.zig+72-90| ... | ... | @@ -62,7 +62,6 @@ const libcxx_base_files = [_][]const u8{ |
| 62 | 62 | "src/ios.cpp", |
| 63 | 63 | "src/ios.instantiations.cpp", |
| 64 | 64 | "src/iostream.cpp", |
| 65 | "src/legacy_pointer_safety.cpp", | |
| 66 | 65 | "src/locale.cpp", |
| 67 | 66 | "src/memory.cpp", |
| 68 | 67 | "src/memory_resource.cpp", |
| ... | ... | @@ -145,12 +144,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError! |
| 145 | 144 | const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" }); |
| 146 | 145 | const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" }); |
| 147 | 146 | const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" }); |
| 148 | const abi_version_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{ | |
| 149 | @intFromEnum(comp.libcxx_abi_version), | |
| 150 | }); | |
| 151 | const abi_namespace_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{ | |
| 152 | @intFromEnum(comp.libcxx_abi_version), | |
| 153 | }); | |
| 147 | const cxx_libc_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "libc" }); | |
| 154 | 148 | |
| 155 | 149 | const optimize_mode = comp.compilerRtOptMode(); |
| 156 | 150 | const strip = comp.compilerRtStrip(); |
| ... | ... | @@ -220,59 +214,27 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError! |
| 220 | 214 | var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxx_files.len); |
| 221 | 215 | |
| 222 | 216 | for (libcxx_files) |cxx_src| { |
| 223 | var cflags = std.ArrayList([]const u8).init(arena); | |
| 224 | ||
| 225 | if ((target.os.tag == .windows and (target.abi == .msvc or target.abi == .itanium)) or target.os.tag == .wasi) { | |
| 226 | // Filesystem stuff isn't supported on WASI and Windows (MSVC). | |
| 227 | if (std.mem.startsWith(u8, cxx_src, "src/filesystem/")) | |
| 228 | continue; | |
| 229 | } | |
| 230 | ||
| 217 | // These don't compile on WASI due to e.g. `fchmod` usage. | |
| 218 | if (std.mem.startsWith(u8, cxx_src, "src/filesystem/") and target.os.tag == .wasi) | |
| 219 | continue; | |
| 231 | 220 | if (std.mem.startsWith(u8, cxx_src, "src/support/win32/") and target.os.tag != .windows) |
| 232 | 221 | continue; |
| 233 | 222 | if (std.mem.startsWith(u8, cxx_src, "src/support/ibm/") and target.os.tag != .zos) |
| 234 | 223 | continue; |
| 235 | if (!comp.config.any_non_single_threaded) | |
| 236 | try cflags.append("-D_LIBCPP_HAS_NO_THREADS"); | |
| 224 | ||
| 225 | var cflags = std.ArrayList([]const u8).init(arena); | |
| 226 | ||
| 227 | try addCxxArgs(comp, arena, &cflags); | |
| 237 | 228 | |
| 238 | 229 | try cflags.append("-DNDEBUG"); |
| 239 | try cflags.append(hardeningModeFlag(optimize_mode)); | |
| 230 | try cflags.append("-DLIBC_NAMESPACE=__llvm_libc_common_utils"); | |
| 240 | 231 | try cflags.append("-D_LIBCPP_BUILDING_LIBRARY"); |
| 241 | try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); | |
| 242 | try cflags.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER"); | |
| 243 | try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS"); | |
| 244 | 232 | try cflags.append("-DLIBCXX_BUILDING_LIBCXXABI"); |
| 245 | try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); | |
| 246 | ||
| 247 | // See libcxx/include/__algorithm/pstl_backends/cpu_backends/backend.h | |
| 248 | // for potentially enabling some fancy features here, which would | |
| 249 | // require corresponding changes in libcxx.zig, as well as | |
| 250 | // Compilation.addCCArgs. This option makes it use serial backend which | |
| 251 | // is simple and works everywhere. | |
| 252 | try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL"); | |
| 253 | ||
| 254 | try cflags.append(abi_version_arg); | |
| 255 | try cflags.append(abi_namespace_arg); | |
| 233 | try cflags.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER"); | |
| 256 | 234 | |
| 257 | 235 | try cflags.append("-fvisibility=hidden"); |
| 258 | 236 | try cflags.append("-fvisibility-inlines-hidden"); |
| 259 | 237 | |
| 260 | if (target.abi.isMusl()) { | |
| 261 | try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC"); | |
| 262 | } | |
| 263 | ||
| 264 | if (target.isGnuLibC()) { | |
| 265 | // glibc 2.16 introduced aligned_alloc | |
| 266 | if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) { | |
| 267 | try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION"); | |
| 268 | } | |
| 269 | } | |
| 270 | ||
| 271 | if (target.os.tag == .wasi) { | |
| 272 | // WASI doesn't support exceptions yet. | |
| 273 | try cflags.append("-fno-exceptions"); | |
| 274 | } | |
| 275 | ||
| 276 | 238 | if (target.os.tag == .zos) { |
| 277 | 239 | try cflags.append("-fno-aligned-allocation"); |
| 278 | 240 | } else { |
| ... | ... | @@ -299,6 +261,9 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError! |
| 299 | 261 | try cache_exempt_flags.append("-I"); |
| 300 | 262 | try cache_exempt_flags.append(cxx_src_include_path); |
| 301 | 263 | |
| 264 | try cache_exempt_flags.append("-I"); | |
| 265 | try cache_exempt_flags.append(cxx_libc_include_path); | |
| 266 | ||
| 302 | 267 | c_source_files.appendAssumeCapacity(.{ |
| 303 | 268 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", cxx_src }), |
| 304 | 269 | .extra_flags = cflags.items, |
| ... | ... | @@ -389,12 +354,6 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 389 | 354 | const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" }); |
| 390 | 355 | const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" }); |
| 391 | 356 | const cxx_src_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "src" }); |
| 392 | const abi_version_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{ | |
| 393 | @intFromEnum(comp.libcxx_abi_version), | |
| 394 | }); | |
| 395 | const abi_namespace_arg = try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{ | |
| 396 | @intFromEnum(comp.libcxx_abi_version), | |
| 397 | }); | |
| 398 | 357 | |
| 399 | 358 | const optimize_mode = comp.compilerRtOptMode(); |
| 400 | 359 | const strip = comp.compilerRtStrip(); |
| ... | ... | @@ -465,51 +424,26 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 465 | 424 | var c_source_files = try std.ArrayList(Compilation.CSourceFile).initCapacity(arena, libcxxabi_files.len); |
| 466 | 425 | |
| 467 | 426 | for (libcxxabi_files) |cxxabi_src| { |
| 427 | if (!comp.config.any_non_single_threaded and std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp")) | |
| 428 | continue; | |
| 429 | ||
| 468 | 430 | var cflags = std.ArrayList([]const u8).init(arena); |
| 469 | 431 | |
| 470 | if (target.os.tag == .wasi) { | |
| 471 | // WASI doesn't support exceptions yet. | |
| 472 | if (std.mem.startsWith(u8, cxxabi_src, "src/cxa_exception.cpp") or | |
| 473 | std.mem.startsWith(u8, cxxabi_src, "src/cxa_personality.cpp")) | |
| 474 | continue; | |
| 475 | try cflags.append("-fno-exceptions"); | |
| 476 | } | |
| 432 | try addCxxArgs(comp, arena, &cflags); | |
| 477 | 433 | |
| 478 | // WASM targets are single threaded. | |
| 434 | try cflags.append("-DNDEBUG"); | |
| 435 | try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY"); | |
| 479 | 436 | if (!comp.config.any_non_single_threaded) { |
| 480 | if (std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp")) { | |
| 481 | continue; | |
| 482 | } | |
| 483 | 437 | try cflags.append("-D_LIBCXXABI_HAS_NO_THREADS"); |
| 484 | } else if (target.abi.isGnu()) { | |
| 438 | } | |
| 439 | if (target.abi.isGnu()) { | |
| 485 | 440 | if (target.os.tag != .linux or !(target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 18, .patch = 0 }) == .lt)) |
| 486 | 441 | try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL"); |
| 487 | 442 | } |
| 488 | 443 | |
| 489 | try cflags.append("-DNDEBUG"); | |
| 490 | try cflags.append(hardeningModeFlag(optimize_mode)); | |
| 491 | try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY"); | |
| 492 | try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); | |
| 493 | try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); | |
| 494 | try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS"); | |
| 495 | ||
| 496 | try cflags.append(abi_version_arg); | |
| 497 | try cflags.append(abi_namespace_arg); | |
| 498 | ||
| 499 | 444 | try cflags.append("-fvisibility=hidden"); |
| 500 | 445 | try cflags.append("-fvisibility-inlines-hidden"); |
| 501 | 446 | |
| 502 | if (target.abi.isMusl()) { | |
| 503 | try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC"); | |
| 504 | } | |
| 505 | ||
| 506 | if (target.isGnuLibC()) { | |
| 507 | // glibc 2.16 introduced aligned_alloc | |
| 508 | if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) { | |
| 509 | try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION"); | |
| 510 | } | |
| 511 | } | |
| 512 | ||
| 513 | 447 | if (target_util.supports_fpic(target)) { |
| 514 | 448 | try cflags.append("-fPIC"); |
| 515 | 449 | } |
| ... | ... | @@ -593,10 +527,58 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr |
| 593 | 527 | comp.queueLinkTaskMode(crt_file.full_object_path, output_mode); |
| 594 | 528 | } |
| 595 | 529 | |
| 596 | pub fn hardeningModeFlag(optimize_mode: std.builtin.OptimizeMode) []const u8 { | |
| 597 | return switch (optimize_mode) { | |
| 530 | pub fn addCxxArgs( | |
| 531 | comp: *const Compilation, | |
| 532 | arena: std.mem.Allocator, | |
| 533 | cflags: *std.ArrayList([]const u8), | |
| 534 | ) error{OutOfMemory}!void { | |
| 535 | const target = comp.getTarget(); | |
| 536 | const optimize_mode = comp.compilerRtOptMode(); | |
| 537 | ||
| 538 | try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{ | |
| 539 | @intFromEnum(comp.libcxx_abi_version), | |
| 540 | })); | |
| 541 | try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{ | |
| 542 | @intFromEnum(comp.libcxx_abi_version), | |
| 543 | })); | |
| 544 | try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}THREADS", .{ | |
| 545 | if (!comp.config.any_non_single_threaded) "NO_" else "", | |
| 546 | })); | |
| 547 | try cflags.append("-D_LIBCPP_HAS_MONOTONIC_CLOCK"); | |
| 548 | try cflags.append("-D_LIBCPP_HAS_TERMINAL"); | |
| 549 | try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}MUSL_LIBC", .{ | |
| 550 | if (!target.abi.isMusl()) "NO_" else "", | |
| 551 | })); | |
| 552 | try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); | |
| 553 | try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); | |
| 554 | try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS"); | |
| 555 | try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}FILESYSTEM", .{ | |
| 556 | if (target.os.tag == .wasi) "NO_" else "", | |
| 557 | })); | |
| 558 | try cflags.append("-D_LIBCPP_HAS_RANDOM_DEVICE"); | |
| 559 | try cflags.append("-D_LIBCPP_HAS_LOCALIZATION"); | |
| 560 | try cflags.append("-D_LIBCPP_HAS_UNICODE"); | |
| 561 | try cflags.append("-D_LIBCPP_HAS_WIDE_CHARACTERS"); | |
| 562 | try cflags.append("-D_LIBCPP_HAS_NO_STD_MODULES"); | |
| 563 | if (target.os.tag == .linux) { | |
| 564 | try cflags.append("-D_LIBCPP_HAS_TIME_ZONE_DATABASE"); | |
| 565 | } | |
| 566 | // See libcxx/include/__algorithm/pstl_backends/cpu_backends/backend.h | |
| 567 | // for potentially enabling some fancy features here, which would | |
| 568 | // require corresponding changes in libcxx.zig, as well as | |
| 569 | // Compilation.addCCArgs. This option makes it use serial backend which | |
| 570 | // is simple and works everywhere. | |
| 571 | try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL"); | |
| 572 | try cflags.append(switch (optimize_mode) { | |
| 598 | 573 | .Debug => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG", |
| 599 | 574 | .ReleaseFast, .ReleaseSmall => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE", |
| 600 | 575 | .ReleaseSafe => "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST", |
| 601 | }; | |
| 576 | }); | |
| 577 | if (target.isGnuLibC()) { | |
| 578 | // glibc 2.16 introduced aligned_alloc | |
| 579 | if (target.os.versionRange().gnuLibCVersion().?.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) { | |
| 580 | try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION"); | |
| 581 | } | |
| 582 | } | |
| 583 | try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS"); | |
| 602 | 584 | } |