c++中的(..)参数是做什么的

what do the (...) arguments in C++ do

本文关键字:什么 参数 中的 c++      更新时间:2023-10-16

言归正说,在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参数列表。