template <class T> struct bit_xor;
123456
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; };
operator()
x^y
123456789101112
// 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; }
xor: 11