class template
<functional>
std::logical_nottemplate <class T> struct logical_not;
Logical NOT function object class
Unary function object class whose call returns the result of the logical "not" operation on its argument (as returned by operator !).Generically, function objects are instances of a class with member function operator() defined. This member function allows the object to be used with the same syntax as a function call.
It is defined with the same behavior as:
1
2
3
template <class T> struct logical_not : unary_function <T,bool> {
bool operator() (const T& x) const {return !x;}
};
1
2
3
4
5
template <class T> struct logical_not {
bool operator() (const T& x) const {return !x;}
typedef T argument_type;
typedef bool result_type;
};
operator()
result_type bool Type returned by member operator()
!x
).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// logical_not example
#include <iostream> // std::cout, std::boolalpha
#include <functional> // std::logical_not
#include <algorithm> // std::transform
int main () {
bool values[] = {true,false};
bool result[2];
std::transform (values, values+2, result, std::logical_not<bool>());
std::cout << std::boolalpha << "Logical NOT:\n";
for (int i=0; i<2; i++)
std::cout << "NOT " << values[i] << " = " << result[i] << "\n";
return 0;
}
Logical NOT: NOT true = false NOT false = true
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