bit_xor
描述 (Description)
它是一个按位XOR函数对象类和二进制函数对象类,其调用返回在其两个参数之间应用按位“异或”操作的结果(由运算符^返回)。
声明 (Declaration)
以下是std :: bit_xor的声明。
template <class T> struct bit_xor;
C++11
template <class T> struct bit_xor;
参数 (Parameters)
T - 它是函数调用的参数和返回类型的一种类型。
返回值 (Return Value)
没有
异常 (Exceptions)
noexcep - 它不会抛出任何异常。
例子 (Example)
在下面的例子中解释了std :: bit_xor。
#include <iostream>
#include <functional>
#include <algorithm>
#include <iterator>
int main () {
int flags[] = {10,20,30,40,50,60,70,80,90,100};
int acc = std::accumulate (flags, std::end(flags), 0, std::bit_xor<int>());
std::cout << "xor: " << acc << '\n';
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 -
xor: 14