1
是什么解释,下面的测试案例编译失败的根本原因:推导可变参数模板失败?
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
template<typename Type, typename... Args>
void apply(std::vector<Type> &v, Args... args, void(*algo)(Type*, Type*, Args...))
{
algo(&*v.begin(), &*v.end(), args...);
}
int main()
{
std::vector<int> v(10, 50);
apply(v, 3, std::iota);
for (unsigned int i = 0; i < v.size(); ++i) {
std::cout<<v[i]<<std::endl;
}
}
是否有函数原型解决方法?
'apply(v,std :: iota,3);'[也很好](http://liveworkspace.org/code/6809848b76a05fc6c5f947d36c8063b7) - 不需要手动指定'Args ...' 。 (并且此处没有模板模板参数。) –
ildjarn
模板模板是错误的词,但我想不出正确的模板模板参数。 – Wug