![]() |
VOOZH | about |
std :: find_if and std :: find_if_not are algorithm functions in C++ Standard Library in <algorithm> header file. These functions provide an efficient way to search for an element in a container using a predicate function.
This function returns an iterator to the first element in the range [first, last) for which pred(Unary Function) returns true. If no such element is found, the function returns last.
InputIterator find_if (InputIterator first, InputIterator last, UnaryPredicate pred);
The following C++ program illustrates the use of the find_if() function.
The first odd value is 25
This function returns an iterator to the first element in the range [first, last) for which pred(Unary Function) returns false. If no such element is found, the function returns last.
InputIterator find_if_not (InputIterator first, InputIterator last, UnaryPredicate pred);
The following C++ program illustrates the use of the find_if_not() function.
The first non-odd(or even) value is 10
Related Articles: