template <class T> struct logical_not; |
C++98 |
template <class T> struct logical_not : unary_function <T,bool> { bool operator() (const T& x) const {return !x;} }; |
成员类型 | 定义 | 注释 |
argument_type | T | 成员operator()中参数的类型 |
result_type | bool | 成员operator()返回的类型 |
T operator() (const T& x) |
// 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_and | 逻辑与函数对象类(类模板) |
logical_or | 逻辑或函数对象类(类模板) |
unary_function | 一元函数对象基类 (类模板) |