目录

logical_not

描述 (Description)

它是一个逻辑NOT函数对象类和一个一元函数对象类,其调用在其参数上返回逻辑“not”操作的结果(由operator返回!)。

声明 (Declaration)

以下是std :: logical_not的声明。

template <class T> struct logical_not;

C++11

template <class T> struct logical_not;

参数 (Parameters)

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

返回值 (Return Value)

没有

异常 (Exceptions)

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

例子 (Example)

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

#include <iostream>
#include <functional>
#include <algorithm>
int main () {
   bool values[] = {true,false};
   bool result[2];
   std::transform (values, values+2, result, std::logical_not<bool>());
   std::cout << std::boolalpha << "Logical NOT Example as shown below:\n";
   for (int i=0; i<2; i++)
      std::cout << "NOT " << values[i] << " = " << result[i] << "\n";
   return 0;
}

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

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