命名空间
变体
操作

std::copyable_function::operator()

来自 cppreference.cn
 
 
 
函数对象
函数调用
(C++17)(C++23)
恒等函数对象
(C++20)
透明运算符包装器
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

旧绑定器和适配器
(直到 C++17*)
(直到 C++17*)
(直到 C++17*)
(直到 C++17*)  
(直到 C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(直到 C++20*)
(直到 C++20*)
(直到 C++17*)(直到 C++17*)
(直到 C++17*)(直到 C++17*)

(直到 C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(直到 C++20*)
(直到 C++20*)
 
 
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 refconstconst &,则为 std::as_const(f),或者
  • 如果 cv ref&&,则为 std::move(f),或者
  • 如果 cv refconst &&,则为 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 起)
(函数模板) [编辑]