operator== <functional>
Veröffentlicht: Juli 2016
Testet, ob das aufrufbare Objekt leer ist.
Syntax
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);
Parameter
Fty
Der zu umschließende Funktionstyp.f
Das Funktionsobjektnpc
Ein Nullzeiger.
Hinweise
Beide Operatoren nehmen ein Argument, das einen Verweis auf ein function-Objekt darstellt, und ein Argument, das eine Nullzeigerkonstante ist. Beide geben nur dann true zurück, wenn das function-Objekt ist leer.
Beispiel
// 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);
}
empty == true empty == false
Anforderungen
Header: <functional>
Namespace: std