Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/include/pstl/internal/algorithm_impl.h
Show All 23 Lines | |||||
#include "pstl_config.h" | #include "pstl_config.h" | ||||
#include "unseq_backend_simd.h" | #include "unseq_backend_simd.h" | ||||
_PSTL_HIDE_FROM_ABI_PUSH | _PSTL_HIDE_FROM_ABI_PUSH | ||||
namespace __pstl { | namespace __pstl { | ||||
namespace __internal { | namespace __internal { | ||||
//------------------------------------------------------------------------ | |||||
// any_of | |||||
//------------------------------------------------------------------------ | |||||
template <class _ForwardIterator, class _Pred> | |||||
bool __brick_any_of(const _ForwardIterator __first, | |||||
const _ForwardIterator __last, | |||||
_Pred __pred, | |||||
/*__is_vector=*/std::false_type) noexcept { | |||||
return std::any_of(__first, __last, __pred); | |||||
}; | |||||
template <class _RandomAccessIterator, class _Pred> | |||||
bool __brick_any_of(const _RandomAccessIterator __first, | |||||
const _RandomAccessIterator __last, | |||||
_Pred __pred, | |||||
/*__is_vector=*/std::true_type) noexcept { | |||||
return __unseq_backend::__simd_or(__first, __last - __first, __pred); | |||||
}; | |||||
template <class _Tag, class _ExecutionPolicy, class _ForwardIterator, class _Pred> | |||||
bool __pattern_any_of( | |||||
_Tag, _ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) noexcept { | |||||
return __internal::__brick_any_of(__first, __last, __pred, typename _Tag::__is_vector{}); | |||||
} | |||||
template <class _IsVector, class _ExecutionPolicy, class _RandomAccessIterator, class _Pred> | |||||
bool __pattern_any_of(__parallel_tag<_IsVector> __tag, | |||||
_ExecutionPolicy&& __exec, | |||||
_RandomAccessIterator __first, | |||||
_RandomAccessIterator __last, | |||||
_Pred __pred) { | |||||
using __backend_tag = typename decltype(__tag)::__backend_tag; | |||||
return __internal::__except_handler([&]() { | |||||
return __internal::__parallel_or( | |||||
__backend_tag{}, | |||||
std::forward<_ExecutionPolicy>(__exec), | |||||
__first, | |||||
__last, | |||||
[__pred](_RandomAccessIterator __i, _RandomAccessIterator __j) { | |||||
return __internal::__brick_any_of(__i, __j, __pred, _IsVector{}); | |||||
}); | |||||
}); | |||||
} | |||||
// [alg.foreach] | // [alg.foreach] | ||||
// for_each_n with no policy | // for_each_n with no policy | ||||
template <class _ForwardIterator, class _Size, class _Function> | template <class _ForwardIterator, class _Size, class _Function> | ||||
_ForwardIterator __for_each_n_it_serial(_ForwardIterator __first, _Size __n, _Function __f) { | _ForwardIterator __for_each_n_it_serial(_ForwardIterator __first, _Size __n, _Function __f) { | ||||
for (; __n > 0; ++__first, --__n) | for (; __n > 0; ++__first, --__n) | ||||
__f(__first); | __f(__first); | ||||
return __first; | return __first; | ||||
▲ Show 20 Lines • Show All 4,359 Lines • Show Last 20 Lines |