这是cppreference的示例。我不明白模式如何扩展。省略号出现在模板函数的参数声明中
template<typename ...Ts, int... N> void g(Ts (&...arr)[N]) {}
int n[1];
g<const char, int>("a", n); // Ts (&...arr)[N] expands to
// const char (&)[2], int(&)[1]
Note: In the pattern Ts (&...arr)[N], the ellipsis is the innermost element, not the last element as in all other pack expansions.
问题1:什么是ARR?
问题2:n是一个int数组,它是否与int ... N匹配?
问题3:为什么它可以扩展为const char(&)[2],INT(&)[1]
查看有关包扩展的任何问题,例如[this one](https://stackoverflow.com/a/26767333/2069064) – Barry
要解决问题2:'Ts'是数组类型的类型包,而'N'是数组维数的一个int数据包,所以'n'将'int'类型提供到'Ts'包中,并将维度1提供到'N'包中。 – cdhowie
使用可变参数模板引用C数组的丑陋语法('int(&a)[42]')。 – Jarod42