Namespaces
Variants

std::copyable_function:: operator()

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
R operator ( ) ( Args... args ) /*cv*/ /*ref*/ noexcept ( /*noex*/ ) ;
(自 C++26 起)

使用参数 args 调用存储的可调用目标。 /*cv*/ /*ref*/ /*noex*/ 部分与 std::copyable_function 模板参数的对应部分完全一致。

等价于 return std:: invoke_r < R > ( /*cv-ref-cast*/ ( f ) , std:: forward < Args > ( args ) ... ) ; ,其中 f 是表示 * this 目标对象的无cv限定左值,而 /*cv-ref-cast*/ ( f ) 等价于:

  • f cv ref 为空或为 & ,或
  • std:: as_const ( f ) cv ref const const & ,或
  • std :: move ( f ) cv ref && ,或
  • std :: move ( std:: as_const ( f ) ) cv ref const &&

* 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 起)
(函数模板)