operator== <functional>

,如果可调用的对象为空,测试。

template<class Fty>
    bool operator==(const function<Fty>& f, null_ptr_type npc);
template<class Fty>
    bool operator==(null_ptr_type npc, const function<Fty>& f);

参数

  • Fty
    包装的函数类型。

  • f
    函数对象

  • npc
    null 指针。

备注

运算符采用是对 function 对象和参数是一个空指针常数的参数。 ,仅当 function 对象为空,两个返回 true。

示例

 

// std_tr1__functional__operator_eq.cpp 
// compile with: /EHsc 
#include <functional> 
#include <iostream> 
 
int neg(int val) 
    { 
    return (-val); 
    } 
 
int main() 
    { 
    std::function<int (int)> fn0; 
    std::cout << std::boolalpha << "empty == " 
        << (fn0 == 0) << std::endl; 
 
    std::function<int (int)> fn1(neg); 
    std::cout << std::boolalpha << "empty == " 
        << (fn1 == 0) << std::endl; 
 
    return (0); 
    } 
 
  

要求

**标题:**functional

命名空间: std

请参见

参考

operator!= <functional>

其他资源

functional 成员