std::is_bind_expression
来自cppreference.com
                    
                                        
                    < cpp | utility | functional
                    
                                                            
                    |   定义于头文件  <functional>
  | 
||
|   template< class T > struct is_bind_expression;  | 
(C++11 起) | |
若 T 是调用 std::bind 产生的类型,则此模板从 std::true_type 导出。对于任何其他类型,此模板从 std::false_type 导出。
此模板可对用户定义类型 T 特化,以实现一元类型特征 (UnaryTypeTrait) ,其基特征为 std::true_type 指示 T 应被处理成如同它是 bind 子表达式的类型:调用 bind 生成的函数对象时,此类型的被绑定参数将作为函数对象调用,且将被给予传递给 bind 生成对象的所有未绑定参数。
辅助变量模板
|   template< class T > inline constexpr bool is_bind_expression_v = is_bind_expression<T>::value;  | 
(C++17 起) | |
继承自 std::integral_constant
成员常量
|    value [静态]  | 
   若 T 是 std::bind 生成的函数对象则为 true ,否则为 false  (公开静态成员常量)  | 
成员函数
|    operator bool  | 
   转换对象为 bool ,返回 value  (公开成员函数)  | 
|    operator() (C++14)  | 
   返回 value  (公开成员函数)  | 
成员类型
| 类型 | 定义 | 
  value_type
 | 
  bool
 | 
  type
 | 
std::integral_constant<bool, value> | 
示例
运行此代码
#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() { // 如同 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'; }
输出:
Adding 2 to the sum of 10 and 11 gives 23
参阅
|    (C++11)  | 
  绑定一或多个实参到函数对象  (函数模板)  |