From cppreference.com
template<classT>structis_bind_expression;(since C++11)If T is a type produced by a call to
(but not
or
), this template is derived from
. For any other type (unless user-specialized), this template is derived from
.
A program may specialize this template for a
T to implement
with base characteristic of
to indicate that T should be treated by
as if it were 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.
Helper variable template
template<classT>constexprboolis_bind_expression_v=is_bind_expression<T>::value;(since C++17)Inherited from
Member constants
value
[static]
true if T is a function object generated by
, false otherwise
(public static member constant)Member functions
operator bool
converts the object to bool, returns value
(public member function)operator()
(C++14)
returns value
(public member function)Member types
Type Definition value_typebooltypestd::integral_constant<bool,value>Example
Run this code
#include<functional>#include<iostream>#include<type_traits>structMyBind{typedefintresult_type;intoperator()(inta,intb)const{returna+b;}};namespacestd{template<>structis_bind_expression<MyBind>:publictrue_type{};}intf(intn1,intn2){returnn1+n2;}intmain(){// as if bind(f, bind(MyBind(), _1, _2), 2)autob=std::bind(f,MyBind(),2);std::cout<<"Adding 2 to the sum of 10 and 11 gives "<<b(10,11)<<'\n';}Output:
Adding 2 to the sum of 10 and 11 gives 23 Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior
C++11 program-defined specializations could
only be derived from
can be derived from
See also
(C++11)
binds one or more arguments to a function object
(function template)