目录

logical_or

描述 (Description)

它是一个逻辑OR函数对象类和二进制函数对象类,其调用返回其两个参数之间的逻辑“或”操作的结果(由operator ||返回)。

声明 (Declaration)

以下是std :: logical_or的声明。

template <class T> struct logical_or;

C++11

template <class T> struct logical_or;

参数 (Parameters)

T - 它是函数调用的参数和返回类型的一种类型。

返回值 (Return Value)

没有

异常 (Exceptions)

noexcep - 它不会抛出任何异常。

例子 (Example)

在下面的例子中解释了std :: logical_or。

#include <iostream>
#include <functional>
#include <algorithm>
int main () {
   bool foo[] = {true,true,false,false};
   bool bar[] = {true,false,true,false};
   bool result[4];
   std::transform (foo, foo+4, bar, result, std::logical_or<bool>());
   std::cout << std::boolalpha << "Logical OR example as shown below:\n";
   for (int i=0; i<4; i++)
      std::cout << foo[i] << " OR " << bar[i] << " = " << result[i] << "\n";
   return 0;
}

让我们编译并运行上面的程序,这将产生以下结果 -

Logical OR example as shown below:
true OR true = true
true OR false = true
false OR true = true
false OR false = false
↑回到顶部↑
WIKI教程 @2018