名稱空間
變體
操作

std::copyable_function::operator()

來自 cppreference.com
 
 
 
函式物件
函式呼叫
(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 起)
(函式模板) [編輯]