Namespaces
Variants

operator==(std::move_only_function)

cppreference.net에서 가져옴
 
 
유틸리티 라이브러리
일반 유틸리티
관계 연산자 (C++20에서 폐지됨)
정수 비교 함수
(C++20)(C++20)(C++20)    
(C++20)
Swap 및 타입 연산
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
공통 어휘 타입
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)



 
함수 객체
함수 호출
(C++17)(C++23)
항등 함수 객체
(C++20)
투명 연산자 래퍼
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

이전의 바인더와 어댑터
(C++17까지*)
(C++17까지*)
(C++17까지*)
(C++17까지*)  
(C++17까지*)
(C++17까지*)(C++17까지*)(C++17까지*)(C++17까지*)
(C++20까지*)
(C++20까지*)
(C++17까지*)(C++17까지*)
(C++17까지*)(C++17까지*)

(C++17까지*)
(C++17까지*)(C++17까지*)(C++17까지*)(C++17까지*)
(C++20까지*)
(C++20까지*)
 
 
friend bool operator==( const std::move_only_function& f, std::nullptr_t ) noexcept;
(C++23부터)

래퍼 f에 호출 가능한 대상이 있는지 여부를 std::nullptr_t와 공식적으로 비교하여 확인합니다. 빈 래퍼(즉, 대상이 없는 래퍼)는 같음으로 비교되고, 비어 있지 않은 함수는 같지 않음으로 비교됩니다.

이 함수는 일반적인 비한정 또는 한정 조회에 표시되지 않으며, 인자 종속 조회를 통해서만 찾을 수 있습니다. 이때 std::move_only_function<FunctionType>은(는) 인자의 연관된 클래스여야 합니다.

!= 연산자는 에서 합성operator==됩니다.

매개변수

f - std::move_only_function 비교 대상

반환값

! f .

예제

#include <functional>
#include <iostream>
#include <utility>
using SomeVoidFunc = std::move_only_function<void(int) const>;
class C {
public:
    C() = default;
    C(SomeVoidFunc func) : void_func_(std::move(func)) {}
    void default_func(int i) const { std::cout << i << '\n'; };
    void operator()() const
    {
        if (void_func_ == nullptr) // nullptr과의 특수화된 비교
            default_func(7);
        else
            void_func_(7);
    }
private:
    SomeVoidFunc void_func_{};
};
void user_func(int i)
{
    std::cout << (i + 1) << '\n';
}
int main()
{
    C c1;
    C c2(user_func);
    c1();
    c2();
}

출력:

7
8

참고 항목

std::move_only_function 이 대상을 가지고 있는지 확인합니다
(public member function)
(removed in C++20)
std::function 과 nullptr 을 비교합니다
(function template)