diff options
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__numeric')
15 files changed, 160 insertions, 78 deletions
diff --git a/contrib/llvm-project/libcxx/include/__numeric/accumulate.h b/contrib/llvm-project/libcxx/include/__numeric/accumulate.h index d75c16ead2f2..1ab6c4b616db 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/accumulate.h +++ b/contrib/llvm-project/libcxx/include/__numeric/accumulate.h @@ -23,13 +23,13 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _Tp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) { for (; __first != __last; ++__first) #if _LIBCPP_STD_VER >= 20 - __init = _VSTD::move(__init) + *__first; + __init = std::move(__init) + *__first; #else __init = __init + *__first; #endif @@ -37,13 +37,13 @@ accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) } template <class _InputIterator, class _Tp, class _BinaryOperation> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op) { for (; __first != __last; ++__first) #if _LIBCPP_STD_VER >= 20 - __init = __binary_op(_VSTD::move(__init), *__first); + __init = __binary_op(std::move(__init), *__first); #else __init = __binary_op(__init, *__first); #endif diff --git a/contrib/llvm-project/libcxx/include/__numeric/adjacent_difference.h b/contrib/llvm-project/libcxx/include/__numeric/adjacent_difference.h index 4b06f9f29f8d..31ffe9c04a1d 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/adjacent_difference.h +++ b/contrib/llvm-project/libcxx/include/__numeric/adjacent_difference.h @@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _OutputIterator> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { @@ -36,18 +36,18 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat { typename iterator_traits<_InputIterator>::value_type __val(*__first); #if _LIBCPP_STD_VER >= 20 - *__result = __val - _VSTD::move(__acc); + *__result = __val - std::move(__acc); #else *__result = __val - __acc; #endif - __acc = _VSTD::move(__val); + __acc = std::move(__val); } } return __result; } template <class _InputIterator, class _OutputIterator, class _BinaryOperation> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOperation __binary_op) @@ -60,11 +60,11 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat { typename iterator_traits<_InputIterator>::value_type __val(*__first); #if _LIBCPP_STD_VER >= 20 - *__result = __binary_op(__val, _VSTD::move(__acc)); + *__result = __binary_op(__val, std::move(__acc)); #else *__result = __binary_op(__val, __acc); #endif - __acc = _VSTD::move(__val); + __acc = std::move(__val); } } return __result; diff --git a/contrib/llvm-project/libcxx/include/__numeric/exclusive_scan.h b/contrib/llvm-project/libcxx/include/__numeric/exclusive_scan.h index b6091f153a46..8b4a5c820dd9 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/exclusive_scan.h +++ b/contrib/llvm-project/libcxx/include/__numeric/exclusive_scan.h @@ -26,17 +26,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b) { if (__first != __last) { _Tp __tmp(__b(__init, *__first)); while (true) { - *__result = _VSTD::move(__init); + *__result = std::move(__init); ++__result; ++__first; if (__first == __last) break; - __init = _VSTD::move(__tmp); + __init = std::move(__tmp); __tmp = __b(__init, *__first); } } @@ -44,9 +44,9 @@ exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __ } template <class _InputIterator, class _OutputIterator, class _Tp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init) { - return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>()); + return std::exclusive_scan(__first, __last, __result, __init, std::plus<>()); } #endif // _LIBCPP_STD_VER >= 17 diff --git a/contrib/llvm-project/libcxx/include/__numeric/gcd_lcm.h b/contrib/llvm-project/libcxx/include/__numeric/gcd_lcm.h index 1e5ab5713d7f..693be704af29 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/gcd_lcm.h +++ b/contrib/llvm-project/libcxx/include/__numeric/gcd_lcm.h @@ -34,7 +34,7 @@ template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source template <typename _Result, typename _Source> struct __ct_abs<_Result, _Source, true> { - _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { if (__t >= 0) return __t; @@ -45,7 +45,7 @@ struct __ct_abs<_Result, _Source, true> { template <typename _Result, typename _Source> struct __ct_abs<_Result, _Source, false> { - _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { return __t; } }; @@ -55,11 +55,11 @@ _LIBCPP_CONSTEXPR _LIBCPP_HIDDEN _Tp __gcd(_Tp __m, _Tp __n) { static_assert((!is_signed<_Tp>::value), ""); - return __n == 0 ? __m : _VSTD::__gcd<_Tp>(__n, __m % __n); + return __n == 0 ? __m : std::__gcd<_Tp>(__n, __m % __n); } template<class _Tp, class _Up> -_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp,_Up> gcd(_Tp __m, _Up __n) { @@ -68,13 +68,13 @@ gcd(_Tp __m, _Up __n) static_assert((!is_same<__remove_cv_t<_Up>, bool>::value), "Second argument to gcd cannot be bool" ); using _Rp = common_type_t<_Tp,_Up>; using _Wp = make_unsigned_t<_Rp>; - return static_cast<_Rp>(_VSTD::__gcd( + return static_cast<_Rp>(std::__gcd( static_cast<_Wp>(__ct_abs<_Rp, _Tp>()(__m)), static_cast<_Wp>(__ct_abs<_Rp, _Up>()(__n)))); } template<class _Tp, class _Up> -_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp,_Up> lcm(_Tp __m, _Up __n) { @@ -85,7 +85,7 @@ lcm(_Tp __m, _Up __n) return 0; using _Rp = common_type_t<_Tp,_Up>; - _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / _VSTD::gcd(__m, __n); + _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / std::gcd(__m, __n); _Rp __val2 = __ct_abs<_Rp, _Up>()(__n); _LIBCPP_ASSERT_UNCATEGORIZED((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm"); return __val1 * __val2; diff --git a/contrib/llvm-project/libcxx/include/__numeric/inclusive_scan.h b/contrib/llvm-project/libcxx/include/__numeric/inclusive_scan.h index bd963446027d..162b9e688433 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/inclusive_scan.h +++ b/contrib/llvm-project/libcxx/include/__numeric/inclusive_scan.h @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _Tp __init) { for (; __first != __last; ++__first, (void)++__result) { __init = __b(__init, *__first); @@ -34,23 +34,23 @@ inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __ } template <class _InputIterator, class _OutputIterator, class _BinaryOp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b) { if (__first != __last) { typename iterator_traits<_InputIterator>::value_type __init = *__first; *__result++ = __init; if (++__first != __last) - return _VSTD::inclusive_scan(__first, __last, __result, __b, __init); + return std::inclusive_scan(__first, __last, __result, __b, __init); } return __result; } template <class _InputIterator, class _OutputIterator> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator inclusive_scan(_InputIterator __first, +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { - return _VSTD::inclusive_scan(__first, __last, __result, _VSTD::plus<>()); + return std::inclusive_scan(__first, __last, __result, std::plus<>()); } #endif // _LIBCPP_STD_VER >= 17 diff --git a/contrib/llvm-project/libcxx/include/__numeric/inner_product.h b/contrib/llvm-project/libcxx/include/__numeric/inner_product.h index 14144257ea9f..48f2ea348987 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/inner_product.h +++ b/contrib/llvm-project/libcxx/include/__numeric/inner_product.h @@ -23,13 +23,13 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator1, class _InputIterator2, class _Tp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) { for (; __first1 != __last1; ++__first1, (void) ++__first2) #if _LIBCPP_STD_VER >= 20 - __init = _VSTD::move(__init) + *__first1 * *__first2; + __init = std::move(__init) + *__first1 * *__first2; #else __init = __init + *__first1 * *__first2; #endif @@ -37,14 +37,14 @@ inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 } template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2) { for (; __first1 != __last1; ++__first1, (void) ++__first2) #if _LIBCPP_STD_VER >= 20 - __init = __binary_op1(_VSTD::move(__init), __binary_op2(*__first1, *__first2)); + __init = __binary_op1(std::move(__init), __binary_op2(*__first1, *__first2)); #else __init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); #endif diff --git a/contrib/llvm-project/libcxx/include/__numeric/iota.h b/contrib/llvm-project/libcxx/include/__numeric/iota.h index eacdc5b6ec7f..473ca969d8ec 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/iota.h +++ b/contrib/llvm-project/libcxx/include/__numeric/iota.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _ForwardIterator, class _Tp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value) { diff --git a/contrib/llvm-project/libcxx/include/__numeric/midpoint.h b/contrib/llvm-project/libcxx/include/__numeric/midpoint.h index 5325f5e6b322..c92e450767c9 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/midpoint.h +++ b/contrib/llvm-project/libcxx/include/__numeric/midpoint.h @@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 20 template <class _Tp> -_LIBCPP_INLINE_VISIBILITY constexpr +_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_Tp>, _Tp> midpoint(_Tp __a, _Tp __b) noexcept _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK @@ -53,14 +53,14 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK template <class _TPtr> -_LIBCPP_INLINE_VISIBILITY constexpr +_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<is_pointer_v<_TPtr> && is_object_v<remove_pointer_t<_TPtr>> && ! is_void_v<remove_pointer_t<_TPtr>> && (sizeof(remove_pointer_t<_TPtr>) > 0), _TPtr> midpoint(_TPtr __a, _TPtr __b) noexcept { - return __a + _VSTD::midpoint(ptrdiff_t(0), __b - __a); + return __a + std::midpoint(ptrdiff_t(0), __b - __a); } @@ -73,7 +73,7 @@ template <typename _Fp> _LIBCPP_HIDE_FROM_ABI constexpr _Fp __fp_abs(_Fp __f) { return __f >= 0 ? __f : -__f; } template <class _Fp> -_LIBCPP_INLINE_VISIBILITY constexpr +_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<is_floating_point_v<_Fp>, _Fp> midpoint(_Fp __a, _Fp __b) noexcept { diff --git a/contrib/llvm-project/libcxx/include/__numeric/partial_sum.h b/contrib/llvm-project/libcxx/include/__numeric/partial_sum.h index 76349750b62a..49afcbb746f5 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/partial_sum.h +++ b/contrib/llvm-project/libcxx/include/__numeric/partial_sum.h @@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _OutputIterator> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { @@ -35,7 +35,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) { #if _LIBCPP_STD_VER >= 20 - __t = _VSTD::move(__t) + *__first; + __t = std::move(__t) + *__first; #else __t = __t + *__first; #endif @@ -46,7 +46,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res } template <class _InputIterator, class _OutputIterator, class _BinaryOperation> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOperation __binary_op) @@ -58,7 +58,7 @@ partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __res for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) { #if _LIBCPP_STD_VER >= 20 - __t = __binary_op(_VSTD::move(__t), *__first); + __t = __binary_op(std::move(__t), *__first); #else __t = __binary_op(__t, *__first); #endif diff --git a/contrib/llvm-project/libcxx/include/__numeric/pstl_reduce.h b/contrib/llvm-project/libcxx/include/__numeric/pstl_reduce.h index 163e0078e10e..b19972a46db7 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/pstl_reduce.h +++ b/contrib/llvm-project/libcxx/include/__numeric/pstl_reduce.h @@ -33,16 +33,16 @@ template <class _ExecutionPolicy, class _BinaryOperation = plus<>, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _Tp -reduce(_ExecutionPolicy&& __policy, - _ForwardIterator __first, - _ForwardIterator __last, - _Tp __init, - _BinaryOperation __op = {}) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_Tp> +__reduce(_ExecutionPolicy&& __policy, + _ForwardIterator&& __first, + _ForwardIterator&& __last, + _Tp&& __init, + _BinaryOperation&& __op = {}) noexcept { return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Tp __g_init, _BinaryOperation __g_op) { - return std::transform_reduce( + return std::__transform_reduce( __policy, std::move(__g_first), std::move(__g_last), std::move(__g_init), std::move(__g_op), __identity{}); }, std::move(__first), @@ -53,19 +53,50 @@ reduce(_ExecutionPolicy&& __policy, template <class _ExecutionPolicy, class _ForwardIterator, + class _Tp, + class _BinaryOperation = plus<>, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI __iter_value_type<_ForwardIterator> -reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { +_LIBCPP_HIDE_FROM_ABI _Tp +reduce(_ExecutionPolicy&& __policy, + _ForwardIterator __first, + _ForwardIterator __last, + _Tp __init, + _BinaryOperation __op = {}) { + auto __res = std::__reduce(__policy, std::move(__first), std::move(__last), std::move(__init), std::move(__op)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + +template <class _ExecutionPolicy, + class _ForwardIterator, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_value_type<_ForwardIterator>> +__reduce(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last) noexcept { return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last) { - return std::reduce(__policy, __g_first, __g_last, __iter_value_type<_ForwardIterator>()); + return std::__reduce( + __policy, std::move(__g_first), std::move(__g_last), __iter_value_type<_ForwardIterator>()); }, std::move(__first), std::move(__last)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI __iter_value_type<_ForwardIterator> +reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { + auto __res = std::__reduce(__policy, std::move(__first), std::move(__last)); + 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/__numeric/pstl_transform_reduce.h b/contrib/llvm-project/libcxx/include/__numeric/pstl_transform_reduce.h index b7c9d8d288f9..112772604666 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/pstl_transform_reduce.h +++ b/contrib/llvm-project/libcxx/include/__numeric/pstl_transform_reduce.h @@ -16,7 +16,7 @@ #include <__numeric/transform_reduce.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 @@ -34,27 +34,57 @@ template <class _ExecutionPolicy, class _BinaryOperation2, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( +_LIBCPP_HIDE_FROM_ABI optional<_Tp> __transform_reduce( _ExecutionPolicy&&, + _ForwardIterator1&& __first1, + _ForwardIterator1&& __last1, + _ForwardIterator2&& __first2, + _Tp&& __init, + _BinaryOperation1&& __reduce, + _BinaryOperation2&& __transform) noexcept { + using _Backend = typename __select_backend<_RawPolicy>::type; + return std::__pstl_transform_reduce<_RawPolicy>( + _Backend{}, + std::move(__first1), + std::move(__last1), + std::move(__first2), + std::move(__init), + std::move(__reduce), + std::move(__transform)); +} + +template <class _ExecutionPolicy, + class _ForwardIterator1, + class _ForwardIterator2, + class _Tp, + class _BinaryOperation1, + class _BinaryOperation2, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( + _ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _Tp __init, _BinaryOperation1 __reduce, _BinaryOperation2 __transform) { - using _Backend = typename __select_backend<_RawPolicy>::type; - return std::__pstl_transform_reduce<_RawPolicy>( - _Backend{}, + auto __res = std::__transform_reduce( + __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__init), std::move(__reduce), std::move(__transform)); + + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); } // This overload doesn't get a customization point because it's trivial to detect (through e.g. -// __is_trivial_plus_operation) when specializing the more general variant, which should always be preferred +// __desugars_to) when specializing the more general variant, which should always be preferred template <class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, @@ -76,13 +106,13 @@ template <class _ExecutionPolicy, class _UnaryOperation, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_Tp>> __transform_reduce( _ExecutionPolicy&&, - _ForwardIterator __first, - _ForwardIterator __last, - _Tp __init, - _BinaryOperation __reduce, - _UnaryOperation __transform) { + _ForwardIterator&& __first, + _ForwardIterator&& __last, + _Tp&& __init, + _BinaryOperation&& __reduce, + _UnaryOperation&& __transform) noexcept { using _Backend = typename __select_backend<_RawPolicy>::type; return std::__pstl_transform_reduce<_RawPolicy>( _Backend{}, @@ -93,6 +123,27 @@ _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( std::move(__transform)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Tp, + class _BinaryOperation, + class _UnaryOperation, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( + _ExecutionPolicy&& __policy, + _ForwardIterator __first, + _ForwardIterator __last, + _Tp __init, + _BinaryOperation __reduce, + _UnaryOperation __transform) { + auto __res = std::__transform_reduce( + __policy, std::move(__first), std::move(__last), std::move(__init), std::move(__reduce), std::move(__transform)); + 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/__numeric/reduce.h b/contrib/llvm-project/libcxx/include/__numeric/reduce.h index 8daa7cf60e25..eb53053c26a6 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/reduce.h +++ b/contrib/llvm-project/libcxx/include/__numeric/reduce.h @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 template <class _InputIterator, class _Tp, class _BinaryOp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp reduce(_InputIterator __first, _InputIterator __last, +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b) { for (; __first != __last; ++__first) __init = __b(std::move(__init), *__first); @@ -31,15 +31,15 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp reduce(_InputIterato } template <class _InputIterator, class _Tp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp reduce(_InputIterator __first, _InputIterator __last, +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp reduce(_InputIterator __first, _InputIterator __last, _Tp __init) { - return _VSTD::reduce(__first, __last, __init, _VSTD::plus<>()); + return std::reduce(__first, __last, __init, std::plus<>()); } template <class _InputIterator> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename iterator_traits<_InputIterator>::value_type +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename iterator_traits<_InputIterator>::value_type reduce(_InputIterator __first, _InputIterator __last) { - return _VSTD::reduce(__first, __last, typename iterator_traits<_InputIterator>::value_type{}); + return std::reduce(__first, __last, typename iterator_traits<_InputIterator>::value_type{}); } #endif diff --git a/contrib/llvm-project/libcxx/include/__numeric/transform_exclusive_scan.h b/contrib/llvm-project/libcxx/include/__numeric/transform_exclusive_scan.h index 3d5574c7d0a0..b8d7bd2c4463 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/transform_exclusive_scan.h +++ b/contrib/llvm-project/libcxx/include/__numeric/transform_exclusive_scan.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator transform_exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, diff --git a/contrib/llvm-project/libcxx/include/__numeric/transform_inclusive_scan.h b/contrib/llvm-project/libcxx/include/__numeric/transform_inclusive_scan.h index ee9168928aec..e1b818ca58e0 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/transform_inclusive_scan.h +++ b/contrib/llvm-project/libcxx/include/__numeric/transform_inclusive_scan.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init) @@ -36,7 +36,7 @@ transform_inclusive_scan(_InputIterator __first, _InputIterator __last, } template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator transform_inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _UnaryOp __u) @@ -45,7 +45,7 @@ transform_inclusive_scan(_InputIterator __first, _InputIterator __last, typename iterator_traits<_InputIterator>::value_type __init = __u(*__first); *__result++ = __init; if (++__first != __last) - return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init); + return std::transform_inclusive_scan(__first, __last, __result, __b, __u, __init); } return __result; diff --git a/contrib/llvm-project/libcxx/include/__numeric/transform_reduce.h b/contrib/llvm-project/libcxx/include/__numeric/transform_reduce.h index 7e47f34d374e..04d02b6c6a6b 100644 --- a/contrib/llvm-project/libcxx/include/__numeric/transform_reduce.h +++ b/contrib/llvm-project/libcxx/include/__numeric/transform_reduce.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator __first, +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b, _UnaryOp __u) { for (; __first != __last; ++__first) @@ -31,7 +31,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_In } template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOp1, class _BinaryOp2> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator1 __first1, +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init, _BinaryOp1 __b1, _BinaryOp2 __b2) { @@ -41,11 +41,11 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_In } template <class _InputIterator1, class _InputIterator2, class _Tp> -_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator1 __first1, +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) { - return _VSTD::transform_reduce(__first1, __last1, __first2, _VSTD::move(__init), _VSTD::plus<>(), - _VSTD::multiplies<>()); + return std::transform_reduce(__first1, __last1, __first2, std::move(__init), std::plus<>(), + std::multiplies<>()); } #endif |
