function template
<functional>

std::not2

template <class Predicate>  binary_negate<Predicate> not2 (const Predicate& pred);
Return negation of binary function object
Constructs a binary function object (of a binary_negate type) that returns the opposite of pred (as returned by operator !).

It is defined with the same behavior as:
1
2
3
4
template <class Predicate> binary_negate<Predicate> not2 (const Predicate& pred)
{
  return binary_negate<Predicate>(pred);
}

Parameters

Predicate
Binary function object derived from binary_function.

Return value

A binary function object with the opposite behavior of pred.
See binary_negate.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// not2 example
#include <iostream>     // std::cout
#include <functional>   // std::not2, std::equal_to
#include <algorithm>    // std::mismatch
#include <utility>      // std::pair

int main () {
  int foo[] = {10,20,30,40,50};
  int bar[] = {0,15,30,45,60};
  std::pair<int*,int*> firstmatch,firstmismatch;
  firstmismatch = std::mismatch (foo, foo+5, bar, std::equal_to<int>());
  firstmatch = std::mismatch (foo, foo+5, bar, std::not2(std::equal_to<int>()));
  std::cout << "First mismatch in bar is " << *firstmismatch.second << '\n';
  std::cout << "First match in bar is " << *firstmatch.second << '\n';
  return 0;
}


First mismatch in bar is 0
First match in bar is 30


See also