为什么variadic非类型模板不允许作为函数参数?

时间:2014-06-11 17:28:56

标签: c++ templates variadic-templates variadic-functions variadic

int max(int n, int ... rest)
{
    //Do stuff
}

为什么不允许这样的事情?如果要创建接受可变参数函数参数的函数,则必须使用模板和类型名称。但是,即使你知道你只接受某种类型的参数(在这种情况下为int),为什么C ++会强迫你这样做

template <typename ... N>
int max(int n, N ... rest)
{
    //Do stuff
}

0 个答案:

没有答案
相关问题