std::copyable_function::operator()
來自 cppreference.com
< 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 起) (函式模板) |