Returns true if pred returns false for all the elements in the range [first, last] or if the range is empty, and false otherwise.
Template : bool none_of(InputIterator first, InputIterator last, UnaryPredicate pred); first, last Input iterators to the initial and final positions in a sequence. The range used is [first, last], which contains all the elements between first and last, including the element pointed by first but not the element pointed by last. pred Unary function that accepts an element in the range as argument and returns a value convertible to bool. The value returned indicates whether the element fulfills the condition checked by this function. The function shall not modify its argument. This can either be a function pointer or a function object. Return type : true if pred returns false for all the elements in the range [first, last] or if the range is empty, and false otherwise.
Array contains : 2 4 6 8 12 0 No negative elements in the range.
Practical Application :
std :: none_of function returns true if certain condition returns false for all the elements in the range [first, last] or if the range is empty, and false otherwise.
1. Check if array contains all even number or odd or both.
Array contains : 2 4 6 8 12 0 24 32 Array contains even number only
2. To check whether array contains all prime number or not.
Array contains : 4 6 8 12 0 All numbers are composite.
This article is contributed by Sachin Bisht. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Difference between Virtual function and Pure virtual function in C++
- cin get() in C++ with Examples
- Difference between Increment and Decrement Operators
- Map of Vectors in C++ STL with Examples
- Problem in comparing Floating point numbers and how to compare them correctly?
- exit(0) vs exit(1) in C/C++ with Examples
- C++ program to print all Even and Odd numbers from 1 to N
- Reverse the content of a file and store it in another
- Minimum cells to be flipped to get a 2*2 submatrix with equal elements
- Nested Loops in C++ with Examples
- _Find_first() function in C++ bitset with Examples
- _Find_next() function in C++ bitset with Examples
- Left-Right traversal of all the levels of N-ary tree
- Difference between Iterators and Pointers in C/C++ with Examples
- ostream::seekp(pos) method in C++ with Exmaples