<functional>
연산자
연산자==
호출 가능 개체가 비어 있는지 테스트합니다.
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);
매개 변수
Fty
래핑할 함수 형식입니다.
f
함수 개체입니다.
npc
null 포인터입니다.
설명
연산자는 둘 다 function
개체에 대한 참조인 인수와 null 포인터 상수인 인수를 사용합니다. function
개체가 비어 있는 경우에만 둘 다 true를 반환합니다.
예시
// 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!=
호출 가능 개체가 비어 있지 않은지 테스트합니다.
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);
매개 변수
Fty
래핑할 함수 형식입니다.
f
함수 개체입니다.
npc
null 포인터입니다.
설명
연산자는 둘 다 function
개체에 대한 참조인 인수와 null 포인터 상수인 인수를 사용합니다. function
개체가 비어 있지 않은 경우에만 둘 다 true를 반환합니다.
예제
// 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