std::is_bind_expression
De cppreference.com
< cpp | utility | functional
![]() | 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. |
Déclaré dans l'en-tête <functional> | ||
template<class T > struct is_bind_expression; | (depuis C++11) | |
Si
T
est le type généré par un appel à std::bind, ce modèle fournit un membre de valeur value constante égale à true. Pour tout autre type, value
est false .Original:
If
T
is the type produced by a call to std::bind, this template provides the member constant value equal true. For any other type, value
is false.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.
Ce modèle peut être spécialisé pour un type défini par l'utilisateur qui doit être traitée par std::bind comme si elle était le type d'une sous-expression bind: si un objet fonction bind généré est invoquée, un argument lié de ce type sera appelée comme une fonction objet et sera donné tous les arguments non liés passées à l'objet bind généré .
Original:
This template may be specialized for a user-defined type which should be treated by std::bind as if it was the type of a bind subexpression: when a bind-generated function object is invoked, a bound argument of this type will be invoked as a function object and will be given all the unbound arguments passed to the bind-generated object.
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.
Sommaire |
Inherited from std::integral_constant
Member constants
value [ statique ]Original: static The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | true si T is a function object generated by std::bind, false autrement Original: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (constante membre statique publique) |
Member functions
operator bool | convertit l'objet en bool, retourne value Original: converts the object to bool, returns value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) |
Member types
Type d' 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 | bool |
type | std::integral_constant<bool, value> |
[modifier]Exemple
#include <iostream>#include <type_traits>#include <functional> struct MyBind {typedefint result_type;int operator()(int a, int b)const{return a + b;}}; namespace std {template<>struct is_bind_expression<MyBind>:public true_type {};} int f(int n1, int n2){return n1+n2;} int main(){// as if bind(f, bind(MyBind::operator(), _1, _2), 2)auto b =std::bind(f, MyBind(), 2); std::cout<<"Adding 2 to the sum of 10 and 11 gives "<< b(10, 11)<<'\n';}
Résultat :
Adding 2 to the sum of 10 and 11 gives 23
[modifier]Voir aussi
(C++11) | liaison de paramètres et application partielle d'un foncteur (fonction générique) |