Template Function thrust::all_of(InputIterator, InputIterator, Predicate)

Function Documentation

template<typename InputIterator, typename Predicate>
bool thrust::all_of(InputIterator first, InputIterator last, Predicate pred)

all_of determines whether all elements in a range satify a predicate. Specifically, all_of returns true if pred(*i) is true for every iterator i in the range [first, last) and false otherwise.

#include <thrust/logical.h>
#include <thrust/functional.h>
...
bool A[3] = {true, true, false};

thrust::all_of(A, A + 2, thrust::identity<bool>()); // returns true
thrust::all_of(A, A + 3, thrust::identity<bool>()); // returns false

// empty range
thrust::all_of(A, A, thrust::identity<bool>()); // returns false
Return

true, if all elements satisfy the predicate; false, otherwise.

Parameters
  • first: The beginning of the sequence.

  • last: The end of the sequence.

  • pred: A predicate used to test range elements.

Template Parameters

See

any_of

See

none_of

See

transform_reduce