GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::is_placeholder(3) C++ Standard Libary std::is_placeholder(3)

std::is_placeholder - std::is_placeholder


Defined in header <functional>
template< class T > (since C++11)
struct is_placeholder;


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>


The template may be specialized for any user-defined T type: the specialization must
satisfy UnaryTypeTrait with base characteristic 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.


Helper variable template


template< class T > (since C++17)
inline constexpr int is_placeholder_v = is_placeholder<T>::value;

Inherited from std::integral_constant


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


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


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

// Run this code


#include <iostream>
#include <type_traits>
#include <functional>


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<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) // 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


bind binds one or more arguments to a function object
(C++11) (function template)
_1, _2, _3, _4, ... placeholders for the unbound arguments in a std::bind expression
(C++11) (constant)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.