G++ std::is_function 实现:_ArgTypes后跟 6 个句点是什么意思

g++ std::is_function implementation: what does _ArgTypes followed by 6 periods mean?

本文关键字:句点 是什么 意思 后跟 实现 std is function G++ ArgTypes      更新时间:2023-10-16

我正在查看我的标头 (g++-4.5.2) 以获取 中某些模板的实现,我发现了以下内容:

/// is_function
template<typename>
  struct is_function
  : public false_type { };
template<typename _Res, typename... _ArgTypes>
  struct is_function<_Res(_ArgTypes...)>
  : public true_type { };
template<typename _Res, typename... _ArgTypes>
  struct is_function<_Res(_ArgTypes......)>
  : public true_type { };

前两个声明似乎是合理的,但我无法弄清楚第三个声明是如何工作的。什么是......?我在标准中寻找它,但找不到任何东西。

它与:

_Res(_ArgTypes..., ...)

省略号参数前面的逗号是可选的。

此模板处理函数中的可变长度参数。例如:

void foo(bool, char, int...)