std::is_bind_expression

Header: <functional>

If T is a type produced by a call to std::bind (but not std::bind_front or std::bind_back), this template is derived from std::true_type. For any other type (unless user-specialized), this template is derived from std::false_type.

# Declarations

template< class T >
struct is_bind_expression;

(since C++11)

# Example

#include <functional>
#include <iostream>
#include <type_traits>
 
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(), _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';
}

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 2010C++11program-defined specializations couldonly be derived from std::false_typecan be derived fromstd::true_type

# See also