Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Tests if stored callable object exists.
operator unspecified();
Remarks
The operator returns a value that is convertible to bool with a true value only if the object is not empty. You use it to test whether the object is empty.
Example
// std_tr1__functional__function_operator_bool.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 == " << (bool)fn0 << std::endl;
std::function<int (int)> fn1(neg);
std::cout << std::boolalpha << "not empty == " << (bool)fn1 << std::endl;
return (0);
}
not empty == false not empty == true
Requirements
Header: <functional>
Namespace: std