Namespaces
Variants

std::is_bind_expression

cppreference.net에서 가져옴
 
 
유틸리티 라이브러리
일반 유틸리티
관계 연산자 (C++20에서 폐지됨)
정수 비교 함수
(C++20)(C++20)(C++20)    
(C++20)
교체 및 타입 연산
(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까지*)
 
헤더 <functional>
template< class T >
struct is_bind_expression;
에 정의됨 (C++11부터)

만약 T가 std::bind (그러나 std::bind_front 또는 std::bind_front는 제외) 호출에 의해 생성된 타입이라면, 이 템플릿은 std::true_type에서 파생됩니다. 다른 모든 타입에 대해 (사용자 전문화가 없다면) 이 템플릿은 std::false_type에서 파생됩니다.

프로그램은 이 템플릿을 프로그램 정의 타입 T에 대해 전문화하여, 기본 특성이 std::true_type인 UnaryTypeTrait을 구현할 수 있습니다. 이는 T가 바인드 하위 표현식의 타입인 것처럼 std::bind에 의해 처리되어야 함을 나타냅니다. 즉, 바인드 생성 함수 객체가 호출될 때, 이 타입의 바인드된 인자는 함수 객체로 호출되며, 바인드 생성 객체에 전달된 모든 바인드되지 않은 인자를 전달받게 됩니다.

헬퍼 변수 템플릿

template < class T >
constexpr bool is_bind_expression_v = is_bind_expression < T > :: value ;
(C++17부터)

std:: integral_constant 에서 상속됨

멤버 상수

value
[static]
true 만약 T 가 std::bind 에 의해 생성된 함수 객체인 경우, false 그렇지 않은 경우
(public static member constant)

멤버 함수

operator bool
객체를 bool 로 변환, value 반환
(public member function)
operator()
(C++14)
value 반환
(public member function)

멤버 타입

타입 정의
value_type bool
type std:: integral_constant < bool , value >

예제

#include <functional>
#include <iostream>
#include <type_traits>
struct MyBind
{
    typedef int result_type;
    int operator()(int a, int b) const { return a + b; }
};
namespace std
{
    template<>
    struct is_bind_expression<MyBind> : public true_type {};
}
int f(int n1, int n2)
{
    return n1 + n2;
}
int main()
{
    // as if bind(f, bind(MyBind(), _1, _2), 2)
    auto b = std::bind(f, MyBind(), 2); 
    std::cout << "Adding 2 to the sum of 10 and 11 gives " << b(10, 11) << '\n';
}

출력:

Adding 2 to the sum of 10 and 11 gives 23

결함 보고서

다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 2010 C++11 프로그램 정의 특수화는
std::false_type 에서만 파생될 수 있었음
std::true_type 에서도 파생될 수 있음

참고 항목

(C++11)
하나 이상의 인수를 함수 객체에 바인딩합니다
(함수 템플릿)