命名空间
变体
操作

std::experimental::invocation_type, std::experimental::raw_invocation_type

来自 cppreference.cn
 
 
实验性
技术规范
文件系统库 (filesystem TS)
库基础 (library fundamentals TS)
库基础 2 (library fundamentals TS v2)
库基础 3 (library fundamentals TS v3)
并行扩展 (parallelism TS)
并行扩展 2 (parallelism TS v2)
并发扩展 (concurrency TS)
并发扩展 2 (concurrency TS v2)
概念 (concepts TS)
范围 (ranges TS)
反射 (reflection TS)
数学特殊函数 (special functions TR)
实验性非TS
模式匹配
线性代数
std::execution
契约
2D图形
 
 
定义于头文件 <experimental/type_traits>
template< class >

struct raw_invocation_type; //undefined

template< class Fn, class... ArgTypes >

struct raw_invocation_type<Fn(ArgTypes...)>;
(1) (library fundamentals TS)
template< class >

struct invocation_type; //undefined

template< class Fn, class... ArgTypes >

struct invocation_type<Fn(ArgTypes...)>;
(2) (library fundamentals TS)

当使用参数 ArgTypes... 调用 Fn 时,计算调用参数,如 INVOKE(std::declval<Fn>(), std::declval<ArgTypes>()...),其中 INVOKE 是在 Callable 中定义的操作。

表达式 INVOKE(f, t1, t2, ..., tN)调用参数定义如下,其中 T1t1 的(可能带有 cv 限定符的)类型,而 U1t1 是左值时为 T1&,否则为 T1&&

  • 如果 f 是指向类 T 的成员函数的指针,则调用参数为 U1,后跟 f 的参数,这些参数与 t2, ..., tN 匹配。
  • 如果 N == 1f 是指向类 T 的成员数据的指针,则调用参数为 U1
  • 如果 f 是类类型的对象,则调用参数是在 f 的函数调用运算符和替代调用函数中,与参数 t1, ..., tN 的最佳可行函数匹配的参数。
  • 在所有其他情况下,调用参数是与 t1, ..., tN 匹配的 f 的参数。

如果参数 tI 与函数参数列表中的省略号匹配,则相应的调用参数是将默认参数提升应用于 tI 的结果。

FnArgTypes 中的所有类型可以是任何完整类型、未知边界数组或(可能带有 cv 限定符的)void

目录

[编辑] 成员类型

成员类型 定义
raw_invocation_type<Fn(ArgTypes...)>::type R(T1, T2, ...),其中

仅当可以在未求值上下文中用参数 ArgTypes... 调用 Fn 时定义。

invocation_type<Fn(ArgTypes...)>::type R(U1, U2, ...),其中

仅当可以在未求值上下文中用参数 ArgTypes... 调用 Fn 时定义。

[编辑] 辅助类型

template< class T >
using raw_invocation_type_t = typename raw_invocation_type<T>::type;
(library fundamentals TS)
template< class T >
using invocation_type_t = typename invocation_type<T>::type;
(library fundamentals TS)

[编辑] 示例

[编辑] 参见

C++ 文档,关于 Reflection TS