operator== <function>

更新 : 2007 年 11 月

呼び出し可能オブジェクトが空であるかどうかをテストします。

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
    function オブジェクト。

  • npc
    null ポインタ。

解説

これらの演算子は、引数として、function オブジェクトへの参照と、null ポインタ定数を受け取ります。どちらも、function オブジェクトが空の場合にのみ、true を返します。

使用例

 

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

必要条件

ヘッダー : <functional>

名前空間 : std::tr1

参照

参照

<functional> (TR1)

operator!= <function>