aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/libcxx/include/__algorithm
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__algorithm')
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/any_of.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/binary_search.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/clamp.h30
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/comp.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/comp_ref_type.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/copy.h7
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/copy_if.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/copy_n.h30
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/count.h69
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/count_if.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/equal.h25
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/fill.h10
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/fill_n.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find.h89
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find_if.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find_if_not.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/find_segment_if.h62
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/for_each.h31
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/for_each_n.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/generate.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/generate_n.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/half_positive.h20
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h12
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_heap.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_sorted.h8
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/is_sorted_until.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/iter_swap.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/iterator_operations.h12
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/lexicographical_compare.h8
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/make_projected.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/max.h14
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/max_element.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/merge.h12
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/min.h14
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/min_element.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/minmax.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/mismatch.h8
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/move.h5
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/move_backward.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/none_of.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/nth_element.h38
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partition.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/partition_point.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_any_all_none_of.h87
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backend.h156
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backend.h15
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h38
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h26
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h70
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h30
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h240
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h68
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h19
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h16
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h14
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h82
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h121
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_copy.h73
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_count.h47
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_equal.h170
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_fill.h51
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_find.h83
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_for_each.h53
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_frontend_dispatch.h9
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_generate.h53
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_is_partitioned.h20
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h37
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_move.h79
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_replace.h149
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_rotate_copy.h80
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_sort.h22
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_stable_sort.h19
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/pstl_transform.h54
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_adjacent_find.h5
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_clamp.h5
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_count.h9
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_ends_with.h196
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_equal_range.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_find_if_not.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_max.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_max_element.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_remove.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_replace.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_rotate_copy.h5
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/ranges_upper_bound.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/remove.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/remove_copy.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/remove_copy_if.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/remove_if.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/replace.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/replace_copy.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/replace_copy_if.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/replace_if.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/reverse.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/reverse_copy.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/rotate.h20
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/rotate_copy.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/sample.h12
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/search.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/shift_left.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/shift_right.h12
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/sift_down.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/sort.h30
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h6
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h2
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/three_way_comp_ref_type.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/transform.h4
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/unwrap_range.h9
117 files changed, 2200 insertions, 798 deletions
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/any_of.h b/contrib/llvm-project/libcxx/include/__algorithm/any_of.h
index fe0882816b9b..8ba7aae2b225 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/any_of.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/any_of.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
for (; __first != __last; ++__first)
if (__pred(*__first))
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/binary_search.h b/contrib/llvm-project/libcxx/include/__algorithm/binary_search.h
index 0c8f5545e066..5a1d49f5f43e 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/binary_search.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/binary_search.h
@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp)
{
@@ -33,7 +33,7 @@ binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
template <class _ForwardIterator, class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/clamp.h b/contrib/llvm-project/libcxx/include/__algorithm/clamp.h
index 31deb4fd94aa..1631b2673c3f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/clamp.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/clamp.h
@@ -20,24 +20,22 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 17
-template<class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY constexpr
-const _Tp&
-clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
-{
- _LIBCPP_ASSERT_UNCATEGORIZED(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
- return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
-
+template <class _Tp, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
+clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v,
+ _LIBCPP_LIFETIMEBOUND const _Tp& __lo,
+ _LIBCPP_LIFETIMEBOUND const _Tp& __hi,
+ _Compare __comp) {
+ _LIBCPP_ASSERT_UNCATEGORIZED(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
+ return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
}
-template<class _Tp>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY constexpr
-const _Tp&
-clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
-{
- return _VSTD::clamp(__v, __lo, __hi, __less<>());
+template <class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
+clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v,
+ _LIBCPP_LIFETIMEBOUND const _Tp& __lo,
+ _LIBCPP_LIFETIMEBOUND const _Tp& __hi) {
+ return std::clamp(__v, __lo, __hi, __less<>());
}
#endif
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/comp.h b/contrib/llvm-project/libcxx/include/__algorithm/comp.h
index 9474536615ff..3902f7560304 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/comp.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/comp.h
@@ -11,7 +11,7 @@
#include <__config>
#include <__type_traits/integral_constant.h>
-#include <__type_traits/predicate_traits.h>
+#include <__type_traits/operation_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -26,8 +26,8 @@ struct __equal_to {
}
};
-template <class _Lhs, class _Rhs>
-struct __is_trivial_equality_predicate<__equal_to, _Lhs, _Rhs> : true_type {};
+template <class _Tp, class _Up>
+struct __desugars_to<__equal_tag, __equal_to, _Tp, _Up> : true_type {};
// The definition is required because __less is part of the ABI, but it's empty
// because all comparisons should be transparent.
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/comp_ref_type.h b/contrib/llvm-project/libcxx/include/__algorithm/comp_ref_type.h
index d16bd0f53100..2797e9da6658 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/comp_ref_type.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/comp_ref_type.h
@@ -47,7 +47,7 @@ struct __debug_less
template <class _LHS, class _RHS>
_LIBCPP_CONSTEXPR_SINCE_CXX14
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_HIDE_FROM_ABI
decltype((void)std::declval<_Compare&>()(
std::declval<_LHS &>(), std::declval<_RHS &>()))
__do_compare_assert(int, _LHS & __l, _RHS & __r) {
@@ -59,13 +59,13 @@ struct __debug_less
template <class _LHS, class _RHS>
_LIBCPP_CONSTEXPR_SINCE_CXX14
- inline _LIBCPP_INLINE_VISIBILITY
+ inline _LIBCPP_HIDE_FROM_ABI
void __do_compare_assert(long, _LHS &, _RHS &) {}
};
// Pass the comparator by lvalue reference. Or in debug mode, using a
// debugging wrapper that stores a reference.
-#if _LIBCPP_ENABLE_DEBUG_MODE
+# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
template <class _Comp>
using __comp_ref_type = __debug_less<_Comp>;
#else
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy.h b/contrib/llvm-project/libcxx/include/__algorithm/copy.h
index dfe9898c6480..4c3815405af0 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/copy.h
@@ -51,9 +51,10 @@ struct __copy_loop {
_OutIter& __result_;
- _LIBCPP_HIDE_FROM_ABI _CopySegment(_OutIter& __result) : __result_(__result) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit _CopySegment(_OutIter& __result)
+ : __result_(__result) {}
- _LIBCPP_HIDE_FROM_ABI void
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {
__result_ = std::__copy<_AlgPolicy>(__lfirst, __llast, std::move(__result_)).second;
}
@@ -112,7 +113,7 @@ __copy(_InIter __first, _Sent __last, _OutIter __result) {
}
template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second;
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy_if.h b/contrib/llvm-project/libcxx/include/__algorithm/copy_if.h
index a5938b8719da..d68d1dbbadf8 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/copy_if.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/copy_if.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _InputIterator, class _OutputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
copy_if(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Predicate __pred)
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/copy_n.h b/contrib/llvm-project/libcxx/include/__algorithm/copy_n.h
index f3701662aac3..1707e26688c6 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/copy_n.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/copy_n.h
@@ -21,17 +21,14 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
-typename enable_if
-<
- __has_input_iterator_category<_InputIterator>::value &&
- !__has_random_access_iterator_category<_InputIterator>::value,
- _OutputIterator
->::type
+template<class _InputIterator, class _Size, class _OutputIterator,
+ __enable_if_t<__has_input_iterator_category<_InputIterator>::value &&
+ !__has_random_access_iterator_category<_InputIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+_OutputIterator
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
- typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
if (__n > 0)
{
@@ -47,19 +44,16 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
return __result;
}
-template<class _InputIterator, class _Size, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
-typename enable_if
-<
- __has_random_access_iterator_category<_InputIterator>::value,
- _OutputIterator
->::type
+template<class _InputIterator, class _Size, class _OutputIterator,
+ __enable_if_t<__has_random_access_iterator_category<_InputIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+_OutputIterator
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
typedef typename iterator_traits<_InputIterator>::difference_type difference_type;
- typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
- return _VSTD::copy(__first, __first + difference_type(__n), __result);
+ return std::copy(__first, __first + difference_type(__n), __result);
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/count.h b/contrib/llvm-project/libcxx/include/__algorithm/count.h
index 6c8c7fda35df..23a7d3c4dcfe 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/count.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/count.h
@@ -10,26 +10,83 @@
#ifndef _LIBCPP___ALGORITHM_COUNT_H
#define _LIBCPP___ALGORITHM_COUNT_H
+#include <__algorithm/iterator_operations.h>
+#include <__algorithm/min.h>
+#include <__bit/invert_if.h>
+#include <__bit/popcount.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__fwd/bit_reference.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _InputIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
- typename iterator_traits<_InputIterator>::difference_type
- count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
- typename iterator_traits<_InputIterator>::difference_type __r(0);
+// generic implementation
+template <class _AlgPolicy, class _Iter, class _Sent, class _Tp, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename _IterOps<_AlgPolicy>::template __difference_type<_Iter>
+__count(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
+ typename _IterOps<_AlgPolicy>::template __difference_type<_Iter> __r(0);
for (; __first != __last; ++__first)
- if (*__first == __value)
+ if (std::__invoke(__proj, *__first) == __value)
++__r;
return __r;
}
+// __bit_iterator implementation
+template <bool _ToCount, class _Cp, bool _IsConst>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bit_iterator<_Cp, _IsConst>::difference_type
+__count_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) {
+ using _It = __bit_iterator<_Cp, _IsConst>;
+ using __storage_type = typename _It::__storage_type;
+ using difference_type = typename _It::difference_type;
+
+ const int __bits_per_word = _It::__bits_per_word;
+ difference_type __r = 0;
+ // do first partial word
+ if (__first.__ctz_ != 0) {
+ __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+ __storage_type __dn = std::min(__clz_f, __n);
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ __r = std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_) & __m);
+ __n -= __dn;
+ ++__first.__seg_;
+ }
+ // do middle whole words
+ for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
+ __r += std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_));
+ // do last partial word
+ if (__n > 0) {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __r += std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_) & __m);
+ }
+ return __r;
+}
+
+template <class, class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_identity<_Proj>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<__bit_iterator<_Cp, _IsConst> >
+__count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) {
+ if (__value)
+ return std::__count_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first));
+ return std::__count_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first));
+}
+
+template <class _InputIterator, class _Tp>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator>
+count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
+ __identity __proj;
+ return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj);
+}
+
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP___ALGORITHM_COUNT_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/count_if.h b/contrib/llvm-project/libcxx/include/__algorithm/count_if.h
index b96521fe0a85..04f52b894f8b 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/count_if.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/count_if.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
typename iterator_traits<_InputIterator>::difference_type
count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
typename iterator_traits<_InputIterator>::difference_type __r(0);
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/equal.h b/contrib/llvm-project/libcxx/include/__algorithm/equal.h
index b69aeff92bb9..fb358613e210 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/equal.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/equal.h
@@ -23,7 +23,7 @@
#include <__type_traits/is_constant_evaluated.h>
#include <__type_traits/is_equality_comparable.h>
#include <__type_traits/is_volatile.h>
-#include <__type_traits/predicate_traits.h>
+#include <__type_traits/operation_traits.h>
#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -41,13 +41,12 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 boo
return true;
}
-template <
- class _Tp,
- class _Up,
- class _BinaryPredicate,
- __enable_if_t<__is_trivial_equality_predicate<_BinaryPredicate, _Tp, _Up>::value && !is_volatile<_Tp>::value &&
- !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
- int> = 0>
+template <class _Tp,
+ class _Up,
+ class _BinaryPredicate,
+ __enable_if_t<__desugars_to<__equal_tag, _BinaryPredicate, _Tp, _Up>::value && !is_volatile<_Tp>::value &&
+ !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
+ int> = 0>
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
__equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&) {
return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
@@ -94,12 +93,12 @@ template <class _Tp,
class _Pred,
class _Proj1,
class _Proj2,
- __enable_if_t<__is_trivial_equality_predicate<_Pred, _Tp, _Up>::value && __is_identity<_Proj1>::value &&
+ __enable_if_t<__desugars_to<__equal_tag, _Pred, _Tp, _Up>::value && __is_identity<_Proj1>::value &&
__is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
__libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
int> = 0>
-_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl(
- _Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) {
+_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
+__equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&, _Proj2&) {
return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
}
@@ -108,7 +107,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
_RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag,
random_access_iterator_tag) {
- if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
+ if (std::distance(__first1, __last1) != std::distance(__first2, __last2))
return false;
__identity __proj;
return std::__equal_impl(
@@ -125,7 +124,7 @@ template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
_BinaryPredicate __pred) {
- return _VSTD::__equal<_BinaryPredicate&>(
+ return std::__equal<_BinaryPredicate&>(
__first1, __last1, __first2, __last2, __pred, typename iterator_traits<_InputIterator1>::iterator_category(),
typename iterator_traits<_InputIterator2>::iterator_category());
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/fill.h b/contrib/llvm-project/libcxx/include/__algorithm/fill.h
index 0753c427ae4e..360e2c3c3c85 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/fill.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/fill.h
@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag)
{
@@ -31,19 +31,19 @@ __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, fo
}
template <class _RandomAccessIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag)
{
- _VSTD::fill_n(__first, __last - __first, __value);
+ std::fill_n(__first, __last - __first, __value);
}
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
- _VSTD::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category());
+ std::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h b/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h
index e7863ac7ec7e..89681a342ea7 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/fill_n.h
@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
template <class _OutputIterator, class _Size, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
{
@@ -32,11 +32,11 @@ __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
}
template <class _OutputIterator, class _Size, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value)
{
- return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value);
+ return std::__fill_n(__first, std::__convert_to_integral(__n), __value);
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find.h b/contrib/llvm-project/libcxx/include/__algorithm/find.h
index e0de5032878e..754e597130c5 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/find.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find.h
@@ -10,12 +10,19 @@
#ifndef _LIBCPP___ALGORITHM_FIND_H
#define _LIBCPP___ALGORITHM_FIND_H
+#include <__algorithm/find_segment_if.h>
+#include <__algorithm/min.h>
#include <__algorithm/unwrap_iter.h>
+#include <__bit/countr.h>
+#include <__bit/invert_if.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/invoke.h>
+#include <__fwd/bit_reference.h>
+#include <__iterator/segmented_iterator.h>
#include <__string/constexpr_c_functions.h>
#include <__type_traits/is_same.h>
+#include <__utility/move.h>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
# include <cwchar>
@@ -25,8 +32,12 @@
# pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
+// generic implementation
template <class _Iter, class _Sent, class _Tp, class _Proj>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter
__find_impl(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
@@ -36,6 +47,7 @@ __find_impl(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
return __first;
}
+// trivially equality comparable implementations
template <class _Tp,
class _Up,
class _Proj,
@@ -64,8 +76,81 @@ __find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) {
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+// __bit_iterator implementation
+template <bool _ToFind, class _Cp, bool _IsConst>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst>
+__find_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) {
+ using _It = __bit_iterator<_Cp, _IsConst>;
+ using __storage_type = typename _It::__storage_type;
+
+ const int __bits_per_word = _It::__bits_per_word;
+ // do first partial word
+ if (__first.__ctz_ != 0) {
+ __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
+ __storage_type __dn = std::min(__clz_f, __n);
+ __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
+ __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m;
+ if (__b)
+ return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b)));
+ if (__n == __dn)
+ return __first + __n;
+ __n -= __dn;
+ ++__first.__seg_;
+ }
+ // do middle whole words
+ for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) {
+ __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_);
+ if (__b)
+ return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b)));
+ }
+ // do last partial word
+ if (__n > 0) {
+ __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
+ __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m;
+ if (__b)
+ return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b)));
+ }
+ return _It(__first.__seg_, static_cast<unsigned>(__n));
+}
+
+template <class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_identity<_Proj>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, _IsConst>
+__find_impl(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) {
+ if (static_cast<bool>(__value))
+ return std::__find_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first));
+ return std::__find_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first));
+}
+
+// segmented iterator implementation
+
+template <class>
+struct __find_segment;
+
+template <class _SegmentedIterator,
+ class _Tp,
+ class _Proj,
+ __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator
+__find_impl(_SegmentedIterator __first, _SegmentedIterator __last, const _Tp& __value, _Proj& __proj) {
+ return std::__find_segment_if(std::move(__first), std::move(__last), __find_segment<_Tp>(__value), __proj);
+}
+
+template <class _Tp>
+struct __find_segment {
+ const _Tp& __value_;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __find_segment(const _Tp& __value) : __value_(__value) {}
+
+ template <class _InputIterator, class _Proj>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _InputIterator
+ operator()(_InputIterator __first, _InputIterator __last, _Proj& __proj) const {
+ return std::__find_impl(__first, __last, __value_, __proj);
+ }
+};
+
+// public API
template <class _InputIterator, class _Tp>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
__identity __proj;
return std::__rewrap_iter(
@@ -74,4 +159,6 @@ find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP___ALGORITHM_FIND_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h b/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h
index 12f0109a616c..15a147242b0e 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find_first_of.h
@@ -35,14 +35,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_first_of_ce(_ForwardItera
}
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2,
_ForwardIterator2 __last2, _BinaryPredicate __pred) {
- return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred);
+ return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred);
}
template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(
_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to());
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find_if.h b/contrib/llvm-project/libcxx/include/__algorithm/find_if.h
index f4ef3ac31cfe..09a39f646351 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/find_if.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find_if.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
for (; __first != __last; ++__first)
if (__pred(*__first))
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find_if_not.h b/contrib/llvm-project/libcxx/include/__algorithm/find_if_not.h
index 96c159cf5ed3..bf29ebb7cdd9 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/find_if_not.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find_if_not.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
for (; __first != __last; ++__first)
if (!__pred(*__first))
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/find_segment_if.h b/contrib/llvm-project/libcxx/include/__algorithm/find_segment_if.h
new file mode 100644
index 000000000000..9d6064f3e283
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/find_segment_if.h
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_FIND_SEGMENT_IF_H
+#define _LIBCPP___ALGORITHM_FIND_SEGMENT_IF_H
+
+#include <__config>
+#include <__iterator/segmented_iterator.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __find_segment_if is a utility function for optimizing iteration over segmented iterators linearly.
+// [__first, __last) has to be a segmented range. __pred is expected to take a range of local iterators and the __proj.
+// It returns an iterator to the first element that satisfies the predicate, or a one-past-the-end iterator if there was
+// no match. __proj may be anything that should be passed to __pred, but is expected to be a projection to support
+// ranges algorithms, or __identity for classic algorithms.
+
+template <class _SegmentedIterator, class _Pred, class _Proj>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator
+__find_segment_if(_SegmentedIterator __first, _SegmentedIterator __last, _Pred __pred, _Proj& __proj) {
+ using _Traits = __segmented_iterator_traits<_SegmentedIterator>;
+
+ auto __sfirst = _Traits::__segment(__first);
+ auto __slast = _Traits::__segment(__last);
+
+ // We are in a single segment, so we might not be at the beginning or end
+ if (__sfirst == __slast)
+ return _Traits::__compose(__sfirst, __pred(_Traits::__local(__first), _Traits::__local(__last), __proj));
+
+ { // We have more than one segment. Iterate over the first segment, since we might not start at the beginning
+ auto __llast = _Traits::__end(__sfirst);
+ auto __liter = __pred(_Traits::__local(__first), __llast, __proj);
+ if (__liter != __llast)
+ return _Traits::__compose(__sfirst, __liter);
+ }
+ ++__sfirst;
+
+ // Iterate over the segments which are guaranteed to be completely in the range
+ while (__sfirst != __slast) {
+ auto __llast = _Traits::__end(__sfirst);
+ auto __liter = __pred(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), __proj);
+ if (__liter != __llast)
+ return _Traits::__compose(__sfirst, __liter);
+ ++__sfirst;
+ }
+
+ // Iterate over the last segment
+ return _Traits::__compose(__sfirst, __pred(_Traits::__begin(__sfirst), _Traits::__local(__last), __proj));
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_FIND_SEGMENT_IF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/for_each.h b/contrib/llvm-project/libcxx/include/__algorithm/for_each.h
index 6564f31cd0e7..259e527f87f9 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/for_each.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/for_each.h
@@ -10,23 +10,48 @@
#ifndef _LIBCPP___ALGORITHM_FOR_EACH_H
#define _LIBCPP___ALGORITHM_FOR_EACH_H
+#include <__algorithm/for_each_segment.h>
#include <__config>
+#include <__iterator/segmented_iterator.h>
+#include <__ranges/movable_box.h>
+#include <__type_traits/enable_if.h>
+#include <__utility/in_place.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Function>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function for_each(_InputIterator __first,
- _InputIterator __last,
- _Function __f) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function
+for_each(_InputIterator __first, _InputIterator __last, _Function __f) {
for (; __first != __last; ++__first)
__f(*__first);
return __f;
}
+// __movable_box is available in C++20, but is actually a copyable-box, so optimization is only correct in C++23
+#if _LIBCPP_STD_VER >= 23
+template <class _SegmentedIterator, class _Function>
+ requires __is_segmented_iterator<_SegmentedIterator>::value
+_LIBCPP_HIDE_FROM_ABI constexpr _Function
+for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Function __func) {
+ ranges::__movable_box<_Function> __wrapped_func(in_place, std::move(__func));
+ std::__for_each_segment(__first, __last, [&](auto __lfirst, auto __llast) {
+ __wrapped_func =
+ ranges::__movable_box<_Function>(in_place, std::for_each(__lfirst, __llast, std::move(*__wrapped_func)));
+ });
+ return std::move(*__wrapped_func);
+}
+#endif // _LIBCPP_STD_VER >= 23
+
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP___ALGORITHM_FOR_EACH_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/for_each_n.h b/contrib/llvm-project/libcxx/include/__algorithm/for_each_n.h
index 5bd7318224d1..a72a0912cfa5 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/for_each_n.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/for_each_n.h
@@ -22,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 17
template <class _InputIterator, class _Size, class _Function>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator for_each_n(_InputIterator __first,
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator for_each_n(_InputIterator __first,
_Size __orig_n,
_Function __f) {
- typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
while (__n > 0) {
__f(*__first);
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/generate.h b/contrib/llvm-project/libcxx/include/__algorithm/generate.h
index 48e21b51e6c4..e2051dc16dc0 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/generate.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/generate.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Generator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/generate_n.h b/contrib/llvm-project/libcxx/include/__algorithm/generate_n.h
index ff5c82d3e422..5719826e93ed 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/generate_n.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/generate_n.h
@@ -19,11 +19,11 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _OutputIterator, class _Size, class _Generator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
{
- typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
+ typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
for (; __n > 0; ++__first, (void) --__n)
*__first = __gen();
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/half_positive.h b/contrib/llvm-project/libcxx/include/__algorithm/half_positive.h
index 5a0f4baf6aaa..2315e154fb2e 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/half_positive.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/half_positive.h
@@ -22,25 +22,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// Perform division by two quickly for positive integers (llvm.org/PR39129)
-template <typename _Integral>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename enable_if
-<
- is_integral<_Integral>::value,
- _Integral
->::type
+template <typename _Integral, __enable_if_t<is_integral<_Integral>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+_Integral
__half_positive(_Integral __value)
{
return static_cast<_Integral>(static_cast<__make_unsigned_t<_Integral> >(__value) / 2);
}
-template <typename _Tp>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-typename enable_if
-<
- !is_integral<_Tp>::value,
- _Tp
->::type
+template <typename _Tp, __enable_if_t<!is_integral<_Tp>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+_Tp
__half_positive(_Tp __value)
{
return __value / 2;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h b/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h
index 44a9425559ef..d49c2e5cedda 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/inplace_merge.h
@@ -44,17 +44,17 @@ class __invert // invert the sense of a comparison
private:
_Predicate __p_;
public:
- _LIBCPP_INLINE_VISIBILITY __invert() {}
+ _LIBCPP_HIDE_FROM_ABI __invert() {}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
explicit __invert(_Predicate __p) : __p_(__p) {}
template <class _T1>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
bool operator()(const _T1& __x) {return !__p_(__x);}
template <class _T1, class _T2>
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_HIDE_FROM_ABI
bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);}
};
@@ -224,10 +224,10 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle);
difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last);
- difference_type __buf_size = _VSTD::min(__len1, __len2);
+ difference_type __buf_size = std::min(__len1, __len2);
// TODO: Remove the use of std::get_temporary_buffer
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
+ pair<value_type*, ptrdiff_t> __buf = std::get_temporary_buffer<value_type>(__buf_size);
_LIBCPP_SUPPRESS_DEPRECATED_POP
unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
return std::__inplace_merge<_AlgPolicy>(
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h
index 93d84d33806e..dd78031579ec 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_heap.h
@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _RandomAccessIterator, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
@@ -32,11 +32,11 @@ is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __
template<class _RandomAccessIterator>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
- return _VSTD::is_heap(__first, __last, __less<>());
+ return std::is_heap(__first, __last, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h b/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h
index d7131114bd60..85f70e649f56 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_heap_until.h
@@ -58,7 +58,7 @@ template<class _RandomAccessIterator>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
- return _VSTD::__is_heap_until(__first, __last, __less<>());
+ return std::__is_heap_until(__first, __last, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_sorted.h b/contrib/llvm-project/libcxx/include/__algorithm/is_sorted.h
index a321c2c12dc4..0003097b362c 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/is_sorted.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_sorted.h
@@ -23,20 +23,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
- return _VSTD::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last;
+ return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last;
}
template<class _ForwardIterator>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last)
{
- return _VSTD::is_sorted(__first, __last, __less<>());
+ return std::is_sorted(__first, __last, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/is_sorted_until.h b/contrib/llvm-project/libcxx/include/__algorithm/is_sorted_until.h
index 890b93631c46..aeb3f1c8be98 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/is_sorted_until.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/is_sorted_until.h
@@ -41,14 +41,14 @@ template <class _ForwardIterator, class _Compare>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
- return _VSTD::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp);
+ return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp);
}
template<class _ForwardIterator>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
{
- return _VSTD::is_sorted_until(__first, __last, __less<>());
+ return std::is_sorted_until(__first, __last, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/iter_swap.h b/contrib/llvm-project/libcxx/include/__algorithm/iter_swap.h
index 44422b5de0f0..f647e7432467 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/iter_swap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/iter_swap.h
@@ -20,7 +20,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void iter_swap(_ForwardIterator1 __a,
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void iter_swap(_ForwardIterator1 __a,
_ForwardIterator2 __b)
// _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b)))
_NOEXCEPT_(_NOEXCEPT_(swap(*std::declval<_ForwardIterator1>(), *std::declval<_ForwardIterator2>()))) {
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/iterator_operations.h b/contrib/llvm-project/libcxx/include/__algorithm/iterator_operations.h
index 002978014cc7..e6176da4f560 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/iterator_operations.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/iterator_operations.h
@@ -110,27 +110,23 @@ struct _IterOps<_ClassicAlgPolicy> {
}
// iter_move
- template <class _Iter>
+ template <class _Iter, __enable_if_t<is_reference<__deref_t<_Iter> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
// If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note
// that the C++03 mode doesn't support `decltype(auto)` as the return type.
- __enable_if_t<
- is_reference<__deref_t<_Iter> >::value,
- __move_t<_Iter> >
+ __move_t<_Iter>
__iter_move(_Iter&& __i) {
__validate_iter_reference<_Iter>();
return std::move(*std::forward<_Iter>(__i));
}
- template <class _Iter>
+ template <class _Iter, __enable_if_t<!is_reference<__deref_t<_Iter> >::value, int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static
// If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a
// value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that
// temporary. Note that the C++03 mode doesn't support `auto` as the return type.
- __enable_if_t<
- !is_reference<__deref_t<_Iter> >::value,
- __deref_t<_Iter> >
+ __deref_t<_Iter>
__iter_move(_Iter&& __i) {
__validate_iter_reference<_Iter>();
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/lexicographical_compare.h b/contrib/llvm-project/libcxx/include/__algorithm/lexicographical_compare.h
index 62b72edc80f7..1ee189a25902 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/lexicographical_compare.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/lexicographical_compare.h
@@ -37,22 +37,22 @@ __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
template <class _InputIterator1, class _InputIterator2, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
{
- return _VSTD::__lexicographical_compare<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __comp);
+ return std::__lexicographical_compare<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __comp);
}
template <class _InputIterator1, class _InputIterator2>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2)
{
- return _VSTD::lexicographical_compare(__first1, __last1, __first2, __last2, __less<>());
+ return std::lexicographical_compare(__first1, __last1, __first2, __last2, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/make_projected.h b/contrib/llvm-project/libcxx/include/__algorithm/make_projected.h
index ec854763a5a2..3a8670111814 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/make_projected.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/make_projected.h
@@ -96,7 +96,7 @@ decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __p
return __comp;
} else {
- return [&](auto&& __lhs, auto&& __rhs) {
+ return [&](auto&& __lhs, auto&& __rhs) -> bool {
return std::invoke(__comp,
std::invoke(__proj1, std::forward<decltype(__lhs)>(__lhs)),
std::invoke(__proj2, std::forward<decltype(__rhs)>(__rhs)));
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/max.h b/contrib/llvm-project/libcxx/include/__algorithm/max.h
index 5d8e64cfff39..183a4e9cac06 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/max.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/max.h
@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Tp&
max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp)
{
@@ -35,31 +35,31 @@ max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b,
template <class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Tp&
max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
{
- return _VSTD::max(__a, __b, __less<>());
+ return std::max(__a, __b, __less<>());
}
#ifndef _LIBCPP_CXX03_LANG
template<class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp
max(initializer_list<_Tp> __t, _Compare __comp)
{
- return *_VSTD::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
+ return *std::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
}
template<class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp
max(initializer_list<_Tp> __t)
{
- return *_VSTD::max_element(__t.begin(), __t.end(), __less<>());
+ return *std::max_element(__t.begin(), __t.end(), __less<>());
}
#endif // _LIBCPP_CXX03_LANG
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/max_element.h b/contrib/llvm-project/libcxx/include/__algorithm/max_element.h
index 8fd52c77723c..a2dc9707c00b 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/max_element.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/max_element.h
@@ -40,7 +40,7 @@ template <class _ForwardIterator, class _Compare>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
- return _VSTD::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp);
+ return std::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp);
}
@@ -48,7 +48,7 @@ template <class _ForwardIterator>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last)
{
- return _VSTD::max_element(__first, __last, __less<>());
+ return std::max_element(__first, __last, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/merge.h b/contrib/llvm-project/libcxx/include/__algorithm/merge.h
index 7ee7aaad716e..8a6021f1880b 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/merge.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/merge.h
@@ -30,7 +30,7 @@ __merge(_InputIterator1 __first1, _InputIterator1 __last1,
for (; __first1 != __last1; ++__result)
{
if (__first2 == __last2)
- return _VSTD::copy(__first1, __last1, __result);
+ return std::copy(__first1, __last1, __result);
if (__comp(*__first2, *__first1))
{
*__result = *__first2;
@@ -42,25 +42,25 @@ __merge(_InputIterator1 __first1, _InputIterator1 __last1,
++__first1;
}
}
- return _VSTD::copy(__first2, __last2, __result);
+ return std::copy(__first2, __last2, __result);
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
- return _VSTD::__merge<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp);
+ return std::__merge<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp);
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
{
- return _VSTD::merge(__first1, __last1, __first2, __last2, __result, __less<>());
+ return std::merge(__first1, __last1, __first2, __last2, __result, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/min.h b/contrib/llvm-project/libcxx/include/__algorithm/min.h
index 3c0debd6b046..58574517132f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/min.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/min.h
@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Tp&
min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp)
{
@@ -35,31 +35,31 @@ min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b,
template <class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
const _Tp&
min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
{
- return _VSTD::min(__a, __b, __less<>());
+ return std::min(__a, __b, __less<>());
}
#ifndef _LIBCPP_CXX03_LANG
template<class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp
min(initializer_list<_Tp> __t, _Compare __comp)
{
- return *_VSTD::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
+ return *std::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
}
template<class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
_Tp
min(initializer_list<_Tp> __t)
{
- return *_VSTD::min_element(__t.begin(), __t.end(), __less<>());
+ return *std::min_element(__t.begin(), __t.end(), __less<>());
}
#endif // _LIBCPP_CXX03_LANG
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/min_element.h b/contrib/llvm-project/libcxx/include/__algorithm/min_element.h
index 45f3e85ef92d..0ce7af69333f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/min_element.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/min_element.h
@@ -64,7 +64,7 @@ template <class _ForwardIterator>
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last)
{
- return _VSTD::min_element(__first, __last, __less<>());
+ return std::min_element(__first, __last, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/minmax.h b/contrib/llvm-project/libcxx/include/__algorithm/minmax.h
index bdcf57b101e4..115bf93f90ba 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/minmax.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/minmax.h
@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template<class _Tp, class _Compare>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<const _Tp&, const _Tp&>
minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp)
{
@@ -35,7 +35,7 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __
template<class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<const _Tp&, const _Tp&>
minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
{
@@ -55,7 +55,7 @@ pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {
template<class _Tp>
_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __t)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/mismatch.h b/contrib/llvm-project/libcxx/include/__algorithm/mismatch.h
index e5b014f45738..8330d21d56f3 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/mismatch.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/mismatch.h
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
for (; __first1 != __last1; ++__first1, (void)++__first2)
@@ -32,7 +32,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
}
template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
return std::mismatch(__first1, __last1, __first2, __equal_to());
@@ -40,7 +40,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
#if _LIBCPP_STD_VER >= 14
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
_BinaryPredicate __pred) {
@@ -51,7 +51,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
}
template <class _InputIterator1, class _InputIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
return std::mismatch(__first1, __last1, __first2, __last2, __equal_to());
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/move.h b/contrib/llvm-project/libcxx/include/__algorithm/move.h
index 01aeef4e177e..e0da07117e66 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/move.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/move.h
@@ -52,9 +52,10 @@ struct __move_loop {
_OutIter& __result_;
- _LIBCPP_HIDE_FROM_ABI _MoveSegment(_OutIter& __result) : __result_(__result) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit _MoveSegment(_OutIter& __result)
+ : __result_(__result) {}
- _LIBCPP_HIDE_FROM_ABI void
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
operator()(typename _Traits::__local_iterator __lfirst, typename _Traits::__local_iterator __llast) {
__result_ = std::__move<_AlgPolicy>(__lfirst, __llast, std::move(__result_)).second;
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h b/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h
index e396abfe0d38..8151e4ef3243 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/move_backward.h
@@ -127,7 +127,7 @@ __move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _Bidirectiona
}
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator2
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator2
move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {
return std::__move_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).second;
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h
index d89768ddc194..ebaed15ae2ad 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/next_permutation.h
@@ -56,7 +56,7 @@ __next_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&&
}
template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
@@ -65,11 +65,11 @@ next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last,
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
- return _VSTD::next_permutation(__first, __last, __less<>());
+ return std::next_permutation(__first, __last, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/none_of.h b/contrib/llvm-project/libcxx/include/__algorithm/none_of.h
index 19357eb2367c..ce59187a3a65 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/none_of.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/none_of.h
@@ -19,7 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Predicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
for (; __first != __last; ++__first)
if (__pred(*__first))
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/nth_element.h b/contrib/llvm-project/libcxx/include/__algorithm/nth_element.h
index dbacf58f9ecd..6b3b2bb434d5 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/nth_element.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/nth_element.h
@@ -13,6 +13,7 @@
#include <__algorithm/comp_ref_type.h>
#include <__algorithm/iterator_operations.h>
#include <__algorithm/sort.h>
+#include <__assert>
#include <__config>
#include <__debug_utils/randomize_range.h>
#include <__iterator/iterator_traits.h>
@@ -42,6 +43,7 @@ __nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j,
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
+// NOLINTNEXTLINE(readability-function-cognitive-complexity)
__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
{
using _Ops = _IterOps<_AlgPolicy>;
@@ -90,7 +92,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
if (!__comp(*__i, *__m)) // if *__first == *__m
{
// *__first == *__m, *__first doesn't go in first part
- if (_VSTD::__nth_element_find_guard<_Compare>(__i, __j, __m, __comp)) {
+ if (std::__nth_element_find_guard<_Compare>(__i, __j, __m, __comp)) {
_Ops::iter_swap(__i, __j);
++__n_swaps;
} else {
@@ -116,10 +118,18 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
return;
}
while (true) {
- while (!__comp(*__first, *__i))
+ while (!__comp(*__first, *__i)) {
++__i;
- while (__comp(*__first, *--__j))
- ;
+ _LIBCPP_ASSERT_UNCATEGORIZED(
+ __i != __last,
+ "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?");
+ }
+ do {
+ _LIBCPP_ASSERT_UNCATEGORIZED(
+ __j != __first,
+ "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?");
+ --__j;
+ } while (__comp(*__first, *__j));
if (__i >= __j)
break;
_Ops::iter_swap(__i, __j);
@@ -132,7 +142,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
return;
}
// __nth_element the second part
- // _VSTD::__nth_element<_Compare>(__i, __nth, __last, __comp);
+ // std::__nth_element<_Compare>(__i, __nth, __last, __comp);
__first = __i;
continue;
}
@@ -146,11 +156,19 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
while (true)
{
// __m still guards upward moving __i
- while (__comp(*__i, *__m))
+ while (__comp(*__i, *__m)) {
++__i;
+ _LIBCPP_ASSERT_UNCATEGORIZED(
+ __i != __last,
+ "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?");
+ }
// It is now known that a guard exists for downward moving __j
- while (!__comp(*--__j, *__m))
- ;
+ do {
+ _LIBCPP_ASSERT_UNCATEGORIZED(
+ __j != __first,
+ "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?");
+ --__j;
+ } while (!__comp(*__j, *__m));
if (__i >= __j)
break;
_Ops::iter_swap(__i, __j);
@@ -210,12 +228,12 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando
// __nth_element on range containing __nth
if (__nth < __i)
{
- // _VSTD::__nth_element<_Compare>(__first, __nth, __i, __comp);
+ // std::__nth_element<_Compare>(__first, __nth, __i, __comp);
__last = __i;
}
else
{
- // _VSTD::__nth_element<_Compare>(__i+1, __nth, __last, __comp);
+ // std::__nth_element<_Compare>(__i+1, __nth, __last, __comp);
__first = ++__i;
}
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h
index 56bc9052c748..de4ebfcbd858 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort.h
@@ -71,7 +71,7 @@ _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAcces
}
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
_Compare __comp)
@@ -83,11 +83,11 @@ partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
}
template <class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last)
{
- _VSTD::partial_sort(__first, __middle, __last, __less<>());
+ std::partial_sort(__first, __middle, __last, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h
index b9635c51d5fa..2c1e786d030e 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partial_sort_copy.h
@@ -60,7 +60,7 @@ __partial_sort_copy(_InputIterator __first, _Sentinel1 __last,
}
template <class _InputIterator, class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_RandomAccessIterator
partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
@@ -74,12 +74,12 @@ partial_sort_copy(_InputIterator __first, _InputIterator __last,
}
template <class _InputIterator, class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_RandomAccessIterator
partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first, _RandomAccessIterator __result_last)
{
- return _VSTD::partial_sort_copy(__first, __last, __result_first, __result_last, __less<>());
+ return std::partial_sort_copy(__first, __last, __result_first, __result_last, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partition.h b/contrib/llvm-project/libcxx/include/__algorithm/partition.h
index a58dd6464aae..a6aaf634aaa5 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/partition.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partition.h
@@ -83,7 +83,7 @@ pair<_ForwardIterator, _ForwardIterator> __partition(
}
template <class _ForwardIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator
partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/partition_point.h b/contrib/llvm-project/libcxx/include/__algorithm/partition_point.h
index 6ede71a264cd..a61ed5ec5b41 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/partition_point.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/partition_point.h
@@ -26,12 +26,12 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
- difference_type __len = _VSTD::distance(__first, __last);
+ difference_type __len = std::distance(__first, __last);
while (__len != 0)
{
- difference_type __l2 = _VSTD::__half_positive(__len);
+ difference_type __l2 = std::__half_positive(__len);
_ForwardIterator __m = __first;
- _VSTD::advance(__m, __l2);
+ std::advance(__m, __l2);
if (__pred(*__m))
{
__first = ++__m;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h b/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h
index 187f1e3e5ba3..4a6bf4a66439 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/prev_permutation.h
@@ -57,7 +57,7 @@ __prev_permutation(_BidirectionalIterator __first, _Sentinel __last, _Compare&&
}
template <class _BidirectionalIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
@@ -66,11 +66,11 @@ prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last,
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
bool
prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
- return _VSTD::prev_permutation(__first, __last, __less<>());
+ return std::prev_permutation(__first, __last, __less<>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_any_all_none_of.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_any_all_none_of.h
index 0e50e0ed3662..d93fdba2224c 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_any_all_none_of.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_any_all_none_of.h
@@ -13,12 +13,11 @@
#include <__algorithm/pstl_frontend_dispatch.h>
#include <__config>
#include <__iterator/cpp17_iterator_concepts.h>
-#include <__iterator/iterator_traits.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
#include <__utility/move.h>
-#include <__utility/terminate_on_exception.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -36,19 +35,35 @@ template <class _ExecutionPolicy,
class _Predicate,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
-any_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
- _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> __any_of(
+ _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept {
return std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_any_of),
- [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) {
- return std::find_if(__policy, __g_first, __g_last, __g_pred) != __g_last;
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_any_of, _RawPolicy),
+ [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) -> optional<bool> {
+ auto __res = std::__find_if(__policy, __g_first, __g_last, __g_pred);
+ if (!__res)
+ return nullopt;
+ return *__res != __g_last;
},
std::move(__first),
std::move(__last),
std::move(__pred));
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Predicate,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
+any_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ auto __res = std::__any_of(__policy, std::move(__first), std::move(__last), std::move(__pred));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
+}
+
template <class>
void __pstl_all_of(); // declaration needed for the frontend dispatch below
@@ -57,21 +72,37 @@ template <class _ExecutionPolicy,
class _Pred,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
-all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
- _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
+__all_of(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Pred&& __pred) noexcept {
return std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_all_of),
- [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) {
- return !std::any_of(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __value) {
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_all_of, _RawPolicy),
+ [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) -> optional<bool> {
+ auto __res = std::__any_of(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __value) {
return !__g_pred(__value);
});
+ if (!__res)
+ return nullopt;
+ return !*__res;
},
std::move(__first),
std::move(__last),
std::move(__pred));
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Pred,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
+all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ auto __res = std::__all_of(__policy, std::move(__first), std::move(__last), std::move(__pred));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
+}
+
template <class>
void __pstl_none_of(); // declaration needed for the frontend dispatch below
@@ -80,19 +111,35 @@ template <class _ExecutionPolicy,
class _Pred,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
-none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
- _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
+__none_of(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Pred&& __pred) noexcept {
return std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_none_of),
- [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) {
- return !std::any_of(__policy, __g_first, __g_last, __g_pred);
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_none_of, _RawPolicy),
+ [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) -> optional<bool> {
+ auto __res = std::__any_of(__policy, __g_first, __g_last, __g_pred);
+ if (!__res)
+ return nullopt;
+ return !*__res;
},
std::move(__first),
std::move(__last),
std::move(__pred));
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Pred,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
+none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ auto __res = std::__none_of(__policy, std::move(__first), std::move(__last), std::move(__pred));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backend.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backend.h
index 93372f019031..3af03ce2fbc8 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backend.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backend.h
@@ -27,23 +27,38 @@ TODO: Documentation of how backends work
A PSTL parallel backend is a tag type to which the following functions are associated, at minimum:
template <class _ExecutionPolicy, class _Iterator, class _Func>
- void __pstl_for_each(_Backend, _ExecutionPolicy&&, _Iterator __first, _Iterator __last, _Func __f);
+ optional<__empty> __pstl_for_each(_Backend, _ExecutionPolicy&&, _Iterator __first, _Iterator __last, _Func __f);
template <class _ExecutionPolicy, class _Iterator, class _Predicate>
- _Iterator __pstl_find_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
+ optional<_Iterator> __pstl_find_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp>
- void __pstl_stable_sort(_Backend, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp);
+ optional<__empty>
+ __pstl_stable_sort(_Backend, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp);
+
+ template <class _ExecutionPolicy,
+ class _ForwardIterator1,
+ class _ForwardIterator2,
+ class _ForwardOutIterator,
+ class _Comp>
+ optional<_ForwardOutIterator> __pstl_merge(_Backend,
+ _ForwardIterator1 __first1,
+ _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2,
+ _ForwardOutIterator __result,
+ _Comp __comp);
template <class _ExecutionPolicy, class _InIterator, class _OutIterator, class _UnaryOperation>
- _OutIterator __pstl_transform(_InIterator __first, _InIterator __last, _OutIterator __result, _UnaryOperation __op);
+ optional<_OutIterator>
+ __pstl_transform(_Backend, _InIterator __first, _InIterator __last, _OutIterator __result, _UnaryOperation __op);
template <class _ExecutionPolicy, class _InIterator1, class _InIterator2, class _OutIterator, class _BinaryOperation>
- _OutIterator __pstl_transform(_InIterator1 __first1,
- _InIterator1 __last1,
- _InIterator2 __first2,
- _OutIterator __result,
- _BinaryOperation __op);
+ optional<_OutIterator> __pstl_transform(_InIterator1 __first1,
+ _InIterator2 __first2,
+ _InIterator1 __last1,
+ _OutIterator __result,
+ _BinaryOperation __op);
template <class _ExecutionPolicy,
class _Iterator1,
@@ -51,22 +66,22 @@ A PSTL parallel backend is a tag type to which the following functions are assoc
class _Tp,
class _BinaryOperation1,
class _BinaryOperation2>
- _Tp __pstl_transform_reduce(_Backend,
- _Iterator1 __first1,
- _Iterator1 __last1,
- _Iterator2 __first2,
- _Iterator2 __last2,
- _Tp __init,
- _BinaryOperation1 __reduce,
- _BinaryOperation2 __transform);
+ optional<_Tp> __pstl_transform_reduce(_Backend,
+ _Iterator1 __first1,
+ _Iterator1 __last1,
+ _Iterator2 __first2,
+ _Iterator2 __last2,
+ _Tp __init,
+ _BinaryOperation1 __reduce,
+ _BinaryOperation2 __transform);
template <class _ExecutionPolicy, class _Iterator, class _Tp, class _BinaryOperation, class _UnaryOperation>
- _Tp __pstl_transform_reduce(_Backend,
- _Iterator __first,
- _Iterator __last,
- _Tp __init,
- _BinaryOperation __reduce,
- _UnaryOperation __transform);
+ optional<_Tp> __pstl_transform_reduce(_Backend,
+ _Iterator __first,
+ _Iterator __last,
+ _Tp __init,
+ _BinaryOperation __reduce,
+ _UnaryOperation __transform);
// TODO: Complete this list
@@ -75,86 +90,105 @@ algorithms, otherwise they are implemented in terms of other algorithms. If none
implemented, all the algorithms will eventually forward to the basis algorithms listed above:
template <class _ExecutionPolicy, class _Iterator, class _Size, class _Func>
- void __pstl_for_each_n(_Backend, _Iterator __first, _Size __n, _Func __f);
+ optional<__empty> __pstl_for_each_n(_Backend, _Iterator __first, _Size __n, _Func __f);
template <class _ExecutionPolicy, class _Iterator, class _Predicate>
- bool __pstl_any_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred);
+ optional<bool> __pstl_any_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred);
template <class _ExecutionPolicy, class _Iterator, class _Predicate>
- bool __pstl_all_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred);
+ optional<bool> __pstl_all_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred);
template <class _ExecutionPolicy, class _Iterator, class _Predicate>
- bool __pstl_none_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred);
+ optional<bool> __pstl_none_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred);
template <class _ExecutionPolicy, class _Iterator, class _Tp>
- _Iterator __pstl_find(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value);
+ optional<_Iterator> __pstl_find(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value);
template <class _ExecutionPolicy, class _Iterator, class _Predicate>
- _Iterator __pstl_find_if_not(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
+ optional<_Iterator> __pstl_find_if_not(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
template <class _ExecutionPolicy, class _Iterator, class _Tp>
- void __pstl_fill(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value);
+ optional<__empty> __pstl_fill(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value);
template <class _ExecutionPolicy, class _Iterator, class _SizeT, class _Tp>
- void __pstl_fill_n(_Backend, _Iterator __first, _SizeT __n, const _Tp& __value);
+ optional<__empty> __pstl_fill_n(_Backend, _Iterator __first, _SizeT __n, const _Tp& __value);
template <class _ExecutionPolicy, class _Iterator, class _Generator>
- void __pstl_generate(_Backend, _Iterator __first, _Iterator __last, _Generator __gen);
+ optional<__empty> __pstl_generate(_Backend, _Iterator __first, _Iterator __last, _Generator __gen);
template <class _ExecutionPolicy, class _Iterator, class _Predicate>
- void __pstl_is_partitioned(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
+ optional<__empty> __pstl_is_partitioned(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
template <class _ExecutionPolicy, class _Iterator, class _Size, class _Generator>
- void __pstl_generator_n(_Backend, _Iterator __first, _Size __n, _Generator __gen);
+ optional<__empty> __pstl_generator_n(_Backend, _Iterator __first, _Size __n, _Generator __gen);
template <class _ExecutionPolicy, class _terator1, class _Iterator2, class _OutIterator, class _Comp>
- _OutIterator __pstl_merge(_Backend,
- _Iterator1 __first1,
- _Iterator1 __last1,
- _Iterator2 __first2,
- _Iterator2 __last2,
- _OutIterator __result,
- _Comp __comp);
+ optional<_OutIterator> __pstl_merge(_Backend,
+ _Iterator1 __first1,
+ _Iterator1 __last1,
+ _Iterator2 __first2,
+ _Iterator2 __last2,
+ _OutIterator __result,
+ _Comp __comp);
+
+ template <class _ExecutionPolicy, class _Iterator, class _OutIterator>
+ optional<_OutIterator> __pstl_move(_Backend, _Iterator __first, _Iterator __last, _OutIterator __result);
template <class _ExecutionPolicy, class _Iterator, class _Tp, class _BinaryOperation>
- _Tp __pstl_reduce(_Backend, _Iterator __first, _Iterator __last, _Tp __init, _BinaryOperation __op);
+ optional<_Tp> __pstl_reduce(_Backend, _Iterator __first, _Iterator __last, _Tp __init, _BinaryOperation __op);
temlate <class _ExecutionPolicy, class _Iterator>
- __iter_value_type<_Iterator> __pstl_reduce(_Backend, _Iterator __first, _Iterator __last);
+ optional<__iter_value_type<_Iterator>> __pstl_reduce(_Backend, _Iterator __first, _Iterator __last);
- template <class _ExecuitonPolicy, class _Iterator, class _Tp>
- __iter_diff_t<_Iterator> __pstl_count(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value);
+ template <class _ExecutionPolicy, class _Iterator, class _Tp>
+ optional<__iter_diff_t<_Iterator>> __pstl_count(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value);
template <class _ExecutionPolicy, class _Iterator, class _Predicate>
- __iter_diff_t<_Iterator> __pstl_count_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
+ optional<__iter_diff_t<_Iterator>> __pstl_count_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
template <class _ExecutionPolicy, class _Iterator, class _Tp>
- void __pstl_replace(_Backend, _Iterator __first, _Iterator __last, const _Tp& __old_value, const _Tp& __new_value);
+ optional<__empty>
+ __pstl_replace(_Backend, _Iterator __first, _Iterator __last, const _Tp& __old_value, const _Tp& __new_value);
template <class _ExecutionPolicy, class _Iterator, class _Pred, class _Tp>
- void __pstl_replace_if(_Backend, _Iterator __first, _Iterator __last, _Pred __pred, const _Tp& __new_value);
+ optional<__empty>
+ __pstl_replace_if(_Backend, _Iterator __first, _Iterator __last, _Pred __pred, const _Tp& __new_value);
template <class _ExecutionPolicy, class _Iterator, class _OutIterator, class _Tp>
- void __pstl_replace_copy(_Backend,
- _Iterator __first,
- _Iterator __last,
- _OutIterator __result,
- const _Tp& __old_value,
- const _Tp& __new_value);
+ optional<__empty> __pstl_replace_copy(_Backend,
+ _Iterator __first,
+ _Iterator __last,
+ _OutIterator __result,
+ const _Tp& __old_value,
+ const _Tp& __new_value);
template <class _ExecutionPolicy, class _Iterator, class _OutIterator, class _Pred, class _Tp>
- void __pstl_replace_copy_if(_Backend,
- _Iterator __first,
- _Iterator __last,
- _OutIterator __result,
- _Pred __pred,
- const _Tp& __new_value);
+ optional<__empty> __pstl_replace_copy_if(_Backend,
+ _Iterator __first,
+ _Iterator __last,
+ _OutIterator __result,
+ _Pred __pred,
+ const _Tp& __new_value);
+
+ template <class _ExecutionPolicy, class _Iterator, class _OutIterator>
+ optional<_Iterator> __pstl_rotate_copy(
+ _Backend, _Iterator __first, _Iterator __middle, _Iterator __last, _OutIterator __result);
template <class _ExecutionPolicy, class _Iterator, class _Comp>
- void __pstl_sort(_Backend, _Iterator __first, _Iterator __last, _Comp __comp);
+ optional<__empty> __pstl_sort(_Backend, _Iterator __first, _Iterator __last, _Comp __comp);
+
+ template <class _ExecutionPolicy, class _Iterator1, class _Iterator2, class _Comp>
+ optional<bool> __pstl_equal(_Backend, _Iterator1 first1, _Iterator1 last1, _Iterator2 first2, _Comp __comp);
// TODO: Complete this list
+Exception handling
+==================
+
+PSTL backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their
+implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are turned
+into a program termination at the front-end level. When a backend returns a disengaged `optional` to the frontend, the
+frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to the user.
*/
template <class _ExecutionPolicy>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backend.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backend.h
index e54f331b9430..6980ded189ea 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backend.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backend.h
@@ -15,10 +15,11 @@
// _Functor takes a subrange for [__first, __last) that should be executed in serial
template <class _RandomAccessIterator, class _Functor>
- void __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func);
+ optional<__empty> __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func);
template <class _Iterator, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduction>
- _Tp __parallel_transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduction);
+ optional<_Tp>
+ __parallel_transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduction);
// Cancel the execution of other jobs - they aren't needed anymore
void __cancel_execution();
@@ -28,7 +29,7 @@
class _RandomAccessIterator3,
class _Compare,
class _LeafMerge>
- void __parallel_merge(
+ optional<void> __parallel_merge(
_RandomAccessIterator1 __first1,
_RandomAccessIterator1 __last1,
_RandomAccessIterator2 __first2,
@@ -44,6 +45,14 @@
_LeafSort __leaf_sort);
TODO: Document the parallel backend
+
+Exception handling
+==================
+
+CPU backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their
+implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are turned
+into a program termination at the front-end level. When a backend returns a disengaged `optional` to the frontend, the
+frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to the user.
*/
#include <__algorithm/pstl_backends/cpu_backends/any_of.h>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h
index 8fe26797bf15..13dff80086e7 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h
@@ -16,26 +16,32 @@
#include <__atomic/memory_order.h>
#include <__config>
#include <__functional/operations.h>
-#include <__iterator/iterator_traits.h>
+#include <__iterator/concepts.h>
#include <__type_traits/is_execution_policy.h>
+#include <__utility/move.h>
#include <__utility/pair.h>
-#include <__utility/terminate_on_exception.h>
#include <cstdint>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+_LIBCPP_PUSH_MACROS
+# include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Index, class _Brick>
-_LIBCPP_HIDE_FROM_ABI bool __parallel_or(_Index __first, _Index __last, _Brick __f) {
+_LIBCPP_HIDE_FROM_ABI optional<bool> __parallel_or(_Index __first, _Index __last, _Brick __f) {
std::atomic<bool> __found(false);
- __par_backend::__parallel_for(__first, __last, [__f, &__found](_Index __i, _Index __j) {
+ auto __ret = __par_backend::__parallel_for(__first, __last, [__f, &__found](_Index __i, _Index __j) {
if (!__found.load(std::memory_order_relaxed) && __f(__i, __j)) {
__found.store(true, std::memory_order_relaxed);
__par_backend::__cancel_execution();
}
});
- return __found;
+ if (!__ret)
+ return nullopt;
+ return static_cast<bool>(__found);
}
// TODO: check whether __simd_first() can be used here
@@ -64,19 +70,19 @@ _LIBCPP_HIDE_FROM_ABI bool __simd_or(_Index __first, _DifferenceType __n, _Pred
}
template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate>
-_LIBCPP_HIDE_FROM_ABI bool
+_LIBCPP_HIDE_FROM_ABI optional<bool>
__pstl_any_of(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value) {
- return std::__terminate_on_exception([&] {
- return std::__parallel_or(
- __first, __last, [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
- return std::__pstl_any_of<__remove_parallel_policy_t<_ExecutionPolicy>>(
- __cpu_backend_tag{}, __brick_first, __brick_last, __pred);
- });
- });
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
+ return std::__parallel_or(
+ __first, __last, [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
+ auto __res = std::__pstl_any_of<__remove_parallel_policy_t<_ExecutionPolicy>>(
+ __cpu_backend_tag{}, __brick_first, __brick_last, __pred);
+ _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
+ return *std::move(__res);
+ });
} else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value) {
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
return std::__simd_or(__first, __last - __first, __pred);
} else {
return std::any_of(__first, __last, __pred);
@@ -85,6 +91,8 @@ __pstl_any_of(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __la
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h
index 5e5e0a23bf89..64babe9fd2bd 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h
@@ -12,9 +12,10 @@
#include <__algorithm/fill.h>
#include <__algorithm/pstl_backends/cpu_backends/backend.h>
#include <__config>
-#include <__iterator/iterator_traits.h>
+#include <__iterator/concepts.h>
#include <__type_traits/is_execution_policy.h>
-#include <__utility/terminate_on_exception.h>
+#include <__utility/empty.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -34,22 +35,23 @@ _LIBCPP_HIDE_FROM_ABI _Index __simd_fill_n(_Index __first, _DifferenceType __n,
}
template <class _ExecutionPolicy, class _ForwardIterator, class _Tp>
-_LIBCPP_HIDE_FROM_ABI void
+_LIBCPP_HIDE_FROM_ABI optional<__empty>
__pstl_fill(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value) {
- std::__terminate_on_exception([&] {
- __par_backend::__parallel_for(
- __first, __last, [&__value](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
- std::__pstl_fill<__remove_parallel_policy_t<_ExecutionPolicy>>(
- __cpu_backend_tag{}, __brick_first, __brick_last, __value);
- });
- });
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
+ return __par_backend::__parallel_for(
+ __first, __last, [&__value](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
+ [[maybe_unused]] auto __res = std::__pstl_fill<__remove_parallel_policy_t<_ExecutionPolicy>>(
+ __cpu_backend_tag{}, __brick_first, __brick_last, __value);
+ _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
+ });
} else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value) {
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
std::__simd_fill_n(__first, __last - __first, __value);
+ return __empty{};
} else {
std::fill(__first, __last, __value);
+ return __empty{};
}
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h
index 3fa49549e64e..170470e4fb7e 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h
@@ -14,11 +14,13 @@
#include <__atomic/atomic.h>
#include <__config>
#include <__functional/operations.h>
+#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
#include <__type_traits/is_execution_policy.h>
+#include <__utility/move.h>
#include <__utility/pair.h>
-#include <__utility/terminate_on_exception.h>
#include <cstddef>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -26,31 +28,37 @@
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+_LIBCPP_PUSH_MACROS
+# include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Index, class _Brick, class _Compare>
-_LIBCPP_HIDE_FROM_ABI _Index
+_LIBCPP_HIDE_FROM_ABI optional<_Index>
__parallel_find(_Index __first, _Index __last, _Brick __f, _Compare __comp, bool __b_first) {
typedef typename std::iterator_traits<_Index>::difference_type _DifferenceType;
const _DifferenceType __n = __last - __first;
_DifferenceType __initial_dist = __b_first ? __n : -1;
std::atomic<_DifferenceType> __extremum(__initial_dist);
// TODO: find out what is better here: parallel_for or parallel_reduce
- __par_backend::__parallel_for(__first, __last, [__comp, __f, __first, &__extremum](_Index __i, _Index __j) {
- // See "Reducing Contention Through Priority Updates", PPoPP '13, for discussion of
- // why using a shared variable scales fairly well in this situation.
- if (__comp(__i - __first, __extremum)) {
- _Index __res = __f(__i, __j);
- // If not '__last' returned then we found what we want so put this to extremum
- if (__res != __j) {
- const _DifferenceType __k = __res - __first;
- for (_DifferenceType __old = __extremum; __comp(__k, __old); __old = __extremum) {
- __extremum.compare_exchange_weak(__old, __k);
+ auto __res =
+ __par_backend::__parallel_for(__first, __last, [__comp, __f, __first, &__extremum](_Index __i, _Index __j) {
+ // See "Reducing Contention Through Priority Updates", PPoPP '13, for discussion of
+ // why using a shared variable scales fairly well in this situation.
+ if (__comp(__i - __first, __extremum)) {
+ _Index __result = __f(__i, __j);
+ // If not '__last' returned then we found what we want so put this to extremum
+ if (__result != __j) {
+ const _DifferenceType __k = __result - __first;
+ for (_DifferenceType __old = __extremum; __comp(__k, __old); __old = __extremum) {
+ __extremum.compare_exchange_weak(__old, __k);
+ }
+ }
}
- }
- }
- });
- return __extremum != __initial_dist ? __first + __extremum : __last;
+ });
+ if (!__res)
+ return nullopt;
+ return __extremum.load() != __initial_dist ? __first + __extremum.load() : __last;
}
template <class _Index, class _DifferenceType, class _Compare>
@@ -90,23 +98,23 @@ __simd_first(_Index __first, _DifferenceType __begin, _DifferenceType __end, _Co
}
template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate>
-_LIBCPP_HIDE_FROM_ABI _ForwardIterator
+_LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator>
__pstl_find_if(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value) {
- return std::__terminate_on_exception([&] {
- return std::__parallel_find(
- __first,
- __last,
- [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
- return std::__pstl_find_if<__remove_parallel_policy_t<_ExecutionPolicy>>(
- __cpu_backend_tag{}, __brick_first, __brick_last, __pred);
- },
- less<>{},
- true);
- });
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
+ return std::__parallel_find(
+ __first,
+ __last,
+ [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
+ auto __res = std::__pstl_find_if<__remove_parallel_policy_t<_ExecutionPolicy>>(
+ __cpu_backend_tag{}, __brick_first, __brick_last, __pred);
+ _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
+ return *std::move(__res);
+ },
+ less<>{},
+ true);
} else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value) {
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
using __diff_t = __iter_diff_t<_ForwardIterator>;
return std::__simd_first(__first, __diff_t(0), __last - __first, [&__pred](_ForwardIterator __iter, __diff_t __i) {
return __pred(__iter[__i]);
@@ -118,6 +126,8 @@ __pstl_find_if(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __l
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h
index 36d0ac238e24..81fd4526b8db 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h
@@ -12,9 +12,10 @@
#include <__algorithm/for_each.h>
#include <__algorithm/pstl_backends/cpu_backends/backend.h>
#include <__config>
-#include <__iterator/iterator_traits.h>
+#include <__iterator/concepts.h>
#include <__type_traits/is_execution_policy.h>
-#include <__utility/terminate_on_exception.h>
+#include <__utility/empty.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -25,7 +26,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Iterator, class _DifferenceType, class _Function>
-_LIBCPP_HIDE_FROM_ABI _Iterator __simd_walk_1(_Iterator __first, _DifferenceType __n, _Function __f) noexcept {
+_LIBCPP_HIDE_FROM_ABI _Iterator __simd_walk(_Iterator __first, _DifferenceType __n, _Function __f) noexcept {
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
__f(__first[__i]);
@@ -34,22 +35,23 @@ _LIBCPP_HIDE_FROM_ABI _Iterator __simd_walk_1(_Iterator __first, _DifferenceType
}
template <class _ExecutionPolicy, class _ForwardIterator, class _Functor>
-_LIBCPP_HIDE_FROM_ABI void
+_LIBCPP_HIDE_FROM_ABI optional<__empty>
__pstl_for_each(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Functor __func) {
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value) {
- std::__terminate_on_exception([&] {
- std::__par_backend::__parallel_for(
- __first, __last, [__func](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
- std::__pstl_for_each<__remove_parallel_policy_t<_ExecutionPolicy>>(
- __cpu_backend_tag{}, __brick_first, __brick_last, __func);
- });
- });
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
+ return std::__par_backend::__parallel_for(
+ __first, __last, [__func](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
+ [[maybe_unused]] auto __res = std::__pstl_for_each<__remove_parallel_policy_t<_ExecutionPolicy>>(
+ __cpu_backend_tag{}, __brick_first, __brick_last, __func);
+ _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
+ });
} else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value) {
- std::__simd_walk_1(__first, __last - __first, __func);
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
+ std::__simd_walk(__first, __last - __first, __func);
+ return __empty{};
} else {
std::for_each(__first, __last, __func);
+ return __empty{};
}
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h
index bab6a3639bd0..e885e7f22517 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h
@@ -9,8 +9,10 @@
#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_LIBDISPATCH_H
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_LIBDISPATCH_H
+#include <__algorithm/inplace_merge.h>
#include <__algorithm/lower_bound.h>
#include <__algorithm/max.h>
+#include <__algorithm/merge.h>
#include <__algorithm/upper_bound.h>
#include <__atomic/atomic.h>
#include <__config>
@@ -21,12 +23,13 @@
#include <__memory/construct_at.h>
#include <__memory/unique_ptr.h>
#include <__numeric/reduce.h>
+#include <__utility/empty.h>
#include <__utility/exception_guard.h>
#include <__utility/move.h>
#include <__utility/pair.h>
-#include <__utility/terminate_on_exception.h>
#include <cstddef>
#include <new>
+#include <optional>
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
@@ -57,13 +60,11 @@ struct __chunk_partitions {
ptrdiff_t __first_chunk_size_;
};
-[[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI __chunk_partitions __partition_chunks(ptrdiff_t __size);
+[[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI __chunk_partitions __partition_chunks(ptrdiff_t __size) noexcept;
template <class _RandomAccessIterator, class _Functor>
-_LIBCPP_HIDE_FROM_ABI void
-__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) {
- auto __partitions = __libdispatch::__partition_chunks(__last - __first);
-
+_LIBCPP_HIDE_FROM_ABI optional<__empty>
+__dispatch_parallel_for(__chunk_partitions __partitions, _RandomAccessIterator __first, _Functor __func) {
// Perform the chunked execution.
__libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) {
auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_;
@@ -73,6 +74,15 @@ __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fun
: (__chunk * __partitions.__chunk_size_) + (__partitions.__first_chunk_size_ - __partitions.__chunk_size_);
__func(__first + __index, __first + __index + __this_chunk_size);
});
+
+ return __empty{};
+}
+
+template <class _RandomAccessIterator, class _Functor>
+_LIBCPP_HIDE_FROM_ABI optional<__empty>
+__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) {
+ return __libdispatch::__dispatch_parallel_for(
+ __libdispatch::__partition_chunks(__last - __first), std::move(__first), std::move(__func));
}
template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _RandomAccessIteratorOut>
@@ -90,23 +100,23 @@ template <typename _RandomAccessIterator1,
typename _RandomAccessIterator3,
typename _Compare,
typename _LeafMerge>
-_LIBCPP_HIDE_FROM_ABI void __parallel_merge(
+_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge(
_RandomAccessIterator1 __first1,
_RandomAccessIterator1 __last1,
_RandomAccessIterator2 __first2,
_RandomAccessIterator2 __last2,
_RandomAccessIterator3 __result,
_Compare __comp,
- _LeafMerge __leaf_merge) {
+ _LeafMerge __leaf_merge) noexcept {
__chunk_partitions __partitions =
__libdispatch::__partition_chunks(std::max<ptrdiff_t>(__last1 - __first1, __last2 - __first2));
if (__partitions.__chunk_count_ == 0)
- return;
+ return __empty{};
if (__partitions.__chunk_count_ == 1) {
__leaf_merge(__first1, __last1, __first2, __last2, __result, __comp);
- return;
+ return __empty{};
}
using __merge_range_t = __merge_range<_RandomAccessIterator1, _RandomAccessIterator2, _RandomAccessIterator3>;
@@ -117,61 +127,76 @@ _LIBCPP_HIDE_FROM_ABI void __parallel_merge(
std::destroy_n(__ptr, __n_ranges);
std::allocator<__merge_range_t>().deallocate(__ptr, __n_ranges);
};
- unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges(
- std::allocator<__merge_range_t>().allocate(__n_ranges), __destroy);
- // TODO: Improve the case where the smaller range is merged into just a few (or even one) chunks of the larger case
- std::__terminate_on_exception([&] {
- __merge_range_t* __r = __ranges.get();
- std::__construct_at(__r++, __first1, __first2, __result);
-
- bool __iterate_first_range = __last1 - __first1 > __last2 - __first2;
-
- auto __compute_chunk = [&](size_t __chunk_size) -> __merge_range_t {
- auto [__mid1, __mid2] = [&] {
- if (__iterate_first_range) {
- auto __m1 = __first1 + __chunk_size;
- auto __m2 = std::lower_bound(__first2, __last2, __m1[-1], __comp);
- return std::make_pair(__m1, __m2);
- } else {
- auto __m2 = __first2 + __chunk_size;
- auto __m1 = std::lower_bound(__first1, __last1, __m2[-1], __comp);
- return std::make_pair(__m1, __m2);
+ unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges(
+ [&]() -> __merge_range_t* {
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+ try {
+# endif
+ return std::allocator<__merge_range_t>().allocate(__n_ranges);
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+ } catch (const std::bad_alloc&) {
+ return nullptr;
}
- }();
+# endif
+ }(),
+ __destroy);
- __result += (__mid1 - __first1) + (__mid2 - __first2);
- __first1 = __mid1;
- __first2 = __mid2;
- return {std::move(__mid1), std::move(__mid2), __result};
- };
+ if (!__ranges)
+ return nullopt;
+
+ // TODO: Improve the case where the smaller range is merged into just a few (or even one) chunks of the larger case
+ __merge_range_t* __r = __ranges.get();
+ std::__construct_at(__r++, __first1, __first2, __result);
+
+ bool __iterate_first_range = __last1 - __first1 > __last2 - __first2;
+
+ auto __compute_chunk = [&](size_t __chunk_size) -> __merge_range_t {
+ auto [__mid1, __mid2] = [&] {
+ if (__iterate_first_range) {
+ auto __m1 = __first1 + __chunk_size;
+ auto __m2 = std::lower_bound(__first2, __last2, __m1[-1], __comp);
+ return std::make_pair(__m1, __m2);
+ } else {
+ auto __m2 = __first2 + __chunk_size;
+ auto __m1 = std::lower_bound(__first1, __last1, __m2[-1], __comp);
+ return std::make_pair(__m1, __m2);
+ }
+ }();
+
+ __result += (__mid1 - __first1) + (__mid2 - __first2);
+ __first1 = __mid1;
+ __first2 = __mid2;
+ return {std::move(__mid1), std::move(__mid2), __result};
+ };
- // handle first chunk
- std::__construct_at(__r++, __compute_chunk(__partitions.__first_chunk_size_));
-
- // handle 2 -> N - 1 chunks
- for (ptrdiff_t __i = 0; __i != __partitions.__chunk_count_ - 2; ++__i)
- std::__construct_at(__r++, __compute_chunk(__partitions.__chunk_size_));
-
- // handle last chunk
- std::__construct_at(__r, __last1, __last2, __result);
-
- __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __index) {
- auto __first_iters = __ranges[__index];
- auto __last_iters = __ranges[__index + 1];
- __leaf_merge(
- __first_iters.__mid1_,
- __last_iters.__mid1_,
- __first_iters.__mid2_,
- __last_iters.__mid2_,
- __first_iters.__result_,
- __comp);
- });
+ // handle first chunk
+ std::__construct_at(__r++, __compute_chunk(__partitions.__first_chunk_size_));
+
+ // handle 2 -> N - 1 chunks
+ for (ptrdiff_t __i = 0; __i != __partitions.__chunk_count_ - 2; ++__i)
+ std::__construct_at(__r++, __compute_chunk(__partitions.__chunk_size_));
+
+ // handle last chunk
+ std::__construct_at(__r, __last1, __last2, __result);
+
+ __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __index) {
+ auto __first_iters = __ranges[__index];
+ auto __last_iters = __ranges[__index + 1];
+ __leaf_merge(
+ __first_iters.__mid1_,
+ __last_iters.__mid1_,
+ __first_iters.__mid2_,
+ __last_iters.__mid2_,
+ __first_iters.__result_,
+ __comp);
});
+
+ return __empty{};
}
template <class _RandomAccessIterator, class _Transform, class _Value, class _Combiner, class _Reduction>
-_LIBCPP_HIDE_FROM_ABI _Value __parallel_transform_reduce(
+_LIBCPP_HIDE_FROM_ABI optional<_Value> __parallel_transform_reduce(
_RandomAccessIterator __first,
_RandomAccessIterator __last,
_Transform __transform,
@@ -211,20 +236,101 @@ _LIBCPP_HIDE_FROM_ABI _Value __parallel_transform_reduce(
}
});
- return std::__terminate_on_exception([&] {
- return std::reduce(
- std::make_move_iterator(__values.get()),
- std::make_move_iterator(__values.get() + __partitions.__chunk_count_),
- std::move(__init),
- __combiner);
- });
+ return std::reduce(
+ std::make_move_iterator(__values.get()),
+ std::make_move_iterator(__values.get() + __partitions.__chunk_count_),
+ std::move(__init),
+ __combiner);
}
-// TODO: parallelize this
template <class _RandomAccessIterator, class _Comp, class _LeafSort>
-_LIBCPP_HIDE_FROM_ABI void __parallel_stable_sort(
+_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort(
_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp, _LeafSort __leaf_sort) {
- __leaf_sort(__first, __last, __comp);
+ const auto __size = __last - __first;
+ auto __partitions = __libdispatch::__partition_chunks(__size);
+
+ if (__partitions.__chunk_count_ == 0)
+ return __empty{};
+
+ if (__partitions.__chunk_count_ == 1) {
+ __leaf_sort(__first, __last, __comp);
+ return __empty{};
+ }
+
+ using _Value = __iter_value_type<_RandomAccessIterator>;
+
+ auto __destroy = [__size](_Value* __ptr) {
+ std::destroy_n(__ptr, __size);
+ std::allocator<_Value>().deallocate(__ptr, __size);
+ };
+
+ // TODO: use __uninitialized_buffer
+ unique_ptr<_Value[], decltype(__destroy)> __values(std::allocator<_Value>().allocate(__size), __destroy);
+
+ // Initialize all elements to a moved-from state
+ // TODO: Don't do this - this can be done in the first merge - see https://llvm.org/PR63928
+ std::__construct_at(__values.get(), std::move(*__first));
+ for (__iter_diff_t<_RandomAccessIterator> __i = 1; __i != __size; ++__i) {
+ std::__construct_at(__values.get() + __i, std::move(__values.get()[__i - 1]));
+ }
+ *__first = std::move(__values.get()[__size - 1]);
+
+ __libdispatch::__dispatch_parallel_for(
+ __partitions,
+ __first,
+ [&__leaf_sort, &__comp](_RandomAccessIterator __chunk_first, _RandomAccessIterator __chunk_last) {
+ __leaf_sort(std::move(__chunk_first), std::move(__chunk_last), __comp);
+ });
+
+ bool __objects_are_in_buffer = false;
+ do {
+ const auto __old_chunk_size = __partitions.__chunk_size_;
+ if (__partitions.__chunk_count_ % 2 == 1) {
+ auto __inplace_merge_chunks = [&__comp, &__partitions](auto __first_chunk_begin) {
+ std::inplace_merge(
+ __first_chunk_begin,
+ __first_chunk_begin + __partitions.__first_chunk_size_,
+ __first_chunk_begin + __partitions.__first_chunk_size_ + __partitions.__chunk_size_,
+ __comp);
+ };
+ if (__objects_are_in_buffer)
+ __inplace_merge_chunks(__values.get());
+ else
+ __inplace_merge_chunks(__first);
+ __partitions.__first_chunk_size_ += 2 * __partitions.__chunk_size_;
+ } else {
+ __partitions.__first_chunk_size_ += __partitions.__chunk_size_;
+ }
+
+ __partitions.__chunk_size_ *= 2;
+ __partitions.__chunk_count_ /= 2;
+
+ auto __merge_chunks = [__partitions, __old_chunk_size, &__comp](auto __from_first, auto __to_first) {
+ __libdispatch::__dispatch_parallel_for(
+ __partitions,
+ __from_first,
+ [__old_chunk_size, &__from_first, &__to_first, &__comp](auto __chunk_first, auto __chunk_last) {
+ std::merge(std::make_move_iterator(__chunk_first),
+ std::make_move_iterator(__chunk_last - __old_chunk_size),
+ std::make_move_iterator(__chunk_last - __old_chunk_size),
+ std::make_move_iterator(__chunk_last),
+ __to_first + (__chunk_first - __from_first),
+ __comp);
+ });
+ };
+
+ if (__objects_are_in_buffer)
+ __merge_chunks(__values.get(), __first);
+ else
+ __merge_chunks(__first, __values.get());
+ __objects_are_in_buffer = !__objects_are_in_buffer;
+ } while (__partitions.__chunk_count_ > 1);
+
+ if (__objects_are_in_buffer) {
+ std::move(__values.get(), __values.get() + __size, __first);
+ }
+
+ return __empty{};
}
_LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h
index d5be1e302d35..b0db70f58b2e 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h
@@ -12,10 +12,10 @@
#include <__algorithm/merge.h>
#include <__algorithm/pstl_backends/cpu_backends/backend.h>
#include <__config>
-#include <__iterator/iterator_traits.h>
+#include <__iterator/concepts.h>
#include <__type_traits/is_execution_policy.h>
#include <__utility/move.h>
-#include <__utility/terminate_on_exception.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -23,6 +23,9 @@
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+_LIBCPP_PUSH_MACROS
+# include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ExecutionPolicy,
@@ -30,7 +33,7 @@ template <class _ExecutionPolicy,
class _ForwardIterator2,
class _ForwardOutIterator,
class _Comp>
-_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_merge(
+_LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_merge(
__cpu_backend_tag,
_ForwardIterator1 __first1,
_ForwardIterator1 __last1,
@@ -39,34 +42,35 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_merge(
_ForwardOutIterator __result,
_Comp __comp) {
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator1>::value &&
- __has_random_access_iterator_category<_ForwardIterator2>::value &&
- __has_random_access_iterator_category<_ForwardOutIterator>::value) {
- return std::__terminate_on_exception([&] {
- __par_backend::__parallel_merge(
- __first1,
- __last1,
- __first2,
- __last2,
- __result,
- __comp,
- [](_ForwardIterator1 __g_first1,
- _ForwardIterator1 __g_last1,
- _ForwardIterator2 __g_first2,
- _ForwardIterator2 __g_last2,
- _ForwardOutIterator __g_result,
- _Comp __g_comp) {
- return std::__pstl_merge<__remove_parallel_policy_t<_ExecutionPolicy>>(
- __cpu_backend_tag{},
- std::move(__g_first1),
- std::move(__g_last1),
- std::move(__g_first2),
- std::move(__g_last2),
- std::move(__g_result),
- std::move(__g_comp));
- });
- return __result + (__last1 - __first1) + (__last2 - __first2);
- });
+ __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
+ __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
+ __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
+ auto __res = __par_backend::__parallel_merge(
+ __first1,
+ __last1,
+ __first2,
+ __last2,
+ __result,
+ __comp,
+ [](_ForwardIterator1 __g_first1,
+ _ForwardIterator1 __g_last1,
+ _ForwardIterator2 __g_first2,
+ _ForwardIterator2 __g_last2,
+ _ForwardOutIterator __g_result,
+ _Comp __g_comp) {
+ [[maybe_unused]] auto __g_res = std::__pstl_merge<__remove_parallel_policy_t<_ExecutionPolicy>>(
+ __cpu_backend_tag{},
+ std::move(__g_first1),
+ std::move(__g_last1),
+ std::move(__g_first2),
+ std::move(__g_last2),
+ std::move(__g_result),
+ std::move(__g_comp));
+ _LIBCPP_ASSERT_INTERNAL(__g_res, "unsed/sed should never try to allocate!");
+ });
+ if (!__res)
+ return nullopt;
+ return __result + (__last1 - __first1) + (__last2 - __first2);
} else {
return std::merge(__first1, __last1, __first2, __last2, __result, __comp);
}
@@ -74,6 +78,8 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_merge(
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h
index f151c3b098f6..afcc7ffb2661 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h
@@ -11,8 +11,10 @@
#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H
#include <__config>
+#include <__utility/empty.h>
#include <__utility/move.h>
#include <cstddef>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -20,26 +22,32 @@
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+_LIBCPP_PUSH_MACROS
+# include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
namespace __par_backend {
inline namespace __serial_cpu_backend {
template <class _RandomAccessIterator, class _Fp>
-_LIBCPP_HIDE_FROM_ABI void __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
+_LIBCPP_HIDE_FROM_ABI optional<__empty>
+__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
__f(__first, __last);
+ return __empty{};
}
template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce>
-_LIBCPP_HIDE_FROM_ABI _Tp
+_LIBCPP_HIDE_FROM_ABI optional<_Tp>
__parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) {
return __reduce(std::move(__first), std::move(__last), std::move(__init));
}
template <class _RandomAccessIterator, class _Compare, class _LeafSort>
-_LIBCPP_HIDE_FROM_ABI void __parallel_stable_sort(
+_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort(
_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) {
__leaf_sort(__first, __last, __comp);
+ return __empty{};
}
_LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {}
@@ -49,7 +57,7 @@ template <class _RandomAccessIterator1,
class _RandomAccessIterator3,
class _Compare,
class _LeafMerge>
-_LIBCPP_HIDE_FROM_ABI void __parallel_merge(
+_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge(
_RandomAccessIterator1 __first1,
_RandomAccessIterator1 __last1,
_RandomAccessIterator2 __first2,
@@ -58,6 +66,7 @@ _LIBCPP_HIDE_FROM_ABI void __parallel_merge(
_Compare __comp,
_LeafMerge __leaf_merge) {
__leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp);
+ return __empty{};
}
// TODO: Complete this list
@@ -67,6 +76,8 @@ _LIBCPP_HIDE_FROM_ABI void __parallel_merge(
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h
index 0a701443b3c4..34c423586c4b 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h
@@ -13,7 +13,8 @@
#include <__algorithm/stable_sort.h>
#include <__config>
#include <__type_traits/is_execution_policy.h>
-#include <__utility/terminate_on_exception.h>
+#include <__utility/empty.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -24,17 +25,16 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp>
-_LIBCPP_HIDE_FROM_ABI void
+_LIBCPP_HIDE_FROM_ABI optional<__empty>
__pstl_stable_sort(__cpu_backend_tag, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy>) {
- std::__terminate_on_exception([&] {
- __par_backend::__parallel_stable_sort(
- __first, __last, __comp, [](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) {
- std::stable_sort(__g_first, __g_last, __g_comp);
- });
- });
+ return __par_backend::__parallel_stable_sort(
+ __first, __last, __comp, [](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) {
+ std::stable_sort(__g_first, __g_last, __g_comp);
+ });
} else {
std::stable_sort(__first, __last, __comp);
+ return __empty{};
}
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h
index 30eb0ae3626d..eb11a961b760 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h
@@ -11,8 +11,10 @@
#include <__assert>
#include <__config>
+#include <__utility/empty.h>
#include <__utility/move.h>
#include <cstddef>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -32,20 +34,23 @@ namespace __par_backend {
inline namespace __thread_cpu_backend {
template <class _RandomAccessIterator, class _Fp>
-_LIBCPP_HIDE_FROM_ABI void __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
+_LIBCPP_HIDE_FROM_ABI optional<__empty>
+__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
__f(__first, __last);
+ return __empty{};
}
template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce>
-_LIBCPP_HIDE_FROM_ABI _Tp
+_LIBCPP_HIDE_FROM_ABI optional<_Tp>
__parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) {
return __reduce(std::move(__first), std::move(__last), std::move(__init));
}
template <class _RandomAccessIterator, class _Compare, class _LeafSort>
-_LIBCPP_HIDE_FROM_ABI void __parallel_stable_sort(
+_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort(
_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) {
__leaf_sort(__first, __last, __comp);
+ return __empty{};
}
_LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {}
@@ -55,7 +60,7 @@ template <class _RandomAccessIterator1,
class _RandomAccessIterator3,
class _Compare,
class _LeafMerge>
-_LIBCPP_HIDE_FROM_ABI void __parallel_merge(
+_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge(
_RandomAccessIterator1 __first1,
_RandomAccessIterator1 __last1,
_RandomAccessIterator2 __first2,
@@ -64,6 +69,7 @@ _LIBCPP_HIDE_FROM_ABI void __parallel_merge(
_Compare __comp,
_LeafMerge __leaf_merge) {
__leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp);
+ return __empty{};
}
} // namespace __thread_cpu_backend
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h
index ef25ff0238da..fdf1a2e78dad 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h
@@ -12,11 +12,12 @@
#include <__algorithm/pstl_backends/cpu_backends/backend.h>
#include <__algorithm/transform.h>
#include <__config>
+#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
-#include <__utility/terminate_on_exception.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -24,11 +25,14 @@
#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+_LIBCPP_PUSH_MACROS
+# include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Function>
_LIBCPP_HIDE_FROM_ABI _Iterator2
-__simd_walk_2(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Function __f) noexcept {
+__simd_walk(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Function __f) noexcept {
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
__f(__first1[__i], __first2[__i]);
@@ -36,27 +40,27 @@ __simd_walk_2(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Fu
}
template <class _ExecutionPolicy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation>
-_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform(
+_LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_transform(
__cpu_backend_tag,
_ForwardIterator __first,
_ForwardIterator __last,
_ForwardOutIterator __result,
_UnaryOperation __op) {
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value &&
- __has_random_access_iterator_category<_ForwardOutIterator>::value) {
- std::__terminate_on_exception([&] {
- std::__par_backend::__parallel_for(
- __first, __last, [__op, __first, __result](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
- return std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>(
- __cpu_backend_tag{}, __brick_first, __brick_last, __result + (__brick_first - __first), __op);
- });
- });
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value &&
+ __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
+ std::__par_backend::__parallel_for(
+ __first, __last, [__op, __first, __result](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
+ auto __res = std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>(
+ __cpu_backend_tag{}, __brick_first, __brick_last, __result + (__brick_first - __first), __op);
+ _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
+ return *std::move(__res);
+ });
return __result + (__last - __first);
} else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value &&
- __has_random_access_iterator_category<_ForwardOutIterator>::value) {
- return std::__simd_walk_2(
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value &&
+ __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
+ return std::__simd_walk(
__first,
__last - __first,
__result,
@@ -69,7 +73,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform(
}
template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Iterator3, class _Function>
-_LIBCPP_HIDE_FROM_ABI _Iterator3 __simd_walk_3(
+_LIBCPP_HIDE_FROM_ABI _Iterator3 __simd_walk(
_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Iterator3 __first3, _Function __f) noexcept {
_PSTL_PRAGMA_SIMD
for (_DifferenceType __i = 0; __i < __n; ++__i)
@@ -82,7 +86,7 @@ template <class _ExecutionPolicy,
class _ForwardOutIterator,
class _BinaryOperation,
enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform(
+_LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_transform(
__cpu_backend_tag,
_ForwardIterator1 __first1,
_ForwardIterator1 __last1,
@@ -90,29 +94,29 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform(
_ForwardOutIterator __result,
_BinaryOperation __op) {
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator1>::value &&
- __has_random_access_iterator_category<_ForwardIterator2>::value &&
- __has_random_access_iterator_category<_ForwardOutIterator>::value) {
- std::__terminate_on_exception([&] {
- std::__par_backend::__parallel_for(
- __first1,
- __last1,
- [__op, __first1, __first2, __result](_ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last) {
- return std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>(
- __cpu_backend_tag{},
- __brick_first,
- __brick_last,
- __first2 + (__brick_first - __first1),
- __result + (__brick_first - __first1),
- __op);
- });
- });
+ __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
+ __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
+ __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
+ auto __res = std::__par_backend::__parallel_for(
+ __first1,
+ __last1,
+ [__op, __first1, __first2, __result](_ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last) {
+ return std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>(
+ __cpu_backend_tag{},
+ __brick_first,
+ __brick_last,
+ __first2 + (__brick_first - __first1),
+ __result + (__brick_first - __first1),
+ __op);
+ });
+ if (!__res)
+ return nullopt;
return __result + (__last1 - __first1);
} else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator1>::value &&
- __has_random_access_iterator_category<_ForwardIterator2>::value &&
- __has_random_access_iterator_category<_ForwardOutIterator>::value) {
- return std::__simd_walk_3(
+ __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
+ __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
+ __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
+ return std::__simd_walk(
__first1,
__last1 - __first1,
__first2,
@@ -127,6 +131,8 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform(
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h
index c51c312d938a..ab2e3172b8b6 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h
@@ -11,14 +11,15 @@
#include <__algorithm/pstl_backends/cpu_backends/backend.h>
#include <__config>
+#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
#include <__numeric/transform_reduce.h>
#include <__type_traits/is_arithmetic.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/operation_traits.h>
#include <__utility/move.h>
-#include <__utility/terminate_on_exception.h>
#include <new>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -28,12 +29,14 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <
- typename _DifferenceType,
- typename _Tp,
- typename _BinaryOperation,
- typename _UnaryOperation,
- __enable_if_t<__is_trivial_plus_operation<_BinaryOperation, _Tp, _Tp>::value && is_arithmetic_v<_Tp>, int> = 0>
+template <typename _DifferenceType,
+ typename _Tp,
+ typename _BinaryOperation,
+ typename _UnaryOperation,
+ typename _UnaryResult = invoke_result_t<_UnaryOperation, _DifferenceType>,
+ __enable_if_t<__desugars_to<__plus_tag, _BinaryOperation, _Tp, _UnaryResult>::value && is_arithmetic_v<_Tp> &&
+ is_arithmetic_v<_UnaryResult>,
+ int> = 0>
_LIBCPP_HIDE_FROM_ABI _Tp
__simd_transform_reduce(_DifferenceType __n, _Tp __init, _BinaryOperation, _UnaryOperation __f) noexcept {
_PSTL_PRAGMA_SIMD_REDUCTION(+ : __init)
@@ -42,12 +45,14 @@ __simd_transform_reduce(_DifferenceType __n, _Tp __init, _BinaryOperation, _Unar
return __init;
}
-template <
- typename _Size,
- typename _Tp,
- typename _BinaryOperation,
- typename _UnaryOperation,
- __enable_if_t<!(__is_trivial_plus_operation<_BinaryOperation, _Tp, _Tp>::value && is_arithmetic_v<_Tp>), int> = 0>
+template <typename _Size,
+ typename _Tp,
+ typename _BinaryOperation,
+ typename _UnaryOperation,
+ typename _UnaryResult = invoke_result_t<_UnaryOperation, _Size>,
+ __enable_if_t<!(__desugars_to<__plus_tag, _BinaryOperation, _Tp, _UnaryResult>::value &&
+ is_arithmetic_v<_Tp> && is_arithmetic_v<_UnaryResult>),
+ int> = 0>
_LIBCPP_HIDE_FROM_ABI _Tp
__simd_transform_reduce(_Size __n, _Tp __init, _BinaryOperation __binary_op, _UnaryOperation __f) noexcept {
const _Size __block_size = __lane_size / sizeof(_Tp);
@@ -97,7 +102,7 @@ template <class _ExecutionPolicy,
class _Tp,
class _BinaryOperation1,
class _BinaryOperation2>
-_LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce(
+_LIBCPP_HIDE_FROM_ABI optional<_Tp> __pstl_transform_reduce(
__cpu_backend_tag,
_ForwardIterator1 __first1,
_ForwardIterator1 __last1,
@@ -106,32 +111,30 @@ _LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce(
_BinaryOperation1 __reduce,
_BinaryOperation2 __transform) {
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator1>::value &&
- __has_random_access_iterator_category<_ForwardIterator2>::value) {
- return std::__terminate_on_exception([&] {
- return __par_backend::__parallel_transform_reduce(
- __first1,
- std::move(__last1),
- [__first1, __first2, __transform](_ForwardIterator1 __iter) {
- return __transform(*__iter, *(__first2 + (__iter - __first1)));
- },
- std::move(__init),
- std::move(__reduce),
- [__first1, __first2, __reduce, __transform](
- _ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last, _Tp __brick_init) {
- return std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>(
- __cpu_backend_tag{},
- __brick_first,
- std::move(__brick_last),
- __first2 + (__brick_first - __first1),
- std::move(__brick_init),
- std::move(__reduce),
- std::move(__transform));
- });
- });
+ __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
+ __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) {
+ return __par_backend::__parallel_transform_reduce(
+ __first1,
+ std::move(__last1),
+ [__first1, __first2, __transform](_ForwardIterator1 __iter) {
+ return __transform(*__iter, *(__first2 + (__iter - __first1)));
+ },
+ std::move(__init),
+ std::move(__reduce),
+ [__first1, __first2, __reduce, __transform](
+ _ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last, _Tp __brick_init) {
+ return *std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>(
+ __cpu_backend_tag{},
+ __brick_first,
+ std::move(__brick_last),
+ __first2 + (__brick_first - __first1),
+ std::move(__brick_init),
+ std::move(__reduce),
+ std::move(__transform));
+ });
} else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator1>::value &&
- __has_random_access_iterator_category<_ForwardIterator2>::value) {
+ __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
+ __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) {
return std::__simd_transform_reduce(
__last1 - __first1, std::move(__init), std::move(__reduce), [&](__iter_diff_t<_ForwardIterator1> __i) {
return __transform(__first1[__i], __first2[__i]);
@@ -148,7 +151,7 @@ _LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce(
}
template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation>
-_LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce(
+_LIBCPP_HIDE_FROM_ABI optional<_Tp> __pstl_transform_reduce(
__cpu_backend_tag,
_ForwardIterator __first,
_ForwardIterator __last,
@@ -156,26 +159,26 @@ _LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce(
_BinaryOperation __reduce,
_UnaryOperation __transform) {
if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value) {
- return std::__terminate_on_exception([&] {
- return __par_backend::__parallel_transform_reduce(
- std::move(__first),
- std::move(__last),
- [__transform](_ForwardIterator __iter) { return __transform(*__iter); },
- std::move(__init),
- __reduce,
- [__transform, __reduce](auto __brick_first, auto __brick_last, _Tp __brick_init) {
- return std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>(
- __cpu_backend_tag{},
- std::move(__brick_first),
- std::move(__brick_last),
- std::move(__brick_init),
- std::move(__reduce),
- std::move(__transform));
- });
- });
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
+ return __par_backend::__parallel_transform_reduce(
+ std::move(__first),
+ std::move(__last),
+ [__transform](_ForwardIterator __iter) { return __transform(*__iter); },
+ std::move(__init),
+ __reduce,
+ [__transform, __reduce](auto __brick_first, auto __brick_last, _Tp __brick_init) {
+ auto __res = std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>(
+ __cpu_backend_tag{},
+ std::move(__brick_first),
+ std::move(__brick_last),
+ std::move(__brick_init),
+ std::move(__reduce),
+ std::move(__transform));
+ _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
+ return *std::move(__res);
+ });
} else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
- __has_random_access_iterator_category<_ForwardIterator>::value) {
+ __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
return std::__simd_transform_reduce(
__last - __first,
std::move(__init),
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_copy.h
index 83c712c35407..19f275a0d5d9 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_copy.h
@@ -10,15 +10,19 @@
#define _LIBCPP___ALGORITHM_PSTL_COPY_H
#include <__algorithm/copy_n.h>
+#include <__algorithm/pstl_backend.h>
+#include <__algorithm/pstl_frontend_dispatch.h>
#include <__algorithm/pstl_transform.h>
#include <__config>
#include <__functional/identity.h>
-#include <__iterator/iterator_traits.h>
+#include <__iterator/concepts.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_constant_evaluated.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/is_trivially_copyable.h>
#include <__type_traits/remove_cvref.h>
+#include <__utility/move.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -30,26 +34,79 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// TODO: Use the std::copy/move shenanigans to forward to std::memmove
+template <class>
+void __pstl_copy();
+
template <class _ExecutionPolicy,
class _ForwardIterator,
class _ForwardOutIterator,
- enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
+__copy(_ExecutionPolicy&& __policy,
+ _ForwardIterator&& __first,
+ _ForwardIterator&& __last,
+ _ForwardOutIterator&& __result) noexcept {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_copy, _RawPolicy),
+ [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result) {
+ return std::__transform(__policy, __g_first, __g_last, __g_result, __identity());
+ },
+ std::move(__first),
+ std::move(__last),
+ std::move(__result));
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _ForwardOutIterator,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
copy(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) {
- return std::transform(__policy, __first, __last, __result, __identity());
+ auto __res = std::__copy(__policy, std::move(__first), std::move(__last), std::move(__result));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
+}
+
+template <class>
+void __pstl_copy_n();
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _ForwardOutIterator,
+ class _Size,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __copy_n(
+ _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __n, _ForwardOutIterator&& __result) noexcept {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_copy_n, _RawPolicy),
+ [&__policy](
+ _ForwardIterator __g_first, _Size __g_n, _ForwardOutIterator __g_result) -> optional<_ForwardIterator> {
+ if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value)
+ return std::__copy(__policy, std::move(__g_first), std::move(__g_first + __g_n), std::move(__g_result));
+ else
+ return std::copy_n(__g_first, __g_n, __g_result);
+ },
+ std::move(__first),
+ std::move(__n),
+ std::move(__result));
}
template <class _ExecutionPolicy,
class _ForwardIterator,
class _ForwardOutIterator,
class _Size,
- enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
copy_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _ForwardOutIterator __result) {
- if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value)
- return std::copy(__policy, __first, __first + __n, __result);
- else
- return std::copy_n(__first, __n, __result);
+ auto __res = std::__copy_n(__policy, std::move(__first), std::move(__n), std::move(__result));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_count.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_count.h
index 15acb85de0bf..28806fca0637 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_count.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_count.h
@@ -23,7 +23,7 @@
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
#include <__utility/move.h>
-#include <__utility/terminate_on_exception.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -41,13 +41,13 @@ template <class _ExecutionPolicy,
class _Predicate,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator>
-count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>> __count_if(
+ _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept {
using __diff_t = __iter_diff_t<_ForwardIterator>;
return std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count_if),
- [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) {
- return std::transform_reduce(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count_if, _RawPolicy),
+ [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) -> optional<__diff_t> {
+ return std::__transform_reduce(
__policy,
std::move(__g_first),
std::move(__g_last),
@@ -60,6 +60,19 @@ count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator
std::move(__pred));
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Predicate,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator>
+count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
+ auto __res = std::__count_if(__policy, std::move(__first), std::move(__last), std::move(__pred));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
+}
+
template <class>
void __pstl_count(); // declaration needed for the frontend dispatch below
@@ -68,11 +81,12 @@ template <class _ExecutionPolicy,
class _Tp,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator>
-count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>>
+__count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
return std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count),
- [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) {
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count, _RawPolicy),
+ [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value)
+ -> optional<__iter_diff_t<_ForwardIterator>> {
return std::count_if(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __v) {
return __v == __g_value;
});
@@ -82,6 +96,19 @@ count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __
__value);
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Tp,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator>
+count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
+ auto __res = std::__count(__policy, std::move(__first), std::move(__last), __value);
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *__res;
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_equal.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_equal.h
new file mode 100644
index 000000000000..b343d2675980
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_equal.h
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_PSTL_EQUAL_H
+#define _LIBCPP___ALGORITHM_PSTL_EQUAL_H
+
+#include <__algorithm/equal.h>
+#include <__algorithm/pstl_frontend_dispatch.h>
+#include <__config>
+#include <__functional/operations.h>
+#include <__iterator/iterator_traits.h>
+#include <__numeric/pstl_transform_reduce.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class>
+void __pstl_equal();
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator1,
+ class _ForwardIterator2,
+ class _Pred,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
+__equal(_ExecutionPolicy&& __policy,
+ _ForwardIterator1&& __first1,
+ _ForwardIterator1&& __last1,
+ _ForwardIterator2&& __first2,
+ _Pred&& __pred) noexcept {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_equal, _RawPolicy),
+ [&__policy](
+ _ForwardIterator1 __g_first1, _ForwardIterator1 __g_last1, _ForwardIterator2 __g_first2, _Pred __g_pred) {
+ return std::__transform_reduce(
+ __policy,
+ std::move(__g_first1),
+ std::move(__g_last1),
+ std::move(__g_first2),
+ true,
+ std::logical_and{},
+ std::move(__g_pred));
+ },
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__pred));
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator1,
+ class _ForwardIterator2,
+ class _Pred,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI bool
+equal(_ExecutionPolicy&& __policy,
+ _ForwardIterator1 __first1,
+ _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2,
+ _Pred __pred) {
+ auto __res = std::__equal(__policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__pred));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *__res;
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator1,
+ class _ForwardIterator2,
+ enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI bool
+equal(_ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
+ return std::equal(__policy, std::move(__first1), std::move(__last1), std::move(__first2), std::equal_to{});
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator1,
+ class _ForwardIterator2,
+ class _Pred,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
+__equal(_ExecutionPolicy&& __policy,
+ _ForwardIterator1&& __first1,
+ _ForwardIterator1&& __last1,
+ _ForwardIterator2&& __first2,
+ _ForwardIterator2&& __last2,
+ _Pred&& __pred) noexcept {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_equal, _RawPolicy),
+ [&__policy](_ForwardIterator1 __g_first1,
+ _ForwardIterator1 __g_last1,
+ _ForwardIterator2 __g_first2,
+ _ForwardIterator2 __g_last2,
+ _Pred __g_pred) -> optional<bool> {
+ if constexpr (__has_random_access_iterator_category<_ForwardIterator1>::value &&
+ __has_random_access_iterator_category<_ForwardIterator2>::value) {
+ if (__g_last1 - __g_first1 != __g_last2 - __g_first2)
+ return false;
+ return std::__equal(
+ __policy, std::move(__g_first1), std::move(__g_last1), std::move(__g_first2), std::move(__g_pred));
+ } else {
+ (void)__policy; // Avoid unused lambda capture warning
+ return std::equal(
+ std::move(__g_first1),
+ std::move(__g_last1),
+ std::move(__g_first2),
+ std::move(__g_last2),
+ std::move(__g_pred));
+ }
+ },
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__pred));
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator1,
+ class _ForwardIterator2,
+ class _Pred,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI bool
+equal(_ExecutionPolicy&& __policy,
+ _ForwardIterator1 __first1,
+ _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2,
+ _Pred __pred) {
+ auto __res = std::__equal(
+ __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::move(__pred));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *__res;
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator1,
+ class _ForwardIterator2,
+ enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI bool
+equal(_ExecutionPolicy&& __policy,
+ _ForwardIterator1 __first1,
+ _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2) {
+ return std::equal(
+ __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::equal_to{});
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+
+#endif // _LIBCPP___ALGORITHM_PSTL_EQUAL_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_fill.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_fill.h
index d64c828d9046..3057dcc04f1a 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_fill.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_fill.h
@@ -13,13 +13,14 @@
#include <__algorithm/pstl_for_each.h>
#include <__algorithm/pstl_frontend_dispatch.h>
#include <__config>
+#include <__iterator/concepts.h>
#include <__iterator/cpp17_iterator_concepts.h>
#include <__iterator/iterator_traits.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
#include <__utility/move.h>
-#include <__utility/terminate_on_exception.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -37,13 +38,13 @@ template <class _ExecutionPolicy,
class _Tp,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void
-fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
+_LIBCPP_HIDE_FROM_ABI optional<__empty>
+__fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) noexcept {
_LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
- std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill),
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill, _RawPolicy),
[&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) {
- std::for_each(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) {
+ return std::__for_each(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) {
__element = __g_value;
});
},
@@ -52,6 +53,18 @@ fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __l
__value);
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Tp,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI void
+fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ if (!std::__fill(__policy, std::move(__first), std::move(__last), __value))
+ std::__throw_bad_alloc();
+}
+
template <class>
void __pstl_fill_n(); // declaration needed for the frontend dispatch below
@@ -61,22 +74,36 @@ template <class _ExecutionPolicy,
class _Tp,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void
-fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _SizeT __n, const _Tp& __value) {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
+__fill_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _SizeT&& __n, const _Tp& __value) noexcept {
_LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
- std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill_n),
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill_n, _RawPolicy),
[&](_ForwardIterator __g_first, _SizeT __g_n, const _Tp& __g_value) {
- if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value)
+ if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value)
std::fill(__policy, __g_first, __g_first + __g_n, __g_value);
else
std::fill_n(__g_first, __g_n, __g_value);
+ return optional<__empty>{__empty{}};
},
std::move(__first),
- __n,
+ std::move(__n),
__value);
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _SizeT,
+ class _Tp,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI void
+fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _SizeT __n, const _Tp& __value) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ if (!std::__fill_n(__policy, std::move(__first), std::move(__n), __value))
+ std::__throw_bad_alloc();
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_find.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_find.h
index 8e8adfecfa46..adc05ea1a9e5 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_find.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_find.h
@@ -15,12 +15,11 @@
#include <__algorithm/pstl_frontend_dispatch.h>
#include <__config>
#include <__iterator/cpp17_iterator_concepts.h>
-#include <__iterator/iterator_traits.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
#include <__utility/move.h>
-#include <__utility/terminate_on_exception.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -35,13 +34,26 @@ template <class _ExecutionPolicy,
class _Predicate,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI _ForwardIterator
-find_if(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
- _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>>
+__find_if(_ExecutionPolicy&&, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept {
using _Backend = typename __select_backend<_RawPolicy>::type;
return std::__pstl_find_if<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__pred));
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Predicate,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _ForwardIterator
+find_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ auto __res = std::__find_if(__policy, std::move(__first), std::move(__last), std::move(__pred));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
+}
+
template <class>
void __pstl_find_if_not();
@@ -50,21 +62,36 @@ template <class _ExecutionPolicy,
class _Predicate,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI _ForwardIterator
-find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
- _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>>
+__find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) {
return std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find_if_not),
- [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) {
- return std::find_if(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __value) {
- return !__g_pred(__value);
- });
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find_if_not, _RawPolicy),
+ [&](_ForwardIterator&& __g_first, _ForwardIterator&& __g_last, _Predicate&& __g_pred)
+ -> optional<__remove_cvref_t<_ForwardIterator>> {
+ return std::__find_if(
+ __policy, __g_first, __g_last, [&](__iter_reference<__remove_cvref_t<_ForwardIterator>> __value) {
+ return !__g_pred(__value);
+ });
},
std::move(__first),
std::move(__last),
std::move(__pred));
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Predicate,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _ForwardIterator
+find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ auto __res = std::__find_if_not(__policy, std::move(__first), std::move(__last), std::move(__pred));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
+}
+
template <class>
void __pstl_find();
@@ -73,21 +100,35 @@ template <class _ExecutionPolicy,
class _Tp,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI _ForwardIterator
-find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
- _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>>
+__find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) noexcept {
return std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find),
- [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) {
- return std::find_if(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) {
- return __element == __g_value;
- });
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find, _RawPolicy),
+ [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) -> optional<_ForwardIterator> {
+ return std::find_if(
+ __policy, __g_first, __g_last, [&](__iter_reference<__remove_cvref_t<_ForwardIterator>> __element) {
+ return __element == __g_value;
+ });
},
std::move(__first),
std::move(__last),
__value);
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Tp,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _ForwardIterator
+find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ auto __res = std::__find(__policy, std::move(__first), std::move(__last), __value);
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_for_each.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_for_each.h
index 09efc24950db..819a43d685ab 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_for_each.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_for_each.h
@@ -14,14 +14,15 @@
#include <__algorithm/pstl_backend.h>
#include <__algorithm/pstl_frontend_dispatch.h>
#include <__config>
+#include <__iterator/concepts.h>
#include <__iterator/cpp17_iterator_concepts.h>
-#include <__iterator/iterator_traits.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
#include <__type_traits/void_t.h>
+#include <__utility/empty.h>
#include <__utility/move.h>
-#include <__utility/terminate_on_exception.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -36,11 +37,22 @@ template <class _ExecutionPolicy,
class _Function,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
+__for_each(_ExecutionPolicy&&, _ForwardIterator&& __first, _ForwardIterator&& __last, _Function&& __func) noexcept {
+ using _Backend = typename __select_backend<_RawPolicy>::type;
+ return std::__pstl_for_each<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__func));
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Function,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
_LIBCPP_HIDE_FROM_ABI void
-for_each(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator __last, _Function __func) {
+for_each(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Function __func) {
_LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
- using _Backend = typename __select_backend<_RawPolicy>::type;
- std::__pstl_for_each<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__func));
+ if (!std::__for_each(__policy, std::move(__first), std::move(__last), std::move(__func)))
+ std::__throw_bad_alloc();
}
template <class>
@@ -52,23 +64,38 @@ template <class _ExecutionPolicy,
class _Function,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void
-for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) {
- _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
+__for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __size, _Function&& __func) noexcept {
return std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_for_each_n),
- [&](_ForwardIterator __g_first, _Size __g_size, _Function __g_func) {
- if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value) {
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_for_each_n, _RawPolicy),
+ [&](_ForwardIterator __g_first, _Size __g_size, _Function __g_func) -> optional<__empty> {
+ if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
std::for_each(__policy, std::move(__g_first), __g_first + __g_size, std::move(__g_func));
+ return __empty{};
} else {
std::for_each_n(std::move(__g_first), __g_size, std::move(__g_func));
+ return __empty{};
}
},
- __first,
- __size,
+ std::move(__first),
+ std::move(__size),
std::move(__func));
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Size,
+ class _Function,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI void
+for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ auto __res = std::__for_each_n(__policy, std::move(__first), std::move(__size), std::move(__func));
+ if (!__res)
+ std::__throw_bad_alloc();
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_frontend_dispatch.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_frontend_dispatch.h
index dc49f3e5163a..6fa110749115 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_frontend_dispatch.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_frontend_dispatch.h
@@ -21,11 +21,10 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-# define _LIBCPP_PSTL_CUSTOMIZATION_POINT(name) \
- [](auto&&... __args) -> decltype(std::name<_RawPolicy>(typename __select_backend<_RawPolicy>::type{}, \
- std::forward<decltype(__args)>(__args)...)) { \
- return std::name<_RawPolicy>( \
- typename __select_backend<_RawPolicy>::type{}, std::forward<decltype(__args)>(__args)...); \
+# define _LIBCPP_PSTL_CUSTOMIZATION_POINT(name, policy) \
+ [](auto&&... __args) -> decltype(std::name<policy>( \
+ typename __select_backend<policy>::type{}, std::forward<decltype(__args)>(__args)...)) { \
+ return std::name<policy>(typename __select_backend<policy>::type{}, std::forward<decltype(__args)>(__args)...); \
}
template <class _SpecializedImpl, class _GenericImpl, class... _Args>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_generate.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_generate.h
index e1ba0183dcba..56538392d5b5 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_generate.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_generate.h
@@ -14,10 +14,12 @@
#include <__algorithm/pstl_frontend_dispatch.h>
#include <__config>
#include <__iterator/cpp17_iterator_concepts.h>
+#include <__iterator/iterator_traits.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
#include <__utility/move.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -35,13 +37,13 @@ template <class _ExecutionPolicy,
class _Generator,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void
-generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
+__generate(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Generator&& __gen) {
_LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
- std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate),
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate, _RawPolicy),
[&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Generator __g_gen) {
- std::for_each(
+ return std::__for_each(
__policy, std::move(__g_first), std::move(__g_last), [&](__iter_reference<_ForwardIterator> __element) {
__element = __g_gen();
});
@@ -51,6 +53,18 @@ generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator
std::move(__gen));
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Generator,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI void
+generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ if (!std::__generate(__policy, std::move(__first), std::move(__last), std::move(__gen)))
+ std::__throw_bad_alloc();
+}
+
template <class>
void __pstl_generate_n();
@@ -60,21 +74,34 @@ template <class _ExecutionPolicy,
class _Generator,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void
-generate_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _Generator __gen) {
- _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
- std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate_n),
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
+__generate_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __n, _Generator&& __gen) {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate_n, _RawPolicy),
[&__policy](_ForwardIterator __g_first, _Size __g_n, _Generator __g_gen) {
- std::for_each_n(__policy, std::move(__g_first), __g_n, [&](__iter_reference<_ForwardIterator> __element) {
- __element = __g_gen();
- });
+ return std::__for_each_n(
+ __policy, std::move(__g_first), std::move(__g_n), [&](__iter_reference<_ForwardIterator> __element) {
+ __element = __g_gen();
+ });
},
std::move(__first),
__n,
std::move(__gen));
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Size,
+ class _Generator,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI void
+generate_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _Generator __gen) {
+ _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
+ if (!std::__generate_n(__policy, std::move(__first), std::move(__n), std::move(__gen)))
+ std::__throw_bad_alloc();
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_is_partitioned.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_is_partitioned.h
index 6f6e9b2f4478..39cf6369339d 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_is_partitioned.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_is_partitioned.h
@@ -18,6 +18,7 @@
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
#include <__utility/move.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -35,10 +36,10 @@ template <class _ExecutionPolicy,
class _Predicate,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
-is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> __is_partitioned(
+ _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) {
return std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_is_partitioned),
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_is_partitioned, _RawPolicy),
[&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) {
__g_first = std::find_if_not(__policy, __g_first, __g_last, __g_pred);
if (__g_first == __g_last)
@@ -51,6 +52,19 @@ is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIt
std::move(__pred));
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Predicate,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
+is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
+ auto __res = std::__is_partitioned(__policy, std::move(__first), std::move(__last), std::move(__pred));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h
index f10ac7674282..ed8014510863 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_merge.h
@@ -16,6 +16,7 @@
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
#include <__utility/move.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -32,23 +33,51 @@ template <class _ExecutionPolicy,
class _Comp = std::less<>,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
+__merge(_ExecutionPolicy&&,
+ _ForwardIterator1 __first1,
+ _ForwardIterator1 __last1,
+ _ForwardIterator2 __first2,
+ _ForwardIterator2 __last2,
+ _ForwardOutIterator __result,
+ _Comp __comp = {}) noexcept {
+ using _Backend = typename __select_backend<_RawPolicy>::type;
+ return std::__pstl_merge<_RawPolicy>(
+ _Backend{},
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::move(__result),
+ std::move(__comp));
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator1,
+ class _ForwardIterator2,
+ class _ForwardOutIterator,
+ class _Comp = std::less<>,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
-merge(_ExecutionPolicy&&,
+merge(_ExecutionPolicy&& __policy,
_ForwardIterator1 __first1,
_ForwardIterator1 __last1,
_ForwardIterator2 __first2,
_ForwardIterator2 __last2,
_ForwardOutIterator __result,
_Comp __comp = {}) {
- using _Backend = typename __select_backend<_RawPolicy>::type;
- return std::__pstl_merge<_RawPolicy>(
- _Backend{},
+ auto __res = std::__merge(
+ __policy,
std::move(__first1),
std::move(__last1),
std::move(__first2),
std::move(__last2),
std::move(__result),
std::move(__comp));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_move.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_move.h
new file mode 100644
index 000000000000..52baab57591e
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_move.h
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_PSTL_MOVE_H
+#define _LIBCPP___ALGORITHM_PSTL_MOVE_H
+
+#include <__algorithm/copy_n.h>
+#include <__algorithm/pstl_backend.h>
+#include <__algorithm/pstl_frontend_dispatch.h>
+#include <__algorithm/pstl_transform.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__iterator/iterator_traits.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_constant_evaluated.h>
+#include <__type_traits/is_execution_policy.h>
+#include <__type_traits/is_trivially_copyable.h>
+#include <__type_traits/remove_cvref.h>
+#include <optional>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// TODO: Use the std::copy/move shenanigans to forward to std::memmove
+// Investigate whether we want to still forward to std::transform(policy)
+// in that case for the execution::par part, or whether we actually want
+// to run everything serially in that case.
+
+template <class>
+void __pstl_move();
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _ForwardOutIterator,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
+__move(_ExecutionPolicy&& __policy,
+ _ForwardIterator&& __first,
+ _ForwardIterator&& __last,
+ _ForwardOutIterator&& __result) noexcept {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_move, _RawPolicy),
+ [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result) {
+ return std::__transform(__policy, __g_first, __g_last, __g_result, [](auto&& __v) { return std::move(__v); });
+ },
+ std::move(__first),
+ std::move(__last),
+ std::move(__result));
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _ForwardOutIterator,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
+move(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) {
+ auto __res = std::__move(__policy, std::move(__first), std::move(__last), std::move(__result));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *__res;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+
+#endif // _LIBCPP___ALGORITHM_PSTL_MOVE_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_replace.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_replace.h
index 04ffaaba596a..05dee3f6a4f3 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_replace.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_replace.h
@@ -18,6 +18,7 @@
#include <__type_traits/enable_if.h>
#include <__type_traits/remove_cvref.h>
#include <__utility/move.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -36,19 +37,21 @@ template <class _ExecutionPolicy,
class _Tp,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void
-replace_if(_ExecutionPolicy&& __policy,
- _ForwardIterator __first,
- _ForwardIterator __last,
- _Pred __pred,
- const _Tp& __new_value) {
- std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_if),
- [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred, const _Tp& __g_new_value) {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
+__replace_if(_ExecutionPolicy&& __policy,
+ _ForwardIterator&& __first,
+ _ForwardIterator&& __last,
+ _Pred&& __pred,
+ const _Tp& __new_value) noexcept {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_if, _RawPolicy),
+ [&__policy](
+ _ForwardIterator&& __g_first, _ForwardIterator&& __g_last, _Pred&& __g_pred, const _Tp& __g_new_value) {
std::for_each(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) {
if (__g_pred(__element))
__element = __g_new_value;
});
+ return optional<__empty>{__empty{}};
},
std::move(__first),
std::move(__last),
@@ -56,6 +59,23 @@ replace_if(_ExecutionPolicy&& __policy,
__new_value);
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Pred,
+ class _Tp,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI void
+replace_if(_ExecutionPolicy&& __policy,
+ _ForwardIterator __first,
+ _ForwardIterator __last,
+ _Pred __pred,
+ const _Tp& __new_value) {
+ auto __res = std::__replace_if(__policy, std::move(__first), std::move(__last), std::move(__pred), __new_value);
+ if (!__res)
+ std::__throw_bad_alloc();
+}
+
template <class>
void __pstl_replace();
@@ -64,17 +84,17 @@ template <class _ExecutionPolicy,
class _Tp,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void
-replace(_ExecutionPolicy&& __policy,
- _ForwardIterator __first,
- _ForwardIterator __last,
- const _Tp& __old_value,
- const _Tp& __new_value) {
- std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace),
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
+__replace(_ExecutionPolicy&& __policy,
+ _ForwardIterator __first,
+ _ForwardIterator __last,
+ const _Tp& __old_value,
+ const _Tp& __new_value) noexcept {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace, _RawPolicy),
[&__policy](
_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_old_value, const _Tp& __g_new_value) {
- std::replace_if(
+ return std::__replace_if(
__policy,
std::move(__g_first),
std::move(__g_last),
@@ -87,6 +107,21 @@ replace(_ExecutionPolicy&& __policy,
__new_value);
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _Tp,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI void
+replace(_ExecutionPolicy&& __policy,
+ _ForwardIterator __first,
+ _ForwardIterator __last,
+ const _Tp& __old_value,
+ const _Tp& __new_value) {
+ if (!std::__replace(__policy, std::move(__first), std::move(__last), __old_value, __new_value))
+ std::__throw_bad_alloc();
+}
+
template <class>
void __pstl_replace_copy_if();
@@ -97,23 +132,26 @@ template <class _ExecutionPolicy,
class _Tp,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void replace_copy_if(
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __replace_copy_if(
_ExecutionPolicy&& __policy,
- _ForwardIterator __first,
- _ForwardIterator __last,
- _ForwardOutIterator __result,
- _Pred __pred,
+ _ForwardIterator&& __first,
+ _ForwardIterator&& __last,
+ _ForwardOutIterator&& __result,
+ _Pred&& __pred,
const _Tp& __new_value) {
- std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy_if),
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy_if, _RawPolicy),
[&__policy](_ForwardIterator __g_first,
_ForwardIterator __g_last,
_ForwardOutIterator __g_result,
_Pred __g_pred,
- const _Tp& __g_new_value) {
- std::transform(__policy, __g_first, __g_last, __g_result, [&](__iter_reference<_ForwardIterator> __element) {
- return __g_pred(__element) ? __g_new_value : __element;
- });
+ const _Tp& __g_new_value) -> optional<__empty> {
+ if (!std::__transform(
+ __policy, __g_first, __g_last, __g_result, [&](__iter_reference<_ForwardIterator> __element) {
+ return __g_pred(__element) ? __g_new_value : __element;
+ }))
+ return nullopt;
+ return __empty{};
},
std::move(__first),
std::move(__last),
@@ -122,30 +160,49 @@ _LIBCPP_HIDE_FROM_ABI void replace_copy_if(
__new_value);
}
-template <class>
-void __pstl_replace_copy();
-
template <class _ExecutionPolicy,
class _ForwardIterator,
class _ForwardOutIterator,
+ class _Pred,
class _Tp,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void replace_copy(
+_LIBCPP_HIDE_FROM_ABI void replace_copy_if(
_ExecutionPolicy&& __policy,
_ForwardIterator __first,
_ForwardIterator __last,
_ForwardOutIterator __result,
- const _Tp& __old_value,
+ _Pred __pred,
const _Tp& __new_value) {
- std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy),
+ if (!std::__replace_copy_if(
+ __policy, std::move(__first), std::move(__last), std::move(__result), std::move(__pred), __new_value))
+ std::__throw_bad_alloc();
+}
+
+template <class>
+void __pstl_replace_copy();
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _ForwardOutIterator,
+ class _Tp,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __replace_copy(
+ _ExecutionPolicy&& __policy,
+ _ForwardIterator&& __first,
+ _ForwardIterator&& __last,
+ _ForwardOutIterator&& __result,
+ const _Tp& __old_value,
+ const _Tp& __new_value) noexcept {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy, _RawPolicy),
[&__policy](_ForwardIterator __g_first,
_ForwardIterator __g_last,
_ForwardOutIterator __g_result,
const _Tp& __g_old_value,
const _Tp& __g_new_value) {
- return std::replace_copy_if(
+ return std::__replace_copy_if(
__policy,
std::move(__g_first),
std::move(__g_last),
@@ -160,6 +217,24 @@ _LIBCPP_HIDE_FROM_ABI void replace_copy(
__new_value);
}
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _ForwardOutIterator,
+ class _Tp,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI void replace_copy(
+ _ExecutionPolicy&& __policy,
+ _ForwardIterator __first,
+ _ForwardIterator __last,
+ _ForwardOutIterator __result,
+ const _Tp& __old_value,
+ const _Tp& __new_value) {
+ if (!std::__replace_copy(
+ __policy, std::move(__first), std::move(__last), std::move(__result), __old_value, __new_value))
+ std::__throw_bad_alloc();
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_rotate_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_rotate_copy.h
new file mode 100644
index 000000000000..33dc9a3635f7
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_rotate_copy.h
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H
+#define _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H
+
+#include <__algorithm/pstl_backend.h>
+#include <__algorithm/pstl_copy.h>
+#include <__algorithm/pstl_frontend_dispatch.h>
+#include <__type_traits/is_execution_policy.h>
+#include <optional>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class>
+void __pstl_rotate_copy();
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _ForwardOutIterator,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
+__rotate_copy(_ExecutionPolicy&& __policy,
+ _ForwardIterator&& __first,
+ _ForwardIterator&& __middle,
+ _ForwardIterator&& __last,
+ _ForwardOutIterator&& __result) noexcept {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_rotate_copy, _RawPolicy),
+ [&__policy](_ForwardIterator __g_first,
+ _ForwardIterator __g_middle,
+ _ForwardIterator __g_last,
+ _ForwardOutIterator __g_result) -> optional<_ForwardOutIterator> {
+ auto __result_mid =
+ std::__copy(__policy, _ForwardIterator(__g_middle), std::move(__g_last), std::move(__g_result));
+ if (!__result_mid)
+ return nullopt;
+ return std::__copy(__policy, std::move(__g_first), std::move(__g_middle), *std::move(__result_mid));
+ },
+ std::move(__first),
+ std::move(__middle),
+ std::move(__last),
+ std::move(__result));
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _ForwardOutIterator,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator rotate_copy(
+ _ExecutionPolicy&& __policy,
+ _ForwardIterator __first,
+ _ForwardIterator __middle,
+ _ForwardIterator __last,
+ _ForwardOutIterator __result) {
+ auto __res =
+ std::__rotate_copy(__policy, std::move(__first), std::move(__middle), std::move(__last), std::move(__result));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *__res;
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
+
+#endif // _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_sort.h
index 75c77ed40527..3e71e0aa5ae0 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_sort.h
@@ -16,8 +16,10 @@
#include <__functional/operations.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
+#include <__utility/empty.h>
#include <__utility/forward.h>
#include <__utility/move.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -35,12 +37,13 @@ template <class _ExecutionPolicy,
class _Comp,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void
-sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
- std::__pstl_frontend_dispatch(
- _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_sort),
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __sort(
+ _ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) noexcept {
+ return std::__pstl_frontend_dispatch(
+ _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_sort, _RawPolicy),
[&__policy](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) {
std::stable_sort(__policy, std::move(__g_first), std::move(__g_last), std::move(__g_comp));
+ return optional<__empty>{__empty{}};
},
std::move(__first),
std::move(__last),
@@ -49,6 +52,17 @@ sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIt
template <class _ExecutionPolicy,
class _RandomAccessIterator,
+ class _Comp,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI void
+sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
+ if (!std::__sort(__policy, std::move(__first), std::move(__last), std::move(__comp)))
+ std::__throw_bad_alloc();
+}
+
+template <class _ExecutionPolicy,
+ class _RandomAccessIterator,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
_LIBCPP_HIDE_FROM_ABI void
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_stable_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_stable_sort.h
index 510ffd862980..c9d375535fc4 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_stable_sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_stable_sort.h
@@ -15,7 +15,9 @@
#include <__type_traits/enable_if.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
+#include <__utility/empty.h>
#include <__utility/move.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -30,10 +32,21 @@ template <class _ExecutionPolicy,
class _Comp = less<>,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
-_LIBCPP_HIDE_FROM_ABI void
-stable_sort(_ExecutionPolicy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp = {}) {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __stable_sort(
+ _ExecutionPolicy&&, _RandomAccessIterator&& __first, _RandomAccessIterator&& __last, _Comp&& __comp = {}) noexcept {
using _Backend = typename __select_backend<_RawPolicy>::type;
- std::__pstl_stable_sort<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__comp));
+ return std::__pstl_stable_sort<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__comp));
+}
+
+template <class _ExecutionPolicy,
+ class _RandomAccessIterator,
+ class _Comp = less<>,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI void stable_sort(
+ _ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp = {}) {
+ if (!std::__stable_sort(__policy, std::move(__first), std::move(__last), std::move(__comp)))
+ std::__throw_bad_alloc();
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/pstl_transform.h b/contrib/llvm-project/libcxx/include/__algorithm/pstl_transform.h
index 27d95349fc8b..aad59d1f30e6 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/pstl_transform.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/pstl_transform.h
@@ -12,12 +12,11 @@
#include <__algorithm/pstl_backend.h>
#include <__config>
#include <__iterator/cpp17_iterator_concepts.h>
-#include <__iterator/iterator_traits.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_execution_policy.h>
#include <__type_traits/remove_cvref.h>
#include <__utility/move.h>
-#include <__utility/terminate_on_exception.h>
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -33,8 +32,25 @@ template <class _ExecutionPolicy,
class _UnaryOperation,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardOutIterator>>
+__transform(_ExecutionPolicy&&,
+ _ForwardIterator&& __first,
+ _ForwardIterator&& __last,
+ _ForwardOutIterator&& __result,
+ _UnaryOperation&& __op) noexcept {
+ using _Backend = typename __select_backend<_RawPolicy>::type;
+ return std::__pstl_transform<_RawPolicy>(
+ _Backend{}, std::move(__first), std::move(__last), std::move(__result), std::move(__op));
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator,
+ class _ForwardOutIterator,
+ class _UnaryOperation,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
- _ExecutionPolicy&&,
+ _ExecutionPolicy&& __policy,
_ForwardIterator __first,
_ForwardIterator __last,
_ForwardOutIterator __result,
@@ -42,9 +58,29 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
_LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
_LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator);
_LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(__op(*__first)));
+ auto __res = std::__transform(__policy, std::move(__first), std::move(__last), std::move(__result), std::move(__op));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
+}
+
+template <class _ExecutionPolicy,
+ class _ForwardIterator1,
+ class _ForwardIterator2,
+ class _ForwardOutIterator,
+ class _BinaryOperation,
+ class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
+ enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardOutIterator>>
+__transform(_ExecutionPolicy&&,
+ _ForwardIterator1&& __first1,
+ _ForwardIterator1&& __last1,
+ _ForwardIterator2&& __first2,
+ _ForwardOutIterator&& __result,
+ _BinaryOperation&& __op) noexcept {
using _Backend = typename __select_backend<_RawPolicy>::type;
return std::__pstl_transform<_RawPolicy>(
- _Backend{}, std::move(__first), std::move(__last), std::move(__result), std::move(__op));
+ _Backend{}, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__result), std::move(__op));
}
template <class _ExecutionPolicy,
@@ -55,7 +91,7 @@ template <class _ExecutionPolicy,
class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
- _ExecutionPolicy&&,
+ _ExecutionPolicy&& __policy,
_ForwardIterator1 __first1,
_ForwardIterator1 __last1,
_ForwardIterator2 __first2,
@@ -65,9 +101,11 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
_LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2);
_LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator);
_LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(__op(*__first1, *__first2)));
- using _Backend = typename __select_backend<_RawPolicy>::type;
- return std::__pstl_transform<_RawPolicy>(
- _Backend{}, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__result), std::move(__op));
+ auto __res = std::__transform(
+ __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__result), std::move(__op));
+ if (!__res)
+ std::__throw_bad_alloc();
+ return *std::move(__res);
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_adjacent_find.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_adjacent_find.h
index 5f33192666ae..a10b04167ede 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_adjacent_find.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_adjacent_find.h
@@ -24,6 +24,9 @@
# pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
#if _LIBCPP_STD_VER >= 20
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -75,4 +78,6 @@ _LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 20
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_clamp.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_clamp.h
index 9613f7f37720..e6c86207254a 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_clamp.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_clamp.h
@@ -37,9 +37,10 @@ struct __fn {
_LIBCPP_ASSERT_UNCATEGORIZED(!bool(std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __low))),
"Bad bounds passed to std::ranges::clamp");
- if (std::invoke(__comp, std::invoke(__proj, __value), std::invoke(__proj, __low)))
+ auto&& __projected = std::invoke(__proj, __value);
+ if (std::invoke(__comp, std::forward<decltype(__projected)>(__projected), std::invoke(__proj, __low)))
return __low;
- else if (std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __value)))
+ else if (std::invoke(__comp, std::invoke(__proj, __high), std::forward<decltype(__projected)>(__projected)))
return __high;
else
return __value;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_count.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_count.h
index 82f54567561f..4c8f1b2cbea7 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_count.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_count.h
@@ -9,7 +9,8 @@
#ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_H
#define _LIBCPP___ALGORITHM_RANGES_COUNT_H
-#include <__algorithm/ranges_count_if.h>
+#include <__algorithm/count.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__functional/identity.h>
#include <__functional/ranges_operations.h>
@@ -36,16 +37,14 @@ struct __fn {
requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
- auto __pred = [&](auto&& __e) { return __e == __value; };
- return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
+ return std::__count<_RangeAlgPolicy>(std::move(__first), std::move(__last), __value, __proj);
}
template <input_range _Range, class _Type, class _Proj = identity>
requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range>
operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const {
- auto __pred = [&](auto&& __e) { return __e == __value; };
- return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
+ return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj);
}
};
} // namespace __count
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_ends_with.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_ends_with.h
new file mode 100644
index 000000000000..2afb74bff0f1
--- /dev/null
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_ends_with.h
@@ -0,0 +1,196 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_ENDS_WITH_H
+#define _LIBCPP___ALGORITHM_RANGES_ENDS_WITH_H
+
+#include <__algorithm/ranges_equal.h>
+#include <__algorithm/ranges_starts_with.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/ranges_operations.h>
+#include <__functional/reference_wrapper.h>
+#include <__iterator/advance.h>
+#include <__iterator/concepts.h>
+#include <__iterator/distance.h>
+#include <__iterator/indirectly_comparable.h>
+#include <__iterator/reverse_iterator.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+namespace __ends_with {
+struct __fn {
+ template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
+ static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl_bidirectional(
+ _Iter1 __first1,
+ _Sent1 __last1,
+ _Iter2 __first2,
+ _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2) {
+ auto __rbegin1 = std::make_reverse_iterator(__last1);
+ auto __rend1 = std::make_reverse_iterator(__first1);
+ auto __rbegin2 = std::make_reverse_iterator(__last2);
+ auto __rend2 = std::make_reverse_iterator(__first2);
+ return ranges::starts_with(
+ __rbegin1, __rend1, __rbegin2, __rend2, std::ref(__pred), std::ref(__proj1), std::ref(__proj2));
+ }
+
+ template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
+ static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl(
+ _Iter1 __first1,
+ _Sent1 __last1,
+ _Iter2 __first2,
+ _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2) {
+ if constexpr (std::bidirectional_iterator<_Sent1> && std::bidirectional_iterator<_Sent2> &&
+ (!std::random_access_iterator<_Sent1>)&&(!std::random_access_iterator<_Sent2>)) {
+ return __ends_with_fn_impl_bidirectional(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2);
+
+ } else {
+ auto __n1 = ranges::distance(__first1, __last1);
+ auto __n2 = ranges::distance(__first2, __last2);
+ if (__n2 == 0)
+ return true;
+ if (__n2 > __n1)
+ return false;
+
+ return __ends_with_fn_impl_with_offset(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ __pred,
+ __proj1,
+ __proj2,
+ __n1 - __n2);
+ }
+ }
+
+ template <class _Iter1,
+ class _Sent1,
+ class _Iter2,
+ class _Sent2,
+ class _Pred,
+ class _Proj1,
+ class _Proj2,
+ class _Offset>
+ static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl_with_offset(
+ _Iter1 __first1,
+ _Sent1 __last1,
+ _Iter2 __first2,
+ _Sent2 __last2,
+ _Pred& __pred,
+ _Proj1& __proj1,
+ _Proj2& __proj2,
+ _Offset __offset) {
+ if constexpr (std::bidirectional_iterator<_Sent1> && std::bidirectional_iterator<_Sent2> &&
+ !std::random_access_iterator<_Sent1> && !std::random_access_iterator<_Sent2>) {
+ return __ends_with_fn_impl_bidirectional(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __pred, __proj1, __proj2);
+
+ } else {
+ ranges::advance(__first1, __offset);
+ return ranges::equal(
+ std::move(__first1),
+ std::move(__last1),
+ std::move(__first2),
+ std::move(__last2),
+ std::ref(__pred),
+ std::ref(__proj1),
+ std::ref(__proj2));
+ }
+ }
+
+ template <input_iterator _Iter1,
+ sentinel_for<_Iter1> _Sent1,
+ input_iterator _Iter2,
+ sentinel_for<_Iter2> _Sent2,
+ class _Pred = ranges::equal_to,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires(forward_iterator<_Iter1> || sized_sentinel_for<_Sent1, _Iter1>) &&
+ (forward_iterator<_Iter2> || sized_sentinel_for<_Sent2, _Iter2>) &&
+ indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+ _Iter1 __first1,
+ _Sent1 __last1,
+ _Iter2 __first2,
+ _Sent2 __last2,
+ _Pred __pred = {},
+ _Proj1 __proj1 = {},
+ _Proj2 __proj2 = {}) const {
+ return __ends_with_fn_impl(
+ std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __pred, __proj1, __proj2);
+ }
+
+ template <input_range _Range1,
+ input_range _Range2,
+ class _Pred = ranges::equal_to,
+ class _Proj1 = identity,
+ class _Proj2 = identity>
+ requires(forward_range<_Range1> || sized_range<_Range1>) && (forward_range<_Range2> || sized_range<_Range2>) &&
+ indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
+ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
+ _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
+ if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
+ auto __n1 = ranges::size(__range1);
+ auto __n2 = ranges::size(__range2);
+ if (__n2 == 0)
+ return true;
+ if (__n2 > __n1)
+ return false;
+ auto __offset = __n1 - __n2;
+
+ return __ends_with_fn_impl_with_offset(
+ ranges::begin(__range1),
+ ranges::end(__range1),
+ ranges::begin(__range2),
+ ranges::end(__range2),
+ __pred,
+ __proj1,
+ __proj2,
+ __offset);
+
+ } else {
+ return __ends_with_fn_impl(
+ ranges::begin(__range1),
+ ranges::end(__range1),
+ ranges::begin(__range2),
+ ranges::end(__range2),
+ __pred,
+ __proj1,
+ __proj2);
+ }
+ }
+};
+} // namespace __ends_with
+
+inline namespace __cpo {
+inline constexpr auto ends_with = __ends_with::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP___ALGORITHM_RANGES_ENDS_WITH_H
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_equal_range.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_equal_range.h
index ed78cf312c6b..1ff8856ca03f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_equal_range.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_equal_range.h
@@ -1,6 +1,6 @@
//===----------------------------------------------------------------------===//
//
-// Part of the LLVM __project, under the Apache License v2.0 with LLVM Exceptions.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_find_if_not.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_find_if_not.h
index 6beade1462e0..a18bea43165e 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_find_if_not.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_find_if_not.h
@@ -39,14 +39,14 @@ struct __fn {
indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip
operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
- auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
+ auto __pred2 = [&](auto&& __e) -> bool { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj);
}
template <input_range _Rp, class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
- auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
+ auto __pred2 = [&](auto&& __e) -> bool { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);
}
};
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_max.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_max.h
index 5cc418d3393c..782ce2670f05 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_max.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_max.h
@@ -56,7 +56,7 @@ struct __fn {
operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
_LIBCPP_ASSERT_UNCATEGORIZED(__il.begin() != __il.end(), "initializer_list must contain at least one element");
- auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
+ auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp_lhs_rhs_swapped, __proj);
}
@@ -72,7 +72,9 @@ struct __fn {
_LIBCPP_ASSERT_UNCATEGORIZED(__first != __last, "range must contain at least one element");
if constexpr (forward_range<_Rp> && !__is_cheap_to_copy<range_value_t<_Rp>>) {
- auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
+ auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool {
+ return std::invoke(__comp, __rhs, __lhs);
+ };
return *ranges::__min_element_impl(std::move(__first), std::move(__last), __comp_lhs_rhs_swapped, __proj);
} else {
range_value_t<_Rp> __result = *__first;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_max_element.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_max_element.h
index 2d92661c8109..2ba97042f1f6 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_max_element.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_max_element.h
@@ -37,7 +37,7 @@ struct __fn {
indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip
operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
- auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
+ auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);
}
@@ -46,7 +46,7 @@ struct __fn {
indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
- auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); };
+ auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
}
};
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove.h
index bf0928df599c..e27c4bdd733d 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove.h
@@ -36,7 +36,7 @@ struct __fn {
requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
- auto __pred = [&](auto&& __other) { return __value == __other; };
+ auto __pred = [&](auto&& __other) -> bool { return __value == __other; };
return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
}
@@ -45,7 +45,7 @@ struct __fn {
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
- auto __pred = [&](auto&& __other) { return __value == __other; };
+ auto __pred = [&](auto&& __other) -> bool { return __value == __other; };
return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
}
};
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy.h
index 457d593957ad..5158a78e4814 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_remove_copy.h
@@ -47,7 +47,7 @@ struct __fn {
indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*>
_LIBCPP_HIDE_FROM_ABI constexpr remove_copy_result<_InIter, _OutIter>
operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
- auto __pred = [&](auto&& __val) { return __value == __val; };
+ auto __pred = [&](auto&& __val) -> bool { return __value == __val; };
return ranges::__remove_copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
}
@@ -56,7 +56,7 @@ struct __fn {
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
_LIBCPP_HIDE_FROM_ABI constexpr remove_copy_result<borrowed_iterator_t<_Range>, _OutIter>
operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const {
- auto __pred = [&](auto&& __val) { return __value == __val; };
+ auto __pred = [&](auto&& __val) -> bool { return __value == __val; };
return ranges::__remove_copy_if_impl(
ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __proj);
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace.h
index 714fd5c7b089..b66a41aa8d0d 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace.h
@@ -36,7 +36,7 @@ struct __fn {
indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type1*>
_LIBCPP_HIDE_FROM_ABI constexpr _Iter operator()(
_Iter __first, _Sent __last, const _Type1& __old_value, const _Type2& __new_value, _Proj __proj = {}) const {
- auto __pred = [&](const auto& __val) { return __val == __old_value; };
+ auto __pred = [&](const auto& __val) -> bool { return __val == __old_value; };
return ranges::__replace_if_impl(std::move(__first), std::move(__last), __pred, __new_value, __proj);
}
@@ -45,7 +45,7 @@ struct __fn {
indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type1*>
_LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
operator()(_Range&& __range, const _Type1& __old_value, const _Type2& __new_value, _Proj __proj = {}) const {
- auto __pred = [&](auto&& __val) { return __val == __old_value; };
+ auto __pred = [&](auto&& __val) -> bool { return __val == __old_value; };
return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj);
}
};
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy.h
index 124ff8f2c559..a7627024812f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_replace_copy.h
@@ -53,7 +53,7 @@ struct __fn {
const _OldType& __old_value,
const _NewType& __new_value,
_Proj __proj = {}) const {
- auto __pred = [&](const auto& __value) { return __value == __old_value; };
+ auto __pred = [&](const auto& __value) -> bool { return __value == __old_value; };
return ranges::__replace_copy_if_impl(
std::move(__first), std::move(__last), std::move(__result), __pred, __new_value, __proj);
}
@@ -68,7 +68,7 @@ struct __fn {
_LIBCPP_HIDE_FROM_ABI constexpr replace_copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(
_Range&& __range, _OutIter __result, const _OldType& __old_value, const _NewType& __new_value, _Proj __proj = {})
const {
- auto __pred = [&](const auto& __value) { return __value == __old_value; };
+ auto __pred = [&](const auto& __value) -> bool { return __value == __old_value; };
return ranges::__replace_copy_if_impl(
ranges::begin(__range), ranges::end(__range), std::move(__result), __pred, __new_value, __proj);
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_rotate_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_rotate_copy.h
index 301672707f72..ab76c0944c47 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_rotate_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_rotate_copy.h
@@ -13,7 +13,6 @@
#include <__algorithm/ranges_copy.h>
#include <__config>
#include <__iterator/concepts.h>
-#include <__iterator/reverse_iterator.h>
#include <__ranges/access.h>
#include <__ranges/concepts.h>
#include <__ranges/dangling.h>
@@ -34,7 +33,7 @@ using rotate_copy_result = in_out_result<_InIter, _OutIter>;
namespace __rotate_copy {
struct __fn {
- template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
+ template <forward_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
requires indirectly_copyable<_InIter, _OutIter>
_LIBCPP_HIDE_FROM_ABI constexpr rotate_copy_result<_InIter, _OutIter>
operator()(_InIter __first, _InIter __middle, _Sent __last, _OutIter __result) const {
@@ -43,7 +42,7 @@ struct __fn {
return {std::move(__res1.in), std::move(__res2.out)};
}
- template <bidirectional_range _Range, weakly_incrementable _OutIter>
+ template <forward_range _Range, weakly_incrementable _OutIter>
requires indirectly_copyable<iterator_t<_Range>, _OutIter>
_LIBCPP_HIDE_FROM_ABI constexpr rotate_copy_result<borrowed_iterator_t<_Range>, _OutIter>
operator()(_Range&& __range, iterator_t<_Range> __middle, _OutIter __result) const {
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/ranges_upper_bound.h b/contrib/llvm-project/libcxx/include/__algorithm/ranges_upper_bound.h
index a12a0e39b084..7b571fb3448f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/ranges_upper_bound.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/ranges_upper_bound.h
@@ -39,7 +39,7 @@ struct __fn {
indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter
operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
- auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) {
+ auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) -> bool {
return !std::invoke(__comp, __rhs, __lhs);
};
@@ -52,7 +52,7 @@ struct __fn {
indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
- auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) {
+ auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) -> bool {
return !std::invoke(__comp, __rhs, __lhs);
};
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/remove.h b/contrib/llvm-project/libcxx/include/__algorithm/remove.h
index 533e41b54fa4..eff22757186e 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/remove.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/remove.h
@@ -24,7 +24,7 @@ template <class _ForwardIterator, class _Tp>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
- __first = _VSTD::find(__first, __last, __value);
+ __first = std::find(__first, __last, __value);
if (__first != __last)
{
_ForwardIterator __i = __first;
@@ -32,7 +32,7 @@ remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
{
if (!(*__i == __value))
{
- *__first = _VSTD::move(*__i);
+ *__first = std::move(*__i);
++__first;
}
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/remove_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/remove_copy.h
index ecba08a053e6..060833813d21 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/remove_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/remove_copy.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/remove_copy_if.h b/contrib/llvm-project/libcxx/include/__algorithm/remove_copy_if.h
index 2f235fd32ff6..9858d43c043f 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/remove_copy_if.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/remove_copy_if.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/remove_if.h b/contrib/llvm-project/libcxx/include/__algorithm/remove_if.h
index 27350728d256..8197e4fc2f8e 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/remove_if.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/remove_if.h
@@ -23,7 +23,7 @@ template <class _ForwardIterator, class _Predicate>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
- __first = _VSTD::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred);
+ __first = std::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred);
if (__first != __last)
{
_ForwardIterator __i = __first;
@@ -31,7 +31,7 @@ remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
if (!__pred(*__i))
{
- *__first = _VSTD::move(*__i);
+ *__first = std::move(*__i);
++__first;
}
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/replace.h b/contrib/llvm-project/libcxx/include/__algorithm/replace.h
index ce6215066f51..09b1dac79b70 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/replace.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/replace.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/replace_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/replace_copy.h
index bebb14cbe210..107e92968944 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/replace_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/replace_copy.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
const _Tp& __old_value, const _Tp& __new_value)
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/replace_copy_if.h b/contrib/llvm-project/libcxx/include/__algorithm/replace_copy_if.h
index e1ddb527be84..a77b1caa805a 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/replace_copy_if.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/replace_copy_if.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
_Predicate __pred, const _Tp& __new_value)
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/replace_if.h b/contrib/llvm-project/libcxx/include/__algorithm/replace_if.h
index b3a3367d2233..05269065f025 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/replace_if.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/replace_if.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _Predicate, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/reverse.h b/contrib/llvm-project/libcxx/include/__algorithm/reverse.h
index aa76951707a3..86634520aa26 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/reverse.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/reverse.h
@@ -22,7 +22,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy, class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
__reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag)
{
@@ -36,7 +36,7 @@ __reverse_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, bi
}
template <class _AlgPolicy, class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
__reverse_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag)
{
@@ -53,7 +53,7 @@ void __reverse(_BidirectionalIterator __first, _Sentinel __last) {
}
template <class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
void
reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/reverse_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/reverse_copy.h
index f4a0e9713dd5..7672fc86686b 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/reverse_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/reverse_copy.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/rotate.h b/contrib/llvm-project/libcxx/include/__algorithm/rotate.h
index 7ed6f18628c7..f9236fcaafb2 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/rotate.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/rotate.h
@@ -35,7 +35,7 @@ __rotate_left(_ForwardIterator __first, _ForwardIterator __last)
value_type __tmp = _Ops::__iter_move(__first);
_ForwardIterator __lm1 = std::__move<_AlgPolicy>(
_Ops::next(__first), __last, __first).second;
- *__lm1 = _VSTD::move(__tmp);
+ *__lm1 = std::move(__tmp);
return __lm1;
}
@@ -49,7 +49,7 @@ __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last)
_BidirectionalIterator __lm1 = _Ops::prev(__last);
value_type __tmp = _Ops::__iter_move(__lm1);
_BidirectionalIterator __fp1 = std::__move_backward<_AlgPolicy>(__first, __lm1, std::move(__last)).second;
- *__first = _VSTD::move(__tmp);
+ *__first = std::move(__tmp);
return __fp1;
}
@@ -89,7 +89,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt
}
template<typename _Integral>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX17 _Integral
__algo_gcd(_Integral __x, _Integral __y)
{
@@ -117,7 +117,7 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
std::__swap_ranges<_AlgPolicy>(__first, __middle, __middle, __last);
return __middle;
}
- const difference_type __g = _VSTD::__algo_gcd(__m1, __m2);
+ const difference_type __g = std::__algo_gcd(__m1, __m2);
for (_RandomAccessIterator __p = __first + __g; __p != __first;)
{
value_type __t(_Ops::__iter_move(--__p));
@@ -133,16 +133,16 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran
else
__p2 = __first + (__m1 - __d);
} while (__p2 != __p);
- *__p1 = _VSTD::move(__t);
+ *__p1 = std::move(__t);
}
return __first + __m2;
}
template <class _AlgPolicy, class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
__rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
- _VSTD::forward_iterator_tag)
+ std::forward_iterator_tag)
{
typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
if (is_trivially_move_assignable<value_type>::value)
@@ -154,7 +154,7 @@ __rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardItera
}
template <class _AlgPolicy, class _BidirectionalIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX14 _BidirectionalIterator
__rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last,
bidirectional_iterator_tag)
@@ -171,7 +171,7 @@ __rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _
}
template <class _AlgPolicy, class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX14 _RandomAccessIterator
__rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
random_access_iterator_tag)
@@ -208,7 +208,7 @@ __rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {
}
template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/rotate_copy.h b/contrib/llvm-project/libcxx/include/__algorithm/rotate_copy.h
index c154649ab98c..6e886cb73cfc 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/rotate_copy.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/rotate_copy.h
@@ -19,11 +19,11 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ForwardIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result)
{
- return _VSTD::copy(__first, __middle, _VSTD::copy(__middle, __last, __result));
+ return std::copy(__first, __middle, std::copy(__middle, __last, __result));
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/sample.h b/contrib/llvm-project/libcxx/include/__algorithm/sample.h
index c7a1898e5308..100b0a466863 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/sample.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/sample.h
@@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _AlgPolicy,
class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_SampleIterator __sample(_PopulationIterator __first,
_PopulationSentinel __last, _SampleIterator __output_iter,
_Distance __n,
@@ -47,20 +47,20 @@ _SampleIterator __sample(_PopulationIterator __first,
if (__r < __sz)
__output_iter[__r] = *__first;
}
- return __output_iter + _VSTD::min(__n, __k);
+ return __output_iter + std::min(__n, __k);
}
template <class _AlgPolicy,
class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_SampleIterator __sample(_PopulationIterator __first,
_PopulationSentinel __last, _SampleIterator __output_iter,
_Distance __n,
_UniformRandomNumberGenerator& __g,
forward_iterator_tag) {
_Distance __unsampled_sz = _IterOps<_AlgPolicy>::distance(__first, __last);
- for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) {
+ for (__n = std::min(__n, __unsampled_sz); __n != 0; ++__first) {
_Distance __r = uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g);
if (__r < __n) {
*__output_iter++ = *__first;
@@ -73,7 +73,7 @@ _SampleIterator __sample(_PopulationIterator __first,
template <class _AlgPolicy,
class _PopulationIterator, class _PopulationSentinel, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
-_LIBCPP_INLINE_VISIBILITY
+_LIBCPP_HIDE_FROM_ABI
_SampleIterator __sample(_PopulationIterator __first,
_PopulationSentinel __last, _SampleIterator __output_iter,
_Distance __n, _UniformRandomNumberGenerator& __g) {
@@ -91,7 +91,7 @@ _SampleIterator __sample(_PopulationIterator __first,
#if _LIBCPP_STD_VER >= 17
template <class _PopulationIterator, class _SampleIterator, class _Distance,
class _UniformRandomNumberGenerator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
_SampleIterator sample(_PopulationIterator __first,
_PopulationIterator __last, _SampleIterator __output_iter,
_Distance __n, _UniformRandomNumberGenerator&& __g) {
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/search.h b/contrib/llvm-project/libcxx/include/__algorithm/search.h
index 5882a04808ba..544e127f7d4c 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/search.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/search.h
@@ -171,7 +171,7 @@ pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1,
}
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
_BinaryPredicate __pred) {
@@ -182,7 +182,7 @@ _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
}
template <class _ForwardIterator1, class _ForwardIterator2>
-_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2) {
return std::search(__first1, __last1, __first2, __last2, __equal_to());
@@ -190,7 +190,7 @@ _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
#if _LIBCPP_STD_VER >= 17
template <class _ForwardIterator, class _Searcher>
-_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) {
return __s(__f, __l).first;
}
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h b/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h
index 023b56dcfcae..c9f2cbb9f7b6 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/shift_left.h
@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY constexpr
+inline _LIBCPP_HIDE_FROM_ABI constexpr
_ForwardIterator
shift_left(_ForwardIterator __first, _ForwardIterator __last,
typename iterator_traits<_ForwardIterator>::difference_type __n)
@@ -45,7 +45,7 @@ shift_left(_ForwardIterator __first, _ForwardIterator __last,
++__m;
}
}
- return _VSTD::move(__m, __last, __first);
+ return std::move(__m, __last, __first);
}
#endif // _LIBCPP_STD_VER >= 20
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/shift_right.h b/contrib/llvm-project/libcxx/include/__algorithm/shift_right.h
index 70aff45fe572..70983e327bcb 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/shift_right.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/shift_right.h
@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY constexpr
+inline _LIBCPP_HIDE_FROM_ABI constexpr
_ForwardIterator
shift_right(_ForwardIterator __first, _ForwardIterator __last,
typename iterator_traits<_ForwardIterator>::difference_type __n)
@@ -40,7 +40,7 @@ shift_right(_ForwardIterator __first, _ForwardIterator __last,
return __last;
}
_ForwardIterator __m = __first + (__d - __n);
- return _VSTD::move_backward(__first, __m, __last);
+ return std::move_backward(__first, __m, __last);
} else if constexpr (__has_bidirectional_iterator_category<_ForwardIterator>::value) {
_ForwardIterator __m = __last;
for (; __n > 0; --__n) {
@@ -49,7 +49,7 @@ shift_right(_ForwardIterator __first, _ForwardIterator __last,
}
--__m;
}
- return _VSTD::move_backward(__first, __m, __last);
+ return std::move_backward(__first, __m, __last);
} else {
_ForwardIterator __ret = __first;
for (; __n > 0; --__n) {
@@ -69,7 +69,7 @@ shift_right(_ForwardIterator __first, _ForwardIterator __last,
auto __lead = __ret;
while (__trail != __ret) {
if (__lead == __last) {
- _VSTD::move(__first, __trail, __ret);
+ std::move(__first, __trail, __ret);
return __ret;
}
++__trail;
@@ -79,8 +79,8 @@ shift_right(_ForwardIterator __first, _ForwardIterator __last,
_ForwardIterator __mid = __first;
while (true) {
if (__lead == __last) {
- __trail = _VSTD::move(__mid, __ret, __trail);
- _VSTD::move(__first, __mid, __trail);
+ __trail = std::move(__mid, __ret, __trail);
+ std::move(__first, __mid, __trail);
return __ret;
}
swap(*__mid, *__trail);
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h b/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h
index 20f0b0275dd9..3a222f7c7f1b 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/sift_down.h
@@ -77,7 +77,7 @@ __sift_down(_RandomAccessIterator __first, _Compare&& __comp,
// check if we are in heap-order
} while (!__comp(*__child_i, __top));
- *__start = _VSTD::move(__top);
+ *__start = std::move(__top);
}
template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/sort.h b/contrib/llvm-project/libcxx/include/__algorithm/sort.h
index 3b594fa4d2a8..567c988ff0d3 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/sort.h
@@ -175,23 +175,26 @@ inline _LIBCPP_HIDE_FROM_ABI void __partially_sorted_swap(_RandomAccessIterator
*__y = __r ? *__y : __tmp;
}
-template <class, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_Compare __c) {
std::__cond_swap<_Compare>(__x2, __x3, __c);
std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c);
}
-template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_Compare __c) {
std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c);
}
-template <class, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_RandomAccessIterator __x4, _Compare __c) {
std::__cond_swap<_Compare>(__x1, __x3, __c);
@@ -201,15 +204,17 @@ __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2,
std::__cond_swap<_Compare>(__x2, __x3, __c);
}
-template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_RandomAccessIterator __x4, _Compare __c) {
std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c);
}
-template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort5_maybe_branchless(
_RandomAccessIterator __x1,
_RandomAccessIterator __x2,
@@ -225,8 +230,9 @@ __sort5_maybe_branchless(
std::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __c);
}
-template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
-inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator,
+ __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI void
__sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3,
_RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) {
std::__sort5<_AlgPolicy, _Compare, _RandomAccessIterator>(
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h b/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h
index 38fa9ce37d00..0e92a0a5f73d 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/stable_partition.h
@@ -144,7 +144,7 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred
{
// TODO: Remove the use of std::get_temporary_buffer
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- __p = _VSTD::get_temporary_buffer<value_type>(__len);
+ __p = std::get_temporary_buffer<value_type>(__len);
_LIBCPP_SUPPRESS_DEPRECATED_POP
__h.reset(__p.first);
}
@@ -298,7 +298,7 @@ __stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator _
{
// TODO: Remove the use of std::get_temporary_buffer
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- __p = _VSTD::get_temporary_buffer<value_type>(__len);
+ __p = std::get_temporary_buffer<value_type>(__len);
_LIBCPP_SUPPRESS_DEPRECATED_POP
__h.reset(__p.first);
}
@@ -315,7 +315,7 @@ _ForwardIterator __stable_partition(
}
template <class _ForwardIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_HIDE_FROM_ABI
_ForwardIterator
stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h b/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h
index dc24218b74dd..175393fc4777 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/stable_sort.h
@@ -230,7 +230,7 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
__d.__set(__len, (value_type*)nullptr);
std::__merge_move_assign<_AlgPolicy, _Compare>(
__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp);
-// _VSTD::__merge<_Compare>(move_iterator<value_type*>(__buff),
+// std::__merge<_Compare>(move_iterator<value_type*>(__buff),
// move_iterator<value_type*>(__buff + __l2),
// move_iterator<_RandomAccessIterator>(__buff + __l2),
// move_iterator<_RandomAccessIterator>(__buff + __len),
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h b/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h
index 5ce5ed8c8845..96eba7484bf4 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/swap_ranges.h
@@ -49,7 +49,7 @@ __swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2
}
template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator2
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator2
swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
return std::__swap_ranges<_ClassicAlgPolicy>(
std::move(__first1), std::move(__last1), std::move(__first2)).second;
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/three_way_comp_ref_type.h b/contrib/llvm-project/libcxx/include/__algorithm/three_way_comp_ref_type.h
index 19c102f4c96c..8fd15c5d66f2 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/three_way_comp_ref_type.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/three_way_comp_ref_type.h
@@ -50,7 +50,7 @@ struct __debug_three_way_comp {
__expected = _Order::greater;
if (__o == _Order::greater)
__expected = _Order::less;
- _LIBCPP_ASSERT(__comp_(__l, __r) == __expected, "Comparator does not induce a strict weak ordering");
+ _LIBCPP_ASSERT_UNCATEGORIZED(__comp_(__l, __r) == __expected, "Comparator does not induce a strict weak ordering");
(void)__l;
(void)__r;
}
@@ -58,7 +58,7 @@ struct __debug_three_way_comp {
// Pass the comparator by lvalue reference. Or in debug mode, using a
// debugging wrapper that stores a reference.
-# if _LIBCPP_ENABLE_DEBUG_MODE
+# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
template <class _Comp>
using __three_way_comp_ref_type = __debug_three_way_comp<_Comp>;
# else
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/transform.h b/contrib/llvm-project/libcxx/include/__algorithm/transform.h
index 4722c154cfff..76b9bb780cf9 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/transform.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/transform.h
@@ -18,7 +18,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _OutputIterator, class _UnaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
{
@@ -28,7 +28,7 @@ transform(_InputIterator __first, _InputIterator __last, _OutputIterator __resul
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _BinaryOperation>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
_OutputIterator
transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
_OutputIterator __result, _BinaryOperation __binary_op)
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/unwrap_range.h b/contrib/llvm-project/libcxx/include/__algorithm/unwrap_range.h
index 2c75c8f49de9..053fd550b302 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/unwrap_range.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/unwrap_range.h
@@ -50,7 +50,7 @@ struct __unwrap_range_impl {
}
_LIBCPP_HIDE_FROM_ABI static constexpr auto __rewrap(const _Iter&, _Iter __iter)
- requires (!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>))
+ requires(!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>))
{
return __iter;
}
@@ -73,10 +73,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __unwrap_range(_Iter __first, _Sent __last)
return __unwrap_range_impl<_Iter, _Sent>::__unwrap(std::move(__first), std::move(__last));
}
-template <
- class _Sent,
- class _Iter,
- class _Unwrapped = decltype(std::__unwrap_range(std::declval<_Iter>(), std::declval<_Sent>()))>
+template < class _Sent, class _Iter, class _Unwrapped>
_LIBCPP_HIDE_FROM_ABI constexpr _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
return __unwrap_range_impl<_Iter, _Sent>::__rewrap(std::move(__orig_iter), std::move(__iter));
}
@@ -86,7 +83,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair<_Unwrapped, _Unwrapped> __unwrap_ra
return std::make_pair(std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last)));
}
-template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
+template <class _Iter, class _Unwrapped>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
}