【发布时间】:2011-04-08 18:24:13
【问题描述】:
我有点困惑如何使用可变参数模板从元组中读取每个参数。
考虑这个函数:
template<class...A> int func(A...args){
int size = sizeof...(A);
.... }
我从主文件中调用它,例如:
func(1,10,100,1000);
现在,我不知道如何扩展 func 的主体,以便能够分别读取每个参数,例如,我可以将参数存储在数组中。
【问题讨论】:
-
您在上一个问题中遗漏了什么? (stackoverflow.com/questions/3634379/variadic-templates) 你为什么不接受你的问题的答案?
-
答案应该在链接的线程中(莫蒂,没有投票?)
-
@sami:阅读常见问题解答至少一次...引用它:
When you have decided which answer is the most helpful to you, mark it as the accepted answer by clicking on the check box outline to the left of the answer. -
@sami:这不是重点。您问了 5 个问题,但没有接受 任何个问题的答案。这个 (stackoverflow.com/questions/3626483/…) 出了什么问题?如果您觉得自己无法花 10 秒时间感谢某人花费了一些时间来帮助您,那么这可能不是适合您的网站。