template <class T> struct bit_xor; |
template <class T> struct bit_xor { T operator() (const T& x, const T& y) const {return x^y;} typedef T first_argument_type; typedef T second_argument_type; typedef T result_type; }; |
成员类型 | 定义 | 注释 |
result_type | T | 成员operator()返回的类型 |
first_argument_type | T | 成员operator()中第一个参数的类型 |
second_argument_type | T | 成员operator()中第二个参数的类型 |
// bit_xor example #include <iostream> // std::cout #include <functional> // std::bit_xor #include <algorithm> // std::accumulate #include <iterator> // std::end int main () { int flags[] = {1,2,3,4,5,6,7,8,9,10}; int acc = std::accumulate (flags, std::end(flags), 0, std::bit_xor<int>()); std::cout << "xor: " << acc << '\n'; return 0; } |
bit_and | 按位与函数对象类(类模板) |
bit_or | 按位或函数对象类(类模板) |