The std::unary_negate() is a wrapper function object returning the complement of the unary predicate it holds. A wrapper function is a subroutine in a software library or a computer program whose main purpose is to call a second subroutine or a system call with little or no additional computation. An object of type unary_negate are generally constructed using function std::not1().
std::unary_negate<class T> variable_name(Object of class T);
Parameters: The function std::unary_negate() accepts the predicate function object as a parameters and returns the logical compliment of the result generated by calling predicate function.
Return Value: It returns the logical complement of the result by calling predicate function.
Below is the program to illustrate the function std::unary_negate():
Explanation: In the above program arrar arr has elements from 1 to 10 and the number of elements which is greater than equals to 4 is 7.
There are 0 elements with even values!
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.