< cpp‎ | utility‎ | functional
Function objects
Function wrappers
Reference wrappers
Operator wrappers
Deprecated binders and adaptors
Defined in header <functional>
template< class T >
struct is_placeholder;
(since C++11)

If T is the type of a standard placeholder (_1, _2, _3, ...), then this template is derived from std::integral_constant<int,1>, std::integral_constant<int,2>, std::integral_constant<int,3>, respectively.

If T is not a standard placeholder type, this template is derived from std::integral_constant<int,0>


Inherited from std::integral_constant

Member constants

placeholder value or 0 for non-placeholder types
(public static member constant)

Member functions

operator int
converts the object to int, returns value
(public member function)

Member types

Type Definition
value_type int
type std::integral_constant<int, value>

The template may be specialized for any user-defined T type: the specialization must satisfy UnaryTypeTrait with BaseCharacteristic of std::integral_constant<int, N> with N > 0 to indicate that T should be treated as N'th placeholder type.

std::bind uses std::is_placeholder to detect placeholders for unbound arguments.

[edit] Example

#include <iostream>
#include <type_traits>
#include <functional>
struct My_2 {
} my_2;
namespace std {
    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<decltype(std::placeholders::_5)>::value
              << '\n';
    auto b = std::bind(f, my_2, 2);
    std::cout << "Adding 2 to 11 selected with a custom placeholder gives " 
              << b(10, 11) 
              << '\n';


Standard placeholder _5 is for the argument number 5
Adding 2 to 11 selected with a custom placeholder gives 13

[edit] See also

binds one or more arguments to a function object
(function template)
placeholders for the unbound arguments in a std::bind expression