function template
<functional>
std::not1template <class Predicate> unary_negate<Predicate> not1 (const Predicate& pred);
Return negation of unary function object
Constructs a unary function object (of a unary_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> unary_negate<Predicate> not1 (const Predicate& pred)
{
return unary_negate<Predicate>(pred);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// not1 example
#include <iostream> // std::cout
#include <functional> // std::not1
#include <algorithm> // std::count_if
struct IsOdd {
bool operator() (const int& x) const {return x%2==1;}
typedef int argument_type;
};
int main () {
int values[] = {1,2,3,4,5};
int cx = std::count_if (values, values+5, std::not1(IsOdd()));
std::cout << "There are " << cx << " elements with even values.\n";
return 0;
}
There are 2 elements with even values.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4