binary_negate is generally used as a type. The function not2 (also defined in header <functional>) can be used to directly construct an object of this type.
binary_negate is constructed using a binary function object as argument. A copy of this object is used by its member operator() to return true whenever the original object would return false, and false whenever the object would return true, inverting its behavior.
This class is derived from binary_function and is defined as:
| 1 2 3 4 5 6 7 8 9 10 11 12 |
|
binary_negate class is specifically designed to negate function objects (predicates) derived from binary_function (it requires member first_argument_type and second_argument_type).
Members
- constructor
- Constructs an object with the opposite behavior than the object passed as its argument.
- operator()
- Member function returning the opposite of the function object with which the object was constructed.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Output:
First mismatch in bar is 0 First match in bar is 30 |
See also
| not2 | Return negation of binary function object (function template) |
| unary_negate | Generate negation of unary function object class (class template) |
| binary_function | Binary function object base class (class template) |
