std::invocable, std::regular_invocable
來自 cppreference.com
定義於標頭檔案 <concepts> |
||
template< class F, class... Args > concept invocable = |
(C++20 起) | |
template< class F, class... Args > concept regular_invocable = std::invocable<F, Args...>; |
(C++20 起) | |
invocable
概念指定一個可呼叫型別 F
可以透過函式模板 std::invoke 與一組引數 Args...
一起呼叫。
regular_invocable
概念在 invocable
概念的基礎上增加要求,即 invoke
表示式是保持相等性的,並且不修改函式物件或引數。
目錄 |
[編輯] 相等性保持
在標準庫概念的 requires 表示式中宣告的表示式必須是保持相等性的(除非另有說明)。
[編輯] 注意
invocable
和 regular_invocable
之間的區別純粹是語義上的。
一個隨機數生成器可能滿足 invocable
但不能滿足 regular_invocable
(那些滑稽的除外)。
[編輯] 參考
- C++23 標準 (ISO/IEC 14882:2024)
- 18.7.2 概念
invocable
[concept.invocable]
- 18.7.2 概念
- 18.7.3 概念
regular_invocable
[concept.regularinvocable]
- 18.7.3 概念
- C++20 標準 (ISO/IEC 14882:2020)
- 18.7.2 概念
invocable
[concept.invocable]
- 18.7.2 概念
- 18.7.3 概念
regular_invocable
[concept.regularinvocable]
- 18.7.3 概念
[編輯] 另請參閱
檢查一個型別是否可以使用給定引數型別進行呼叫(如同透過 std::invoke) (類模板) |
[編輯] 外部連結
一個笑話示例,展示了同時滿足 invocable 和 regular_invocable 的隨機數生成器。 |