Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

operator!= <functional>

Tests if callable object is not empty.

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);


The function type to wrap.


The function object


A null pointer.

The operators both take an argument that is a reference to a function object and an argument that is a null pointer constant. Both return true only if the function object is not empty.


// std_tr1__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

Header: <functional>

Namespace: std

© 2015 Microsoft