template <class T> struct bit_or;
123456
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; };
operator()
x|y
123456789101112
// bit_or example #include <iostream> // std::cout #include <functional> // std::bit_or #include <numeric> // std::accumulate #include <iterator> // std::end int main () { int flags[] = {1,2,4,8,16,32,64,128}; int acc = std::accumulate (flags, std::end(flags), 0, std::bit_or<int>()); std::cout << "accumulated: " << acc << '\n'; return 0; }
accumulated: 255