std:: is_placeholder
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Old binders and adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
헤더에 정의됨
<functional>
|
||
|
template
<
class
T
>
struct is_placeholder ; |
(C++11부터) | |
만약
T
가 표준 플레이스홀더
(_1, _2, _3, ...)
의 타입이라면, 이 템플릿은 각각
std::
integral_constant
<
int
,
1
>
,
std::
integral_constant
<
int
,
2
>
,
std::
integral_constant
<
int
,
3
>
에서 파생됩니다.
만약
T
가 표준 플레이스홀더 타입이 아닌 경우, 이 템플릿은
std::
integral_constant
<
int
,
0
>
에서 파생됩니다.
프로그램은
프로그램 정의 타입
T
에 대해 이 템플릿을 특수화하여
UnaryTypeTrait
을 구현할 수 있으며, 기본 특성으로 양의
N
값을 갖는
std::
integral_constant
<
int
, N
>
을 사용하여
T
가
N
번째
플레이스홀더 타입으로 처리되어야 함을 나타낼 수 있습니다.
std::bind
는 바인딩되지 않은 인수를 위한 플레이스홀더를 감지하기 위해
std::is_placeholder
를 사용합니다.
목차 |
헬퍼 변수 템플릿
|
template
<
class
T
>
constexpr int is_placeholder_v = is_placeholder < T > :: value ; |
(C++17부터) | |
std:: integral_constant 로부터 상속됨
멤버 상수
|
value
[static]
|
플레이스홀더 값 또는
0
(비-플레이스홀더 타입의 경우)
(public static member constant) |
멤버 함수
|
operator int
|
객체를
int
로 변환,
value
반환
(public member function) |
|
operator()
(C++14)
|
value
반환
(public member function) |
멤버 타입
| 타입 | 정의 |
value_type
|
int |
type
|
std:: integral_constant < int , value > |
예제
#include <functional> #include <iostream> #include <type_traits> struct My_2 {} my_2; namespace std { template<> struct is_placeholder<My_2> : public integral_constant<int, 2> {}; } int f(int n1, int n2) { return n1 + n2; } int main() { std::cout << "Standard placeholder _5 is for the argument number " << std::is_placeholder_v<decltype(std::placeholders::_5)> << '\n'; auto b = std::bind(f, my_2, 2); std::cout << "Adding 2 to 11 selected with a custom placeholder gives " << b(10, 11) // the first argument, namely 10, is ignored << '\n'; }
출력:
Standard placeholder _5 is for the argument number 5 Adding 2 to 11 selected with a custom placeholder gives 13
참고 항목
|
(C++11)
|
하나 이상의 인수를 함수 객체에 바인딩합니다
(함수 템플릿) |
|
(C++11)
|
std::bind
표현식에서 바인딩되지 않은 인수들을 위한 플레이스홀더
(상수) |