Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
operator==
Testet, ob das aufrufbare Objekt leer ist.
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 Funktionsobjekt
Npc
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__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
operator!=
Testet, ob das aufrufbare Objekt nicht leer ist.
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 Funktionsobjekt
Npc
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 nicht leer ist.
Beispiel
// std__functional__operator_ne.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 << "not empty == "
<< (fn0 != 0) << std::endl;
std::function<int (int)> fn1(neg);
std::cout << std::boolalpha << "not empty == "
<< (fn1 != 0) << std::endl;
return (0);
}
not empty == false
not empty == true