function::operator unspecified

호출할 수 있는 개체를 저장 하는 경우 테스트가 있습니다.

operator unspecified();

설명

에 변환 될 값을 반환 하는 연산자 bool 만 개체가 비어 있지 않은 경우 true 값입니다.이 개체가 비어 있는지 여부를 테스트할 수 있습니다.

예제

 

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

요구 사항

헤더: <functional>

네임 스페이스: std

참고 항목

참조

function Class

bad_function_call Class