---
name: "Negation_functors"
section: "3"
platform: "linux"
package: "libstdc++6-4.1-doc"
version: "4.1.2-25"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/Negation_functors"
---

# Negation\_functors(3)

## NAME

Negators -

## Detailed Description

The functions `not1` and `not2` each take a predicate functor and return an instance of **unary\_negate or binary\_negate, respectively. These classes are functors whose** `operator()` **performs the stored predicate function and then returns the negation of the result.**

**For example, given a vector of integers and a trivial predicate,**

```
  struct IntGreaterThanThree
    : public std::unary_function<int, bool>
  {
      bool operator() (int x) { return x > 3; }
  };
  std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree()));
```

 **The call to** `find_if` **will locate the first index (i) of** `v` **for which '!(v\[i\] \> 3)' is true.**

**The not1/unary\_negate combination works on predicates taking a single argument. The not2/binary\_negate combination works on predicates which take two arguments.**

### Classes

class **binary\_negate**\
 *One of the* **negation functors***.*  class **unary\_negate**\
 *One of the* **negation functors***.*

### Functions

template\<class \_Predicate\> unary\_negate\< \_Predicate \> **not1** (const \_Predicate &\_\_pred)\
 template\<class \_Predicate\> binary\_negate\< \_Predicate \> **not2** (const \_Predicate &\_\_pred)\

## Function Documentation

### unary\_negate\<\_Predicate\> std::not1 (const \_Predicate & \_\_pred)` [inline]`

**One of the negation functors.**

**Definition at line 329 of file stl\_function.h.**

### binary\_negate\<\_Predicate\> std::not2 (const \_Predicate & \_\_pred)` [inline]`

**One of the negation functors.**

**Definition at line 355 of file stl\_function.h.**
