c++中的(..)参数是做什么的
what do the (...) arguments in C++ do
言归正说,在thread.h中,线程的构造函数是用下面的内容定义的。
template<class _Fn,
class... _Args>
explicit thread(_Fn&& _Fx, _Args&&... _Ax)
{ // construct with _Fx(_Ax...)
_Launch(&_Thr,
_STD bind(_Decay_copy(_STD forward<_Fn>(_Fx)),
_Decay_copy(_STD forward<_Args>(_Ax))...));
}
我想知道…做我试过谷歌搜索和寻找stackoverflow,但答案似乎没有任何地方!提前感谢:)
这是c++ 11的一个结构,称为可变模板(参见链接)
它叫做可变模板。它允许您编写具有可变数量参数的模板。据我所知,它允许您通过部分绑定定义线程运行函数返回_Fn
类型和_Args
参数列表。
相关文章:
- 传递给std::function template的template参数究竟代表什么
- 什么..(省略号)作为函数原型中唯一的函数参数,C++?
- C++部分概念 id:显式模板规范顺序/第一个参数的特殊状态的原因是什么?
- 引用捕获和在 lambda 中通过引用发送参数有什么区别 (C++)
- C++有什么方法可以在既不调用函数模板也不提供其模板参数的情况下引用函数模板?
- 读取大文件(>2GB)(文本文件包含以太网数据)并通过不同参数随机访问数据的最佳方法是什么?
- 未命名的非类型模板参数有什么意义?
- 有什么方法可以将具有不同模板参数的模板类实例放入向量中?
- 什么是仅调用一次并调用参数的控制台应用
- 在模板参数中使用 {} 在 type_trait{} 中时,其作用是什么<T>?
- 在 C 和 C++ 中作为函数参数,int **a 和 int a[][] 之间有什么确切的区别
- 为什么或在什么情况下,你会将参数作为C++中的引用(或指针)传递给函数?
- 没有大小参数的CString::GetBuffer()做什么
- 可变参数模板和省略号有什么区别?
- 当通知迭代器参数初始化为空列表的开头时,list::insert 行为是什么?
- C++ [错误] 声明'char '隐藏参数。什么意思?
- 用相同的参数声明两个构造函数的最偶像化的方法是什么?
- 这个公式在"accumulate"时采用什么参数?
- C++ 在发送什么参数方面遇到问题
- FindConnectionPoint,传递什么参数