| author | |
| committer | |
| log | e6ccc93aacb54f9c183dce43389c2be34e6fde9a |
| tree | 797936b1a016fe4fb1a68eac72959c175a8c1a93 |
| parent | b5dc8b67bc2e5dd920a5cabbe32c999f8ea71257 |
42 files changed, 1343 insertions(+), 506 deletions(-)
lib/libcxx/include/__algorithm/algorithm_family.h deleted-52| ... | @@ -1,52 +0,0 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H | ||
| 10 | #define _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H | ||
| 11 | |||
| 12 | #include <__algorithm/iterator_operations.h> | ||
| 13 | #include <__algorithm/move.h> | ||
| 14 | #include <__algorithm/ranges_move.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <__utility/move.h> | ||
| 17 | |||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 19 | # pragma GCC system_header | ||
| 20 | #endif | ||
| 21 | |||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 23 | |||
| 24 | template <class _AlgPolicy> | ||
| 25 | struct _AlgFamily; | ||
| 26 | |||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 28 | |||
| 29 | template <> | ||
| 30 | struct _AlgFamily<_RangeAlgPolicy> { | ||
| 31 | static constexpr auto __move = ranges::move; | ||
| 32 | }; | ||
| 33 | |||
| 34 | #endif | ||
| 35 | |||
| 36 | template <> | ||
| 37 | struct _AlgFamily<_ClassicAlgPolicy> { | ||
| 38 | |||
| 39 | // move | ||
| 40 | template <class _InputIterator, class _OutputIterator> | ||
| 41 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 static _OutputIterator | ||
| 42 | __move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | ||
| 43 | return std::move( | ||
| 44 | std::move(__first), | ||
| 45 | std::move(__last), | ||
| 46 | std::move(__result)); | ||
| 47 | } | ||
| 48 | }; | ||
| 49 | |||
| 50 | _LIBCPP_END_NAMESPACE_STD | ||
| 51 | |||
| 52 | #endif // _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H | ||
lib/libcxx/include/__algorithm/clamp.h+2-2| ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | #if _LIBCPP_STD_VER > 14 | 22 | #if _LIBCPP_STD_VER > 14 |
| 23 | template<class _Tp, class _Compare> | 23 | template<class _Tp, class _Compare> |
| 24 | _LIBCPP_NODISCARD_EXT inline | 24 | _LIBCPP_NODISCARD_EXT inline |
| 25 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | 25 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 26 | const _Tp& | 26 | const _Tp& |
| 27 | clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp) | 27 | clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp) |
| 28 | { | 28 | { |
| ... | @@ -33,7 +33,7 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp) | ... | @@ -33,7 +33,7 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp) |
| 33 | 33 | ||
| 34 | template<class _Tp> | 34 | template<class _Tp> |
| 35 | _LIBCPP_NODISCARD_EXT inline | 35 | _LIBCPP_NODISCARD_EXT inline |
| 36 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | 36 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 37 | const _Tp& | 37 | const _Tp& |
| 38 | clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi) | 38 | clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi) |
| 39 | { | 39 | { |
lib/libcxx/include/__algorithm/copy_backward.h+3-3| ... | @@ -20,7 +20,6 @@ | ... | @@ -20,7 +20,6 @@ |
| 20 | #include <__ranges/subrange.h> | 20 | #include <__ranges/subrange.h> |
| 21 | #include <__utility/move.h> | 21 | #include <__utility/move.h> |
| 22 | #include <__utility/pair.h> | 22 | #include <__utility/pair.h> |
| 23 | #include <cstring> | ||
| 24 | #include <type_traits> | 23 | #include <type_traits> |
| 25 | 24 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -44,9 +43,10 @@ __copy_backward(_InputIterator __first, _InputIterator __last, _OutputIterator _ | ... | @@ -44,9 +43,10 @@ __copy_backward(_InputIterator __first, _InputIterator __last, _OutputIterator _ |
| 44 | template <class _AlgPolicy, class _Iter1, class _Sent1, class _Iter2, | 43 | template <class _AlgPolicy, class _Iter1, class _Sent1, class _Iter2, |
| 45 | __enable_if_t<is_same<_AlgPolicy, _RangeAlgPolicy>::value, int> = 0> | 44 | __enable_if_t<is_same<_AlgPolicy, _RangeAlgPolicy>::value, int> = 0> |
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) { | 45 | _LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) { |
| 47 | auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), std::move(__last))); | 46 | auto __last_iter = _IterOps<_AlgPolicy>::next(__first, std::move(__last)); |
| 47 | auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), __last_iter)); | ||
| 48 | auto __ret = ranges::copy(std::move(__reverse_range), std::make_reverse_iterator(__result)); | 48 | auto __ret = ranges::copy(std::move(__reverse_range), std::make_reverse_iterator(__result)); |
| 49 | return std::make_pair(__ret.in.base(), __ret.out.base()); | 49 | return std::make_pair(__last_iter, __ret.out.base()); |
| 50 | } | 50 | } |
| 51 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | 51 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) |
| 52 | 52 |
lib/libcxx/include/__algorithm/find_first_of.h+2-1| ... | @@ -24,7 +24,8 @@ template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredica | ... | @@ -24,7 +24,8 @@ template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredica |
| 24 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1, | 24 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1, |
| 25 | _ForwardIterator1 __last1, | 25 | _ForwardIterator1 __last1, |
| 26 | _ForwardIterator2 __first2, | 26 | _ForwardIterator2 __first2, |
| 27 | _ForwardIterator2 __last2, _BinaryPredicate __pred) { | 27 | _ForwardIterator2 __last2, |
| 28 | _BinaryPredicate&& __pred) { | ||
| 28 | for (; __first1 != __last1; ++__first1) | 29 | for (; __first1 != __last1; ++__first1) |
| 29 | for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) | 30 | for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) |
| 30 | if (__pred(*__first1, *__j)) | 31 | if (__pred(*__first1, *__j)) |
lib/libcxx/include/__algorithm/inplace_merge.h+2-4| ... | @@ -9,7 +9,6 @@ | ... | @@ -9,7 +9,6 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H | 9 | #ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H |
| 10 | #define _LIBCPP___ALGORITHM_INPLACE_MERGE_H | 10 | #define _LIBCPP___ALGORITHM_INPLACE_MERGE_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/algorithm_family.h> | ||
| 13 | #include <__algorithm/comp.h> | 12 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/comp_ref_type.h> | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | #include <__algorithm/iterator_operations.h> | 14 | #include <__algorithm/iterator_operations.h> |
| ... | @@ -65,7 +64,7 @@ void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1, | ... | @@ -65,7 +64,7 @@ void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1, |
| 65 | { | 64 | { |
| 66 | if (__first2 == __last2) | 65 | if (__first2 == __last2) |
| 67 | { | 66 | { |
| 68 | _AlgFamily<_AlgPolicy>::__move(__first1, __last1, __result); | 67 | std::__move<_AlgPolicy>(__first1, __last1, __result); |
| 69 | return; | 68 | return; |
| 70 | } | 69 | } |
| 71 | 70 | ||
| ... | @@ -185,8 +184,7 @@ void __inplace_merge( | ... | @@ -185,8 +184,7 @@ void __inplace_merge( |
| 185 | difference_type __len22 = __len2 - __len21; // distance(__m2, __last) | 184 | difference_type __len22 = __len2 - __len21; // distance(__m2, __last) |
| 186 | // [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) | 185 | // [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) |
| 187 | // swap middle two partitions | 186 | // swap middle two partitions |
| 188 | // TODO(alg-policy): pass `_AlgPolicy` once it's supported by `rotate`. | 187 | __middle = std::__rotate<_AlgPolicy>(__m1, __middle, __m2).first; |
| 189 | __middle = _VSTD::rotate(__m1, __middle, __m2); | ||
| 190 | // __len12 and __len21 now have swapped meanings | 188 | // __len12 and __len21 now have swapped meanings |
| 191 | // merge smaller range with recursive call and larger with tail recursion elimination | 189 | // merge smaller range with recursive call and larger with tail recursion elimination |
| 192 | if (__len11 + __len21 < __len12 + __len22) | 190 | if (__len11 + __len21 < __len12 + __len22) |
lib/libcxx/include/__algorithm/is_permutation.h+168-91| ... | @@ -11,10 +11,16 @@ | ... | @@ -11,10 +11,16 @@ |
| 11 | #define _LIBCPP___ALGORITHM_IS_PERMUTATION_H | 11 | #define _LIBCPP___ALGORITHM_IS_PERMUTATION_H |
| 12 | 12 | ||
| 13 | #include <__algorithm/comp.h> | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/iterator_operations.h> | ||
| 14 | #include <__config> | 15 | #include <__config> |
| 16 | #include <__functional/identity.h> | ||
| 17 | #include <__functional/invoke.h> | ||
| 18 | #include <__iterator/concepts.h> | ||
| 15 | #include <__iterator/distance.h> | 19 | #include <__iterator/distance.h> |
| 16 | #include <__iterator/iterator_traits.h> | 20 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__iterator/next.h> | 21 | #include <__iterator/next.h> |
| 22 | #include <__utility/move.h> | ||
| 23 | #include <type_traits> | ||
| 18 | 24 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header | 26 | # pragma GCC system_header |
| ... | @@ -22,140 +28,211 @@ | ... | @@ -22,140 +28,211 @@ |
| 22 | 28 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 30 | ||
| 25 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | 31 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class = void> |
| 26 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | 32 | struct _ConstTimeDistance : false_type {}; |
| 27 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, | ||
| 28 | _BinaryPredicate __pred) { | ||
| 29 | // shorten sequences as much as possible by lopping of any equal prefix | ||
| 30 | for (; __first1 != __last1; ++__first1, (void)++__first2) | ||
| 31 | if (!__pred(*__first1, *__first2)) | ||
| 32 | break; | ||
| 33 | if (__first1 == __last1) | ||
| 34 | return true; | ||
| 35 | 33 | ||
| 36 | // __first1 != __last1 && *__first1 != *__first2 | 34 | #if _LIBCPP_STD_VER > 17 |
| 37 | typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1; | 35 | |
| 38 | _D1 __l1 = _VSTD::distance(__first1, __last1); | 36 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2> |
| 39 | if (__l1 == _D1(1)) | 37 | struct _ConstTimeDistance<_Iter1, _Sent1, _Iter2, _Sent2, __enable_if_t< |
| 40 | return false; | 38 | sized_sentinel_for<_Sent1, _Iter1> && |
| 41 | _ForwardIterator2 __last2 = _VSTD::next(__first2, __l1); | 39 | sized_sentinel_for<_Sent2, _Iter2> |
| 42 | // For each element in [f1, l1) see if there are the same number of | 40 | >> : true_type {}; |
| 43 | // equal elements in [f2, l2) | 41 | |
| 44 | for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) { | 42 | #else |
| 43 | |||
| 44 | template <class _Iter1, class _Iter2> | ||
| 45 | struct _ConstTimeDistance<_Iter1, _Iter1, _Iter2, _Iter2, __enable_if_t< | ||
| 46 | is_same<typename iterator_traits<_Iter1>::iterator_category, random_access_iterator_tag>::value && | ||
| 47 | is_same<typename iterator_traits<_Iter2>::iterator_category, random_access_iterator_tag>::value | ||
| 48 | > > : true_type {}; | ||
| 49 | |||
| 50 | #endif // _LIBCPP_STD_VER > 17 | ||
| 51 | |||
| 52 | // Internal functions | ||
| 53 | |||
| 54 | // For each element in [f1, l1) see if there are the same number of equal elements in [f2, l2) | ||
| 55 | template <class _AlgPolicy, | ||
| 56 | class _Iter1, class _Sent1, class _Iter2, class _Sent2, | ||
| 57 | class _Proj1, class _Proj2, class _Pred> | ||
| 58 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | ||
| 59 | __is_permutation_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, | ||
| 60 | _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) { | ||
| 61 | using _D1 = __iter_diff_t<_Iter1>; | ||
| 62 | |||
| 63 | for (auto __i = __first1; __i != __last1; ++__i) { | ||
| 45 | // Have we already counted the number of *__i in [f1, l1)? | 64 | // Have we already counted the number of *__i in [f1, l1)? |
| 46 | _ForwardIterator1 __match = __first1; | 65 | auto __match = __first1; |
| 47 | for (; __match != __i; ++__match) | 66 | for (; __match != __i; ++__match) { |
| 48 | if (__pred(*__match, *__i)) | 67 | if (std::__invoke(__pred, std::__invoke(__proj1, *__match), std::__invoke(__proj1, *__i))) |
| 49 | break; | 68 | break; |
| 69 | } | ||
| 70 | |||
| 50 | if (__match == __i) { | 71 | if (__match == __i) { |
| 51 | // Count number of *__i in [f2, l2) | 72 | // Count number of *__i in [f2, l2) |
| 52 | _D1 __c2 = 0; | 73 | _D1 __c2 = 0; |
| 53 | for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) | 74 | for (auto __j = __first2; __j != __last2; ++__j) { |
| 54 | if (__pred(*__i, *__j)) | 75 | if (std::__invoke(__pred, std::__invoke(__proj1, *__i), std::__invoke(__proj2, *__j))) |
| 55 | ++__c2; | 76 | ++__c2; |
| 77 | } | ||
| 56 | if (__c2 == 0) | 78 | if (__c2 == 0) |
| 57 | return false; | 79 | return false; |
| 80 | |||
| 58 | // Count number of *__i in [__i, l1) (we can start with 1) | 81 | // Count number of *__i in [__i, l1) (we can start with 1) |
| 59 | _D1 __c1 = 1; | 82 | _D1 __c1 = 1; |
| 60 | for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j) | 83 | for (auto __j = _IterOps<_AlgPolicy>::next(__i); __j != __last1; ++__j) { |
| 61 | if (__pred(*__i, *__j)) | 84 | if (std::__invoke(__pred, std::__invoke(__proj1, *__i), std::__invoke(__proj1, *__j))) |
| 62 | ++__c1; | 85 | ++__c1; |
| 86 | } | ||
| 63 | if (__c1 != __c2) | 87 | if (__c1 != __c2) |
| 64 | return false; | 88 | return false; |
| 65 | } | 89 | } |
| 66 | } | 90 | } |
| 91 | |||
| 67 | return true; | 92 | return true; |
| 68 | } | 93 | } |
| 69 | 94 | ||
| 70 | template <class _ForwardIterator1, class _ForwardIterator2> | 95 | // 2+1 iterators, predicate. Not used by range algorithms. |
| 71 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | 96 | template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate> |
| 72 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { | 97 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool |
| 73 | typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; | 98 | __is_permutation(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, |
| 74 | typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; | 99 | _BinaryPredicate&& __pred) { |
| 75 | return _VSTD::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>()); | 100 | // Shorten sequences as much as possible by lopping of any equal prefix. |
| 101 | for (; __first1 != __last1; ++__first1, (void)++__first2) { | ||
| 102 | if (!__pred(*__first1, *__first2)) | ||
| 103 | break; | ||
| 104 | } | ||
| 105 | |||
| 106 | if (__first1 == __last1) | ||
| 107 | return true; | ||
| 108 | |||
| 109 | // __first1 != __last1 && *__first1 != *__first2 | ||
| 110 | using _D1 = __iter_diff_t<_ForwardIterator1>; | ||
| 111 | _D1 __l1 = _IterOps<_AlgPolicy>::distance(__first1, __last1); | ||
| 112 | if (__l1 == _D1(1)) | ||
| 113 | return false; | ||
| 114 | auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __l1); | ||
| 115 | |||
| 116 | return std::__is_permutation_impl<_AlgPolicy>( | ||
| 117 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), | ||
| 118 | __pred, __identity(), __identity()); | ||
| 76 | } | 119 | } |
| 77 | 120 | ||
| 78 | #if _LIBCPP_STD_VER > 11 | 121 | // 2+2 iterators, predicate, non-constant time `distance`. |
| 79 | template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2> | 122 | template <class _AlgPolicy, |
| 80 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | 123 | class _Iter1, class _Sent1, class _Iter2, class _Sent2, |
| 81 | __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, | 124 | class _Proj1, class _Proj2, class _Pred> |
| 82 | _ForwardIterator2 __last2, _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) { | 125 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool |
| 83 | // shorten sequences as much as possible by lopping of any equal prefix | 126 | __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, |
| 84 | for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) | 127 | _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2, |
| 85 | if (!__pred(*__first1, *__first2)) | 128 | /*_ConstTimeDistance=*/false_type) { |
| 129 | // Shorten sequences as much as possible by lopping of any equal prefix. | ||
| 130 | while (__first1 != __last1 && __first2 != __last2) { | ||
| 131 | if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | ||
| 86 | break; | 132 | break; |
| 133 | ++__first1; | ||
| 134 | ++__first2; | ||
| 135 | } | ||
| 136 | |||
| 87 | if (__first1 == __last1) | 137 | if (__first1 == __last1) |
| 88 | return __first2 == __last2; | 138 | return __first2 == __last2; |
| 89 | else if (__first2 == __last2) | 139 | if (__first2 == __last2) // Second range is shorter |
| 90 | return false; | 140 | return false; |
| 91 | 141 | ||
| 92 | typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1; | 142 | using _D1 = __iter_diff_t<_Iter1>; |
| 93 | _D1 __l1 = _VSTD::distance(__first1, __last1); | 143 | _D1 __l1 = _IterOps<_AlgPolicy>::distance(__first1, __last1); |
| 94 | 144 | ||
| 95 | typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2; | 145 | using _D2 = __iter_diff_t<_Iter2>; |
| 96 | _D2 __l2 = _VSTD::distance(__first2, __last2); | 146 | _D2 __l2 = _IterOps<_AlgPolicy>::distance(__first2, __last2); |
| 97 | if (__l1 != __l2) | 147 | if (__l1 != __l2) |
| 98 | return false; | 148 | return false; |
| 99 | 149 | ||
| 100 | // For each element in [f1, l1) see if there are the same number of | 150 | return std::__is_permutation_impl<_AlgPolicy>( |
| 101 | // equal elements in [f2, l2) | 151 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), |
| 102 | for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) { | 152 | __pred, __proj1, __proj2); |
| 103 | // Have we already counted the number of *__i in [f1, l1)? | ||
| 104 | _ForwardIterator1 __match = __first1; | ||
| 105 | for (; __match != __i; ++__match) | ||
| 106 | if (__pred(*__match, *__i)) | ||
| 107 | break; | ||
| 108 | if (__match == __i) { | ||
| 109 | // Count number of *__i in [f2, l2) | ||
| 110 | _D1 __c2 = 0; | ||
| 111 | for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) | ||
| 112 | if (__pred(*__i, *__j)) | ||
| 113 | ++__c2; | ||
| 114 | if (__c2 == 0) | ||
| 115 | return false; | ||
| 116 | // Count number of *__i in [__i, l1) (we can start with 1) | ||
| 117 | _D1 __c1 = 1; | ||
| 118 | for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j) | ||
| 119 | if (__pred(*__i, *__j)) | ||
| 120 | ++__c1; | ||
| 121 | if (__c1 != __c2) | ||
| 122 | return false; | ||
| 123 | } | ||
| 124 | } | ||
| 125 | return true; | ||
| 126 | } | 153 | } |
| 127 | 154 | ||
| 128 | template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2> | 155 | // 2+2 iterators, predicate, specialization for constant-time `distance` call. |
| 129 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1, | 156 | template <class _AlgPolicy, |
| 130 | _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2, | 157 | class _Iter1, class _Sent1, class _Iter2, class _Sent2, |
| 131 | _BinaryPredicate __pred, random_access_iterator_tag, | 158 | class _Proj1, class _Proj2, class _Pred> |
| 132 | random_access_iterator_tag) { | 159 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool |
| 133 | if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) | 160 | __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, |
| 161 | _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2, | ||
| 162 | /*_ConstTimeDistance=*/true_type) { | ||
| 163 | if (std::distance(__first1, __last1) != std::distance(__first2, __last2)) | ||
| 134 | return false; | 164 | return false; |
| 135 | return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2, | 165 | return std::__is_permutation<_AlgPolicy>( |
| 136 | _BinaryPredicate&>(__first1, __last1, __first2, __pred); | 166 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), |
| 167 | __pred, __proj1, __proj2, | ||
| 168 | /*_ConstTimeDistance=*/false_type()); | ||
| 169 | } | ||
| 170 | |||
| 171 | // 2+2 iterators, predicate | ||
| 172 | template <class _AlgPolicy, | ||
| 173 | class _Iter1, class _Sent1, class _Iter2, class _Sent2, | ||
| 174 | class _Proj1, class _Proj2, class _Pred> | ||
| 175 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | ||
| 176 | __is_permutation(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, | ||
| 177 | _Pred&& __pred, _Proj1&& __proj1, _Proj2&& __proj2) { | ||
| 178 | return std::__is_permutation<_AlgPolicy>( | ||
| 179 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), | ||
| 180 | __pred, __proj1, __proj2, | ||
| 181 | _ConstTimeDistance<_Iter1, _Sent1, _Iter2, _Sent2>()); | ||
| 137 | } | 182 | } |
| 138 | 183 | ||
| 184 | // Public interface | ||
| 185 | |||
| 186 | // 2+1 iterators, predicate | ||
| 139 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | 187 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 140 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | 188 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool |
| 141 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, | 189 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, |
| 142 | _ForwardIterator2 __last2, _BinaryPredicate __pred) { | 190 | _BinaryPredicate __pred) { |
| 143 | return _VSTD::__is_permutation<_BinaryPredicate&>( | 191 | static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, |
| 144 | __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), | 192 | "The predicate has to be callable"); |
| 145 | typename iterator_traits<_ForwardIterator2>::iterator_category()); | 193 | |
| 194 | return std::__is_permutation<_ClassicAlgPolicy>( | ||
| 195 | std::move(__first1), std::move(__last1), std::move(__first2), __pred); | ||
| 146 | } | 196 | } |
| 147 | 197 | ||
| 198 | // 2+1 iterators | ||
| 199 | template <class _ForwardIterator1, class _ForwardIterator2> | ||
| 200 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | ||
| 201 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { | ||
| 202 | using __v1 = __iter_value_type<_ForwardIterator1>; | ||
| 203 | using __v2 = __iter_value_type<_ForwardIterator2>; | ||
| 204 | return std::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>()); | ||
| 205 | } | ||
| 206 | |||
| 207 | #if _LIBCPP_STD_VER > 11 | ||
| 208 | |||
| 209 | // 2+2 iterators | ||
| 148 | template <class _ForwardIterator1, class _ForwardIterator2> | 210 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 149 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | 211 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool |
| 150 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, | 212 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, |
| 151 | _ForwardIterator2 __last2) { | 213 | _ForwardIterator2 __last2) { |
| 152 | typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; | 214 | using __v1 = __iter_value_type<_ForwardIterator1>; |
| 153 | typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; | 215 | using __v2 = __iter_value_type<_ForwardIterator2>; |
| 154 | return _VSTD::__is_permutation(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(), | 216 | |
| 155 | typename iterator_traits<_ForwardIterator1>::iterator_category(), | 217 | return std::__is_permutation<_ClassicAlgPolicy>( |
| 156 | typename iterator_traits<_ForwardIterator2>::iterator_category()); | 218 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), |
| 219 | __equal_to<__v1, __v2>(), __identity(), __identity()); | ||
| 157 | } | 220 | } |
| 158 | #endif | 221 | |
| 222 | // 2+2 iterators, predicate | ||
| 223 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | ||
| 224 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | ||
| 225 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, | ||
| 226 | _ForwardIterator2 __last2, _BinaryPredicate __pred) { | ||
| 227 | static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, | ||
| 228 | "The predicate has to be callable"); | ||
| 229 | |||
| 230 | return std::__is_permutation<_ClassicAlgPolicy>( | ||
| 231 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), | ||
| 232 | __pred, __identity(), __identity()); | ||
| 233 | } | ||
| 234 | |||
| 235 | #endif // _LIBCPP_STD_VER > 11 | ||
| 159 | 236 | ||
| 160 | _LIBCPP_END_NAMESPACE_STD | 237 | _LIBCPP_END_NAMESPACE_STD |
| 161 | 238 |
lib/libcxx/include/__algorithm/iterator_operations.h+25-1| ... | @@ -10,13 +10,16 @@ | ... | @@ -10,13 +10,16 @@ |
| 10 | #define _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H | 10 | #define _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/iter_swap.h> | 12 | #include <__algorithm/iter_swap.h> |
| 13 | #include <__algorithm/ranges_iterator_concept.h> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__iterator/advance.h> | 15 | #include <__iterator/advance.h> |
| 15 | #include <__iterator/distance.h> | 16 | #include <__iterator/distance.h> |
| 17 | #include <__iterator/incrementable_traits.h> | ||
| 16 | #include <__iterator/iter_move.h> | 18 | #include <__iterator/iter_move.h> |
| 17 | #include <__iterator/iter_swap.h> | 19 | #include <__iterator/iter_swap.h> |
| 18 | #include <__iterator/iterator_traits.h> | 20 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__iterator/next.h> | 21 | #include <__iterator/next.h> |
| 22 | #include <__iterator/prev.h> | ||
| 20 | #include <__iterator/readable_traits.h> | 23 | #include <__iterator/readable_traits.h> |
| 21 | #include <__utility/declval.h> | 24 | #include <__utility/declval.h> |
| 22 | #include <__utility/forward.h> | 25 | #include <__utility/forward.h> |
| ... | @@ -40,11 +43,18 @@ struct _IterOps<_RangeAlgPolicy> { | ... | @@ -40,11 +43,18 @@ struct _IterOps<_RangeAlgPolicy> { |
| 40 | template <class _Iter> | 43 | template <class _Iter> |
| 41 | using __value_type = iter_value_t<_Iter>; | 44 | using __value_type = iter_value_t<_Iter>; |
| 42 | 45 | ||
| 46 | template <class _Iter> | ||
| 47 | using __iterator_category = ranges::__iterator_concept<_Iter>; | ||
| 48 | |||
| 49 | template <class _Iter> | ||
| 50 | using __difference_type = iter_difference_t<_Iter>; | ||
| 51 | |||
| 43 | static constexpr auto advance = ranges::advance; | 52 | static constexpr auto advance = ranges::advance; |
| 44 | static constexpr auto distance = ranges::distance; | 53 | static constexpr auto distance = ranges::distance; |
| 45 | static constexpr auto __iter_move = ranges::iter_move; | 54 | static constexpr auto __iter_move = ranges::iter_move; |
| 46 | static constexpr auto iter_swap = ranges::iter_swap; | 55 | static constexpr auto iter_swap = ranges::iter_swap; |
| 47 | static constexpr auto next = ranges::next; | 56 | static constexpr auto next = ranges::next; |
| 57 | static constexpr auto prev = ranges::prev; | ||
| 48 | static constexpr auto __advance_to = ranges::advance; | 58 | static constexpr auto __advance_to = ranges::advance; |
| 49 | }; | 59 | }; |
| 50 | 60 | ||
| ... | @@ -58,6 +68,12 @@ struct _IterOps<_ClassicAlgPolicy> { | ... | @@ -58,6 +68,12 @@ struct _IterOps<_ClassicAlgPolicy> { |
| 58 | template <class _Iter> | 68 | template <class _Iter> |
| 59 | using __value_type = typename iterator_traits<_Iter>::value_type; | 69 | using __value_type = typename iterator_traits<_Iter>::value_type; |
| 60 | 70 | ||
| 71 | template <class _Iter> | ||
| 72 | using __iterator_category = typename iterator_traits<_Iter>::iterator_category; | ||
| 73 | |||
| 74 | template <class _Iter> | ||
| 75 | using __difference_type = typename iterator_traits<_Iter>::difference_type; | ||
| 76 | |||
| 61 | // advance | 77 | // advance |
| 62 | template <class _Iter, class _Distance> | 78 | template <class _Iter, class _Distance> |
| 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | 79 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| ... | @@ -132,10 +148,18 @@ struct _IterOps<_ClassicAlgPolicy> { | ... | @@ -132,10 +148,18 @@ struct _IterOps<_ClassicAlgPolicy> { |
| 132 | template <class _Iter> | 148 | template <class _Iter> |
| 133 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 | 149 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 134 | __uncvref_t<_Iter> next(_Iter&& __it, | 150 | __uncvref_t<_Iter> next(_Iter&& __it, |
| 135 | typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1){ | 151 | typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1) { |
| 136 | return std::next(std::forward<_Iter>(__it), __n); | 152 | return std::next(std::forward<_Iter>(__it), __n); |
| 137 | } | 153 | } |
| 138 | 154 | ||
| 155 | // prev | ||
| 156 | template <class _Iter> | ||
| 157 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 | ||
| 158 | __uncvref_t<_Iter> prev(_Iter&& __iter, | ||
| 159 | typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1) { | ||
| 160 | return std::prev(std::forward<_Iter>(__iter), __n); | ||
| 161 | } | ||
| 162 | |||
| 139 | template <class _Iter> | 163 | template <class _Iter> |
| 140 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 | 164 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 141 | void __advance_to(_Iter& __first, _Iter __last) { | 165 | void __advance_to(_Iter& __first, _Iter __last) { |
lib/libcxx/include/__algorithm/move.h+15-11| ... | @@ -9,6 +9,7 @@ | ... | @@ -9,6 +9,7 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_MOVE_H | 9 | #ifndef _LIBCPP___ALGORITHM_MOVE_H |
| 10 | #define _LIBCPP___ALGORITHM_MOVE_H | 10 | #define _LIBCPP___ALGORITHM_MOVE_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | ||
| 12 | #include <__algorithm/unwrap_iter.h> | 13 | #include <__algorithm/unwrap_iter.h> |
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__iterator/iterator_traits.h> | 15 | #include <__iterator/iterator_traits.h> |
| ... | @@ -26,18 +27,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -26,18 +27,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 27 | ||
| 27 | // move | 28 | // move |
| 28 | 29 | ||
| 29 | template <class _InIter, class _Sent, class _OutIter> | 30 | template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> |
| 30 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | 31 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 31 | pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { | 32 | pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { |
| 32 | while (__first != __last) { | 33 | while (__first != __last) { |
| 33 | *__result = std::move(*__first); | 34 | *__result = _IterOps<_AlgPolicy>::__iter_move(__first); |
| 34 | ++__first; | 35 | ++__first; |
| 35 | ++__result; | 36 | ++__result; |
| 36 | } | 37 | } |
| 37 | return std::make_pair(std::move(__first), std::move(__result)); | 38 | return std::make_pair(std::move(__first), std::move(__result)); |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | template <class _InType, | 41 | template <class _AlgPolicy, |
| 42 | class _InType, | ||
| 41 | class _OutType, | 43 | class _OutType, |
| 42 | class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value | 44 | class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value |
| 43 | && is_trivially_move_assignable<_OutType>::value> > | 45 | && is_trivially_move_assignable<_OutType>::value> > |
| ... | @@ -49,7 +51,7 @@ pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutTyp | ... | @@ -49,7 +51,7 @@ pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutTyp |
| 49 | && !is_trivially_copyable<_InType>::value | 51 | && !is_trivially_copyable<_InType>::value |
| 50 | #endif | 52 | #endif |
| 51 | ) | 53 | ) |
| 52 | return std::__move_impl<_InType*, _InType*, _OutType*>(__first, __last, __result); | 54 | return std::__move_impl<_AlgPolicy, _InType*, _InType*, _OutType*>(__first, __last, __result); |
| 53 | const size_t __n = static_cast<size_t>(__last - __first); | 55 | const size_t __n = static_cast<size_t>(__last - __first); |
| 54 | ::__builtin_memmove(__result, __first, __n * sizeof(_OutType)); | 56 | ::__builtin_memmove(__result, __first, __n * sizeof(_OutType)); |
| 55 | return std::make_pair(__first + __n, __result + __n); | 57 | return std::make_pair(__first + __n, __result + __n); |
| ... | @@ -65,7 +67,8 @@ template <class _Iter> | ... | @@ -65,7 +67,8 @@ template <class _Iter> |
| 65 | struct __is_trivially_move_assignable_unwrapped | 67 | struct __is_trivially_move_assignable_unwrapped |
| 66 | : __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {}; | 68 | : __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {}; |
| 67 | 69 | ||
| 68 | template <class _InIter, | 70 | template <class _AlgPolicy, |
| 71 | class _InIter, | ||
| 69 | class _OutIter, | 72 | class _OutIter, |
| 70 | __enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type, | 73 | __enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type, |
| 71 | typename iterator_traits<_OutIter>::value_type>::value | 74 | typename iterator_traits<_OutIter>::value_type>::value |
| ... | @@ -81,33 +84,34 @@ __move_impl(reverse_iterator<_InIter> __first, | ... | @@ -81,33 +84,34 @@ __move_impl(reverse_iterator<_InIter> __first, |
| 81 | auto __last_base = std::__unwrap_iter(__last.base()); | 84 | auto __last_base = std::__unwrap_iter(__last.base()); |
| 82 | auto __result_base = std::__unwrap_iter(__result.base()); | 85 | auto __result_base = std::__unwrap_iter(__result.base()); |
| 83 | auto __result_first = __result_base - (__first_base - __last_base); | 86 | auto __result_first = __result_base - (__first_base - __last_base); |
| 84 | std::__move_impl(__last_base, __first_base, __result_first); | 87 | std::__move_impl<_AlgPolicy>(__last_base, __first_base, __result_first); |
| 85 | return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first))); | 88 | return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first))); |
| 86 | } | 89 | } |
| 87 | 90 | ||
| 88 | template <class _InIter, class _Sent, class _OutIter> | 91 | template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> |
| 89 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | 92 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 90 | __enable_if_t<is_copy_constructible<_InIter>::value | 93 | __enable_if_t<is_copy_constructible<_InIter>::value |
| 91 | && is_copy_constructible<_Sent>::value | 94 | && is_copy_constructible<_Sent>::value |
| 92 | && is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> > | 95 | && is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> > |
| 93 | __move(_InIter __first, _Sent __last, _OutIter __result) { | 96 | __move(_InIter __first, _Sent __last, _OutIter __result) { |
| 94 | auto __ret = std::__move_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result)); | 97 | auto __ret = std::__move_impl<_AlgPolicy>( |
| 98 | std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result)); | ||
| 95 | return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second)); | 99 | return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second)); |
| 96 | } | 100 | } |
| 97 | 101 | ||
| 98 | template <class _InIter, class _Sent, class _OutIter> | 102 | template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> |
| 99 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | 103 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 100 | __enable_if_t<!is_copy_constructible<_InIter>::value | 104 | __enable_if_t<!is_copy_constructible<_InIter>::value |
| 101 | || !is_copy_constructible<_Sent>::value | 105 | || !is_copy_constructible<_Sent>::value |
| 102 | || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> > | 106 | || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> > |
| 103 | __move(_InIter __first, _Sent __last, _OutIter __result) { | 107 | __move(_InIter __first, _Sent __last, _OutIter __result) { |
| 104 | return std::__move_impl(std::move(__first), std::move(__last), std::move(__result)); | 108 | return std::__move_impl<_AlgPolicy>(std::move(__first), std::move(__last), std::move(__result)); |
| 105 | } | 109 | } |
| 106 | 110 | ||
| 107 | template <class _InputIterator, class _OutputIterator> | 111 | template <class _InputIterator, class _OutputIterator> |
| 108 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | 112 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 109 | _OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | 113 | _OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { |
| 110 | return std::__move(__first, __last, __result).second; | 114 | return std::__move<_ClassicAlgPolicy>(__first, __last, __result).second; |
| 111 | } | 115 | } |
| 112 | 116 | ||
| 113 | _LIBCPP_END_NAMESPACE_STD | 117 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/move_backward.h+24-14| ... | @@ -9,6 +9,7 @@ | ... | @@ -9,6 +9,7 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H | 9 | #ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H |
| 10 | #define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H | 10 | #define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | ||
| 12 | #include <__algorithm/unwrap_iter.h> | 13 | #include <__algorithm/unwrap_iter.h> |
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__utility/move.h> | 15 | #include <__utility/move.h> |
| ... | @@ -21,25 +22,25 @@ | ... | @@ -21,25 +22,25 @@ |
| 21 | 22 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 24 | ||
| 24 | template <class _InputIterator, class _OutputIterator> | 25 | template <class _AlgPolicy, class _InputIterator, class _OutputIterator> |
| 25 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | 26 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 26 | _OutputIterator | 27 | _OutputIterator |
| 27 | __move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | 28 | __move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result) |
| 28 | { | 29 | { |
| 29 | while (__first != __last) | 30 | while (__first != __last) |
| 30 | *--__result = _VSTD::move(*--__last); | 31 | *--__result = _IterOps<_AlgPolicy>::__iter_move(--__last); |
| 31 | return __result; | 32 | return __result; |
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | template <class _InputIterator, class _OutputIterator> | 35 | template <class _AlgPolicy, class _InputIterator, class _OutputIterator> |
| 35 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | 36 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 36 | _OutputIterator | 37 | _OutputIterator |
| 37 | __move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | 38 | __move_backward_impl(_InputIterator __first, _InputIterator __last, _OutputIterator __result) |
| 38 | { | 39 | { |
| 39 | return _VSTD::__move_backward_constexpr(__first, __last, __result); | 40 | return _VSTD::__move_backward_constexpr<_AlgPolicy>(__first, __last, __result); |
| 40 | } | 41 | } |
| 41 | 42 | ||
| 42 | template <class _Tp, class _Up> | 43 | template <class _AlgPolicy, class _Tp, class _Up> |
| 43 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | 44 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 44 | typename enable_if | 45 | typename enable_if |
| 45 | < | 46 | < |
| ... | @@ -47,7 +48,7 @@ typename enable_if | ... | @@ -47,7 +48,7 @@ typename enable_if |
| 47 | is_trivially_move_assignable<_Up>::value, | 48 | is_trivially_move_assignable<_Up>::value, |
| 48 | _Up* | 49 | _Up* |
| 49 | >::type | 50 | >::type |
| 50 | __move_backward(_Tp* __first, _Tp* __last, _Up* __result) | 51 | __move_backward_impl(_Tp* __first, _Tp* __last, _Up* __result) |
| 51 | { | 52 | { |
| 52 | const size_t __n = static_cast<size_t>(__last - __first); | 53 | const size_t __n = static_cast<size_t>(__last - __first); |
| 53 | if (__n > 0) | 54 | if (__n > 0) |
| ... | @@ -58,22 +59,31 @@ __move_backward(_Tp* __first, _Tp* __last, _Up* __result) | ... | @@ -58,22 +59,31 @@ __move_backward(_Tp* __first, _Tp* __last, _Up* __result) |
| 58 | return __result; | 59 | return __result; |
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | template <class _BidirectionalIterator1, class _BidirectionalIterator2> | 62 | template <class _AlgPolicy, class _BidirectionalIterator1, class _BidirectionalIterator2> |
| 62 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | 63 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 63 | _BidirectionalIterator2 | 64 | _BidirectionalIterator2 |
| 64 | move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, | 65 | __move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, |
| 65 | _BidirectionalIterator2 __result) | 66 | _BidirectionalIterator2 __result) |
| 66 | { | 67 | { |
| 67 | if (__libcpp_is_constant_evaluated()) { | 68 | if (__libcpp_is_constant_evaluated()) { |
| 68 | return _VSTD::__move_backward_constexpr(__first, __last, __result); | 69 | return _VSTD::__move_backward_constexpr<_AlgPolicy>(__first, __last, __result); |
| 69 | } else { | 70 | } else { |
| 70 | return _VSTD::__rewrap_iter(__result, | 71 | return _VSTD::__rewrap_iter(__result, |
| 71 | _VSTD::__move_backward(_VSTD::__unwrap_iter(__first), | 72 | _VSTD::__move_backward_impl<_AlgPolicy>(_VSTD::__unwrap_iter(__first), |
| 72 | _VSTD::__unwrap_iter(__last), | 73 | _VSTD::__unwrap_iter(__last), |
| 73 | _VSTD::__unwrap_iter(__result))); | 74 | _VSTD::__unwrap_iter(__result))); |
| 74 | } | 75 | } |
| 75 | } | 76 | } |
| 76 | 77 | ||
| 78 | template <class _BidirectionalIterator1, class _BidirectionalIterator2> | ||
| 79 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | ||
| 80 | _BidirectionalIterator2 | ||
| 81 | move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, | ||
| 82 | _BidirectionalIterator2 __result) | ||
| 83 | { | ||
| 84 | return std::__move_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)); | ||
| 85 | } | ||
| 86 | |||
| 77 | _LIBCPP_END_NAMESPACE_STD | 87 | _LIBCPP_END_NAMESPACE_STD |
| 78 | 88 | ||
| 79 | #endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H | 89 | #endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H |
lib/libcxx/include/__algorithm/next_permutation.h+22-14| ... | @@ -11,10 +11,12 @@ | ... | @@ -11,10 +11,12 @@ |
| 11 | 11 | ||
| 12 | #include <__algorithm/comp.h> | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | ||
| 14 | #include <__algorithm/reverse.h> | 15 | #include <__algorithm/reverse.h> |
| 15 | #include <__config> | 16 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__utility/swap.h> | 18 | #include <__utility/move.h> |
| 19 | #include <__utility/pair.h> | ||
| 18 | 20 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| ... | @@ -22,29 +24,34 @@ | ... | @@ -22,29 +24,34 @@ |
| 22 | 24 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 26 | ||
| 25 | template <class _Compare, class _BidirectionalIterator> | 27 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel> |
| 26 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | 28 | _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 27 | __next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) | 29 | pair<_BidirectionalIterator, bool> |
| 30 | __next_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp) | ||
| 28 | { | 31 | { |
| 29 | _BidirectionalIterator __i = __last; | 32 | using _Result = pair<_BidirectionalIterator, bool>; |
| 33 | |||
| 34 | _BidirectionalIterator __last_iter = _IterOps<_AlgPolicy>::next(__first, __last); | ||
| 35 | _BidirectionalIterator __i = __last_iter; | ||
| 30 | if (__first == __last || __first == --__i) | 36 | if (__first == __last || __first == --__i) |
| 31 | return false; | 37 | return _Result(std::move(__last_iter), false); |
| 38 | |||
| 32 | while (true) | 39 | while (true) |
| 33 | { | 40 | { |
| 34 | _BidirectionalIterator __ip1 = __i; | 41 | _BidirectionalIterator __ip1 = __i; |
| 35 | if (__comp(*--__i, *__ip1)) | 42 | if (__comp(*--__i, *__ip1)) |
| 36 | { | 43 | { |
| 37 | _BidirectionalIterator __j = __last; | 44 | _BidirectionalIterator __j = __last_iter; |
| 38 | while (!__comp(*__i, *--__j)) | 45 | while (!__comp(*__i, *--__j)) |
| 39 | ; | 46 | ; |
| 40 | swap(*__i, *__j); | 47 | _IterOps<_AlgPolicy>::iter_swap(__i, __j); |
| 41 | _VSTD::reverse(__ip1, __last); | 48 | std::__reverse<_AlgPolicy>(__ip1, __last_iter); |
| 42 | return true; | 49 | return _Result(std::move(__last_iter), true); |
| 43 | } | 50 | } |
| 44 | if (__i == __first) | 51 | if (__i == __first) |
| 45 | { | 52 | { |
| 46 | _VSTD::reverse(__first, __last); | 53 | std::__reverse<_AlgPolicy>(__first, __last_iter); |
| 47 | return false; | 54 | return _Result(std::move(__last_iter), false); |
| 48 | } | 55 | } |
| 49 | } | 56 | } |
| 50 | } | 57 | } |
| ... | @@ -54,8 +61,9 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | ... | @@ -54,8 +61,9 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 54 | bool | 61 | bool |
| 55 | next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) | 62 | next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) |
| 56 | { | 63 | { |
| 57 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | 64 | using _Comp_ref = typename __comp_ref_type<_Compare>::type; |
| 58 | return _VSTD::__next_permutation<_Comp_ref>(__first, __last, __comp); | 65 | return std::__next_permutation<_ClassicAlgPolicy>( |
| 66 | std::move(__first), std::move(__last), static_cast<_Comp_ref>(__comp)).second; | ||
| 59 | } | 67 | } |
| 60 | 68 | ||
| 61 | template <class _BidirectionalIterator> | 69 | template <class _BidirectionalIterator> |
lib/libcxx/include/__algorithm/prev_permutation.h+22-14| ... | @@ -11,10 +11,12 @@ | ... | @@ -11,10 +11,12 @@ |
| 11 | 11 | ||
| 12 | #include <__algorithm/comp.h> | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | ||
| 14 | #include <__algorithm/reverse.h> | 15 | #include <__algorithm/reverse.h> |
| 15 | #include <__config> | 16 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__utility/swap.h> | 18 | #include <__utility/move.h> |
| 19 | #include <__utility/pair.h> | ||
| 18 | 20 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | # pragma GCC system_header | 22 | # pragma GCC system_header |
| ... | @@ -22,29 +24,34 @@ | ... | @@ -22,29 +24,34 @@ |
| 22 | 24 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 26 | ||
| 25 | template <class _Compare, class _BidirectionalIterator> | 27 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator, class _Sentinel> |
| 26 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | 28 | _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 27 | __prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) | 29 | pair<_BidirectionalIterator, bool> |
| 30 | __prev_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&& __comp) | ||
| 28 | { | 31 | { |
| 29 | _BidirectionalIterator __i = __last; | 32 | using _Result = pair<_BidirectionalIterator, bool>; |
| 33 | |||
| 34 | _BidirectionalIterator __last_iter = _IterOps<_AlgPolicy>::next(__first, __last); | ||
| 35 | _BidirectionalIterator __i = __last_iter; | ||
| 30 | if (__first == __last || __first == --__i) | 36 | if (__first == __last || __first == --__i) |
| 31 | return false; | 37 | return _Result(std::move(__last_iter), false); |
| 38 | |||
| 32 | while (true) | 39 | while (true) |
| 33 | { | 40 | { |
| 34 | _BidirectionalIterator __ip1 = __i; | 41 | _BidirectionalIterator __ip1 = __i; |
| 35 | if (__comp(*__ip1, *--__i)) | 42 | if (__comp(*__ip1, *--__i)) |
| 36 | { | 43 | { |
| 37 | _BidirectionalIterator __j = __last; | 44 | _BidirectionalIterator __j = __last_iter; |
| 38 | while (!__comp(*--__j, *__i)) | 45 | while (!__comp(*--__j, *__i)) |
| 39 | ; | 46 | ; |
| 40 | swap(*__i, *__j); | 47 | _IterOps<_AlgPolicy>::iter_swap(__i, __j); |
| 41 | _VSTD::reverse(__ip1, __last); | 48 | std::__reverse<_AlgPolicy>(__ip1, __last_iter); |
| 42 | return true; | 49 | return _Result(std::move(__last_iter), true); |
| 43 | } | 50 | } |
| 44 | if (__i == __first) | 51 | if (__i == __first) |
| 45 | { | 52 | { |
| 46 | _VSTD::reverse(__first, __last); | 53 | std::__reverse<_AlgPolicy>(__first, __last_iter); |
| 47 | return false; | 54 | return _Result(std::move(__last_iter), false); |
| 48 | } | 55 | } |
| 49 | } | 56 | } |
| 50 | } | 57 | } |
| ... | @@ -54,8 +61,9 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | ... | @@ -54,8 +61,9 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 54 | bool | 61 | bool |
| 55 | prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) | 62 | prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) |
| 56 | { | 63 | { |
| 57 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | 64 | using _Comp_ref = typename __comp_ref_type<_Compare>::type; |
| 58 | return _VSTD::__prev_permutation<_Comp_ref>(__first, __last, __comp); | 65 | return std::__prev_permutation<_ClassicAlgPolicy>( |
| 66 | std::move(__first), std::move(__last), static_cast<_Comp_ref>(__comp)).second; | ||
| 59 | } | 67 | } |
| 60 | 68 | ||
| 61 | template <class _BidirectionalIterator> | 69 | template <class _BidirectionalIterator> |
lib/libcxx/include/__algorithm/ranges_clamp.h created+65| ... | @@ -0,0 +1,65 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_CLAMP_H | ||
| 10 | #define _LIBCPP___ALGORITHM_RANGES_CLAMP_H | ||
| 11 | |||
| 12 | #include <__assert> | ||
| 13 | #include <__config> | ||
| 14 | #include <__functional/identity.h> | ||
| 15 | #include <__functional/invoke.h> | ||
| 16 | #include <__functional/ranges_operations.h> | ||
| 17 | #include <__iterator/concepts.h> | ||
| 18 | #include <__iterator/projected.h> | ||
| 19 | #include <__utility/forward.h> | ||
| 20 | |||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 22 | # pragma GCC system_header | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 26 | |||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 28 | |||
| 29 | namespace ranges { | ||
| 30 | namespace __clamp { | ||
| 31 | struct __fn { | ||
| 32 | |||
| 33 | template <class _Type, | ||
| 34 | class _Proj = identity, | ||
| 35 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> | ||
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr | ||
| 37 | const _Type& operator()(const _Type& __value, | ||
| 38 | const _Type& __low, | ||
| 39 | const _Type& __high, | ||
| 40 | _Comp __comp = {}, | ||
| 41 | _Proj __proj = {}) const { | ||
| 42 | _LIBCPP_ASSERT(!bool(std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __low))), | ||
| 43 | "Bad bounds passed to std::ranges::clamp"); | ||
| 44 | |||
| 45 | if (std::invoke(__comp, std::invoke(__proj, __value), std::invoke(__proj, __low))) | ||
| 46 | return __low; | ||
| 47 | else if (std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __value))) | ||
| 48 | return __high; | ||
| 49 | else | ||
| 50 | return __value; | ||
| 51 | } | ||
| 52 | |||
| 53 | }; | ||
| 54 | } // namespace __clamp | ||
| 55 | |||
| 56 | inline namespace __cpo { | ||
| 57 | inline constexpr auto clamp = __clamp::__fn{}; | ||
| 58 | } // namespace __cpo | ||
| 59 | } // namespace ranges | ||
| 60 | |||
| 61 | _LIBCPP_END_NAMESPACE_STD | ||
| 62 | |||
| 63 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 64 | |||
| 65 | #endif // _LIBCPP___ALGORITHM_RANGES_CLAMP_H | ||
lib/libcxx/include/__algorithm/ranges_is_permutation.h created+89| ... | @@ -0,0 +1,89 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_IS_PERMUTATION_H | ||
| 10 | #define _LIBCPP___ALGORITHM_RANGES_IS_PERMUTATION_H | ||
| 11 | |||
| 12 | #include <__algorithm/is_permutation.h> | ||
| 13 | #include <__algorithm/iterator_operations.h> | ||
| 14 | #include <__config> | ||
| 15 | #include <__functional/identity.h> | ||
| 16 | #include <__functional/ranges_operations.h> | ||
| 17 | #include <__iterator/concepts.h> | ||
| 18 | #include <__iterator/distance.h> | ||
| 19 | #include <__iterator/projected.h> | ||
| 20 | #include <__ranges/access.h> | ||
| 21 | #include <__ranges/concepts.h> | ||
| 22 | #include <__utility/move.h> | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | #endif | ||
| 27 | |||
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 29 | |||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 31 | |||
| 32 | namespace ranges { | ||
| 33 | namespace __is_permutation { | ||
| 34 | struct __fn { | ||
| 35 | |||
| 36 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, | ||
| 37 | class _Proj1, class _Proj2, class _Pred> | ||
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr static | ||
| 39 | bool __is_permutation_func_impl(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, | ||
| 40 | _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { | ||
| 41 | return std::__is_permutation<_RangeAlgPolicy>( | ||
| 42 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), | ||
| 43 | __pred, __proj1, __proj2); | ||
| 44 | } | ||
| 45 | |||
| 46 | template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1, | ||
| 47 | forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2, | ||
| 48 | class _Proj1 = identity, | ||
| 49 | class _Proj2 = identity, | ||
| 50 | indirect_equivalence_relation<projected<_Iter1, _Proj1>, | ||
| 51 | projected<_Iter2, _Proj2>> _Pred = ranges::equal_to> | ||
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr | ||
| 53 | bool operator()(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, | ||
| 54 | _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | ||
| 55 | return __is_permutation_func_impl( | ||
| 56 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), | ||
| 57 | __pred, __proj1, __proj2); | ||
| 58 | } | ||
| 59 | |||
| 60 | template <forward_range _Range1, | ||
| 61 | forward_range _Range2, | ||
| 62 | class _Proj1 = identity, | ||
| 63 | class _Proj2 = identity, | ||
| 64 | indirect_equivalence_relation<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> _Pred = ranges::equal_to> | ||
| 65 | _LIBCPP_HIDE_FROM_ABI constexpr | ||
| 66 | bool operator()(_Range1&& __range1, _Range2&& __range2, | ||
| 67 | _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | ||
| 68 | if constexpr (sized_range<_Range1> && sized_range<_Range2>) { | ||
| 69 | if (ranges::distance(__range1) != ranges::distance(__range2)) | ||
| 70 | return false; | ||
| 71 | } | ||
| 72 | |||
| 73 | return __is_permutation_func_impl( | ||
| 74 | ranges::begin(__range1), ranges::end(__range1), ranges::begin(__range2), ranges::end(__range2), | ||
| 75 | __pred, __proj1, __proj2); | ||
| 76 | } | ||
| 77 | }; | ||
| 78 | } // namespace __is_permutation | ||
| 79 | |||
| 80 | inline namespace __cpo { | ||
| 81 | inline constexpr auto is_permutation = __is_permutation::__fn{}; | ||
| 82 | } // namespace __cpo | ||
| 83 | } // namespace ranges | ||
| 84 | |||
| 85 | _LIBCPP_END_NAMESPACE_STD | ||
| 86 | |||
| 87 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 88 | |||
| 89 | #endif // _LIBCPP___ALGORITHM_RANGES_IS_PERMUTATION_H | ||
lib/libcxx/include/__algorithm/ranges_move.h+2-13| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MOVE_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_MOVE_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | 12 | #include <__algorithm/in_out_result.h> |
| 13 | #include <__algorithm/iterator_operations.h> | ||
| 13 | #include <__algorithm/move.h> | 14 | #include <__algorithm/move.h> |
| 14 | #include <__config> | 15 | #include <__config> |
| 15 | #include <__iterator/concepts.h> | 16 | #include <__iterator/concepts.h> |
| ... | @@ -36,24 +37,12 @@ namespace __move { | ... | @@ -36,24 +37,12 @@ namespace __move { |
| 36 | struct __fn { | 37 | struct __fn { |
| 37 | 38 | ||
| 38 | template <class _InIter, class _Sent, class _OutIter> | 39 | template <class _InIter, class _Sent, class _OutIter> |
| 39 | requires __iter_move::__move_deref<_InIter> // check that we are allowed to std::move() the value | ||
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr static | 40 | _LIBCPP_HIDE_FROM_ABI constexpr static |
| 41 | move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { | 41 | move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { |
| 42 | auto __ret = std::__move(std::move(__first), std::move(__last), std::move(__result)); | 42 | auto __ret = std::__move<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)); |
| 43 | return {std::move(__ret.first), std::move(__ret.second)}; | 43 | return {std::move(__ret.first), std::move(__ret.second)}; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | template <class _InIter, class _Sent, class _OutIter> | ||
| 47 | _LIBCPP_HIDE_FROM_ABI constexpr static | ||
| 48 | move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { | ||
| 49 | while (__first != __last) { | ||
| 50 | *__result = ranges::iter_move(__first); | ||
| 51 | ++__first; | ||
| 52 | ++__result; | ||
| 53 | } | ||
| 54 | return {std::move(__first), std::move(__result)}; | ||
| 55 | } | ||
| 56 | |||
| 57 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> | 46 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> |
| 58 | requires indirectly_movable<_InIter, _OutIter> | 47 | requires indirectly_movable<_InIter, _OutIter> |
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr | 48 | _LIBCPP_HIDE_FROM_ABI constexpr |
lib/libcxx/include/__algorithm/ranges_move_backward.h+3-2| ... | @@ -40,10 +40,11 @@ struct __fn { | ... | @@ -40,10 +40,11 @@ struct __fn { |
| 40 | template <class _InIter, class _Sent, class _OutIter> | 40 | template <class _InIter, class _Sent, class _OutIter> |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr static | 41 | _LIBCPP_HIDE_FROM_ABI constexpr static |
| 42 | move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) { | 42 | move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) { |
| 43 | auto __ret = ranges::move(std::make_reverse_iterator(ranges::next(__first, __last)), | 43 | auto __last_iter = ranges::next(__first, std::move(__last)); |
| 44 | auto __ret = ranges::move(std::make_reverse_iterator(__last_iter), | ||
| 44 | std::make_reverse_iterator(__first), | 45 | std::make_reverse_iterator(__first), |
| 45 | std::make_reverse_iterator(__result)); | 46 | std::make_reverse_iterator(__result)); |
| 46 | return {std::move(__ret.in.base()), std::move(__ret.out.base())}; | 47 | return {std::move(__last_iter), std::move(__ret.out.base())}; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter> | 50 | template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter> |
lib/libcxx/include/__algorithm/ranges_next_permutation.h created+72| ... | @@ -0,0 +1,72 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_NEXT_PERMUTATION_H | ||
| 10 | #define _LIBCPP___ALGORITHM_RANGES_NEXT_PERMUTATION_H | ||
| 11 | |||
| 12 | #include <__algorithm/in_found_result.h> | ||
| 13 | #include <__algorithm/iterator_operations.h> | ||
| 14 | #include <__algorithm/make_projected.h> | ||
| 15 | #include <__algorithm/next_permutation.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__functional/identity.h> | ||
| 18 | #include <__functional/ranges_operations.h> | ||
| 19 | #include <__iterator/concepts.h> | ||
| 20 | #include <__iterator/sortable.h> | ||
| 21 | #include <__ranges/access.h> | ||
| 22 | #include <__ranges/concepts.h> | ||
| 23 | #include <__ranges/dangling.h> | ||
| 24 | #include <__utility/move.h> | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 27 | # pragma GCC system_header | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 31 | |||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 33 | |||
| 34 | namespace ranges { | ||
| 35 | |||
| 36 | template <class _InIter> | ||
| 37 | using next_permutation_result = in_found_result<_InIter>; | ||
| 38 | |||
| 39 | namespace __next_permutation { | ||
| 40 | |||
| 41 | struct __fn { | ||
| 42 | template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | ||
| 43 | requires sortable<_Iter, _Comp, _Proj> | ||
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<_Iter> | ||
| 45 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | ||
| 46 | auto __result = std::__next_permutation<_RangeAlgPolicy>( | ||
| 47 | std::move(__first), std::move(__last), std::__make_projected(__comp, __proj)); | ||
| 48 | return {std::move(__result.first), std::move(__result.second)}; | ||
| 49 | } | ||
| 50 | |||
| 51 | template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity> | ||
| 52 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | ||
| 53 | _LIBCPP_HIDE_FROM_ABI constexpr next_permutation_result<borrowed_iterator_t<_Range>> | ||
| 54 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | ||
| 55 | auto __result = std::__next_permutation<_RangeAlgPolicy>( | ||
| 56 | ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj)); | ||
| 57 | return {std::move(__result.first), std::move(__result.second)}; | ||
| 58 | } | ||
| 59 | }; | ||
| 60 | |||
| 61 | } // namespace __next_permutation | ||
| 62 | |||
| 63 | inline namespace __cpo { | ||
| 64 | constexpr inline auto next_permutation = __next_permutation::__fn{}; | ||
| 65 | } // namespace __cpo | ||
| 66 | } // namespace ranges | ||
| 67 | |||
| 68 | _LIBCPP_END_NAMESPACE_STD | ||
| 69 | |||
| 70 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 71 | |||
| 72 | #endif // _LIBCPP___ALGORITHM_RANGES_NEXT_PERMUTATION_H | ||
lib/libcxx/include/__algorithm/ranges_prev_permutation.h created+76| ... | @@ -0,0 +1,76 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H | ||
| 10 | #define _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H | ||
| 11 | |||
| 12 | #include <__algorithm/in_found_result.h> | ||
| 13 | #include <__algorithm/iterator_operations.h> | ||
| 14 | #include <__algorithm/make_projected.h> | ||
| 15 | #include <__algorithm/prev_permutation.h> | ||
| 16 | #include <__config> | ||
| 17 | #include <__functional/identity.h> | ||
| 18 | #include <__functional/ranges_operations.h> | ||
| 19 | #include <__iterator/concepts.h> | ||
| 20 | #include <__iterator/sortable.h> | ||
| 21 | #include <__ranges/access.h> | ||
| 22 | #include <__ranges/concepts.h> | ||
| 23 | #include <__ranges/dangling.h> | ||
| 24 | #include <__utility/move.h> | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 27 | # pragma GCC system_header | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 31 | |||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 33 | |||
| 34 | namespace ranges { | ||
| 35 | |||
| 36 | template <class _InIter> | ||
| 37 | using prev_permutation_result = in_found_result<_InIter>; | ||
| 38 | |||
| 39 | namespace __prev_permutation { | ||
| 40 | |||
| 41 | struct __fn { | ||
| 42 | |||
| 43 | template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, | ||
| 44 | class _Comp = ranges::less, class _Proj = identity> | ||
| 45 | requires sortable<_Iter, _Comp, _Proj> | ||
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<_Iter> | ||
| 47 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | ||
| 48 | auto __result = std::__prev_permutation<_RangeAlgPolicy>( | ||
| 49 | std::move(__first), std::move(__last), std::__make_projected(__comp, __proj)); | ||
| 50 | return {std::move(__result.first), std::move(__result.second)}; | ||
| 51 | } | ||
| 52 | |||
| 53 | template <bidirectional_range _Range, | ||
| 54 | class _Comp = ranges::less, class _Proj = identity> | ||
| 55 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | ||
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr prev_permutation_result<borrowed_iterator_t<_Range>> | ||
| 57 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | ||
| 58 | auto __result = std::__prev_permutation<_RangeAlgPolicy>( | ||
| 59 | ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj)); | ||
| 60 | return {std::move(__result.first), std::move(__result.second)}; | ||
| 61 | } | ||
| 62 | |||
| 63 | }; | ||
| 64 | |||
| 65 | } // namespace __prev_permutation | ||
| 66 | |||
| 67 | inline namespace __cpo { | ||
| 68 | constexpr inline auto prev_permutation = __prev_permutation::__fn{}; | ||
| 69 | } // namespace __cpo | ||
| 70 | } // namespace ranges | ||
| 71 | |||
| 72 | _LIBCPP_END_NAMESPACE_STD | ||
| 73 | |||
| 74 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 75 | |||
| 76 | #endif // _LIBCPP___ALGORITHM_RANGES_PREV_PERMUTATION_H | ||
lib/libcxx/include/__algorithm/ranges_remove_copy.h+25-30| ... | @@ -10,19 +10,16 @@ | ... | @@ -10,19 +10,16 @@ |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | 12 | #include <__algorithm/in_out_result.h> |
| 13 | #include <__algorithm/make_projected.h> | 13 | #include <__algorithm/ranges_remove_copy_if.h> |
| 14 | #include <__algorithm/remove_copy.h> | ||
| 15 | #include <__config> | 14 | #include <__config> |
| 16 | #include <__functional/identity.h> | 15 | #include <__functional/identity.h> |
| 17 | #include <__functional/invoke.h> | 16 | #include <__functional/invoke.h> |
| 18 | #include <__functional/ranges_operations.h> | 17 | #include <__functional/ranges_operations.h> |
| 19 | #include <__iterator/concepts.h> | 18 | #include <__iterator/concepts.h> |
| 20 | #include <__iterator/iterator_traits.h> | ||
| 21 | #include <__iterator/projected.h> | 19 | #include <__iterator/projected.h> |
| 22 | #include <__ranges/access.h> | 20 | #include <__ranges/access.h> |
| 23 | #include <__ranges/concepts.h> | 21 | #include <__ranges/concepts.h> |
| 24 | #include <__ranges/dangling.h> | 22 | #include <__ranges/dangling.h> |
| 25 | #include <__utility/forward.h> | ||
| 26 | #include <__utility/move.h> | 23 | #include <__utility/move.h> |
| 27 | 24 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -40,32 +37,30 @@ using remove_copy_result = in_out_result<_InIter, _OutIter>; | ... | @@ -40,32 +37,30 @@ using remove_copy_result = in_out_result<_InIter, _OutIter>; |
| 40 | 37 | ||
| 41 | namespace __remove_copy { | 38 | namespace __remove_copy { |
| 42 | 39 | ||
| 43 | struct __fn { | 40 | struct __fn { |
| 44 | 41 | template <input_iterator _InIter, | |
| 45 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, class _Type, | 42 | sentinel_for<_InIter> _Sent, |
| 46 | class _Proj = identity> | 43 | weakly_incrementable _OutIter, |
| 47 | requires indirectly_copyable<_InIter, _OutIter> && | 44 | class _Type, |
| 48 | indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*> | 45 | class _Proj = identity> |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr | 46 | requires indirectly_copyable<_InIter, _OutIter> && |
| 50 | remove_copy_result<_InIter, _OutIter> | 47 | indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*> |
| 51 | operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const { | 48 | _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_result<_InIter, _OutIter> |
| 52 | // TODO: implement | 49 | operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const { |
| 53 | (void)__first; (void)__last; (void)__result; (void)__value; (void)__proj; | 50 | auto __pred = [&](auto&& __val) { return __value == __val; }; |
| 54 | return {}; | 51 | return ranges::__remove_copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj); |
| 55 | } | 52 | } |
| 56 | 53 | ||
| 57 | template <input_range _Range, weakly_incrementable _OutIter, class _Type, class _Proj = identity> | 54 | template <input_range _Range, weakly_incrementable _OutIter, class _Type, class _Proj = identity> |
| 58 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> && | 55 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> && |
| 59 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> | 56 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr | 57 | _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_result<borrowed_iterator_t<_Range>, _OutIter> |
| 61 | remove_copy_result<borrowed_iterator_t<_Range>, _OutIter> | 58 | operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const { |
| 62 | operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const { | 59 | auto __pred = [&](auto&& __val) { return __value == __val; }; |
| 63 | // TODO: implement | 60 | return ranges::__remove_copy_if_impl( |
| 64 | (void)__range; (void)__result; (void)__value; (void)__proj; | 61 | ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __proj); |
| 65 | return {}; | 62 | } |
| 66 | } | 63 | }; |
| 67 | |||
| 68 | }; | ||
| 69 | 64 | ||
| 70 | } // namespace __remove_copy | 65 | } // namespace __remove_copy |
| 71 | 66 |
lib/libcxx/include/__algorithm/ranges_remove_copy_if.h+34-24| ... | @@ -38,33 +38,43 @@ namespace ranges { | ... | @@ -38,33 +38,43 @@ namespace ranges { |
| 38 | template <class _InIter, class _OutIter> | 38 | template <class _InIter, class _OutIter> |
| 39 | using remove_copy_if_result = in_out_result<_InIter, _OutIter>; | 39 | using remove_copy_if_result = in_out_result<_InIter, _OutIter>; |
| 40 | 40 | ||
| 41 | namespace __remove_copy_if { | 41 | template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred> |
| 42 | 42 | _LIBCPP_HIDE_FROM_ABI constexpr in_out_result<_InIter, _OutIter> | |
| 43 | struct __fn { | 43 | __remove_copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) { |
| 44 | 44 | for (; __first != __last; ++__first) { | |
| 45 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, | 45 | if (!std::invoke(__pred, std::invoke(__proj, *__first))) { |
| 46 | class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred> | 46 | *__result = *__first; |
| 47 | requires indirectly_copyable<_InIter, _OutIter> | 47 | ++__result; |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr | 48 | } |
| 49 | remove_copy_if_result<_InIter, _OutIter> | ||
| 50 | operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { | ||
| 51 | // TODO: implement | ||
| 52 | (void)__first; (void)__last; (void)__result; (void)__pred; (void)__proj; | ||
| 53 | return {}; | ||
| 54 | } | 49 | } |
| 50 | return {std::move(__first), std::move(__result)}; | ||
| 51 | } | ||
| 55 | 52 | ||
| 56 | template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity, | 53 | namespace __remove_copy_if { |
| 57 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | ||
| 58 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> | ||
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr | ||
| 60 | remove_copy_if_result<borrowed_iterator_t<_Range>, _OutIter> | ||
| 61 | operator()(_Range&& __range, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { | ||
| 62 | // TODO: implement | ||
| 63 | (void)__range; (void)__result; (void)__pred; (void)__proj; | ||
| 64 | return {}; | ||
| 65 | } | ||
| 66 | 54 | ||
| 67 | }; | 55 | struct __fn { |
| 56 | template <input_iterator _InIter, | ||
| 57 | sentinel_for<_InIter> _Sent, | ||
| 58 | weakly_incrementable _OutIter, | ||
| 59 | class _Proj = identity, | ||
| 60 | indirect_unary_predicate<projected<_InIter, _Proj>> _Pred> | ||
| 61 | requires indirectly_copyable<_InIter, _OutIter> | ||
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_if_result<_InIter, _OutIter> | ||
| 63 | operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { | ||
| 64 | return ranges::__remove_copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj); | ||
| 65 | } | ||
| 66 | |||
| 67 | template <input_range _Range, | ||
| 68 | weakly_incrementable _OutIter, | ||
| 69 | class _Proj = identity, | ||
| 70 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | ||
| 71 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> | ||
| 72 | _LIBCPP_HIDE_FROM_ABI constexpr remove_copy_if_result<borrowed_iterator_t<_Range>, _OutIter> | ||
| 73 | operator()(_Range&& __range, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { | ||
| 74 | return ranges::__remove_copy_if_impl( | ||
| 75 | ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __proj); | ||
| 76 | } | ||
| 77 | }; | ||
| 68 | 78 | ||
| 69 | } // namespace __remove_copy_if | 79 | } // namespace __remove_copy_if |
| 70 | 80 |
lib/libcxx/include/__algorithm/ranges_replace_copy.h+38-31| ... | @@ -10,19 +10,16 @@ | ... | @@ -10,19 +10,16 @@ |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | 12 | #include <__algorithm/in_out_result.h> |
| 13 | #include <__algorithm/make_projected.h> | 13 | #include <__algorithm/ranges_replace_copy_if.h> |
| 14 | #include <__algorithm/replace_copy.h> | ||
| 15 | #include <__config> | 14 | #include <__config> |
| 16 | #include <__functional/identity.h> | 15 | #include <__functional/identity.h> |
| 17 | #include <__functional/invoke.h> | 16 | #include <__functional/invoke.h> |
| 18 | #include <__functional/ranges_operations.h> | 17 | #include <__functional/ranges_operations.h> |
| 19 | #include <__iterator/concepts.h> | 18 | #include <__iterator/concepts.h> |
| 20 | #include <__iterator/iterator_traits.h> | ||
| 21 | #include <__iterator/projected.h> | 19 | #include <__iterator/projected.h> |
| 22 | #include <__ranges/access.h> | 20 | #include <__ranges/access.h> |
| 23 | #include <__ranges/concepts.h> | 21 | #include <__ranges/concepts.h> |
| 24 | #include <__ranges/dangling.h> | 22 | #include <__ranges/dangling.h> |
| 25 | #include <__utility/forward.h> | ||
| 26 | #include <__utility/move.h> | 23 | #include <__utility/move.h> |
| 27 | 24 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -40,35 +37,45 @@ using replace_copy_result = in_out_result<_InIter, _OutIter>; | ... | @@ -40,35 +37,45 @@ using replace_copy_result = in_out_result<_InIter, _OutIter>; |
| 40 | 37 | ||
| 41 | namespace __replace_copy { | 38 | namespace __replace_copy { |
| 42 | 39 | ||
| 43 | struct __fn { | 40 | struct __fn { |
| 44 | 41 | template <input_iterator _InIter, | |
| 45 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type1, class _Type2, | 42 | sentinel_for<_InIter> _Sent, |
| 46 | output_iterator<const _Type2&> _OutIter, class _Proj = identity> | 43 | class _OldType, |
| 47 | requires indirectly_copyable<_InIter, _OutIter> && | 44 | class _NewType, |
| 48 | indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type1*> | 45 | output_iterator<const _NewType&> _OutIter, |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr | 46 | class _Proj = identity> |
| 50 | replace_copy_result<_InIter, _OutIter> | 47 | requires indirectly_copyable<_InIter, _OutIter> && |
| 51 | operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value, | 48 | indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _OldType*> |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_result<_InIter, _OutIter> | ||
| 50 | operator()(_InIter __first, | ||
| 51 | _Sent __last, | ||
| 52 | _OutIter __result, | ||
| 53 | const _OldType& __old_value, | ||
| 54 | const _NewType& __new_value, | ||
| 52 | _Proj __proj = {}) const { | 55 | _Proj __proj = {}) const { |
| 53 | // TODO: implement | 56 | auto __pred = [&](const auto& __value) { return __value == __old_value; }; |
| 54 | (void)__first; (void)__last; (void)__result; (void)__old_value; (void)__new_value; (void)__proj; | 57 | return ranges::__replace_copy_if_impl( |
| 55 | return {}; | 58 | std::move(__first), std::move(__last), std::move(__result), __pred, __new_value, __proj); |
| 56 | } | 59 | } |
| 57 | 60 | ||
| 58 | template <input_range _Range, class _Type1, class _Type2, output_iterator<const _Type2&> _OutIter, | 61 | template <input_range _Range, |
| 59 | class _Proj = identity> | 62 | class _OldType, |
| 60 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> && | 63 | class _NewType, |
| 61 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type1*> | 64 | output_iterator<const _NewType&> _OutIter, |
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr | 65 | class _Proj = identity> |
| 63 | replace_copy_result<borrowed_iterator_t<_Range>, _OutIter> | 66 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> && |
| 64 | operator()(_Range&& __range, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value, | 67 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _OldType*> |
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_result<borrowed_iterator_t<_Range>, _OutIter> | ||
| 69 | operator()(_Range&& __range, | ||
| 70 | _OutIter __result, | ||
| 71 | const _OldType& __old_value, | ||
| 72 | const _NewType& __new_value, | ||
| 65 | _Proj __proj = {}) const { | 73 | _Proj __proj = {}) const { |
| 66 | // TODO: implement | 74 | auto __pred = [&](const auto& __value) { return __value == __old_value; }; |
| 67 | (void)__range; (void)__result; (void)__old_value; (void)__new_value; (void)__proj; | 75 | return ranges::__replace_copy_if_impl( |
| 68 | return {}; | 76 | ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __new_value, __proj); |
| 69 | } | 77 | } |
| 70 | 78 | }; | |
| 71 | }; | ||
| 72 | 79 | ||
| 73 | } // namespace __replace_copy | 80 | } // namespace __replace_copy |
| 74 | 81 |
lib/libcxx/include/__algorithm/ranges_replace_copy_if.h+42-30| ... | @@ -10,19 +10,14 @@ | ... | @@ -10,19 +10,14 @@ |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | 12 | #include <__algorithm/in_out_result.h> |
| 13 | #include <__algorithm/make_projected.h> | ||
| 14 | #include <__algorithm/replace_copy_if.h> | ||
| 15 | #include <__config> | 13 | #include <__config> |
| 16 | #include <__functional/identity.h> | 14 | #include <__functional/identity.h> |
| 17 | #include <__functional/invoke.h> | 15 | #include <__functional/invoke.h> |
| 18 | #include <__functional/ranges_operations.h> | ||
| 19 | #include <__iterator/concepts.h> | 16 | #include <__iterator/concepts.h> |
| 20 | #include <__iterator/iterator_traits.h> | ||
| 21 | #include <__iterator/projected.h> | 17 | #include <__iterator/projected.h> |
| 22 | #include <__ranges/access.h> | 18 | #include <__ranges/access.h> |
| 23 | #include <__ranges/concepts.h> | 19 | #include <__ranges/concepts.h> |
| 24 | #include <__ranges/dangling.h> | 20 | #include <__ranges/dangling.h> |
| 25 | #include <__utility/forward.h> | ||
| 26 | #include <__utility/move.h> | 21 | #include <__utility/move.h> |
| 27 | 22 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -38,34 +33,51 @@ namespace ranges { | ... | @@ -38,34 +33,51 @@ namespace ranges { |
| 38 | template <class _InIter, class _OutIter> | 33 | template <class _InIter, class _OutIter> |
| 39 | using replace_copy_if_result = in_out_result<_InIter, _OutIter>; | 34 | using replace_copy_if_result = in_out_result<_InIter, _OutIter>; |
| 40 | 35 | ||
| 41 | namespace __replace_copy_if { | 36 | template <class _InIter, class _Sent, class _OutIter, class _Pred, class _Type, class _Proj> |
| 42 | 37 | _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> __replace_copy_if_impl( | |
| 43 | struct __fn { | 38 | _InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, const _Type& __new_value, _Proj& __proj) { |
| 44 | 39 | while (__first != __last) { | |
| 45 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type, output_iterator<const _Type&> _OutIter, | 40 | if (std::invoke(__pred, std::invoke(__proj, *__first))) |
| 46 | class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred> | 41 | *__result = __new_value; |
| 47 | requires indirectly_copyable<_InIter, _OutIter> | 42 | else |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr | 43 | *__result = *__first; |
| 49 | replace_copy_if_result<_InIter, _OutIter> | 44 | |
| 50 | operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, const _Type& __new_value, | 45 | ++__first; |
| 51 | _Proj __proj = {}) const { | 46 | ++__result; |
| 52 | // TODO: implement | ||
| 53 | (void)__first; (void)__last; (void)__result; (void)__pred; (void)__new_value; (void)__proj; | ||
| 54 | return {}; | ||
| 55 | } | 47 | } |
| 56 | 48 | ||
| 57 | template <input_range _Range, class _Type, output_iterator<const _Type&> _OutIter, class _Proj = identity, | 49 | return {std::move(__first), std::move(__result)}; |
| 58 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | 50 | } |
| 59 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> | 51 | |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr | 52 | namespace __replace_copy_if { |
| 61 | replace_copy_if_result<borrowed_iterator_t<_Range>, _OutIter> | ||
| 62 | operator()(_Range&& __range, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const { | ||
| 63 | // TODO: implement | ||
| 64 | (void)__range; (void)__result; (void)__pred; (void)__new_value; (void)__proj; | ||
| 65 | return {}; | ||
| 66 | } | ||
| 67 | 53 | ||
| 68 | }; | 54 | struct __fn { |
| 55 | template <input_iterator _InIter, | ||
| 56 | sentinel_for<_InIter> _Sent, | ||
| 57 | class _Type, | ||
| 58 | output_iterator<const _Type&> _OutIter, | ||
| 59 | class _Proj = identity, | ||
| 60 | indirect_unary_predicate<projected<_InIter, _Proj>> _Pred> | ||
| 61 | requires indirectly_copyable<_InIter, _OutIter> | ||
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<_InIter, _OutIter> operator()( | ||
| 63 | _InIter __first, _Sent __last, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) | ||
| 64 | const { | ||
| 65 | return ranges::__replace_copy_if_impl( | ||
| 66 | std::move(__first), std::move(__last), std::move(__result), __pred, __new_value, __proj); | ||
| 67 | } | ||
| 68 | |||
| 69 | template <input_range _Range, | ||
| 70 | class _Type, | ||
| 71 | output_iterator<const _Type&> _OutIter, | ||
| 72 | class _Proj = identity, | ||
| 73 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | ||
| 74 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> | ||
| 75 | _LIBCPP_HIDE_FROM_ABI constexpr replace_copy_if_result<borrowed_iterator_t<_Range>, _OutIter> | ||
| 76 | operator()(_Range&& __range, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const { | ||
| 77 | return ranges::__replace_copy_if_impl( | ||
| 78 | ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __new_value, __proj); | ||
| 79 | } | ||
| 80 | }; | ||
| 69 | 81 | ||
| 70 | } // namespace __replace_copy_if | 82 | } // namespace __replace_copy_if |
| 71 | 83 |
lib/libcxx/include/__algorithm/ranges_rotate.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___ALGORITHM_RANGES_ROTATE_H | ||
| 10 | #define _LIBCPP___ALGORITHM_RANGES_ROTATE_H | ||
| 11 | |||
| 12 | #include <__algorithm/iterator_operations.h> | ||
| 13 | #include <__algorithm/ranges_iterator_concept.h> | ||
| 14 | #include <__algorithm/rotate.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <__iterator/concepts.h> | ||
| 17 | #include <__iterator/iterator_traits.h> | ||
| 18 | #include <__iterator/permutable.h> | ||
| 19 | #include <__ranges/access.h> | ||
| 20 | #include <__ranges/concepts.h> | ||
| 21 | #include <__ranges/subrange.h> | ||
| 22 | #include <__utility/move.h> | ||
| 23 | |||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 25 | # pragma GCC system_header | ||
| 26 | #endif | ||
| 27 | |||
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 29 | |||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 31 | |||
| 32 | namespace ranges { | ||
| 33 | namespace __rotate { | ||
| 34 | |||
| 35 | struct __fn { | ||
| 36 | |||
| 37 | template <class _Iter, class _Sent> | ||
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr | ||
| 39 | static subrange<_Iter> __rotate_fn_impl(_Iter __first, _Iter __middle, _Sent __last) { | ||
| 40 | auto __ret = std::__rotate<_RangeAlgPolicy>( | ||
| 41 | std::move(__first), std::move(__middle), std::move(__last)); | ||
| 42 | return {std::move(__ret.first), std::move(__ret.second)}; | ||
| 43 | } | ||
| 44 | |||
| 45 | template <permutable _Iter, sentinel_for<_Iter> _Sent> | ||
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr | ||
| 47 | subrange<_Iter> operator()(_Iter __first, _Iter __middle, _Sent __last) const { | ||
| 48 | return __rotate_fn_impl(std::move(__first), std::move(__middle), std::move(__last)); | ||
| 49 | } | ||
| 50 | |||
| 51 | template <forward_range _Range> | ||
| 52 | requires permutable<iterator_t<_Range>> | ||
| 53 | _LIBCPP_HIDE_FROM_ABI constexpr | ||
| 54 | borrowed_subrange_t<_Range> operator()(_Range&& __range, iterator_t<_Range> __middle) const { | ||
| 55 | return __rotate_fn_impl(ranges::begin(__range), std::move(__middle), ranges::end(__range)); | ||
| 56 | } | ||
| 57 | |||
| 58 | }; | ||
| 59 | |||
| 60 | } // namespace __rotate | ||
| 61 | |||
| 62 | inline namespace __cpo { | ||
| 63 | inline constexpr auto rotate = __rotate::__fn{}; | ||
| 64 | } // namespace __cpo | ||
| 65 | } // namespace ranges | ||
| 66 | |||
| 67 | _LIBCPP_END_NAMESPACE_STD | ||
| 68 | |||
| 69 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 70 | |||
| 71 | #endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_H | ||
lib/libcxx/include/__algorithm/ranges_sample.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___ALGORITHM_RANGES_SAMPLE_H | ||
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SAMPLE_H | ||
| 11 | |||
| 12 | #include <__algorithm/iterator_operations.h> | ||
| 13 | #include <__algorithm/sample.h> | ||
| 14 | #include <__algorithm/uniform_random_bit_generator_adaptor.h> | ||
| 15 | #include <__config> | ||
| 16 | #include <__iterator/concepts.h> | ||
| 17 | #include <__iterator/incrementable_traits.h> | ||
| 18 | #include <__iterator/iterator_traits.h> | ||
| 19 | #include <__random/uniform_random_bit_generator.h> | ||
| 20 | #include <__ranges/access.h> | ||
| 21 | #include <__ranges/concepts.h> | ||
| 22 | #include <__utility/forward.h> | ||
| 23 | #include <__utility/move.h> | ||
| 24 | #include <type_traits> | ||
| 25 | |||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
| 27 | # pragma GCC system_header | ||
| 28 | #endif | ||
| 29 | |||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 31 | |||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 33 | |||
| 34 | namespace ranges { | ||
| 35 | namespace __sample { | ||
| 36 | |||
| 37 | struct __fn { | ||
| 38 | |||
| 39 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Gen> | ||
| 40 | requires (forward_iterator<_Iter> || random_access_iterator<_OutIter>) && | ||
| 41 | indirectly_copyable<_Iter, _OutIter> && | ||
| 42 | uniform_random_bit_generator<remove_reference_t<_Gen>> | ||
| 43 | _LIBCPP_HIDE_FROM_ABI | ||
| 44 | _OutIter operator()(_Iter __first, _Sent __last, | ||
| 45 | _OutIter __out_first, iter_difference_t<_Iter> __n, _Gen&& __gen) const { | ||
| 46 | _ClassicGenAdaptor<_Gen> __adapted_gen(__gen); | ||
| 47 | return std::__sample<_RangeAlgPolicy>( | ||
| 48 | std::move(__first), std::move(__last), std::move(__out_first), __n, __adapted_gen); | ||
| 49 | } | ||
| 50 | |||
| 51 | template <input_range _Range, weakly_incrementable _OutIter, class _Gen> | ||
| 52 | requires (forward_range<_Range> || random_access_iterator<_OutIter>) && | ||
| 53 | indirectly_copyable<iterator_t<_Range>, _OutIter> && | ||
| 54 | uniform_random_bit_generator<remove_reference_t<_Gen>> | ||
| 55 | _LIBCPP_HIDE_FROM_ABI | ||
| 56 | _OutIter operator()(_Range&& __range, _OutIter __out_first, range_difference_t<_Range> __n, _Gen&& __gen) const { | ||
| 57 | return (*this)(ranges::begin(__range), ranges::end(__range), | ||
| 58 | std::move(__out_first), __n, std::forward<_Gen>(__gen)); | ||
| 59 | } | ||
| 60 | |||
| 61 | }; | ||
| 62 | |||
| 63 | } // namespace __sample | ||
| 64 | |||
| 65 | inline namespace __cpo { | ||
| 66 | inline constexpr auto sample = __sample::__fn{}; | ||
| 67 | } // namespace __cpo | ||
| 68 | } // namespace ranges | ||
| 69 | |||
| 70 | _LIBCPP_END_NAMESPACE_STD | ||
| 71 | |||
| 72 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | ||
| 73 | |||
| 74 | #endif // _LIBCPP___ALGORITHM_RANGES_SAMPLE_H | ||
lib/libcxx/include/__algorithm/ranges_shuffle.h+1-33| ... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | 12 | #include <__algorithm/iterator_operations.h> |
| 13 | #include <__algorithm/shuffle.h> | 13 | #include <__algorithm/shuffle.h> |
| 14 | #include <__algorithm/uniform_random_bit_generator_adaptor.h> | ||
| 14 | #include <__config> | 15 | #include <__config> |
| 15 | #include <__functional/invoke.h> | 16 | #include <__functional/invoke.h> |
| 16 | #include <__functional/ranges_operations.h> | 17 | #include <__functional/ranges_operations.h> |
| ... | @@ -32,43 +33,12 @@ | ... | @@ -32,43 +33,12 @@ |
| 32 | 33 | ||
| 33 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | 34 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) |
| 34 | 35 | ||
| 35 | _LIBCPP_PUSH_MACROS | ||
| 36 | #include <__undef_macros> | ||
| 37 | |||
| 38 | _LIBCPP_BEGIN_NAMESPACE_STD | 36 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 39 | 37 | ||
| 40 | namespace ranges { | 38 | namespace ranges { |
| 41 | namespace __shuffle { | 39 | namespace __shuffle { |
| 42 | 40 | ||
| 43 | struct __fn { | 41 | struct __fn { |
| 44 | // `std::shuffle` is more constrained than `std::ranges::shuffle`. `std::ranges::shuffle` only requires the given | ||
| 45 | // generator to satisfy the `std::uniform_random_bit_generator` concept. `std::shuffle` requires the given | ||
| 46 | // generator to meet the uniform random bit generator requirements; these requirements include satisfying | ||
| 47 | // `std::uniform_random_bit_generator` and add a requirement for the generator to provide a nested `result_type` | ||
| 48 | // typedef (see `[rand.req.urng]`). | ||
| 49 | // | ||
| 50 | // To reuse the implementation from `std::shuffle`, make the given generator meet the classic requirements by wrapping | ||
| 51 | // it into an adaptor type that forwards all of its interface and adds the required typedef. | ||
| 52 | template <class _Gen> | ||
| 53 | class _ClassicGenAdaptor { | ||
| 54 | private: | ||
| 55 | // The generator is not required to be copyable or movable, so it has to be stored as a reference. | ||
| 56 | _Gen& __gen; | ||
| 57 | |||
| 58 | public: | ||
| 59 | using result_type = invoke_result_t<_Gen&>; | ||
| 60 | |||
| 61 | _LIBCPP_HIDE_FROM_ABI | ||
| 62 | static constexpr auto min() { return __uncvref_t<_Gen>::min(); } | ||
| 63 | _LIBCPP_HIDE_FROM_ABI | ||
| 64 | static constexpr auto max() { return __uncvref_t<_Gen>::max(); } | ||
| 65 | |||
| 66 | _LIBCPP_HIDE_FROM_ABI | ||
| 67 | constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen(__g) {} | ||
| 68 | |||
| 69 | _LIBCPP_HIDE_FROM_ABI | ||
| 70 | constexpr auto operator()() const { return __gen(); } | ||
| 71 | }; | ||
| 72 | 42 | ||
| 73 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen> | 43 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen> |
| 74 | requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>> | 44 | requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>> |
| ... | @@ -96,8 +66,6 @@ inline namespace __cpo { | ... | @@ -96,8 +66,6 @@ inline namespace __cpo { |
| 96 | 66 | ||
| 97 | _LIBCPP_END_NAMESPACE_STD | 67 | _LIBCPP_END_NAMESPACE_STD |
| 98 | 68 | ||
| 99 | _LIBCPP_POP_MACROS | ||
| 100 | |||
| 101 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | 69 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) |
| 102 | 70 | ||
| 103 | #endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H | 71 | #endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H |
lib/libcxx/include/__algorithm/ranges_swap_ranges.h+5-6| ... | @@ -10,6 +10,8 @@ | ... | @@ -10,6 +10,8 @@ |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H | 10 | #define _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/in_in_result.h> | 12 | #include <__algorithm/in_in_result.h> |
| 13 | #include <__algorithm/iterator_operations.h> | ||
| 14 | #include <__algorithm/swap_ranges.h> | ||
| 13 | #include <__config> | 15 | #include <__config> |
| 14 | #include <__iterator/concepts.h> | 16 | #include <__iterator/concepts.h> |
| 15 | #include <__iterator/iter_swap.h> | 17 | #include <__iterator/iter_swap.h> |
| ... | @@ -38,12 +40,9 @@ struct __fn { | ... | @@ -38,12 +40,9 @@ struct __fn { |
| 38 | requires indirectly_swappable<_I1, _I2> | 40 | requires indirectly_swappable<_I1, _I2> |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2> | 41 | _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2> |
| 40 | operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2) const { | 42 | operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2) const { |
| 41 | while (__first1 != __last1 && __first2 != __last2) { | 43 | auto __ret = std::__swap_ranges<_RangeAlgPolicy>( |
| 42 | ranges::iter_swap(__first1, __first2); | 44 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2)); |
| 43 | ++__first1; | 45 | return {std::move(__ret.first), std::move(__ret.second)}; |
| 44 | ++__first2; | ||
| 45 | } | ||
| 46 | return {_VSTD::move(__first1), _VSTD::move(__first2)}; | ||
| 47 | } | 46 | } |
| 48 | 47 | ||
| 49 | template <input_range _R1, input_range _R2> | 48 | template <input_range _R1, input_range _R2> |
lib/libcxx/include/__algorithm/reverse.h+16-7| ... | @@ -10,8 +10,10 @@ | ... | @@ -10,8 +10,10 @@ |
| 10 | #define _LIBCPP___ALGORITHM_REVERSE_H | 10 | #define _LIBCPP___ALGORITHM_REVERSE_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/iter_swap.h> | 12 | #include <__algorithm/iter_swap.h> |
| 13 | #include <__algorithm/iterator_operations.h> | ||
| 13 | #include <__config> | 14 | #include <__config> |
| 14 | #include <__iterator/iterator_traits.h> | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <__utility/move.h> | ||
| 15 | 17 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | # pragma GCC system_header | 19 | # pragma GCC system_header |
| ... | @@ -19,28 +21,35 @@ | ... | @@ -19,28 +21,35 @@ |
| 19 | 21 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 23 | ||
| 22 | template <class _BidirectionalIterator> | 24 | template <class _AlgPolicy, class _BidirectionalIterator> |
| 23 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | 25 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 24 | void | 26 | void |
| 25 | __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag) | 27 | __reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag) |
| 26 | { | 28 | { |
| 27 | while (__first != __last) | 29 | while (__first != __last) |
| 28 | { | 30 | { |
| 29 | if (__first == --__last) | 31 | if (__first == --__last) |
| 30 | break; | 32 | break; |
| 31 | _VSTD::iter_swap(__first, __last); | 33 | _IterOps<_AlgPolicy>::iter_swap(__first, __last); |
| 32 | ++__first; | 34 | ++__first; |
| 33 | } | 35 | } |
| 34 | } | 36 | } |
| 35 | 37 | ||
| 36 | template <class _RandomAccessIterator> | 38 | template <class _AlgPolicy, class _RandomAccessIterator> |
| 37 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | 39 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 38 | void | 40 | void |
| 39 | __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag) | 41 | __reverse_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag) |
| 40 | { | 42 | { |
| 41 | if (__first != __last) | 43 | if (__first != __last) |
| 42 | for (; __first < --__last; ++__first) | 44 | for (; __first < --__last; ++__first) |
| 43 | _VSTD::iter_swap(__first, __last); | 45 | _IterOps<_AlgPolicy>::iter_swap(__first, __last); |
| 46 | } | ||
| 47 | |||
| 48 | template <class _AlgPolicy, class _BidirectionalIterator, class _Sentinel> | ||
| 49 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | ||
| 50 | void __reverse(_BidirectionalIterator __first, _Sentinel __last) { | ||
| 51 | using _IterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_BidirectionalIterator>; | ||
| 52 | std::__reverse_impl<_AlgPolicy>(std::move(__first), std::move(__last), _IterCategory()); | ||
| 44 | } | 53 | } |
| 45 | 54 | ||
| 46 | template <class _BidirectionalIterator> | 55 | template <class _BidirectionalIterator> |
| ... | @@ -48,7 +57,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | ... | @@ -48,7 +57,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 48 | void | 57 | void |
| 49 | reverse(_BidirectionalIterator __first, _BidirectionalIterator __last) | 58 | reverse(_BidirectionalIterator __first, _BidirectionalIterator __last) |
| 50 | { | 59 | { |
| 51 | _VSTD::__reverse(__first, __last, typename iterator_traits<_BidirectionalIterator>::iterator_category()); | 60 | std::__reverse<_ClassicAlgPolicy>(std::move(__first), std::move(__last)); |
| 52 | } | 61 | } |
| 53 | 62 | ||
| 54 | _LIBCPP_END_NAMESPACE_STD | 63 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/rotate.h+32-25| ... | @@ -15,10 +15,8 @@ | ... | @@ -15,10 +15,8 @@ |
| 15 | #include <__algorithm/swap_ranges.h> | 15 | #include <__algorithm/swap_ranges.h> |
| 16 | #include <__config> | 16 | #include <__config> |
| 17 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__iterator/next.h> | ||
| 19 | #include <__iterator/prev.h> | ||
| 20 | #include <__utility/move.h> | 18 | #include <__utility/move.h> |
| 21 | #include <__utility/swap.h> | 19 | #include <__utility/pair.h> |
| 22 | #include <type_traits> | 20 | #include <type_traits> |
| 23 | 21 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -32,9 +30,11 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator | ... | @@ -32,9 +30,11 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator |
| 32 | __rotate_left(_ForwardIterator __first, _ForwardIterator __last) | 30 | __rotate_left(_ForwardIterator __first, _ForwardIterator __last) |
| 33 | { | 31 | { |
| 34 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | 32 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; |
| 35 | value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__first); | 33 | using _Ops = _IterOps<_AlgPolicy>; |
| 36 | // TODO(ranges): pass `_AlgPolicy` to `move`. | 34 | |
| 37 | _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first); | 35 | value_type __tmp = _Ops::__iter_move(__first); |
| 36 | _ForwardIterator __lm1 = std::__move<_AlgPolicy>( | ||
| 37 | _Ops::next(__first), __last, __first).second; | ||
| 38 | *__lm1 = _VSTD::move(__tmp); | 38 | *__lm1 = _VSTD::move(__tmp); |
| 39 | return __lm1; | 39 | return __lm1; |
| 40 | } | 40 | } |
| ... | @@ -44,11 +44,11 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator | ... | @@ -44,11 +44,11 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator |
| 44 | __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last) | 44 | __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last) |
| 45 | { | 45 | { |
| 46 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | 46 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; |
| 47 | // TODO(ranges): pass `_AlgPolicy` to `prev`. | 47 | using _Ops = _IterOps<_AlgPolicy>; |
| 48 | _BidirectionalIterator __lm1 = _VSTD::prev(__last); | 48 | |
| 49 | value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__lm1); | 49 | _BidirectionalIterator __lm1 = _Ops::prev(__last); |
| 50 | // TODO(ranges): pass `_AlgPolicy` to `move_backward`. | 50 | value_type __tmp = _Ops::__iter_move(__lm1); |
| 51 | _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last); | 51 | _BidirectionalIterator __fp1 = std::__move_backward<_AlgPolicy>(__first, __lm1, std::move(__last)); |
| 52 | *__first = _VSTD::move(__tmp); | 52 | *__first = _VSTD::move(__tmp); |
| 53 | return __fp1; | 53 | return __fp1; |
| 54 | } | 54 | } |
| ... | @@ -108,26 +108,26 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran | ... | @@ -108,26 +108,26 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran |
| 108 | { | 108 | { |
| 109 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | 109 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 110 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | 110 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| 111 | using _Ops = _IterOps<_AlgPolicy>; | ||
| 111 | 112 | ||
| 112 | const difference_type __m1 = __middle - __first; | 113 | const difference_type __m1 = __middle - __first; |
| 113 | const difference_type __m2 = __last - __middle; | 114 | const difference_type __m2 = _Ops::distance(__middle, __last); |
| 114 | if (__m1 == __m2) | 115 | if (__m1 == __m2) |
| 115 | { | 116 | { |
| 116 | // TODO(ranges): pass `_AlgPolicy` to `swap_ranges`. | 117 | std::__swap_ranges<_AlgPolicy>(__first, __middle, __middle, __last); |
| 117 | _VSTD::swap_ranges(__first, __middle, __middle); | ||
| 118 | return __middle; | 118 | return __middle; |
| 119 | } | 119 | } |
| 120 | const difference_type __g = _VSTD::__algo_gcd(__m1, __m2); | 120 | const difference_type __g = _VSTD::__algo_gcd(__m1, __m2); |
| 121 | for (_RandomAccessIterator __p = __first + __g; __p != __first;) | 121 | for (_RandomAccessIterator __p = __first + __g; __p != __first;) |
| 122 | { | 122 | { |
| 123 | value_type __t(_IterOps<_AlgPolicy>::__iter_move(--__p)); | 123 | value_type __t(_Ops::__iter_move(--__p)); |
| 124 | _RandomAccessIterator __p1 = __p; | 124 | _RandomAccessIterator __p1 = __p; |
| 125 | _RandomAccessIterator __p2 = __p1 + __m1; | 125 | _RandomAccessIterator __p2 = __p1 + __m1; |
| 126 | do | 126 | do |
| 127 | { | 127 | { |
| 128 | *__p1 = _IterOps<_AlgPolicy>::__iter_move(__p2); | 128 | *__p1 = _Ops::__iter_move(__p2); |
| 129 | __p1 = __p2; | 129 | __p1 = __p2; |
| 130 | const difference_type __d = __last - __p2; | 130 | const difference_type __d = _Ops::distance(__p2, __last); |
| 131 | if (__m1 < __d) | 131 | if (__m1 < __d) |
| 132 | __p2 += __m1; | 132 | __p2 += __m1; |
| 133 | else | 133 | else |
| ... | @@ -188,16 +188,23 @@ __rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ra | ... | @@ -188,16 +188,23 @@ __rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ra |
| 188 | return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last); | 188 | return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | template <class _AlgPolicy, class _RandomAccessIterator, class _IterCategory> | 191 | template <class _AlgPolicy, class _Iterator, class _Sentinel> |
| 192 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | 192 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 193 | _RandomAccessIterator __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, | 193 | pair<_Iterator, _Iterator> |
| 194 | _RandomAccessIterator __last, _IterCategory __iter_category) { | 194 | __rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) { |
| 195 | using _Ret = pair<_Iterator, _Iterator>; | ||
| 196 | _Iterator __last_iter = _IterOps<_AlgPolicy>::next(__middle, __last); | ||
| 197 | |||
| 195 | if (__first == __middle) | 198 | if (__first == __middle) |
| 196 | return __last; | 199 | return _Ret(__last_iter, __last_iter); |
| 197 | if (__middle == __last) | 200 | if (__middle == __last) |
| 198 | return __first; | 201 | return _Ret(std::move(__first), std::move(__last_iter)); |
| 202 | |||
| 203 | using _IterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_Iterator>; | ||
| 204 | auto __result = std::__rotate_impl<_AlgPolicy>( | ||
| 205 | std::move(__first), std::move(__middle), __last_iter, _IterCategory()); | ||
| 199 | 206 | ||
| 200 | return std::__rotate_impl<_AlgPolicy>(std::move(__first), std::move(__middle), std::move(__last), __iter_category); | 207 | return _Ret(std::move(__result), std::move(__last_iter)); |
| 201 | } | 208 | } |
| 202 | 209 | ||
| 203 | template <class _ForwardIterator> | 210 | template <class _ForwardIterator> |
| ... | @@ -205,8 +212,8 @@ inline _LIBCPP_INLINE_VISIBILITY | ... | @@ -205,8 +212,8 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 205 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | 212 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator |
| 206 | rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) | 213 | rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) |
| 207 | { | 214 | { |
| 208 | return std::__rotate<_ClassicAlgPolicy>(__first, __middle, __last, | 215 | return std::__rotate<_ClassicAlgPolicy>( |
| 209 | typename iterator_traits<_ForwardIterator>::iterator_category()); | 216 | std::move(__first), std::move(__middle), std::move(__last)).first; |
| 210 | } | 217 | } |
| 211 | 218 | ||
| 212 | _LIBCPP_END_NAMESPACE_STD | 219 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/sample.h+28-20| ... | @@ -9,12 +9,14 @@ | ... | @@ -9,12 +9,14 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_SAMPLE_H | 9 | #ifndef _LIBCPP___ALGORITHM_SAMPLE_H |
| 10 | #define _LIBCPP___ALGORITHM_SAMPLE_H | 10 | #define _LIBCPP___ALGORITHM_SAMPLE_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | ||
| 12 | #include <__algorithm/min.h> | 13 | #include <__algorithm/min.h> |
| 13 | #include <__assert> | 14 | #include <__assert> |
| 14 | #include <__config> | 15 | #include <__config> |
| 15 | #include <__iterator/distance.h> | 16 | #include <__iterator/distance.h> |
| 16 | #include <__iterator/iterator_traits.h> | 17 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__random/uniform_int_distribution.h> | 18 | #include <__random/uniform_int_distribution.h> |
| 19 | #include <__utility/move.h> | ||
| 18 | #include <type_traits> | 20 | #include <type_traits> |
| 19 | 21 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -26,13 +28,14 @@ _LIBCPP_PUSH_MACROS | ... | @@ -26,13 +28,14 @@ _LIBCPP_PUSH_MACROS |
| 26 | 28 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 30 | ||
| 29 | template <class _PopulationIterator, class _SampleIterator, class _Distance, | 31 | template <class _AlgPolicy, |
| 32 | class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance, | ||
| 30 | class _UniformRandomNumberGenerator> | 33 | class _UniformRandomNumberGenerator> |
| 31 | _LIBCPP_INLINE_VISIBILITY | 34 | _LIBCPP_INLINE_VISIBILITY |
| 32 | _SampleIterator __sample(_PopulationIterator __first, | 35 | _SampleIterator __sample(_PopulationIterator __first, |
| 33 | _PopulationIterator __last, _SampleIterator __output_iter, | 36 | _PopulationSentinel __last, _SampleIterator __output_iter, |
| 34 | _Distance __n, | 37 | _Distance __n, |
| 35 | _UniformRandomNumberGenerator & __g, | 38 | _UniformRandomNumberGenerator& __g, |
| 36 | input_iterator_tag) { | 39 | input_iterator_tag) { |
| 37 | 40 | ||
| 38 | _Distance __k = 0; | 41 | _Distance __k = 0; |
| ... | @@ -47,15 +50,16 @@ _SampleIterator __sample(_PopulationIterator __first, | ... | @@ -47,15 +50,16 @@ _SampleIterator __sample(_PopulationIterator __first, |
| 47 | return __output_iter + _VSTD::min(__n, __k); | 50 | return __output_iter + _VSTD::min(__n, __k); |
| 48 | } | 51 | } |
| 49 | 52 | ||
| 50 | template <class _PopulationIterator, class _SampleIterator, class _Distance, | 53 | template <class _AlgPolicy, |
| 54 | class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance, | ||
| 51 | class _UniformRandomNumberGenerator> | 55 | class _UniformRandomNumberGenerator> |
| 52 | _LIBCPP_INLINE_VISIBILITY | 56 | _LIBCPP_INLINE_VISIBILITY |
| 53 | _SampleIterator __sample(_PopulationIterator __first, | 57 | _SampleIterator __sample(_PopulationIterator __first, |
| 54 | _PopulationIterator __last, _SampleIterator __output_iter, | 58 | _PopulationSentinel __last, _SampleIterator __output_iter, |
| 55 | _Distance __n, | 59 | _Distance __n, |
| 56 | _UniformRandomNumberGenerator& __g, | 60 | _UniformRandomNumberGenerator& __g, |
| 57 | forward_iterator_tag) { | 61 | forward_iterator_tag) { |
| 58 | _Distance __unsampled_sz = _VSTD::distance(__first, __last); | 62 | _Distance __unsampled_sz = _IterOps<_AlgPolicy>::distance(__first, __last); |
| 59 | for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) { | 63 | for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) { |
| 60 | _Distance __r = uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g); | 64 | _Distance __r = uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g); |
| 61 | if (__r < __n) { | 65 | if (__r < __n) { |
| ... | @@ -66,24 +70,22 @@ _SampleIterator __sample(_PopulationIterator __first, | ... | @@ -66,24 +70,22 @@ _SampleIterator __sample(_PopulationIterator __first, |
| 66 | return __output_iter; | 70 | return __output_iter; |
| 67 | } | 71 | } |
| 68 | 72 | ||
| 69 | template <class _PopulationIterator, class _SampleIterator, class _Distance, | 73 | template <class _AlgPolicy, |
| 74 | class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance, | ||
| 70 | class _UniformRandomNumberGenerator> | 75 | class _UniformRandomNumberGenerator> |
| 71 | _LIBCPP_INLINE_VISIBILITY | 76 | _LIBCPP_INLINE_VISIBILITY |
| 72 | _SampleIterator __sample(_PopulationIterator __first, | 77 | _SampleIterator __sample(_PopulationIterator __first, |
| 73 | _PopulationIterator __last, _SampleIterator __output_iter, | 78 | _PopulationSentinel __last, _SampleIterator __output_iter, |
| 74 | _Distance __n, _UniformRandomNumberGenerator& __g) { | 79 | _Distance __n, _UniformRandomNumberGenerator& __g) { |
| 75 | typedef typename iterator_traits<_PopulationIterator>::iterator_category | ||
| 76 | _PopCategory; | ||
| 77 | typedef typename iterator_traits<_PopulationIterator>::difference_type | ||
| 78 | _Difference; | ||
| 79 | static_assert(__is_cpp17_forward_iterator<_PopulationIterator>::value || | ||
| 80 | __is_cpp17_random_access_iterator<_SampleIterator>::value, | ||
| 81 | "SampleIterator must meet the requirements of RandomAccessIterator"); | ||
| 82 | typedef typename common_type<_Distance, _Difference>::type _CommonType; | ||
| 83 | _LIBCPP_ASSERT(__n >= 0, "N must be a positive number."); | 80 | _LIBCPP_ASSERT(__n >= 0, "N must be a positive number."); |
| 84 | return _VSTD::__sample( | 81 | |
| 85 | __first, __last, __output_iter, _CommonType(__n), | 82 | using _PopIterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_PopulationIterator>; |
| 86 | __g, _PopCategory()); | 83 | using _Difference = typename _IterOps<_AlgPolicy>::template __difference_type<_PopulationIterator>; |
| 84 | using _CommonType = typename common_type<_Distance, _Difference>::type; | ||
| 85 | |||
| 86 | return std::__sample<_AlgPolicy>( | ||
| 87 | std::move(__first), std::move(__last), std::move(__output_iter), _CommonType(__n), | ||
| 88 | __g, _PopIterCategory()); | ||
| 87 | } | 89 | } |
| 88 | 90 | ||
| 89 | #if _LIBCPP_STD_VER > 14 | 91 | #if _LIBCPP_STD_VER > 14 |
| ... | @@ -93,8 +95,14 @@ inline _LIBCPP_INLINE_VISIBILITY | ... | @@ -93,8 +95,14 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 93 | _SampleIterator sample(_PopulationIterator __first, | 95 | _SampleIterator sample(_PopulationIterator __first, |
| 94 | _PopulationIterator __last, _SampleIterator __output_iter, | 96 | _PopulationIterator __last, _SampleIterator __output_iter, |
| 95 | _Distance __n, _UniformRandomNumberGenerator&& __g) { | 97 | _Distance __n, _UniformRandomNumberGenerator&& __g) { |
| 96 | return _VSTD::__sample(__first, __last, __output_iter, __n, __g); | 98 | static_assert(__is_cpp17_forward_iterator<_PopulationIterator>::value || |
| 99 | __is_cpp17_random_access_iterator<_SampleIterator>::value, | ||
| 100 | "SampleIterator must meet the requirements of RandomAccessIterator"); | ||
| 101 | |||
| 102 | return std::__sample<_ClassicAlgPolicy>( | ||
| 103 | std::move(__first), std::move(__last), std::move(__output_iter), __n, __g); | ||
| 97 | } | 104 | } |
| 105 | |||
| 98 | #endif // _LIBCPP_STD_VER > 14 | 106 | #endif // _LIBCPP_STD_VER > 14 |
| 99 | 107 | ||
| 100 | _LIBCPP_END_NAMESPACE_STD | 108 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/stable_partition.h+2-2| ... | @@ -108,7 +108,7 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred | ... | @@ -108,7 +108,7 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred |
| 108 | __second_half_done: | 108 | __second_half_done: |
| 109 | // TTTFFFFFTTTTTFFFFF | 109 | // TTTFFFFFTTTTTFFFFF |
| 110 | // f ff m sf l | 110 | // f ff m sf l |
| 111 | return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __fit); | 111 | return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false).first; |
| 112 | // TTTTTTTTFFFFFFFFFF | 112 | // TTTTTTTTFFFFFFFFFF |
| 113 | // | | 113 | // | |
| 114 | } | 114 | } |
| ... | @@ -253,7 +253,7 @@ __first_half_done: | ... | @@ -253,7 +253,7 @@ __first_half_done: |
| 253 | __second_half_done: | 253 | __second_half_done: |
| 254 | // TTTFFFFFTTTTTFFFFF | 254 | // TTTFFFFFTTTTTFFFFF |
| 255 | // f ff m sf l | 255 | // f ff m sf l |
| 256 | return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __bit); | 256 | return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false).first; |
| 257 | // TTTTTTTTFFFFFFFFFF | 257 | // TTTTTTTTFFFFFFFFFF |
| 258 | // | | 258 | // | |
| 259 | } | 259 | } |
lib/libcxx/include/__algorithm/swap_ranges.h+33-4| ... | @@ -9,8 +9,10 @@ | ... | @@ -9,8 +9,10 @@ |
| 9 | #ifndef _LIBCPP___ALGORITHM_SWAP_RANGES_H | 9 | #ifndef _LIBCPP___ALGORITHM_SWAP_RANGES_H |
| 10 | #define _LIBCPP___ALGORITHM_SWAP_RANGES_H | 10 | #define _LIBCPP___ALGORITHM_SWAP_RANGES_H |
| 11 | 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | ||
| 12 | #include <__config> | 13 | #include <__config> |
| 13 | #include <__utility/swap.h> | 14 | #include <__utility/move.h> |
| 15 | #include <__utility/pair.h> | ||
| 14 | 16 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header | 18 | # pragma GCC system_header |
| ... | @@ -18,12 +20,39 @@ | ... | @@ -18,12 +20,39 @@ |
| 18 | 20 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 22 | ||
| 23 | // 2+2 iterators: the shorter size will be used. | ||
| 24 | template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2> | ||
| 25 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | ||
| 26 | pair<_ForwardIterator1, _ForwardIterator2> | ||
| 27 | __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _Sentinel2 __last2) { | ||
| 28 | while (__first1 != __last1 && __first2 != __last2) { | ||
| 29 | _IterOps<_AlgPolicy>::iter_swap(__first1, __first2); | ||
| 30 | ++__first1; | ||
| 31 | ++__first2; | ||
| 32 | } | ||
| 33 | |||
| 34 | return pair<_ForwardIterator1, _ForwardIterator2>(std::move(__first1), std::move(__first2)); | ||
| 35 | } | ||
| 36 | |||
| 37 | // 2+1 iterators: size2 >= size1. | ||
| 38 | template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2> | ||
| 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | ||
| 40 | pair<_ForwardIterator1, _ForwardIterator2> | ||
| 41 | __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2) { | ||
| 42 | while (__first1 != __last1) { | ||
| 43 | _IterOps<_AlgPolicy>::iter_swap(__first1, __first2); | ||
| 44 | ++__first1; | ||
| 45 | ++__first2; | ||
| 46 | } | ||
| 47 | |||
| 48 | return pair<_ForwardIterator1, _ForwardIterator2>(std::move(__first1), std::move(__first2)); | ||
| 49 | } | ||
| 50 | |||
| 21 | template <class _ForwardIterator1, class _ForwardIterator2> | 51 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 22 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator2 | 52 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator2 |
| 23 | swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { | 53 | swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { |
| 24 | for (; __first1 != __last1; ++__first1, (void)++__first2) | 54 | return std::__swap_ranges<_ClassicAlgPolicy>( |
| 25 | swap(*__first1, *__first2); | 55 | std::move(__first1), std::move(__last1), std::move(__first2)).second; |
| 26 | return __first2; | ||
| 27 | } | 56 | } |
| 28 | 57 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | 58 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/uniform_random_bit_generator_adaptor.h created+62| ... | @@ -0,0 +1,62 @@ | ||
| 1 | //===----------------------------------------------------------------------===// | ||
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | |||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H | ||
| 10 | #define _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H | ||
| 11 | |||
| 12 | #include <__config> | ||
| 13 | #include <__functional/invoke.h> | ||
| 14 | #include <type_traits> | ||
| 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_PUSH_MACROS | ||
| 23 | #include <__undef_macros> | ||
| 24 | |||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 26 | |||
| 27 | // Range versions of random algorithms (e.g. `std::shuffle`) are less constrained than their classic counterparts. | ||
| 28 | // Range algorithms only require the given generator to satisfy the `std::uniform_random_bit_generator` concept. | ||
| 29 | // Classic algorithms require the given generator to meet the uniform random bit generator requirements; these | ||
| 30 | // requirements include satisfying `std::uniform_random_bit_generator` and add a requirement for the generator to | ||
| 31 | // provide a nested `result_type` typedef (see `[rand.req.urng]`). | ||
| 32 | // | ||
| 33 | // To be able to reuse classic implementations, make the given generator meet the classic requirements by wrapping | ||
| 34 | // it into an adaptor type that forwards all of its interface and adds the required typedef. | ||
| 35 | template <class _Gen> | ||
| 36 | class _ClassicGenAdaptor { | ||
| 37 | private: | ||
| 38 | // The generator is not required to be copyable or movable, so it has to be stored as a reference. | ||
| 39 | _Gen& __gen; | ||
| 40 | |||
| 41 | public: | ||
| 42 | using result_type = invoke_result_t<_Gen&>; | ||
| 43 | |||
| 44 | _LIBCPP_HIDE_FROM_ABI | ||
| 45 | static constexpr auto min() { return __uncvref_t<_Gen>::min(); } | ||
| 46 | _LIBCPP_HIDE_FROM_ABI | ||
| 47 | static constexpr auto max() { return __uncvref_t<_Gen>::max(); } | ||
| 48 | |||
| 49 | _LIBCPP_HIDE_FROM_ABI | ||
| 50 | constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen(__g) {} | ||
| 51 | |||
| 52 | _LIBCPP_HIDE_FROM_ABI | ||
| 53 | constexpr auto operator()() const { return __gen(); } | ||
| 54 | }; | ||
| 55 | |||
| 56 | _LIBCPP_END_NAMESPACE_STD | ||
| 57 | |||
| 58 | _LIBCPP_POP_MACROS | ||
| 59 | |||
| 60 | #endif // _LIBCPP_STD_VER > 17 | ||
| 61 | |||
| 62 | #endif // _LIBCPP___ALGORITHM_RANGES_UNIFORM_RANDOM_BIT_GENERATOR_ADAPTOR_H | ||
lib/libcxx/include/__availability+7-17| ... | @@ -166,11 +166,11 @@ | ... | @@ -166,11 +166,11 @@ |
| 166 | // user has provided their own). | 166 | // user has provided their own). |
| 167 | // | 167 | // |
| 168 | // Users can pass -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED | 168 | // Users can pass -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED |
| 169 | // to the compiler to tell the library to ignore the fact that the | 169 | // to the compiler to tell the library not to define its own verbose abort. |
| 170 | // default function isn't available on their deployment target. Note that | 170 | // Note that defining this macro but failing to define a custom function |
| 171 | // defining this macro but failing to define a custom function will lead to | 171 | // will lead to a load-time error on back-deployment targets, so it should |
| 172 | // a load-time error on back-deployment targets, so it should be avoided. | 172 | // be avoided. |
| 173 | # define _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT | 173 | // # define _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY |
| 174 | 174 | ||
| 175 | #elif defined(__APPLE__) | 175 | #elif defined(__APPLE__) |
| 176 | 176 | ||
| ... | @@ -271,8 +271,8 @@ | ... | @@ -271,8 +271,8 @@ |
| 271 | __attribute__((unavailable)) | 271 | __attribute__((unavailable)) |
| 272 | # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format | 272 | # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format |
| 273 | 273 | ||
| 274 | # define _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT \ | 274 | # define _LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY |
| 275 | __attribute__((unavailable)) | 275 | |
| 276 | #else | 276 | #else |
| 277 | 277 | ||
| 278 | // ...New vendors can add availability markup here... | 278 | // ...New vendors can add availability markup here... |
| ... | @@ -296,14 +296,4 @@ | ... | @@ -296,14 +296,4 @@ |
| 296 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS | 296 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS |
| 297 | #endif | 297 | #endif |
| 298 | 298 | ||
| 299 | // Define the special verbose termination function availability attribute, which can be silenced by | ||
| 300 | // users if they provide their own custom function. The rest of the code should not use the | ||
| 301 | // *_DEFAULT_* macro directly, since that would make it ignore the fact that the user provided | ||
| 302 | // a custom function. | ||
| 303 | #if defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED) | ||
| 304 | # define _LIBCPP_AVAILABILITY_VERBOSE_ABORT /* nothing */ | ||
| 305 | #else | ||
| 306 | # define _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT | ||
| 307 | #endif | ||
| 308 | |||
| 309 | #endif // _LIBCPP___AVAILABILITY | 299 | #endif // _LIBCPP___AVAILABILITY |
lib/libcxx/include/__iterator/incrementable_traits.h+1| ... | @@ -13,6 +13,7 @@ | ... | @@ -13,6 +13,7 @@ |
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__type_traits/is_primary_template.h> | 14 | #include <__type_traits/is_primary_template.h> |
| 15 | #include <concepts> | 15 | #include <concepts> |
| 16 | #include <cstddef> | ||
| 16 | #include <type_traits> | 17 | #include <type_traits> |
| 17 | 18 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__iterator/iterator_traits.h+7| ... | @@ -14,6 +14,7 @@ | ... | @@ -14,6 +14,7 @@ |
| 14 | #include <__iterator/incrementable_traits.h> | 14 | #include <__iterator/incrementable_traits.h> |
| 15 | #include <__iterator/readable_traits.h> | 15 | #include <__iterator/readable_traits.h> |
| 16 | #include <concepts> | 16 | #include <concepts> |
| 17 | #include <cstddef> | ||
| 17 | #include <type_traits> | 18 | #include <type_traits> |
| 18 | 19 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -507,6 +508,12 @@ using __iterator_category_type = typename iterator_traits<_Iter>::iterator_categ | ... | @@ -507,6 +508,12 @@ using __iterator_category_type = typename iterator_traits<_Iter>::iterator_categ |
| 507 | template <class _Iter> | 508 | template <class _Iter> |
| 508 | using __iterator_pointer_type = typename iterator_traits<_Iter>::pointer; | 509 | using __iterator_pointer_type = typename iterator_traits<_Iter>::pointer; |
| 509 | 510 | ||
| 511 | template <class _Iter> | ||
| 512 | using __iter_diff_t = typename iterator_traits<_Iter>::difference_type; | ||
| 513 | |||
| 514 | template<class _InputIterator> | ||
| 515 | using __iter_value_type = typename iterator_traits<_InputIterator>::value_type; | ||
| 516 | |||
| 510 | _LIBCPP_END_NAMESPACE_STD | 517 | _LIBCPP_END_NAMESPACE_STD |
| 511 | 518 | ||
| 512 | #endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H | 519 | #endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H |
lib/libcxx/include/__iterator/reverse_iterator.h+9-1| ... | @@ -363,7 +363,7 @@ class __unconstrained_reverse_iterator { | ... | @@ -363,7 +363,7 @@ class __unconstrained_reverse_iterator { |
| 363 | _Iter __iter_; | 363 | _Iter __iter_; |
| 364 | 364 | ||
| 365 | public: | 365 | public: |
| 366 | static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value); | 366 | static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value || bidirectional_iterator<_Iter>); |
| 367 | 367 | ||
| 368 | using iterator_type = _Iter; | 368 | using iterator_type = _Iter; |
| 369 | using iterator_category = | 369 | using iterator_category = |
| ... | @@ -391,6 +391,14 @@ public: | ... | @@ -391,6 +391,14 @@ public: |
| 391 | } | 391 | } |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | _LIBCPP_HIDE_FROM_ABI friend constexpr | ||
| 395 | iter_rvalue_reference_t<_Iter> iter_move(const __unconstrained_reverse_iterator& __i) | ||
| 396 | noexcept(is_nothrow_copy_constructible_v<_Iter> && | ||
| 397 | noexcept(ranges::iter_move(--declval<_Iter&>()))) { | ||
| 398 | auto __tmp = __i.base(); | ||
| 399 | return ranges::iter_move(--__tmp); | ||
| 400 | } | ||
| 401 | |||
| 394 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator++() { | 402 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator++() { |
| 395 | --__iter_; | 403 | --__iter_; |
| 396 | return *this; | 404 | return *this; |
lib/libcxx/include/__memory/pointer_traits.h+24-2| ... | @@ -12,6 +12,7 @@ | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | ||
| 13 | #include <__config> | 13 | #include <__config> |
| 14 | #include <__memory/addressof.h> | 14 | #include <__memory/addressof.h> |
| 15 | #include <cstddef> | ||
| 15 | #include <type_traits> | 16 | #include <type_traits> |
| 16 | 17 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | @@ -171,9 +172,30 @@ _Tp* __to_address(_Tp* __p) _NOEXCEPT { | ... | @@ -171,9 +172,30 @@ _Tp* __to_address(_Tp* __p) _NOEXCEPT { |
| 171 | return __p; | 172 | return __p; |
| 172 | } | 173 | } |
| 173 | 174 | ||
| 175 | template <class _Pointer, class = void> | ||
| 176 | struct _HasToAddress : false_type {}; | ||
| 177 | |||
| 178 | template <class _Pointer> | ||
| 179 | struct _HasToAddress<_Pointer, | ||
| 180 | decltype((void)pointer_traits<_Pointer>::to_address(declval<const _Pointer&>())) | ||
| 181 | > : true_type {}; | ||
| 182 | |||
| 183 | template <class _Pointer, class = void> | ||
| 184 | struct _HasArrow : false_type {}; | ||
| 185 | |||
| 186 | template <class _Pointer> | ||
| 187 | struct _HasArrow<_Pointer, | ||
| 188 | decltype((void)declval<const _Pointer&>().operator->()) | ||
| 189 | > : true_type {}; | ||
| 190 | |||
| 191 | template <class _Pointer> | ||
| 192 | struct _IsFancyPointer { | ||
| 193 | static const bool value = _HasArrow<_Pointer>::value || _HasToAddress<_Pointer>::value; | ||
| 194 | }; | ||
| 195 | |||
| 174 | // enable_if is needed here to avoid instantiating checks for fancy pointers on raw pointers | 196 | // enable_if is needed here to avoid instantiating checks for fancy pointers on raw pointers |
| 175 | template <class _Pointer, class = __enable_if_t< | 197 | template <class _Pointer, class = __enable_if_t< |
| 176 | !is_pointer<_Pointer>::value && !is_array<_Pointer>::value && !is_function<_Pointer>::value | 198 | _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value |
| 177 | > > | 199 | > > |
| 178 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | 200 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 179 | typename decay<decltype(__to_address_helper<_Pointer>::__call(declval<const _Pointer&>()))>::type | 201 | typename decay<decltype(__to_address_helper<_Pointer>::__call(declval<const _Pointer&>()))>::type |
| ... | @@ -208,7 +230,7 @@ auto to_address(_Tp *__p) noexcept { | ... | @@ -208,7 +230,7 @@ auto to_address(_Tp *__p) noexcept { |
| 208 | 230 | ||
| 209 | template <class _Pointer> | 231 | template <class _Pointer> |
| 210 | inline _LIBCPP_INLINE_VISIBILITY constexpr | 232 | inline _LIBCPP_INLINE_VISIBILITY constexpr |
| 211 | auto to_address(const _Pointer& __p) noexcept { | 233 | auto to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) { |
| 212 | return _VSTD::__to_address(__p); | 234 | return _VSTD::__to_address(__p); |
| 213 | } | 235 | } |
| 214 | #endif | 236 | #endif |
lib/libcxx/include/__ranges/size.h+1| ... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
| 16 | #include <__ranges/access.h> | 16 | #include <__ranges/access.h> |
| 17 | #include <__utility/auto_cast.h> | 17 | #include <__utility/auto_cast.h> |
| 18 | #include <concepts> | 18 | #include <concepts> |
| 19 | #include <cstddef> | ||
| 19 | #include <type_traits> | 20 | #include <type_traits> |
| 20 | 21 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__verbose_abort+25-1| ... | @@ -17,11 +17,35 @@ | ... | @@ -17,11 +17,35 @@ |
| 17 | # pragma GCC system_header | 17 | # pragma GCC system_header |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | // Provide a default implementation of __libcpp_verbose_abort if we know that neither the built | ||
| 21 | // library not the user is providing one. Otherwise, just declare it and use the one from the | ||
| 22 | // built library or the one provided by the user. | ||
| 23 | // | ||
| 24 | // We can't provide a great implementation because it needs to be pretty much | ||
| 25 | // dependency-free (this is included everywhere else in the library). | ||
| 26 | #if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY) && !defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED) | ||
| 27 | |||
| 28 | extern "C" void abort(); | ||
| 29 | |||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 31 | ||
| 22 | _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) | 32 | _LIBCPP_NORETURN _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) _LIBCPP_HIDE_FROM_ABI inline |
| 33 | void __libcpp_verbose_abort(const char *, ...) { | ||
| 34 | ::abort(); | ||
| 35 | __builtin_unreachable(); // never reached, but needed to tell the compiler that the function never returns | ||
| 36 | } | ||
| 37 | |||
| 38 | _LIBCPP_END_NAMESPACE_STD | ||
| 39 | |||
| 40 | #else | ||
| 41 | |||
| 42 | _LIBCPP_BEGIN_NAMESPACE_STD | ||
| 43 | |||
| 44 | _LIBCPP_NORETURN _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) | ||
| 23 | void __libcpp_verbose_abort(const char *__format, ...); | 45 | void __libcpp_verbose_abort(const char *__format, ...); |
| 24 | 46 | ||
| 25 | _LIBCPP_END_NAMESPACE_STD | 47 | _LIBCPP_END_NAMESPACE_STD |
| 26 | 48 | ||
| 49 | #endif | ||
| 50 | |||
| 27 | #endif // _LIBCPP___VERBOSE_ABORT | 51 | #endif // _LIBCPP___VERBOSE_ABORT |
lib/libcxx/include/algorithm+149| ... | @@ -593,6 +593,11 @@ namespace ranges { | ... | @@ -593,6 +593,11 @@ namespace ranges { |
| 593 | constexpr borrowed_iterator_t<R> | 593 | constexpr borrowed_iterator_t<R> |
| 594 | ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20 | 594 | ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20 |
| 595 | 595 | ||
| 596 | template<class T, class Proj = identity, | ||
| 597 | indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> | ||
| 598 | constexpr const T& | ||
| 599 | ranges::clamp(const T& v, const T& lo, const T& hi, Comp comp = {}, Proj proj = {}); // since C++20 | ||
| 600 | |||
| 596 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | 601 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, |
| 597 | class Proj1 = identity, class Proj2 = identity, | 602 | class Proj1 = identity, class Proj2 = identity, |
| 598 | indirect_strict_weak_order<projected<I1, Proj1>, | 603 | indirect_strict_weak_order<projected<I1, Proj1>, |
| ... | @@ -745,6 +750,13 @@ namespace ranges { | ... | @@ -745,6 +750,13 @@ namespace ranges { |
| 745 | constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O> | 750 | constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O> |
| 746 | ranges::reverse_copy(R&& r, O result); // since C++20 | 751 | ranges::reverse_copy(R&& r, O result); // since C++20 |
| 747 | 752 | ||
| 753 | template<permutable I, sentinel_for<I> S> | ||
| 754 | constexpr subrange<I> rotate(I first, I middle, S last); // since C++20 | ||
| 755 | |||
| 756 | template<forward_range R> | ||
| 757 | requires permutable<iterator_t<R>> | ||
| 758 | constexpr borrowed_subrange_t<R> rotate(R&& r, iterator_t<R> middle); // Since C++20 | ||
| 759 | |||
| 748 | template <class _InIter, class _OutIter> | 760 | template <class _InIter, class _OutIter> |
| 749 | using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20 | 761 | using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20 |
| 750 | 762 | ||
| ... | @@ -758,6 +770,18 @@ namespace ranges { | ... | @@ -758,6 +770,18 @@ namespace ranges { |
| 758 | constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O> | 770 | constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O> |
| 759 | ranges::rotate_copy(R&& r, iterator_t<R> middle, O result); // since C++20 | 771 | ranges::rotate_copy(R&& r, iterator_t<R> middle, O result); // since C++20 |
| 760 | 772 | ||
| 773 | template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Gen> | ||
| 774 | requires (forward_iterator<I> || random_access_iterator<O>) && | ||
| 775 | indirectly_copyable<I, O> && | ||
| 776 | uniform_random_bit_generator<remove_reference_t<Gen>> | ||
| 777 | O sample(I first, S last, O out, iter_difference_t<I> n, Gen&& g); // Since C++20 | ||
| 778 | |||
| 779 | template<input_range R, weakly_incrementable O, class Gen> | ||
| 780 | requires (forward_range<R> || random_access_iterator<O>) && | ||
| 781 | indirectly_copyable<iterator_t<R>, O> && | ||
| 782 | uniform_random_bit_generator<remove_reference_t<Gen>> | ||
| 783 | O sample(R&& r, O out, range_difference_t<R> n, Gen&& g); // Since C++20 | ||
| 784 | |||
| 761 | template<random_access_iterator I, sentinel_for<I> S, class Gen> | 785 | template<random_access_iterator I, sentinel_for<I> S, class Gen> |
| 762 | requires permutable<I> && | 786 | requires permutable<I> && |
| 763 | uniform_random_bit_generator<remove_reference_t<Gen>> | 787 | uniform_random_bit_generator<remove_reference_t<Gen>> |
| ... | @@ -768,6 +792,21 @@ namespace ranges { | ... | @@ -768,6 +792,21 @@ namespace ranges { |
| 768 | uniform_random_bit_generator<remove_reference_t<Gen>> | 792 | uniform_random_bit_generator<remove_reference_t<Gen>> |
| 769 | borrowed_iterator_t<R> shuffle(R&& r, Gen&& g); // Since C++20 | 793 | borrowed_iterator_t<R> shuffle(R&& r, Gen&& g); // Since C++20 |
| 770 | 794 | ||
| 795 | template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, | ||
| 796 | sentinel_for<I2> S2, class Proj1 = identity, class Proj2 = identity, | ||
| 797 | indirect_equivalence_relation<projected<I1, Proj1>, | ||
| 798 | projected<I2, Proj2>> Pred = ranges::equal_to> | ||
| 799 | constexpr bool ranges::is_permutation(I1 first1, S1 last1, I2 first2, S2 last2, | ||
| 800 | Pred pred = {}, | ||
| 801 | Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 | ||
| 802 | |||
| 803 | template<forward_range R1, forward_range R2, | ||
| 804 | class Proj1 = identity, class Proj2 = identity, | ||
| 805 | indirect_equivalence_relation<projected<iterator_t<R1>, Proj1>, | ||
| 806 | projected<iterator_t<R2>, Proj2>> Pred = ranges::equal_to> | ||
| 807 | constexpr bool ranges::is_permutation(R1&& r1, R2&& r2, Pred pred = {}, | ||
| 808 | Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 | ||
| 809 | |||
| 771 | template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, | 810 | template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, |
| 772 | sentinel_for<I2> S2, class Pred = ranges::equal_to, | 811 | sentinel_for<I2> S2, class Pred = ranges::equal_to, |
| 773 | class Proj1 = identity, class Proj2 = identity> | 812 | class Proj1 = identity, class Proj2 = identity> |
| ... | @@ -912,8 +951,108 @@ namespace ranges { | ... | @@ -912,8 +951,108 @@ namespace ranges { |
| 912 | indirectly_copyable_storable<iterator_t<R>, O>) | 951 | indirectly_copyable_storable<iterator_t<R>, O>) |
| 913 | constexpr unique_copy_result<borrowed_iterator_t<R>, O> | 952 | constexpr unique_copy_result<borrowed_iterator_t<R>, O> |
| 914 | unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // Since C++20 | 953 | unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // Since C++20 |
| 954 | |||
| 955 | template<class I, class O> | ||
| 956 | using remove_copy_result = in_out_result<I, O>; // Since C++20 | ||
| 957 | |||
| 958 | template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class T, | ||
| 959 | class Proj = identity> | ||
| 960 | indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*> | ||
| 961 | constexpr remove_copy_result<I, O> | ||
| 962 | remove_copy(I first, S last, O result, const T& value, Proj proj = {}); // Since C++20 | ||
| 963 | |||
| 964 | template<input_range R, weakly_incrementable O, class T, class Proj = identity> | ||
| 965 | requires indirectly_copyable<iterator_t<R>, O> && | ||
| 966 | indirect_binary_predicate<ranges::equal_to, | ||
| 967 | projected<iterator_t<R>, Proj>, const T*> | ||
| 968 | constexpr remove_copy_result<borrowed_iterator_t<R>, O> | ||
| 969 | remove_copy(R&& r, O result, const T& value, Proj proj = {}); // Since C++20 | ||
| 970 | |||
| 971 | template<class I, class O> | ||
| 972 | using remove_copy_if_result = in_out_result<I, O>; // Since C++20 | ||
| 973 | |||
| 974 | template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, | ||
| 975 | class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred> | ||
| 976 | requires indirectly_copyable<I, O> | ||
| 977 | constexpr remove_copy_if_result<I, O> | ||
| 978 | remove_copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // Since C++20 | ||
| 979 | |||
| 980 | template<input_range R, weakly_incrementable O, class Proj = identity, | ||
| 981 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | ||
| 982 | requires indirectly_copyable<iterator_t<R>, O> | ||
| 983 | constexpr remove_copy_if_result<borrowed_iterator_t<R>, O> | ||
| 984 | remove_copy_if(R&& r, O result, Pred pred, Proj proj = {}); // Since C++20 | ||
| 985 | |||
| 986 | template<class I, class O> | ||
| 987 | using replace_copy_result = in_out_result<I, O>; // Since C++20 | ||
| 988 | |||
| 989 | template<input_iterator I, sentinel_for<I> S, class T1, class T2, | ||
| 990 | output_iterator<const T2&> O, class Proj = identity> | ||
| 991 | requires indirectly_copyable<I, O> && | ||
| 992 | indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*> | ||
| 993 | constexpr replace_copy_result<I, O> | ||
| 994 | replace_copy(I first, S last, O result, const T1& old_value, const T2& new_value, | ||
| 995 | Proj proj = {}); // Since C++20 | ||
| 996 | |||
| 997 | template<input_range R, class T1, class T2, output_iterator<const T2&> O, | ||
| 998 | class Proj = identity> | ||
| 999 | requires indirectly_copyable<iterator_t<R>, O> && | ||
| 1000 | indirect_binary_predicate<ranges::equal_to, | ||
| 1001 | projected<iterator_t<R>, Proj>, const T1*> | ||
| 1002 | constexpr replace_copy_result<borrowed_iterator_t<R>, O> | ||
| 1003 | replace_copy(R&& r, O result, const T1& old_value, const T2& new_value, | ||
| 1004 | Proj proj = {}); // Since C++20 | ||
| 1005 | |||
| 1006 | template<class I, class O> | ||
| 1007 | using replace_copy_if_result = in_out_result<I, O>; // Since C++20 | ||
| 1008 | |||
| 1009 | template<input_iterator I, sentinel_for<I> S, class T, output_iterator<const T&> O, | ||
| 1010 | class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred> | ||
| 1011 | requires indirectly_copyable<I, O> | ||
| 1012 | constexpr replace_copy_if_result<I, O> | ||
| 1013 | replace_copy_if(I first, S last, O result, Pred pred, const T& new_value, | ||
| 1014 | Proj proj = {}); // Since C++20 | ||
| 1015 | |||
| 1016 | template<input_range R, class T, output_iterator<const T&> O, class Proj = identity, | ||
| 1017 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | ||
| 1018 | requires indirectly_copyable<iterator_t<R>, O> | ||
| 1019 | constexpr replace_copy_if_result<borrowed_iterator_t<R>, O> | ||
| 1020 | replace_copy_if(R&& r, O result, Pred pred, const T& new_value, | ||
| 1021 | Proj proj = {}); // Since C++20 | ||
| 1022 | |||
| 1023 | template<class I> | ||
| 1024 | using prev_permutation_result = in_found_result<I>; // Since C++20 | ||
| 1025 | |||
| 1026 | template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less, | ||
| 1027 | class Proj = identity> | ||
| 1028 | requires sortable<I, Comp, Proj> | ||
| 1029 | constexpr ranges::prev_permutation_result<I> | ||
| 1030 | ranges::prev_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20 | ||
| 1031 | |||
| 1032 | template<bidirectional_range R, class Comp = ranges::less, | ||
| 1033 | class Proj = identity> | ||
| 1034 | requires sortable<iterator_t<R>, Comp, Proj> | ||
| 1035 | constexpr ranges::prev_permutation_result<borrowed_iterator_t<R>> | ||
| 1036 | ranges::prev_permutation(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20 | ||
| 1037 | |||
| 1038 | template<class I> | ||
| 1039 | using next_permutation_result = in_found_result<I>; // Since C++20 | ||
| 1040 | |||
| 1041 | template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less, | ||
| 1042 | class Proj = identity> | ||
| 1043 | requires sortable<I, Comp, Proj> | ||
| 1044 | constexpr ranges::next_permutation_result<I> | ||
| 1045 | ranges::next_permutation(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20 | ||
| 1046 | |||
| 1047 | template<bidirectional_range R, class Comp = ranges::less, | ||
| 1048 | class Proj = identity> | ||
| 1049 | requires sortable<iterator_t<R>, Comp, Proj> | ||
| 1050 | constexpr ranges::next_permutation_result<borrowed_iterator_t<R>> | ||
| 1051 | ranges::next_permutation(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20 | ||
| 1052 | |||
| 915 | } | 1053 | } |
| 916 | 1054 | ||
| 1055 | template <class InputIterator, class Predicate> | ||
| 917 | constexpr bool // constexpr in C++20 | 1056 | constexpr bool // constexpr in C++20 |
| 918 | all_of(InputIterator first, InputIterator last, Predicate pred); | 1057 | all_of(InputIterator first, InputIterator last, Predicate pred); |
| 919 | 1058 | ||
| ... | @@ -1645,6 +1784,7 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1645,6 +1784,7 @@ template <class BidirectionalIterator, class Compare> |
| 1645 | #include <__algorithm/ranges_all_of.h> | 1784 | #include <__algorithm/ranges_all_of.h> |
| 1646 | #include <__algorithm/ranges_any_of.h> | 1785 | #include <__algorithm/ranges_any_of.h> |
| 1647 | #include <__algorithm/ranges_binary_search.h> | 1786 | #include <__algorithm/ranges_binary_search.h> |
| 1787 | #include <__algorithm/ranges_clamp.h> | ||
| 1648 | #include <__algorithm/ranges_copy.h> | 1788 | #include <__algorithm/ranges_copy.h> |
| 1649 | #include <__algorithm/ranges_copy_backward.h> | 1789 | #include <__algorithm/ranges_copy_backward.h> |
| 1650 | #include <__algorithm/ranges_copy_if.h> | 1790 | #include <__algorithm/ranges_copy_if.h> |
| ... | @@ -1669,6 +1809,7 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1669,6 +1809,7 @@ template <class BidirectionalIterator, class Compare> |
| 1669 | #include <__algorithm/ranges_is_heap.h> | 1809 | #include <__algorithm/ranges_is_heap.h> |
| 1670 | #include <__algorithm/ranges_is_heap_until.h> | 1810 | #include <__algorithm/ranges_is_heap_until.h> |
| 1671 | #include <__algorithm/ranges_is_partitioned.h> | 1811 | #include <__algorithm/ranges_is_partitioned.h> |
| 1812 | #include <__algorithm/ranges_is_permutation.h> | ||
| 1672 | #include <__algorithm/ranges_is_sorted.h> | 1813 | #include <__algorithm/ranges_is_sorted.h> |
| 1673 | #include <__algorithm/ranges_is_sorted_until.h> | 1814 | #include <__algorithm/ranges_is_sorted_until.h> |
| 1674 | #include <__algorithm/ranges_lexicographical_compare.h> | 1815 | #include <__algorithm/ranges_lexicographical_compare.h> |
| ... | @@ -1684,6 +1825,7 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1684,6 +1825,7 @@ template <class BidirectionalIterator, class Compare> |
| 1684 | #include <__algorithm/ranges_mismatch.h> | 1825 | #include <__algorithm/ranges_mismatch.h> |
| 1685 | #include <__algorithm/ranges_move.h> | 1826 | #include <__algorithm/ranges_move.h> |
| 1686 | #include <__algorithm/ranges_move_backward.h> | 1827 | #include <__algorithm/ranges_move_backward.h> |
| 1828 | #include <__algorithm/ranges_next_permutation.h> | ||
| 1687 | #include <__algorithm/ranges_none_of.h> | 1829 | #include <__algorithm/ranges_none_of.h> |
| 1688 | #include <__algorithm/ranges_nth_element.h> | 1830 | #include <__algorithm/ranges_nth_element.h> |
| 1689 | #include <__algorithm/ranges_partial_sort.h> | 1831 | #include <__algorithm/ranges_partial_sort.h> |
| ... | @@ -1692,14 +1834,21 @@ template <class BidirectionalIterator, class Compare> | ... | @@ -1692,14 +1834,21 @@ template <class BidirectionalIterator, class Compare> |
| 1692 | #include <__algorithm/ranges_partition_copy.h> | 1834 | #include <__algorithm/ranges_partition_copy.h> |
| 1693 | #include <__algorithm/ranges_partition_point.h> | 1835 | #include <__algorithm/ranges_partition_point.h> |
| 1694 | #include <__algorithm/ranges_pop_heap.h> | 1836 | #include <__algorithm/ranges_pop_heap.h> |
| 1837 | #include <__algorithm/ranges_prev_permutation.h> | ||
| 1695 | #include <__algorithm/ranges_push_heap.h> | 1838 | #include <__algorithm/ranges_push_heap.h> |
| 1696 | #include <__algorithm/ranges_remove.h> | 1839 | #include <__algorithm/ranges_remove.h> |
| 1840 | #include <__algorithm/ranges_remove_copy.h> | ||
| 1841 | #include <__algorithm/ranges_remove_copy_if.h> | ||
| 1697 | #include <__algorithm/ranges_remove_if.h> | 1842 | #include <__algorithm/ranges_remove_if.h> |
| 1698 | #include <__algorithm/ranges_replace.h> | 1843 | #include <__algorithm/ranges_replace.h> |
| 1844 | #include <__algorithm/ranges_replace_copy.h> | ||
| 1845 | #include <__algorithm/ranges_replace_copy_if.h> | ||
| 1699 | #include <__algorithm/ranges_replace_if.h> | 1846 | #include <__algorithm/ranges_replace_if.h> |
| 1700 | #include <__algorithm/ranges_reverse.h> | 1847 | #include <__algorithm/ranges_reverse.h> |
| 1701 | #include <__algorithm/ranges_reverse_copy.h> | 1848 | #include <__algorithm/ranges_reverse_copy.h> |
| 1849 | #include <__algorithm/ranges_rotate.h> | ||
| 1702 | #include <__algorithm/ranges_rotate_copy.h> | 1850 | #include <__algorithm/ranges_rotate_copy.h> |
| 1851 | #include <__algorithm/ranges_sample.h> | ||
| 1703 | #include <__algorithm/ranges_search.h> | 1852 | #include <__algorithm/ranges_search.h> |
| 1704 | #include <__algorithm/ranges_search_n.h> | 1853 | #include <__algorithm/ranges_search_n.h> |
| 1705 | #include <__algorithm/ranges_set_difference.h> | 1854 | #include <__algorithm/ranges_set_difference.h> |
lib/libcxx/include/format+56-45| ... | @@ -23,16 +23,23 @@ namespace std { | ... | @@ -23,16 +23,23 @@ namespace std { |
| 23 | using format_args = basic_format_args<format_context>; | 23 | using format_args = basic_format_args<format_context>; |
| 24 | using wformat_args = basic_format_args<wformat_context>; | 24 | using wformat_args = basic_format_args<wformat_context>; |
| 25 | 25 | ||
| 26 | // [format.fmt.string], class template basic-format-string | 26 | // [format.fmt.string], class template basic_format_string |
| 27 | template<class charT, class... Args> | 27 | template<class charT, class... Args> |
| 28 | struct basic-format-string; // exposition only | 28 | struct basic_format_string { // since C++23, exposition only before C++23 |
| 29 | private: | ||
| 30 | basic_string_view<charT> str; // exposition only | ||
| 29 | 31 | ||
| 32 | public: | ||
| 33 | template<class T> consteval basic_format_string(const T& s); | ||
| 34 | |||
| 35 | constexpr basic_string_view<charT> get() const noexcept { return str; } | ||
| 36 | }; | ||
| 30 | template<class... Args> | 37 | template<class... Args> |
| 31 | using format-string = // exposition only | 38 | using format_string = // since C++23, exposition only before C++23 |
| 32 | basic-format-string<char, type_identity_t<Args>...>; | 39 | basic_format_string<char, type_identity_t<Args>...>; |
| 33 | template<class... Args> | 40 | template<class... Args> |
| 34 | using wformat-string = // exposition only | 41 | using wformat_string = // since C++23, exposition only before C++23 |
| 35 | basic-format-string<wchar_t, type_identity_t<Args>...>; | 42 | basic_format_string<wchar_t, type_identity_t<Args>...>; |
| 36 | 43 | ||
| 37 | // [format.functions], formatting functions | 44 | // [format.functions], formatting functions |
| 38 | template<class... Args> | 45 | template<class... Args> |
| ... | @@ -233,7 +240,7 @@ private: | ... | @@ -233,7 +240,7 @@ private: |
| 233 | }; | 240 | }; |
| 234 | 241 | ||
| 235 | // Dummy format_context only providing the parts used during constant | 242 | // Dummy format_context only providing the parts used during constant |
| 236 | // validation of the basic-format-string. | 243 | // validation of the basic_format_string. |
| 237 | template <class _CharT> | 244 | template <class _CharT> |
| 238 | struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context { | 245 | struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context { |
| 239 | public: | 246 | public: |
| ... | @@ -468,17 +475,21 @@ __vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) { | ... | @@ -468,17 +475,21 @@ __vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) { |
| 468 | } // namespace __format | 475 | } // namespace __format |
| 469 | 476 | ||
| 470 | template <class _CharT, class... _Args> | 477 | template <class _CharT, class... _Args> |
| 471 | struct _LIBCPP_TEMPLATE_VIS __basic_format_string { | 478 | struct _LIBCPP_TEMPLATE_VIS basic_format_string { |
| 472 | basic_string_view<_CharT> __str_; | ||
| 473 | |||
| 474 | template <class _Tp> | 479 | template <class _Tp> |
| 475 | requires convertible_to<const _Tp&, basic_string_view<_CharT>> | 480 | requires convertible_to<const _Tp&, basic_string_view<_CharT>> |
| 476 | consteval __basic_format_string(const _Tp& __str) : __str_{__str} { | 481 | consteval basic_format_string(const _Tp& __str) : __str_{__str} { |
| 477 | __format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)}, | 482 | __format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)}, |
| 478 | _Context{__types_.data(), __handles_.data(), sizeof...(_Args)}); | 483 | _Context{__types_.data(), __handles_.data(), sizeof...(_Args)}); |
| 479 | } | 484 | } |
| 480 | 485 | ||
| 486 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT constexpr basic_string_view<_CharT> get() const noexcept { | ||
| 487 | return __str_; | ||
| 488 | } | ||
| 489 | |||
| 481 | private: | 490 | private: |
| 491 | basic_string_view<_CharT> __str_; | ||
| 492 | |||
| 482 | using _Context = __format::__compile_time_basic_format_context<_CharT>; | 493 | using _Context = __format::__compile_time_basic_format_context<_CharT>; |
| 483 | 494 | ||
| 484 | static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{ | 495 | static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{ |
| ... | @@ -510,11 +521,11 @@ private: | ... | @@ -510,11 +521,11 @@ private: |
| 510 | }; | 521 | }; |
| 511 | 522 | ||
| 512 | template <class... _Args> | 523 | template <class... _Args> |
| 513 | using __format_string_t = __basic_format_string<char, type_identity_t<_Args>...>; | 524 | using format_string = basic_format_string<char, type_identity_t<_Args>...>; |
| 514 | 525 | ||
| 515 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 526 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 516 | template <class... _Args> | 527 | template <class... _Args> |
| 517 | using __wformat_string_t = __basic_format_string<wchar_t, type_identity_t<_Args>...>; | 528 | using wformat_string = basic_format_string<wchar_t, type_identity_t<_Args>...>; |
| 518 | #endif | 529 | #endif |
| 519 | 530 | ||
| 520 | template <class _OutIt, class _CharT, class _FormatOutIt> | 531 | template <class _OutIt, class _CharT, class _FormatOutIt> |
| ... | @@ -555,16 +566,16 @@ vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) { | ... | @@ -555,16 +566,16 @@ vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) { |
| 555 | 566 | ||
| 556 | template <output_iterator<const char&> _OutIt, class... _Args> | 567 | template <output_iterator<const char&> _OutIt, class... _Args> |
| 557 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt | 568 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt |
| 558 | format_to(_OutIt __out_it, __format_string_t<_Args...> __fmt, _Args&&... __args) { | 569 | format_to(_OutIt __out_it, format_string<_Args...> __fmt, _Args&&... __args) { |
| 559 | return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_, | 570 | return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(), |
| 560 | _VSTD::make_format_args(__args...)); | 571 | _VSTD::make_format_args(__args...)); |
| 561 | } | 572 | } |
| 562 | 573 | ||
| 563 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 574 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 564 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> | 575 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> |
| 565 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt | 576 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt |
| 566 | format_to(_OutIt __out_it, __wformat_string_t<_Args...> __fmt, _Args&&... __args) { | 577 | format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 567 | return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_, | 578 | return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(), |
| 568 | _VSTD::make_wformat_args(__args...)); | 579 | _VSTD::make_wformat_args(__args...)); |
| 569 | } | 580 | } |
| 570 | #endif | 581 | #endif |
| ... | @@ -586,16 +597,16 @@ vformat(wstring_view __fmt, wformat_args __args) { | ... | @@ -586,16 +597,16 @@ vformat(wstring_view __fmt, wformat_args __args) { |
| 586 | #endif | 597 | #endif |
| 587 | 598 | ||
| 588 | template <class... _Args> | 599 | template <class... _Args> |
| 589 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(__format_string_t<_Args...> __fmt, | 600 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(format_string<_Args...> __fmt, |
| 590 | _Args&&... __args) { | 601 | _Args&&... __args) { |
| 591 | return _VSTD::vformat(__fmt.__str_, _VSTD::make_format_args(__args...)); | 602 | return _VSTD::vformat(__fmt.get(), _VSTD::make_format_args(__args...)); |
| 592 | } | 603 | } |
| 593 | 604 | ||
| 594 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 605 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 595 | template <class... _Args> | 606 | template <class... _Args> |
| 596 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring | 607 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring |
| 597 | format(__wformat_string_t<_Args...> __fmt, _Args&&... __args) { | 608 | format(wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 598 | return _VSTD::vformat(__fmt.__str_, _VSTD::make_wformat_args(__args...)); | 609 | return _VSTD::vformat(__fmt.get(), _VSTD::make_wformat_args(__args...)); |
| 599 | } | 610 | } |
| 600 | #endif | 611 | #endif |
| 601 | 612 | ||
| ... | @@ -611,16 +622,16 @@ _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, | ... | @@ -611,16 +622,16 @@ _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, |
| 611 | 622 | ||
| 612 | template <output_iterator<const char&> _OutIt, class... _Args> | 623 | template <output_iterator<const char&> _OutIt, class... _Args> |
| 613 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | 624 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> |
| 614 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __format_string_t<_Args...> __fmt, _Args&&... __args) { | 625 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, format_string<_Args...> __fmt, _Args&&... __args) { |
| 615 | return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_format_args(__args...)); | 626 | return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_format_args(__args...)); |
| 616 | } | 627 | } |
| 617 | 628 | ||
| 618 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 629 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 619 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> | 630 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> |
| 620 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | 631 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> |
| 621 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __wformat_string_t<_Args...> __fmt, | 632 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wformat_string<_Args...> __fmt, |
| 622 | _Args&&... __args) { | 633 | _Args&&... __args) { |
| 623 | return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_wformat_args(__args...)); | 634 | return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_wformat_args(__args...)); |
| 624 | } | 635 | } |
| 625 | #endif | 636 | #endif |
| 626 | 637 | ||
| ... | @@ -634,15 +645,15 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, | ... | @@ -634,15 +645,15 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, |
| 634 | 645 | ||
| 635 | template <class... _Args> | 646 | template <class... _Args> |
| 636 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | 647 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t |
| 637 | formatted_size(__format_string_t<_Args...> __fmt, _Args&&... __args) { | 648 | formatted_size(format_string<_Args...> __fmt, _Args&&... __args) { |
| 638 | return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)}); | 649 | return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)}); |
| 639 | } | 650 | } |
| 640 | 651 | ||
| 641 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 652 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 642 | template <class... _Args> | 653 | template <class... _Args> |
| 643 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | 654 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t |
| 644 | formatted_size(__wformat_string_t<_Args...> __fmt, _Args&&... __args) { | 655 | formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 645 | return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)}); | 656 | return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)}); |
| 646 | } | 657 | } |
| 647 | #endif | 658 | #endif |
| 648 | 659 | ||
| ... | @@ -686,16 +697,16 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt v | ... | @@ -686,16 +697,16 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt v |
| 686 | 697 | ||
| 687 | template <output_iterator<const char&> _OutIt, class... _Args> | 698 | template <output_iterator<const char&> _OutIt, class... _Args> |
| 688 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt | 699 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt |
| 689 | format_to(_OutIt __out_it, locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) { | 700 | format_to(_OutIt __out_it, locale __loc, format_string<_Args...> __fmt, _Args&&... __args) { |
| 690 | return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_, | 701 | return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(), |
| 691 | _VSTD::make_format_args(__args...)); | 702 | _VSTD::make_format_args(__args...)); |
| 692 | } | 703 | } |
| 693 | 704 | ||
| 694 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 705 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 695 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> | 706 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> |
| 696 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt | 707 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt |
| 697 | format_to(_OutIt __out_it, locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) { | 708 | format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 698 | return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_, | 709 | return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(), |
| 699 | _VSTD::make_wformat_args(__args...)); | 710 | _VSTD::make_wformat_args(__args...)); |
| 700 | } | 711 | } |
| 701 | #endif | 712 | #endif |
| ... | @@ -720,17 +731,17 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) { | ... | @@ -720,17 +731,17 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) { |
| 720 | 731 | ||
| 721 | template <class... _Args> | 732 | template <class... _Args> |
| 722 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(locale __loc, | 733 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(locale __loc, |
| 723 | __format_string_t<_Args...> __fmt, | 734 | format_string<_Args...> __fmt, |
| 724 | _Args&&... __args) { | 735 | _Args&&... __args) { |
| 725 | return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_, | 736 | return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(), |
| 726 | _VSTD::make_format_args(__args...)); | 737 | _VSTD::make_format_args(__args...)); |
| 727 | } | 738 | } |
| 728 | 739 | ||
| 729 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 740 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 730 | template <class... _Args> | 741 | template <class... _Args> |
| 731 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring | 742 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring |
| 732 | format(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) { | 743 | format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 733 | return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_, | 744 | return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(), |
| 734 | _VSTD::make_wformat_args(__args...)); | 745 | _VSTD::make_wformat_args(__args...)); |
| 735 | } | 746 | } |
| 736 | #endif | 747 | #endif |
| ... | @@ -748,18 +759,18 @@ _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, | ... | @@ -748,18 +759,18 @@ _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, |
| 748 | 759 | ||
| 749 | template <output_iterator<const char&> _OutIt, class... _Args> | 760 | template <output_iterator<const char&> _OutIt, class... _Args> |
| 750 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | 761 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> |
| 751 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __format_string_t<_Args...> __fmt, | 762 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, format_string<_Args...> __fmt, |
| 752 | _Args&&... __args) { | 763 | _Args&&... __args) { |
| 753 | return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_, | 764 | return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(), |
| 754 | _VSTD::make_format_args(__args...)); | 765 | _VSTD::make_format_args(__args...)); |
| 755 | } | 766 | } |
| 756 | 767 | ||
| 757 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 768 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 758 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> | 769 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> |
| 759 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | 770 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> |
| 760 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __wformat_string_t<_Args...> __fmt, | 771 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, wformat_string<_Args...> __fmt, |
| 761 | _Args&&... __args) { | 772 | _Args&&... __args) { |
| 762 | return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_, | 773 | return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(), |
| 763 | _VSTD::make_wformat_args(__args...)); | 774 | _VSTD::make_wformat_args(__args...)); |
| 764 | } | 775 | } |
| 765 | #endif | 776 | #endif |
| ... | @@ -775,15 +786,15 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_ | ... | @@ -775,15 +786,15 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_ |
| 775 | 786 | ||
| 776 | template <class... _Args> | 787 | template <class... _Args> |
| 777 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | 788 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t |
| 778 | formatted_size(locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) { | 789 | formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) { |
| 779 | return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)}); | 790 | return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)}); |
| 780 | } | 791 | } |
| 781 | 792 | ||
| 782 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | 793 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 783 | template <class... _Args> | 794 | template <class... _Args> |
| 784 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | 795 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t |
| 785 | formatted_size(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) { | 796 | formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) { |
| 786 | return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)}); | 797 | return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)}); |
| 787 | } | 798 | } |
| 788 | #endif | 799 | #endif |
| 789 | 800 |
lib/libcxx/include/span+4-3| ... | @@ -453,9 +453,10 @@ public: | ... | @@ -453,9 +453,10 @@ public: |
| 453 | : __data{_VSTD::to_address(__first)}, __size{__count} {} | 453 | : __data{_VSTD::to_address(__first)}, __size{__count} {} |
| 454 | 454 | ||
| 455 | template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End> | 455 | template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End> |
| 456 | _LIBCPP_INLINE_VISIBILITY | 456 | _LIBCPP_INLINE_VISIBILITY constexpr span(_It __first, _End __last) |
| 457 | constexpr span(_It __first, _End __last) | 457 | : __data(_VSTD::to_address(__first)), __size(__last - __first) { |
| 458 | : __data(_VSTD::to_address(__first)), __size(__last - __first) {} | 458 | _LIBCPP_ASSERT(__last - __first >= 0, "invalid range in span's constructor (iterator, sentinel)"); |
| 459 | } | ||
| 459 | 460 | ||
| 460 | template <size_t _Sz> | 461 | template <size_t _Sz> |
| 461 | _LIBCPP_INLINE_VISIBILITY | 462 | _LIBCPP_INLINE_VISIBILITY |
lib/libcxx/include/version+5-3| ... | @@ -331,8 +331,8 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -331,8 +331,8 @@ __cpp_lib_void_t 201411L <type_traits> |
| 331 | # define __cpp_lib_erase_if 202002L | 331 | # define __cpp_lib_erase_if 202002L |
| 332 | # undef __cpp_lib_execution | 332 | # undef __cpp_lib_execution |
| 333 | // # define __cpp_lib_execution 201902L | 333 | // # define __cpp_lib_execution 201902L |
| 334 | # if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) | 334 | # if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) |
| 335 | // # define __cpp_lib_format 202106L | 335 | # define __cpp_lib_format 202106L |
| 336 | # endif | 336 | # endif |
| 337 | # define __cpp_lib_generic_unordered_lookup 201811L | 337 | # define __cpp_lib_generic_unordered_lookup 201811L |
| 338 | # define __cpp_lib_int_pow2 202002L | 338 | # define __cpp_lib_int_pow2 202002L |
| ... | @@ -351,7 +351,9 @@ __cpp_lib_void_t 201411L <type_traits> | ... | @@ -351,7 +351,9 @@ __cpp_lib_void_t 201411L <type_traits> |
| 351 | # define __cpp_lib_list_remove_return_type 201806L | 351 | # define __cpp_lib_list_remove_return_type 201806L |
| 352 | # define __cpp_lib_math_constants 201907L | 352 | # define __cpp_lib_math_constants 201907L |
| 353 | // # define __cpp_lib_polymorphic_allocator 201902L | 353 | // # define __cpp_lib_polymorphic_allocator 201902L |
| 354 | // # define __cpp_lib_ranges 201811L | 354 | # if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) |
| 355 | # define __cpp_lib_ranges 201811L | ||
| 356 | # endif | ||
| 355 | # define __cpp_lib_remove_cvref 201711L | 357 | # define __cpp_lib_remove_cvref 201711L |
| 356 | # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore) | 358 | # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore) |
| 357 | # define __cpp_lib_semaphore 201907L | 359 | # define __cpp_lib_semaphore 201907L |