【发布时间】:2012-10-26 22:49:14
【问题描述】:
下面的测试用例编译失败的根本原因是什么:
#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;
}
}
函数原型有解决方法吗?
【问题讨论】:
标签: c++ templates c++11 function-pointers variadic-templates