function::operator unspecified
Tests if stored callable object exists.
operator unspecified();
설명
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.
예제
// 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);
}
요구 사항
헤더: <기능>
네임스페이스: std