std::function

翻译:function - C++ Reference (cplusplus.com)
template <class T> function;     // undefined
template <class Ret, class... Args> class function<Ret(Args...)>;

Function wrapper

Class that can wrap any kind of callable element (such as functions and function objects) into a copyable object, and whose type depends solely on its call signature (and not on the callable element type itself).

An object of a function class instantiation can wrap any of the following kinds of callable objects: a function, a function pointer, a pointer to member, or any kind of function object (i.e., an object whose class defines operator(), including closures).

decay copy of the wrapped callable object is stored internally by the object, which becomes the function's target. The specific type of this target callable object is not needed in order to instantiate the function wrapper class; only its call signature.

The function object can be copied and moved around, and can be used to directly invoke the callable object with the specified call signature (see member operator()).

function objects can also be in a state with no target callable object. In this case they are known as empty functions, and calling them throws a bad_function_call exception.

Function包裹器类,能够将任意类型的可回调包装成副本对象,其类型不依赖于回调的类型,而依赖于回调的标识。

一个实例化的function类对象能够包裹任何类型可回调的对象。例如:function function指针,指向成员的指针,以及任何类型的function对象。例如: 一个定义了operator()运算,包括 closures的类对象,

被包裹的可回调的对象副本存储对象中,成为函数的目标,一个目标回调对象的特定类型不需要,为了实例化function包裹类,仅需要它的回调标签。
 

function对象能够拷贝,移动,也能够传递特定的回调标识符直接调用可回调对象。

function对象可以不包含可回调的对象,称为空fuction。直接调用它,将会抛出一个bad_function_call异常。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值