std::is_placeholder
Aus cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| definiert in Header <functional>
|
||
template< class T > struct is_placeholder; |
(seit C++11) | |
Wenn
T der Typ einer Standard-Platzhalter (_1, _2, _3, ...) ist, dann ist diese Vorlage aus std::integral_constant<int,1>, std::integral_constant<int,2>, std::integral_constant<int,3> bzw. abgeleitet. Wenn T kein Standard Platzhalter Art wird diese Vorlage aus std::integral_constant<int,0> abgeleitet .Original:
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 text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Die Schablone kann für jeden Benutzer-definierten Art, die durch std::bind behandelt werden, als ob es ein Platzhalter für ungebundene Argumente war spezialisiert sein .
Original:
The template may be specialized for any user-defined type which should be treated by std::bind as if it was a placeholder for unbound arguments.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Inherited from std::integral_constant
Member constants
value [statisch] |
placeholder value or 0 for non-placeholder types (public static Mitglied konstanten) |
Member functions
operator int |
wandelt das Objekt int, gibt value Original: converts the object to int, returns value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (öffentliche Elementfunktion) |
Member types
Type
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
int
|
type
|
std::integral_constant<int, value>
|
Beispiel
#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)
<< '\n';
}
Output:
Standard placeholder _5 is for the argument number 5
Adding 2 to 11 selected with a custom placeholder gives 13
Siehe auch
(C++11) |
bindet ein oder mehrere Argumente an eine Funktion Objekt Original: binds one or more arguments to a function object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Funktions-Template) |
(C++11) |
Platzhalter für den ungebundenen Argumente in einer std::bind Ausdruck Original: placeholders for the unbound arguments in a std::bind expression The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (konstanten) |