std::mem_fun
Defined in header <functional> | | |
|---|---|---|
template< class Res, class T > std::mem_fun_t<Res,T> mem_fun( Res (T::*f)() ); | (1) | (until C++17)(deprecated since C++11) |
template< class Res, class T > std::const_mem_fun_t<Res,T> mem_fun( Res (T::*f)() ); | (1) | (until C++17)(deprecated since C++11) |
template< class Res, class T, class Arg > std::mem_fun1_t<Res,T,Arg> mem_fun( Res (T::*f)(Arg) ); | (2) | (until C++17)(deprecated since C++11) |
template< class Res, class T, class Arg > std::const_mem_fun1_t<Res,T,Arg> mem_fun( S (T::*f)(Arg) ); | (2) | (until C++17)(deprecated since C++11) |
创建成员函数包装对象,从模板参数推断目标类型。包装器对象需要指向类型对象的指针。T作为它的第一个参数operator()...
1%29有效呼叫std::mem_fun_t<S,T>(f)或std::const_mem_fun_t<S,T>(f)...
2%29有效呼叫std::mem_fun1_t<S,T>(f)或std::const_mem_fun1_t<S,T>(f)...
这个函数和相关的类型在C++11中被取消,在C++17中被删除,以支持更一般的std::mem_fn和std::bind,它们都从成员函数创建可调用适配器兼容的函数对象。
参数
f | - | pointer to a member function to create a wrapper for |
|---|
返回值
函数对象包装f...
例外
%280%29
注记
之间的区别std::mem_fun和std::mem_fun_ref前者产生一个函数包装器,期望一个指向对象的指针,而后者--一个引用。
例
另见
mem_fun_ref (until C++17) | creates a wrapper from a pointer to member function, callable with a reference to object (function template) |
|---|
© cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

