Apache C++ Standard Library Reference Guide

## binary_negate

Library: General utilities

    binary_negate  binary_function

- Local Index
- Summary
- Synopsis
- Description
- Interface
- Constructor
- Operator
- See Also
- Standards Conformance

### Local Index

#### Members

binary_negate() | operator()() |

### Summary

A function object that returns the complement of the result of its binary predicate

### Synopsis

    #include <functional>

    namespace std {
      template<class Predicate>
      class binary_negate;
    }

### Description

binary_negate is the function object class that is the return type for the function adaptor `not2()`. `not2()`, known as a negator, takes a binary predicate function object as its argument and returns a binary predicate function object that is the complement of the original.

Note that `not2()` works only with function objects that are defined as subclasses of the class binary_function.

### Interface

    namespace std {

      template<class Predicate>
      class binary_negate : public
           binary_function<typename Predicate::first_argument_type,
                           typename Predicate::second_argument_type,
                           bool>
      {
      public:

        typedef typename binary_function<
                  typename Predicate::first_argument_type,
                  typename Predicate::second_argument_type,
                  bool>::second_argument_type second_argument_type;

        explicit binary_negate (const Predicate&);
        bool operator()
             (const typename Predicate::first_argument_type&,
              const typename Predicate::second_argument_type&)
             const;
      };

      // Nonmember Functions

      template <class Predicate>
      binary_negate<Predicate> not2 (const Predicate& pred);
    }

### Constructor

    explicit binary_negate(const Predicate& pred);

Constructs a binary_negate object from predicate `pred`.

### Operator

    bool
    operator()(const first_argument_type& x,
                const second_argument_type& y) const;

Returns the result of `!pred(x,y)`.

### See Also

binary_function, `not2()`, unary_negate

### Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 20.3.5