std:: invocable, std:: regular_invocable
|
定义于头文件
<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
要求的
随机数生成器玩笑示例
。
|