我尝试将引用列表传递给可变参数模板函数并将其传递给另一个函数。我写的代码如下:
template <typename T>
void fun(cv::Point_<T> & pt) { pt.x++; pt.y++; }
template <class ... args>
void caller(args & ... list) {
typedef typename std::tuple_element<0, std::tuple<args...> >::type T;
std::array<std::reference_wrapper<T>, sizeof...(list)> values {list ... };
for(int i=0; i<values.size(); i++)
fun(values[i]);
}
然后我以这种方式调用函数调用者:
cv::Point2f a, b, c;
caller(a, b, c);
编译器给我以下错误:
No matching function for call to 'fun'
Candidate template ignored: could not match 'Point_' against 'reference_wrapper'
我错过了什么?