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