std:: is_bind_expression
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Old binders and adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
헤더 파일에 정의됨
<functional>
|
||
|
template
<
class
T
>
struct is_bind_expression ; |
(C++11부터) | |
만약
T
가
std::bind
호출로 생성된 타입인 경우(단,
std::bind_front
또는
std::bind_back
은 제외), 이 템플릿은
std::true_type
에서 파생됩니다. 다른 모든 타입의 경우(사용자 특수화가 없는 한) 이 템플릿은
std::false_type
에서 파생됩니다.
프로그램은
프로그램 정의 타입
T
에 대해 이 템플릿을 특수화하여
UnaryTypeTrait
을 구현할 수 있으며, 기본 특성으로
std::true_type
을 사용하여
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)
|
하나 이상의 인수를 함수 객체에 바인딩합니다
(함수 템플릿) |