template <class T> struct bit_or; |
template <class T> struct bit_or { 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_or example #include <iostream> // std::cout #include <functional> // std::bit_or #include <algorithm> // std::transform #include <iterator> // std::end int main () { int values[] = {100,200,300,400,500}; int masks[] = {0xf,0xf,0xf,255,255}; int results[5]; std::transform (values, std::end(values), masks, results, std::bit_or<int>()); std::cout << "results:"; for (const int& x: results) std::cout << ' ' << x; std::cout << '\n'; return 0; } |
bit_and | 按位与函数对象类(类模板) |
bit_xor | 按位异或函数对象类(类模板) |