Namespaces
Variants

std::is_placeholder

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_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을 구현하고 기본 특성을 std::integral_constant<int, N>으로, 양의 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)
하나 이상의 인수를 함수 객체에 바인딩합니다
(함수 템플릿)
std::bind 표현식에서 바인딩되지 않은 인수들을 위한 플레이스홀더
(상수)