diff --git a/thrust/thrust/system/detail/generic/logical.h b/thrust/thrust/system/detail/generic/logical.h index 4049140a4b0..d7c8dadf164 100644 --- a/thrust/thrust/system/detail/generic/logical.h +++ b/thrust/thrust/system/detail/generic/logical.h @@ -25,10 +25,8 @@ #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) # pragma system_header #endif // no system header -#include -#include +#include #include -#include THRUST_NAMESPACE_BEGIN namespace system @@ -42,14 +40,16 @@ template _CCCL_HOST_DEVICE bool all_of(thrust::execution_policy& exec, InputIterator first, InputIterator last, Predicate pred) { - return thrust::find_if(exec, first, last, thrust::not_fn(pred)) == last; + // TODO(bgruber): we could implement this even better using an early exit + return thrust::count_if(exec, first, last, thrust::not_fn(pred)) == 0; } template _CCCL_HOST_DEVICE bool any_of(thrust::execution_policy& exec, InputIterator first, InputIterator last, Predicate pred) { - return thrust::find_if(exec, first, last, pred) != last; + // TODO(bgruber): we could implement this even better using an early exit + return thrust::count_if(exec, first, last, pred) > 0; } template