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

时间:2014-06-24 05:37:23

标签: c++

我会明白,在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但答案似乎没有任何地方! 提前谢谢你:)

2 个答案:

答案 0 :(得分:4)

这是C++11构造,名为variadic templates(按照链接)

答案 1 :(得分:2)

它被称为variadic template。它允许您编写具有可变数量参数的模板。据我所知,它允许您通过部分绑定定义线程运行函数返回_Fn类型和_Args参数列表。