小编nir*_*n90的帖子

处理“std::size_t”类型的可变参数函数参数

我正在尝试掌握可变函数/模板参数的窍门。但是,在下面的两个函数中,我很困惑为什么SumIndices不能编译(我收到编译器错误“expansion pattern \xe2\x80\x98std::size_t\xe2\x80\x99 {aka \xe2\x80\x98long unsigned int\xe2\x80\x99} 不包含参数包”)而包含SumValues

\n
template <typename ...t_data_type>\nconstexpr auto SumValues(t_data_type ..._values) { \n  return (_values + ...); \n}\n\nconstexpr auto SumIndices(std::size_t ..._indices) { \n  return (_indices + ...); \n}\n
Run Code Online (Sandbox Code Playgroud)\n

如果有人能为我澄清这个困惑,我将不胜感激!

\n

c++ variadic-functions variadic-templates c++17 c++20

1
推荐指数
1
解决办法
514
查看次数