std::all_of, std::any_of, std::none_of

From Cppreference

Jump to: navigation, search
Defined in header <algorithm>

template< class InputIterator, class UnaryPredicate >
bool all_of( InputIterator first, InputIterator last, UnaryPredicate p );
(C++0x feature)
template< class InputIterator, class UnaryPredicate >
bool any_of( InputIterator first, InputIterator last, UnaryPredicate p );
(C++0x feature)
template< class InputIterator, class UnaryPredicate >
bool none_of( InputIterator first, InputIterator last, UnaryPredicate p );
(C++0x feature)

1) Checks if unary predicate p returns true for all elements in the range [first, last).

2) Checks if unary predicate p returns true for at least one element in the range [first, last).

3) Checks if unary predicate p returns true for none elements in the range [first, last).

Contents

Parameters

first, last - the range of elements to examine
p - unary predicate .

The signature of the predicate function should be equivalent to the following:

bool pred(const Type &a);

The signature does not need to have const &, but the function must not modify the objects passed to it.
The type ​Type​ must be such that an object of type ​InputIterator​ can be dereferenced and then implicitly converted to ​Type​. ​

Return value

true if unary predicate returns true for all elements in the range, false otherwise.

Complexity

linear in the distance between first and last

Equivalent function

Example

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
In other languages