Espacios de nombres
Variantes
Acciones

std::is_bind_expression

De cppreference.com
< cpp‎ | utility‎ | functional
 
 
Biblioteca de servicios
 
Objetos función
Envoltorios de funciones
(C++11)
(C++11)
Aplicación parcial de funciones
(C++20)
(C++11)
is_bind_expression
(C++11)
Invocación de funciones
(C++17)(C++23)
Objeto función identidad
(C++20)
Envoltorios de referencias
(C++11)(C++11)
Envoltorios de operador transparentes
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
Negadores
(C++17)
Buscadores
Comparadores restringidos
Vinculadores y adaptadores antiguos
(hasta C++17)
(hasta C++17)
(hasta C++17)
(hasta C++17)
(hasta C++17)(hasta C++17)(hasta C++17)(hasta C++17)
(hasta C++20)
(hasta C++20)
(hasta C++17)(hasta C++17)
(hasta C++17)(hasta C++17)

(hasta C++17)
(hasta C++17)(hasta C++17)(hasta C++17)(hasta C++17)
(hasta C++20)
(hasta C++20)
 
Definido en el archivo de encabezado <functional>
template< class T >
struct is_bind_expression;
(desde C++11)
Si T es el tipo producido por una llamada a std::bind, esta plantilla proporciona el miembro constante value true igual. Para cualquier otro tipo, es value 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.
Esta plantilla puede ser especializado para un tipo definido por el usuario que debe ser tratado por std::bind como si fuera la de una subexpresión dilema: cuando un objeto función bind generada se invoca un argumento consolidado de este tipo se invocará en función objeto y se le dará todos los argumentos pasados ​​no consolidados con el objeto de vinculación generado por el .
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.

Contenido

Heredado de std::integral_constant

Constantes miembro

value
[estático]
true si T is a function object generated by std::bind, de lo contrario false.
(constante miembro pública estática)

Funciones miembro

operator bool
Convierte el objeto a bool, devuelve value.
(función miembro pública)
operator()
(C++14)
Devuelve value.
(función miembro pública)

Tipos miembro

Tipo Definición
value_type bool
type std::integral_constant<bool, value>

[editar] Ejemplo

#include <iostream>
#include <type_traits>
#include <functional>
 
struct MyBind {
    typedef int 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';
}

Salida:

Adding 2 to the sum of 10 and 11 gives 23

[editar] Ver también

(C++11)
Vincula uno o más argumentos a un objeto función.
(plantilla de función) [editar]