std::copyable_function::operator()
来自 cppreference.cn
< cpp | utility | functional | copyable function
R operator()( Args... args ) /*cv*/ /*ref*/ noexcept(/*noex*/); |
(C++26 起) | |
调用存储的可调用目标,传入参数args
。 /*cv*/、 /*ref*/ 和 /*noex*/ 部分的 operator() 与 std::copyable_function
的模板参数相同。
等价于 return std::invoke_r<R>(/*cv-ref-cast*/(f), std::forward<Args>(args)...);,其中 f
是一个 cv-非限定左值,表示 *this 的目标对象,并且 /*cv-ref-cast*/(f) 等价于
- 如果 cv ref 为空或 &,则为 f,或者
- 如果 cv ref 为 const 或 const &,则为 std::as_const(f),或者
- 如果 cv ref 为 &&,则为 std::move(f),或者
- 如果 cv ref 为 const &&,则为 std::move(std::as_const(f))。
如果 *this 为空,则行为未定义。
目录 |
[编辑] 参数
args | - | 要传递给存储的可调用目标的参数 |
[编辑] 返回值
std::invoke_r<R>(/*cv-ref-cast*/(f), std::forward<Args>(args)...).
[编辑] 异常
传播底层函数调用所抛出的异常。
[编辑] 示例
本节不完整 原因:无示例 |
[编辑] 参阅
调用目标 ( std::function<R(Args...)> 的公共成员函数) | |
调用目标 ( std::move_only_function 的公共成员函数) | |
调用存储的函数 ( std::reference_wrapper<T> 的公共成员函数) | |
(C++17)(C++23) |
用给定参数调用任何 可调用 (Callable) 对象 并可指定返回类型(C++23 起) (函数模板) |